use of org.wso2.charon.core.client.SCIMClient in project product-is by wso2.
the class ProvisioningTestCase method createUserForSecondServer.
@Test(alwaysRun = true, description = "Add SCIM provisioning user on second server", dependsOnMethods = "createUser")
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
public void createUserForSecondServer() throws Exception {
buildSCIMProvisioningConnector(PORT_OFFSET_1);
addSP(PORT_OFFSET_1);
scimClient = new SCIMClient();
String encodedUser = getScimUser(2);
// create a apache wink ClientHandler to intercept and identify response messages
Resource userResource = getResource(scimClient, scim_url_1);
BasicAuthInfo encodedBasicAuthInfo = getBasicAuthInfo(automationContextMap.get(PORT_OFFSET_0));
String response = userResource.header(SCIMConstants.AUTHORIZATION_HEADER, encodedBasicAuthInfo.getAuthorizationHeader()).contentType(SCIMConstants.APPLICATION_JSON).accept(SCIMConstants.APPLICATION_JSON).post(String.class, encodedUser);
Assert.assertTrue(response.contains(userName2));
}
use of org.wso2.charon.core.client.SCIMClient in project product-is by wso2.
the class ProvisioningTestCase method createUser.
@Test(alwaysRun = true, description = "Add SCIM Provisioning user", priority = 1)
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
public void createUser() throws Exception {
buildSCIMProvisioningConnector(PORT_OFFSET_0);
addSP(PORT_OFFSET_0);
scimClient = new SCIMClient();
String encodedUser = getScimUser(1);
// create a apache wink ClientHandler to intercept and identify response messages
Resource userResource = getResource(scimClient, scim_url_0);
BasicAuthInfo encodedBasicAuthInfo = getBasicAuthInfo(automationContextMap.get(PORT_OFFSET_0));
String response = userResource.header(SCIMConstants.AUTHORIZATION_HEADER, encodedBasicAuthInfo.getAuthorizationHeader()).contentType(SCIMConstants.APPLICATION_JSON).accept(SCIMConstants.APPLICATION_JSON).post(String.class, encodedUser);
log.info(response);
scimUserId = response.split(",")[0].split(":")[1].replace('"', ' ').trim();
// userMgtServiceClients.get(PORT_OFFSET_2).listUsers(userName, 100);
Assert.assertNotNull(scimUserId);
Assert.assertTrue(isUserExists(userName));
}
use of org.wso2.charon.core.client.SCIMClient in project product-is by wso2.
the class IDENTITY4776SCIMServiceWithOAuthTestCase method addUsersUsingOAuthandSCIM.
@Test(groups = "wso2.is", description = "loginUsingSecondaryUserStoreUser")
public void addUsersUsingOAuthandSCIM() throws Exception {
try {
addSecondaryUserStore();
addUserIntoSecondaryUserStore();
registerOAuthApplication();
loginUsingSecondaryUserStoreUser();
// create SCIM client
SCIMClient scimClient = new SCIMClient();
String postData = SCIMUtils.getEncodedSCIMUser(scimClient, SCIM_USER_NAME, "test", new String[] { "scimUser@gmail.com", "scimUser@wso2.com" }, "SCIMUser", "password1", "Sinhala", "0711234567");
// create a apache wink ClientHandler to intercept and identify response messages
Resource userResource = SCIMUtils.getUserResource(scimClient, scimUrl);
String response = userResource.header(SCIMConstants.AUTHORIZATION_HEADER, "Bearer " + accessToken).contentType(SCIMConstants.APPLICATION_JSON).accept(SCIMConstants.APPLICATION_JSON).post(String.class, postData);
Object obj = JSONValue.parse(response);
String scimUserId = ((JSONObject) obj).get("id").toString();
Assert.assertTrue(isUserExists());
Assert.assertNotNull(scimUserId);
} catch (Exception e) {
log.error("Error occured while executing the test case: " + e.getMessage(), e);
throw e;
}
}
use of org.wso2.charon.core.client.SCIMClient in project product-is by wso2.
the class MasterSCIMInitiator method getGroupResource.
protected Resource getGroupResource(SCIMClient scimClient, String skim_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(skim_url + "Groups");
}
use of org.wso2.charon.core.client.SCIMClient in project product-is by wso2.
the class SCIMServiceProviderGroupTestCase method createGroupTest.
@Test(alwaysRun = true, description = "Add SCIM Group")
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
public void createGroupTest() throws Exception {
// create a group according to SCIM Group Schema
Group scimGroup = SCIMUtils.getSCIMGroup(scimClient, scimUserId, USERNAME, EXTERNAL_ID, DISPLAY_NAME);
String encodedGroup = scimClient.encodeSCIMObject(scimGroup, SCIMConstants.JSON);
Resource groupResource = SCIMUtils.getGroupResource(scimClient, scim_url);
BasicAuthInfo encodedBasicAuthInfo = SCIMUtils.getBasicAuthInfo(userInfo);
// send previously registered SCIM consumer credentials in http headers.
String response = groupResource.header(SCIMConstants.AUTHORIZATION_HEADER, encodedBasicAuthInfo.getAuthorizationHeader()).contentType(SCIMConstants.APPLICATION_JSON).accept(SCIMConstants.APPLICATION_JSON).post(String.class, encodedGroup);
// decode the response
log.info(response);
Object obj = JSONValue.parse(response);
scimGroupId = ((JSONObject) obj).get("id").toString();
Assert.assertTrue(userMgtClient.roleNameExists(DISPLAY_NAME));
}
Aggregations