Search in sources :

Example 1 with UserStoreConfigAdminServiceClient

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);
}
Also used : UserStoreConfigAdminServiceClient(org.wso2.identity.integration.common.clients.user.store.config.UserStoreConfigAdminServiceClient) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with UserStoreConfigAdminServiceClient

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);
}
Also used : UserStoreDTO(org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO) H2DataBaseManager(org.wso2.carbon.automation.test.utils.dbutils.H2DataBaseManager) File(java.io.File) PropertyDTO(org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO)

Example 3 with UserStoreConfigAdminServiceClient

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);
}
Also used : ConfigurationContextFactory(org.apache.axis2.context.ConfigurationContextFactory) IntStream(java.util.stream.IntStream) StringUtils(org.apache.commons.lang.StringUtils) UserStoreConfigAdminServiceClient(org.wso2.identity.integration.common.clients.user.store.config.UserStoreConfigAdminServiceClient) GROUPS_ENDPOINT(org.wso2.identity.integration.test.scim2.SCIM2BaseTestCase.GROUPS_ENDPOINT) DataProvider(org.testng.annotations.DataProvider) HttpStatus(org.apache.http.HttpStatus) Test(org.testng.annotations.Test) ISTestUtils(org.wso2.identity.integration.test.utils.ISTestUtils) H2DataBaseManager(org.wso2.carbon.automation.test.utils.dbutils.H2DataBaseManager) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) SQLException(java.sql.SQLException) Assert(org.testng.Assert) ServerConfigurationManager(org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager) UserManagementClient(org.wso2.identity.integration.common.clients.UserManagementClient) HttpHeaders(org.apache.http.HttpHeaders) ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) AfterClass(org.testng.annotations.AfterClass) Factory(org.testng.annotations.Factory) PERMISSIONS_ENDPOINT(org.wso2.identity.integration.test.scim2.SCIM2BaseTestCase.PERMISSIONS_ENDPOINT) BeforeClass(org.testng.annotations.BeforeClass) BeforeMethod(org.testng.annotations.BeforeMethod) TestUserMode(org.wso2.carbon.automation.engine.context.TestUserMode) IOException(java.io.IOException) PropertyDTO(org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO) File(java.io.File) ExtractableResponse(io.restassured.response.ExtractableResponse) Response(io.restassured.response.Response) ApplicationManagementServiceClient(org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient) IsNull.notNullValue(org.hamcrest.core.IsNull.notNullValue) Optional(java.util.Optional) Log(org.apache.commons.logging.Log) LogFactory(org.apache.commons.logging.LogFactory) RestAssured(io.restassured.RestAssured) ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) ExtractableResponse(io.restassured.response.ExtractableResponse) ApplicationManagementServiceClient(org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient) ArrayList(java.util.ArrayList) UserManagementClient(org.wso2.identity.integration.common.clients.UserManagementClient) UserStoreConfigAdminServiceClient(org.wso2.identity.integration.common.clients.user.store.config.UserStoreConfigAdminServiceClient) LinkedHashMap(java.util.LinkedHashMap) Test(org.testng.annotations.Test)

Example 4 with UserStoreConfigAdminServiceClient

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.");
}
Also used : UserStoreDTO(org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO) UserStoreConfigAdminServiceClient(org.wso2.identity.integration.common.clients.user.store.config.UserStoreConfigAdminServiceClient)

Example 5 with UserStoreConfigAdminServiceClient

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.");
}
Also used : UserStoreDTO(org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Aggregations

UserStoreConfigAdminServiceClient (org.wso2.identity.integration.common.clients.user.store.config.UserStoreConfigAdminServiceClient)14 BeforeClass (org.testng.annotations.BeforeClass)11 UserStoreDTO (org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO)9 File (java.io.File)6 Test (org.testng.annotations.Test)5 PropertyDTO (org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO)5 H2DataBaseManager (org.wso2.carbon.automation.test.utils.dbutils.H2DataBaseManager)4 UserManagementClient (org.wso2.identity.integration.common.clients.UserManagementClient)4 ServerConfigurationManager (org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager)3 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)3 Response (io.restassured.response.Response)2 RestAssured (io.restassured.RestAssured)1 ExtractableResponse (io.restassured.response.ExtractableResponse)1 ValidatableResponse (io.restassured.response.ValidatableResponse)1 IOException (java.io.IOException)1 RemoteException (java.rmi.RemoteException)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1