use of org.wso2.identity.integration.test.utils.BasicAuthInfo in project product-is by wso2.
the class SCIMServiceProviderGroupTestCase method createUser.
public void createUser() throws CharonException {
// create SCIM client
String encodedUser = SCIMUtils.getEncodedSCIMUser(scimClient, USERNAME, "test", new String[] { "scimuser1@gmail.com", "scimuser2@wso2.com" }, "SCIMUser2", "password1", "sinhala", "0772202595");
// create a apache wink ClientHandler to intercept and identify response messages
Resource userResource = SCIMUtils.getUserResource(scimClient, scim_url);
BasicAuthInfo encodedBasicAuthInfo = SCIMUtils.getBasicAuthInfo(userInfo);
String response = userResource.header(SCIMConstants.AUTHORIZATION_HEADER, encodedBasicAuthInfo.getAuthorizationHeader()).contentType(SCIMConstants.APPLICATION_JSON).accept(SCIMConstants.APPLICATION_JSON).post(String.class, encodedUser);
log.info(response);
Object obj = JSONValue.parse(response);
scimUserId = ((JSONObject) obj).get("id").toString();
encodedUser = SCIMUtils.getEncodedSCIMUser(scimClient, USERNAME2, "test2", new String[] { "dkasunw2@gmail.com", "dharshanaw2@wso2.com" }, USERNAME2, "testPW2", "sinhala", "0712202541");
response = userResource.header(SCIMConstants.AUTHORIZATION_HEADER, encodedBasicAuthInfo.getAuthorizationHeader()).contentType(SCIMConstants.APPLICATION_JSON).accept(SCIMConstants.APPLICATION_JSON).post(String.class, encodedUser);
obj = JSONValue.parse(response);
scimUserId2 = ((JSONObject) obj).get("id").toString();
}
use of org.wso2.identity.integration.test.utils.BasicAuthInfo in project product-is by wso2.
the class SCIMServiceProviderGroupTestCase method listGroup.
@Test(alwaysRun = true, description = "list SCIM Groups", dependsOnMethods = { "getGroup" })
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
public void listGroup() 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());
FlaggedName[] roleNames = userMgtClient.listRoles("eng", 100);
for (FlaggedName role : roleNames) {
if (!role.getItemName().contains("false")) {
Assert.assertTrue(response.contains(role.getItemName()));
}
}
}
use of org.wso2.identity.integration.test.utils.BasicAuthInfo in project product-is by wso2.
the class SCIMServiceProviderGroupTestCase method deleteGroup.
@Test(alwaysRun = true, description = "Add SCIM user", dependsOnMethods = { "patchGroup" })
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
public void deleteGroup() 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);
// had to set content type for the delete request as well, coz wink client sets */* by default.
String response = groupResource.header(SCIMConstants.AUTHORIZATION_HEADER, encodedBasicAuthInfo.getAuthorizationHeader()).accept(SCIMConstants.APPLICATION_JSON).delete(String.class);
// decode the response
log.info(response.toString());
Assert.assertFalse(userMgtClient.roleNameExists(DISPLAY_NAME));
}
use of org.wso2.identity.integration.test.utils.BasicAuthInfo in project product-is by wso2.
the class SCIMServiceProviderGroupTestCase method deleteUser.
public void deleteUser() {
ClientConfig clientConfig = new ClientConfig();
SCIMResponseHandler responseHandler = new SCIMResponseHandler();
responseHandler.setSCIMClient(scimClient);
clientConfig.handlers(new ClientHandler[] { responseHandler });
RestClient restClient = new RestClient(clientConfig);
BasicAuthInfo encodedBasicAuthInfo = SCIMUtils.getBasicAuthInfo(userInfo);
Resource userResource = restClient.resource(scim_url + "Users/" + scimUserId);
String response = userResource.header(SCIMConstants.AUTHORIZATION_HEADER, encodedBasicAuthInfo.getAuthorizationHeader()).accept(SCIMConstants.APPLICATION_JSON).delete(String.class);
}
use of org.wso2.identity.integration.test.utils.BasicAuthInfo 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(""));
}
Aggregations