use of org.wso2.identity.integration.common.clients.user.store.config.UserStoreConfigAdminServiceClient in project product-is by wso2.
the class OIDCPasswordGrantTest method testInit.
@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
super.init();
userStoreConfigAdminServiceClient = new UserStoreConfigAdminServiceClient(backendURL, sessionCookie);
addSecondaryUserStore();
// Wait till the user-store is deployed
Thread.sleep(5000);
RestAssured.baseURI = backendURL.replace(SERVICES, "");
// Create a user in secondary user-store
OIDCUtilTest.initUser();
OIDCUtilTest.user.setUsername(USER_STORE_DOMAIN + "/" + OIDCUtilTest.user.getUsername());
user = OIDCUtilTest.user;
createUser(OIDCUtilTest.user);
// Create application
OIDCUtilTest.initApplications();
application = OIDCUtilTest.applications.get(OIDCUtilTest.playgroundAppTwoAppName);
createApplication(application);
}
use of org.wso2.identity.integration.common.clients.user.store.config.UserStoreConfigAdminServiceClient in project product-is by wso2.
the class OIDCPasswordGrantTest method addSecondaryUserStore.
private void addSecondaryUserStore() throws Exception {
String jdbcClass = "org.wso2.carbon.user.core.jdbc.UniqueIDJDBCUserStoreManager";
H2DataBaseManager dataBaseManager = new H2DataBaseManager("jdbc:h2:" + ServerConfigurationManager.getCarbonHome() + "/repository/database/" + USER_STORE_DB_NAME, DB_USER_NAME, DB_USER_PASSWORD);
dataBaseManager.executeUpdate(new File(ServerConfigurationManager.getCarbonHome() + "/dbscripts/h2.sql"));
dataBaseManager.disconnect();
PropertyDTO[] propertyDTOs = new PropertyDTO[10];
for (int i = 0; i < 10; i++) {
propertyDTOs[i] = new PropertyDTO();
}
propertyDTOs[0].setName("driverName");
propertyDTOs[0].setValue("org.h2.Driver");
propertyDTOs[1].setName("url");
propertyDTOs[1].setValue("jdbc:h2:" + ServerConfigurationManager.getCarbonHome() + "/repository/database/" + USER_STORE_DB_NAME);
propertyDTOs[2].setName("userName");
propertyDTOs[2].setValue(DB_USER_NAME);
propertyDTOs[3].setName("password");
propertyDTOs[3].setValue(DB_USER_PASSWORD);
propertyDTOs[4].setName("UserIDEnabled");
propertyDTOs[4].setValue("true");
UserStoreDTO userStoreDTO = userStoreConfigAdminServiceClient.createUserStoreDTO(jdbcClass, USER_STORE_DOMAIN, propertyDTOs);
userStoreConfigAdminServiceClient.addUserStore(userStoreDTO);
Thread.sleep(5000);
userStoreConfigUtils.waitForUserStoreDeployment(userStoreConfigAdminServiceClient, USER_STORE_DOMAIN);
}
use of org.wso2.identity.integration.common.clients.user.store.config.UserStoreConfigAdminServiceClient 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.integration.common.clients.user.store.config.UserStoreConfigAdminServiceClient in project product-is by wso2.
the class SCIMUtils method createSecondaryUserStore.
/**
* Create a secondary user store.
*
* @param userStoreType User store type.
* @param userStoreDomain User store domain.
* @param userStoreProperties Configuration properties for the user store.
* @param backendURL Backend URL of the Identity Server.
* @param sessionCookie Session Cookie.
* @throws Exception Thrown if the user store creation fails.
*/
public static void createSecondaryUserStore(String userStoreType, String userStoreDomain, PropertyDTO[] userStoreProperties, String backendURL, String sessionCookie) throws Exception {
UserStoreConfigAdminServiceClient userStoreConfigAdminServiceClient = new UserStoreConfigAdminServiceClient(backendURL, sessionCookie);
UserStoreDTO userStoreDTO = userStoreConfigAdminServiceClient.createUserStoreDTO(userStoreType, userStoreDomain, userStoreProperties);
userStoreConfigAdminServiceClient.addUserStore(userStoreDTO);
Thread.sleep(5000);
Assert.assertTrue(userStoreConfigUtils.waitForUserStoreDeployment(userStoreConfigAdminServiceClient, userStoreDomain), "Domain addition via DTO has failed.");
}
use of org.wso2.identity.integration.common.clients.user.store.config.UserStoreConfigAdminServiceClient in project product-is by wso2.
the class ClaimMappingsOnSecondaryUserStoreTestCase method testAddJDBCUserStore.
@Test(groups = "wso2.is", description = "Check add user store via DTO")
private void testAddJDBCUserStore() throws Exception {
UserStoreDTO userStoreDTO = userStoreConfigAdminServiceClient.createUserStoreDTO(JDBC_CLASS, DOMAIN_ID, userStoreConfigUtils.getJDBCUserStoreProperties(USER_STORE_DB_NAME));
userStoreConfigAdminServiceClient.addUserStore(userStoreDTO);
Thread.sleep(5000);
Assert.assertTrue(userStoreConfigUtils.waitForUserStoreDeployment(userStoreConfigAdminServiceClient, DOMAIN_ID), "Domain addition via DTO has failed.");
}
Aggregations