Search in sources :

Example 26 with RestClient

use of org.apache.wink.client.RestClient in project product-is by wso2.

the class SelfSignUpConsentTest method addPurposeCategory.

private String addPurposeCategory(String name, String description) throws JSONException {
    RestClient restClient = new RestClient();
    Resource piiCatResource = restClient.resource(consentEndpoint + "/" + "purpose-categories");
    String addPurposeCatString = "{\"purposeCategory\": " + "\"" + name + "\"" + ", \"description\": " + "\"" + description + "\"}";
    User user = new User();
    user.setUserName(tenantAdminUserName);
    user.setPassword(ADMIN);
    String content = piiCatResource.contentType(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, getBasicAuthHeader(user)).post(String.class, addPurposeCatString);
    JSONObject purpose = new JSONObject(content);
    return purpose.getString("purposeCategoryId");
}
Also used : User(org.wso2.carbon.automation.engine.context.beans.User) JSONObject(org.json.JSONObject) RestClient(org.apache.wink.client.RestClient) Resource(org.apache.wink.client.Resource)

Example 27 with RestClient

use of org.apache.wink.client.RestClient in project product-is by wso2.

the class SelfSignUpConsentTest method selfRegister.

private void selfRegister(String username, String password, String givenName, String emailAddress, String lastName, String mobile) {
    String consent = getConsentReqBody(financialPurposeId, 1, username);
    String selfRegisterReqBody = "{\"user\": {\"username\": \"" + username + "\",\"realm\": \"\", " + "\"password\": \"" + password + "\",\"claims\": " + "[{\"uri\": \"http://wso2.org/claims/givenname\",\"value\": \"" + givenName + "\" }," + "{\"uri\": \"http://wso2.org/claims/emailaddress\",\"value\": \"" + emailAddress + "\"}," + "{\"uri\": \"http://wso2.org/claims/lastname\",\"value\": \"" + lastName + "\"}," + "{\"uri\": \"http://wso2.org/claims/mobile\",\"value\": \"" + mobile + "\"} ] }," + "\"properties\": [{\"key\": \"consent\", \"value\": \"" + consent + "\"}]}";
    RestClient restClient = new RestClient();
    Resource selfRegistrationResource = restClient.resource(selfRegistrationMeEndpoint);
    User user = new User();
    user.setUserName(tenantAdminUserName);
    user.setPassword(ADMIN);
    selfRegistrationResource.contentType(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, getBasicAuthHeader(user)).post(String.class, selfRegisterReqBody);
}
Also used : User(org.wso2.carbon.automation.engine.context.beans.User) RestClient(org.apache.wink.client.RestClient) Resource(org.apache.wink.client.Resource)

Example 28 with RestClient

use of org.apache.wink.client.RestClient in project product-is by wso2.

the class ConsentMgtTestCase method addPurposeCategory.

private JSONObject addPurposeCategory(String name, String description) {
    RestClient restClient = new RestClient();
    Resource piiCatResource = restClient.resource(consentEndpoint + "/" + "purpose-categories");
    String addPurposeCatString = "{\"purposeCategory\": " + "\"" + name + "\"" + ", \"description\": " + "\"" + description + "\"}";
    String response = piiCatResource.contentType(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, getBasicAuthHeader(userInfo)).post(String.class, addPurposeCatString);
    return (JSONObject) JSONValue.parse(response);
}
Also used : JSONObject(org.json.simple.JSONObject) RestClient(org.apache.wink.client.RestClient) Resource(org.apache.wink.client.Resource)

Example 29 with RestClient

use of org.apache.wink.client.RestClient in project product-is by wso2.

the class ConsentMgtTestCase method addPIICategory.

private JSONObject addPIICategory(String name, String description) {
    RestClient restClient = new RestClient();
    Resource piiCatResource = restClient.resource(consentEndpoint + "/" + "pii-categories");
    String addPIICatString = "{\"piiCategory\": " + "\"" + name + "\"" + ", \"description\": " + "\"" + description + "\" , " + "\"sensitive\": \"" + true + "\"}";
    String response = piiCatResource.contentType(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, getBasicAuthHeader(userInfo)).post(String.class, addPIICatString);
    return (JSONObject) JSONValue.parse(response);
}
Also used : JSONObject(org.json.simple.JSONObject) RestClient(org.apache.wink.client.RestClient) Resource(org.apache.wink.client.Resource)

Example 30 with RestClient

use of org.apache.wink.client.RestClient in project product-is by wso2.

the class SelfSignUpConsentTest method getConsent.

private String getConsent(String username, String password, String receiptId) {
    log.info("Retrieving consent for username " + username + ". reciptId : " + receiptId);
    RestClient restClient = new RestClient();
    Resource resource = restClient.resource(consentEndpoint + "/receipts/" + receiptId);
    log.info("Calling to receipt endpoint :" + consentEndpoint + "/receipts/" + receiptId);
    User user = new User();
    user.setUserName(username);
    user.setPassword(password);
    String response = resource.contentType(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, getBasicAuthHeader(user)).get(String.class);
    return response;
}
Also used : User(org.wso2.carbon.automation.engine.context.beans.User) RestClient(org.apache.wink.client.RestClient) Resource(org.apache.wink.client.Resource)

Aggregations

RestClient (org.apache.wink.client.RestClient)33 Resource (org.apache.wink.client.Resource)28 ClientConfig (org.apache.wink.client.ClientConfig)21 SCIMResponseHandler (org.wso2.identity.integration.test.scim.utils.SCIMResponseHandler)16 Test (org.testng.annotations.Test)14 BasicAuthInfo (org.wso2.identity.integration.test.utils.BasicAuthInfo)13 SetEnvironment (org.wso2.carbon.automation.engine.annotations.SetEnvironment)12 JSONObject (org.json.simple.JSONObject)8 User (org.wso2.carbon.automation.engine.context.beans.User)7 BasicAuthSecurityHandler (org.apache.wink.client.handlers.BasicAuthSecurityHandler)3 JSONObject (org.json.JSONObject)2 SCIMClient (org.wso2.charon.core.client.SCIMClient)2 Group (org.wso2.charon.core.objects.Group)2 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)2 RemoteException (java.rmi.RemoteException)1 JSONArray (org.json.simple.JSONArray)1 UserAdminUserAdminException (org.wso2.carbon.user.mgt.stub.UserAdminUserAdminException)1 FlaggedName (org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName)1