use of org.wso2.identity.scenarios.commons.clients.UserManagementClient in project product-is by wso2.
the class SCIM2MeTestCase method assignUserToGroup.
private void assignUserToGroup(String username) throws Exception {
AutomationContext automationContext;
if (tenant.equals(org.wso2.carbon.base.MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) {
automationContext = new AutomationContext("IDENTITY", TestUserMode.SUPER_TENANT_ADMIN);
} else {
automationContext = new AutomationContext("IDENTITY", TestUserMode.TENANT_ADMIN);
}
String backendUrl = automationContext.getContextUrls().getBackEndUrl();
String sessionCookie = new LoginLogoutClient(automationContext).login();
UserManagementClient userMgtClient = new UserManagementClient(backendUrl, sessionCookie);
String[] roles = { ADMIN_ROLE };
userMgtClient.addRemoveRolesOfUser(username, roles, null);
}
use of org.wso2.identity.scenarios.commons.clients.UserManagementClient in project product-is by wso2.
the class SCIM2GroupTest method testGetGroupsAfterRemovingHybridRoleOfAMember.
@Test(dependsOnMethods = "testGETGroupDetails", description = "Test whether the assigned user list of a hybrid " + "role created by a Service Provider is updated properly when a secondary user store is disabled/deleted " + "where one of the users in the respective secondary user store was assigned to the respective hybrid role.")
public void testGetGroupsAfterRemovingHybridRoleOfAMember() throws Exception {
ApplicationManagementServiceClient applicationManagementServiceClient = new ApplicationManagementServiceClient(sessionCookie, backendURL, ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null));
ServiceProvider serviceProviderApp = new ServiceProvider();
serviceProviderApp.setApplicationName(APPLICATION_NAME);
serviceProviderApp.setDescription("sample-description");
serviceProviderApp.setSaasApp(true);
applicationManagementServiceClient.createApplication(serviceProviderApp);
serviceProviderApp = applicationManagementServiceClient.getApplication(APPLICATION_NAME);
Assert.assertEquals(serviceProviderApp.getApplicationName(), APPLICATION_NAME, "Failed to create the Service Provider: " + APPLICATION_NAME);
UserManagementClient userMgtClient = new UserManagementClient(backendURL, getSessionCookie());
userMgtClient.addUser(USERNAME_OF_THE_NEW_USER, "newUserPassword", new String[] { APPLICATION_ROLE_NAME }, null);
endpointURL = GROUPS_ENDPOINT;
ExtractableResponse scimResponse = getResponseOfGet(endpointURL, SCIM_CONTENT_TYPE).then().assertThat().statusCode(HttpStatus.SC_OK).and().assertThat().header(HttpHeaders.CONTENT_TYPE, SCIM_CONTENT_TYPE).log().ifValidationFails().extract();
Assert.assertNotNull(scimResponse);
Object resourcesAttribute = scimResponse.path("Resources");
Assert.assertTrue(resourcesAttribute instanceof ArrayList, "'Resources' attribute is not a list of " + "objects");
Optional<LinkedHashMap> targetSpApplicationRole = ((ArrayList<LinkedHashMap>) resourcesAttribute).stream().filter(resource -> ((String) resource.get("displayName")).contains(APPLICATION_ROLE_NAME)).findFirst();
Assert.assertTrue(targetSpApplicationRole.isPresent(), "Application role not found for the " + "Service Provider: " + APPLICATION_NAME);
groupId = (String) targetSpApplicationRole.get().get("id");
Optional<LinkedHashMap> targetMemberAttribute = ((ArrayList<LinkedHashMap>) targetSpApplicationRole.get().get("members")).stream().filter(member -> StringUtils.equals((String) member.get("display"), USERNAME_OF_THE_NEW_USER)).findFirst();
Assert.assertTrue(targetMemberAttribute.isPresent(), "User: " + USERNAME_OF_THE_NEW_USER + " is not " + "assigned to the role: " + APPLICATION_ROLE_NAME);
String targetUserId = (String) targetMemberAttribute.get().get("value");
UserStoreConfigAdminServiceClient userStoreConfigAdminServiceClient = new UserStoreConfigAdminServiceClient(backendURL, sessionCookie);
userStoreConfigAdminServiceClient.changeUserStoreState(USER_STORE_DOMAIN, true);
Thread.sleep(20000);
endpointURL += "/" + groupId;
scimResponse = getResponseOfGet(endpointURL, SCIM_CONTENT_TYPE).then().assertThat().statusCode(HttpStatus.SC_OK).and().assertThat().header(HttpHeaders.CONTENT_TYPE, SCIM_CONTENT_TYPE).log().ifValidationFails().extract();
Assert.assertNotNull(scimResponse);
Object membersAttribute = scimResponse.path("members");
Assert.assertTrue(membersAttribute instanceof ArrayList, "'members' attribute is not a list of " + "objects");
targetMemberAttribute = ((ArrayList<LinkedHashMap>) membersAttribute).stream().filter(member -> StringUtils.equals((String) member.get("value"), targetUserId)).findAny();
Assert.assertFalse(targetMemberAttribute.isPresent(), "User: " + USERNAME_OF_THE_NEW_USER + " of the disabled user store: " + USER_STORE_DOMAIN + " is assigned to the application role: " + APPLICATION_ROLE_NAME);
if (ISTestUtils.nameExists(userMgtClient.listAllUsers(USERNAME_OF_THE_NEW_USER, 10), USERNAME_OF_THE_NEW_USER)) {
userMgtClient.deleteUser(USERNAME_OF_THE_NEW_USER);
}
userStoreConfigAdminServiceClient.changeUserStoreState(USER_STORE_DOMAIN, false);
Thread.sleep(20000);
}
use of org.wso2.identity.scenarios.commons.clients.UserManagementClient in project product-is by wso2.
the class SCIMServiceProviderGroupTestCase method initiate.
@BeforeClass(alwaysRun = true)
public void initiate() throws Exception {
AutomationContext automationContext = new AutomationContext("IDENTITY", TestUserMode.SUPER_TENANT_ADMIN);
userInfo = automationContext.getContextTenant().getContextUser();
backendUrl = automationContext.getContextUrls().getBackEndUrl();
serviceEndPoint = automationContext.getContextUrls().getServiceUrl();
scim_url = backendUrl.substring(0, 22) + "/wso2/scim/";
sessionCookie = new LoginLogoutClient(automationContext).login();
userMgtClient = new UserManagementClient(backendUrl, sessionCookie);
scimConfigAdminClient = new SCIMConfigAdminClient(backendUrl, sessionCookie);
scimClient = new SCIMClient();
// creating users for the test
createUser();
}
use of org.wso2.identity.scenarios.commons.clients.UserManagementClient in project product-is by wso2.
the class SCIMServiceProviderUserTestCase method initiate.
@BeforeClass(alwaysRun = true)
public void initiate() throws Exception {
AutomationContext automationContext = new AutomationContext("IDENTITY", TestUserMode.SUPER_TENANT_ADMIN);
provider_userInfo = automationContext.getContextTenant().getContextUser();
backendUrl = automationContext.getContextUrls().getBackEndUrl();
scim_url = backendUrl.substring(0, 22) + "/wso2/scim/";
serviceEndPoint = automationContext.getContextUrls().getServiceUrl();
sessionCookie = new LoginLogoutClient(automationContext).login();
userMgtClient = new UserManagementClient(backendUrl, sessionCookie);
}
use of org.wso2.identity.scenarios.commons.clients.UserManagementClient in project product-is by wso2.
the class UserManagementServiceAbstractTest method testGetRolesOfCurrentUser.
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = "wso2.is", description = "Check get shared of current user", dependsOnMethods = "testChangePasswordOfUser")
public void testGetRolesOfCurrentUser() throws Exception {
String session = authenticatorClient.login(newUserName, newUserPassword, isServer.getInstance().getHosts().get("default"));
UserManagementClient client = new UserManagementClient(backendURL, session);
Assert.assertTrue(nameExists(client.getRolesOfCurrentUser(), newUserRole), "Getting current user roles has failed.");
authenticatorClient.logOut();
}
Aggregations