use of org.wso2.identity.integration.test.scim.utils.SCIMResponseHandler in project product-is by wso2.
the class SCIMServiceProviderUserTestCase method getUser.
@Test(alwaysRun = true, description = "Get SCIM user", dependsOnMethods = { "createUser" })
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
public void getUser() {
// create a apache wink ClientHandler to intercept and identify response messages
SCIMResponseHandler responseHandler = new SCIMResponseHandler();
responseHandler.setSCIMClient(scimClient);
// set the handler in wink client config
ClientConfig clientConfig = new ClientConfig();
clientConfig.handlers(new ClientHandler[] { responseHandler });
// create a wink rest client with the above config
RestClient restClient = new RestClient(clientConfig);
BasicAuthInfo encodedBasicAuthInfo = SCIMUtils.getBasicAuthInfo(provider_userInfo);
// create resource endpoint to access a known user resource.
Resource userResource = restClient.resource(scim_url + "Users/" + scimUserId);
String response = userResource.header(SCIMConstants.AUTHORIZATION_HEADER, encodedBasicAuthInfo.getAuthorizationHeader()).contentType(SCIMConstants.APPLICATION_JSON).accept(SCIMConstants.APPLICATION_JSON).get(String.class);
// decode the response
log.info(response);
Assert.assertTrue(response.contains(""));
}
use of org.wso2.identity.integration.test.scim.utils.SCIMResponseHandler in project product-is by wso2.
the class ProvisioningTestCase method getResource.
private Resource getResource(SCIMClient scimClient, String scim_url) {
SCIMResponseHandler responseHandler = new SCIMResponseHandler();
responseHandler.setSCIMClient(scimClient);
// set the handler in wink client config
ClientConfig clientConfig = new ClientConfig();
clientConfig.handlers(new ClientHandler[] { responseHandler });
// create a wink rest client with the above config
RestClient restClient = new RestClient(clientConfig);
// create resource endpoint to access User resource
return restClient.resource(scim_url + "Users");
}
use of org.wso2.identity.integration.test.scim.utils.SCIMResponseHandler in project product-is by wso2.
the class MasterSCIMInitiator method getResource.
protected Resource getResource(SCIMClient scimClient, String skim_url, String skimId) {
SCIMResponseHandler responseHandler = new SCIMResponseHandler();
responseHandler.setSCIMClient(scimClient);
// set the handler in wink client config
ClientConfig clientConfig = new ClientConfig();
clientConfig.handlers(new ClientHandler[] { responseHandler });
// create a wink rest client with the above config
RestClient restClient = new RestClient(clientConfig);
// create resource endpoint to access User resource
return restClient.resource(skim_url + "Users/" + skimId);
}
use of org.wso2.identity.integration.test.scim.utils.SCIMResponseHandler in project product-is by wso2.
the class SCIMServiceProviderGroupTestCase method getGroup.
@Test(alwaysRun = true, description = "Get SCIM Group", dependsOnMethods = { "createGroupTest" })
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
public void getGroup() throws Exception {
SCIMResponseHandler responseHandler = new SCIMResponseHandler();
responseHandler.setSCIMClient(scimClient);
// set the handler in wink client config
ClientConfig clientConfig = new ClientConfig();
clientConfig.handlers(new ClientHandler[] { responseHandler });
// create a wink rest client with the above config
RestClient restClient = new RestClient(clientConfig);
BasicAuthInfo encodedBasicAuthInfo = SCIMUtils.getBasicAuthInfo(userInfo);
// create resource endpoint to access a known user resource.
Resource groupResource = restClient.resource(scim_url + "Groups/" + scimGroupId);
String response = groupResource.header(SCIMConstants.AUTHORIZATION_HEADER, encodedBasicAuthInfo.getAuthorizationHeader()).contentType(SCIMConstants.APPLICATION_JSON).accept(SCIMConstants.APPLICATION_JSON).get(String.class);
log.info(response.toString());
Object obj = JSONValue.parse(response);
Assert.assertTrue(((JSONObject) obj).get("id").toString().contains(scimGroupId));
}
use of org.wso2.identity.integration.test.scim.utils.SCIMResponseHandler in project product-is by wso2.
the class SCIMServiceProviderGroupTestCase method filterGroup.
@Test(alwaysRun = true, description = "filter SCIM Groups", dependsOnMethods = { "listGroup" })
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
public void filterGroup() throws Exception {
SCIMResponseHandler responseHandler = new SCIMResponseHandler();
responseHandler.setSCIMClient(scimClient);
// set the handler in wink client config
ClientConfig clientConfig = new ClientConfig();
clientConfig.handlers(new ClientHandler[] { responseHandler });
// create a wink rest client with the above config
RestClient restClient = new RestClient(clientConfig);
BasicAuthInfo encodedBasicAuthInfo = SCIMUtils.getBasicAuthInfo(userInfo);
// create resource endpoint to access a known user resource.
Resource groupResource = restClient.resource(scim_url + "Groups?filter=displayNameEqeng");
String response = groupResource.header(SCIMConstants.AUTHORIZATION_HEADER, encodedBasicAuthInfo.getAuthorizationHeader()).contentType(SCIMConstants.APPLICATION_JSON).accept(SCIMConstants.APPLICATION_JSON).get(String.class);
log.info(response.toString());
Assert.assertTrue(response.contains("\"displayName\":\"PRIMARY/eng\""));
}
Aggregations