Search in sources :

Example 1 with UserProfileMgtServiceClient

use of org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient in project product-is by wso2.

the class UserInformationRecoveryServiceTestCase method testInit.

@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
    super.init();
    String carbonHome = Utils.getResidentCarbonHome();
    identityMgtServerFile = new File(carbonHome + File.separator + "repository" + File.separator + "conf" + File.separator + "identity" + File.separator + "identity-mgt.properties");
    File identityMgtConfigFile = new File(getISResourceLocation() + File.separator + "identityMgt" + File.separator + "identity-mgt-enabled.properties");
    axisServerFile = new File(carbonHome + File.separator + "repository" + File.separator + "conf" + File.separator + "axis2" + File.separator + "axis2.xml");
    File axisConfigFile = new File(getISResourceLocation() + File.separator + "identityMgt" + File.separator + "axis2.xml");
    scm = new ServerConfigurationManager(isServer);
    scm.applyConfigurationWithoutRestart(identityMgtConfigFile, identityMgtServerFile, true);
    scm.applyConfigurationWithoutRestart(axisConfigFile, axisServerFile, true);
    scm.restartGracefully();
    super.init();
    loginManger = new AuthenticatorClient(backendURL);
    userMgtClient = new UserManagementClient(backendURL, sessionCookie);
    infoRecoveryClient = new UserInformationRecoveryServiceClient(backendURL, sessionCookie);
    profileClient = new UserProfileMgtServiceClient(backendURL, sessionCookie);
    loginManger.login(isServer.getSuperTenant().getTenantAdmin().getUserName(), isServer.getSuperTenant().getTenantAdmin().getPassword(), isServer.getInstance().getHosts().get("default"));
    claimMgtClient = new ClaimManagementServiceClient(backendURL, sessionCookie);
    ClaimDTO claim1 = new ClaimDTO();
    claim1.setDialectURI("http://wso2.org/claims");
    claim1.setClaimUri("http://wso2.org/claims/identity/unlockTime");
    claim1.setDescription("Account Unlock time");
    ClaimDTO claim2 = new ClaimDTO();
    claim2.setDialectURI("http://wso2.org/claims");
    claim2.setClaimUri("http://wso2.org/claims/identity/failedLoginAttempts");
    claim2.setDescription("Failed login attempts");
    ClaimMappingDTO claimMapping1 = new ClaimMappingDTO();
    claimMapping1.setClaim(claim1);
    claimMapping1.setMappedAttribute("description");
    claimMgtClient.addNewClaimMapping(claimMapping1);
    ClaimMappingDTO claimMapping2 = new ClaimMappingDTO();
    claimMapping2.setClaim(claim2);
    claimMapping2.setMappedAttribute("employeeType");
    claimMgtClient.addNewClaimMapping(claimMapping2);
    userMgtClient.addUser("user11", "passWord1@", null, "default");
    userMgtClient.addRole("umRole11", new String[] { "user11" }, new String[] { "/permission/admin/login" }, false);
}
Also used : UserProfileMgtServiceClient(org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient) ClaimMappingDTO(org.wso2.carbon.claim.mgt.stub.dto.ClaimMappingDTO) UserIdentityClaimDTO(org.wso2.carbon.identity.mgt.stub.dto.UserIdentityClaimDTO) ClaimDTO(org.wso2.carbon.claim.mgt.stub.dto.ClaimDTO) ClaimManagementServiceClient(org.wso2.identity.integration.common.clients.ClaimManagementServiceClient) AuthenticatorClient(org.wso2.carbon.integration.common.admin.client.AuthenticatorClient) ServerConfigurationManager(org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager) UserManagementClient(org.wso2.identity.integration.common.clients.UserManagementClient) File(java.io.File) UserInformationRecoveryServiceClient(org.wso2.identity.integration.common.clients.mgt.UserInformationRecoveryServiceClient) BeforeClass(org.testng.annotations.BeforeClass) SetEnvironment(org.wso2.carbon.automation.engine.annotations.SetEnvironment)

Example 2 with UserProfileMgtServiceClient

use of org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient in project product-is by wso2.

the class OAuth2ServiceJWTGrantTestCase method setup.

@BeforeClass
public void setup() throws Exception {
    super.init(TestUserMode.SUPER_TENANT_ADMIN);
    changeISConfiguration("jwt_token_issuer_enabled.toml");
    super.init(TestUserMode.SUPER_TENANT_ADMIN);
    OAuthConsumerAppDTO appDto = createApplication(createApplicationWithJWTGrantType());
    consumerKey = appDto.getOauthConsumerKey();
    consumerSecret = appDto.getOauthConsumerSecret();
    userManagementClient = new UserManagementClient(backendURL, sessionCookie);
    oauthAdminClient = new OauthAdminClient(backendURL, sessionCookie);
    userProfileMgtServiceClient = new UserProfileMgtServiceClient(backendURL, sessionCookie);
    identityProviderMgtServiceClient = new IdentityProviderMgtServiceClient(sessionCookie, backendURL);
    addNewUserWithClaims();
    claimMetadataManagementServiceClient = new ClaimMetadataManagementServiceClient(backendURL, sessionCookie);
    changeCountryOIDDialect();
    ExternalClaimDTO externalClaimDTO = new ExternalClaimDTO();
    externalClaimDTO.setExternalClaimDialectURI(OAuth2ServiceAuthCodeGrantOpenIdRequestObjectTestCase.OIDC_CLAIM_DIALECT);
    externalClaimDTO.setMappedLocalClaimURI(COUNTRY_LOCAL_CLAIM_URI);
    externalClaimDTO.setExternalClaimURI(COUNTRY_NEW_OIDC_CLAIM);
    claimMetadataManagementServiceClient.addExternalClaim(externalClaimDTO);
    String[] openidValue = new String[1];
    openidValue[0] = COUNTRY_NEW_OIDC_CLAIM;
    oauthAdminClient.updateScope(openIdScope, openidValue, null);
}
Also used : OauthAdminClient(org.wso2.identity.integration.common.clients.oauth.OauthAdminClient) UserProfileMgtServiceClient(org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient) ExternalClaimDTO(org.wso2.carbon.identity.claim.metadata.mgt.stub.dto.ExternalClaimDTO) ClaimMetadataManagementServiceClient(org.wso2.identity.integration.common.clients.claim.metadata.mgt.ClaimMetadataManagementServiceClient) OAuthConsumerAppDTO(org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO) UserManagementClient(org.wso2.carbon.integration.common.admin.client.UserManagementClient) IdentityProviderMgtServiceClient(org.wso2.identity.integration.common.clients.Idp.IdentityProviderMgtServiceClient) BeforeClass(org.testng.annotations.BeforeClass)

Example 3 with UserProfileMgtServiceClient

use of org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient in project product-is by wso2.

the class RESTTestBase method init.

/**
 * Initialize the RestAssured environment and create SwaggerRequestResponseValidator with the swagger definition
 *
 * @param swaggerDefinition swagger definition name
 * @param basePathInSwagger basepath that is defined in the swagger definition (ex: /api/users/v1)
 * @param basePath          basepath of the current test run (ex: /t/carbon.super/api/users/v1)
 * @throws IOException
 * @throws XPathExpressionException
 */
protected void init(String swaggerDefinition, String basePathInSwagger, String basePath) throws RemoteException {
    this.basePath = basePath;
    this.swaggerDefinition = swaggerDefinition;
    RestAssured.baseURI = backendURL.replace(SERVICES, "");
    String swagger = replaceInSwaggerDefinition(swaggerDefinition, basePathInSwagger, basePath);
    OpenApiInteractionValidator openAPIValidator = OpenApiInteractionValidator.createForInlineApiSpecification(swagger).withLevelResolver(LevelResolverFactory.withAdditionalPropertiesIgnored()).build();
    validationFilter = new OpenApiValidationFilter(openAPIValidator);
    remoteUSMServiceClient = new RemoteUserStoreManagerServiceClient(backendURL, sessionCookie);
    userProfileMgtServiceClient = new UserProfileMgtServiceClient(backendURL, sessionCookie);
    identityProviderMgtServiceClient = new IdentityProviderMgtServiceClient(sessionCookie, backendURL);
}
Also used : OpenApiInteractionValidator(com.atlassian.oai.validator.OpenApiInteractionValidator) UserProfileMgtServiceClient(org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient) OpenApiValidationFilter(com.atlassian.oai.validator.restassured.OpenApiValidationFilter) StringContains.containsString(org.hamcrest.core.StringContains.containsString) RemoteUserStoreManagerServiceClient(org.wso2.identity.integration.common.clients.usermgt.remote.RemoteUserStoreManagerServiceClient) IdentityProviderMgtServiceClient(org.wso2.identity.integration.common.clients.Idp.IdentityProviderMgtServiceClient)

Example 4 with UserProfileMgtServiceClient

use of org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient in project product-is by wso2.

the class UserManagementServiceAbstractTest method testListUserByClaim.

@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = "wso2.is", description = "Check list users by claim value", dependsOnMethods = "testGetRolesOfCurrentUser")
public void testListUserByClaim() throws Exception {
    UserProfileMgtServiceClient userProfileMgtServiceClient = new UserProfileMgtServiceClient(backendURL, getSessionCookie());
    UserProfileDTO profile = userProfileMgtServiceClient.getUserProfile(newUserName, "default");
    UserFieldDTO[] fields = userProfileMgtServiceClient.getProfileFieldsForInternalStore().getFieldValues();
    String profileConfigs = profile.getProfileName();
    for (UserFieldDTO field : fields) {
        if (field.getDisplayName().equalsIgnoreCase("Last Name")) {
            field.setFieldValue(newUserName + "LastName");
            continue;
        }
        if (field.getRequired()) {
            if (field.getDisplayName().equalsIgnoreCase("Email")) {
                field.setFieldValue(newUserName + "@wso2.com");
            } else {
                field.setFieldValue(newUserName);
            }
            continue;
        }
        if (field.getFieldValue() == null) {
            field.setFieldValue("");
        }
    }
    // creating a new profile with updated values
    UserProfileDTO newProfile = new UserProfileDTO();
    newProfile.setProfileName(profile.getProfileName());
    newProfile.setFieldValues(fields);
    newProfile.setProfileConifuration(profileConfigs);
    userProfileMgtServiceClient.setUserProfile(newUserName, newProfile);
    ClaimValue claimValue = new ClaimValue();
    claimValue.setClaimURI("http://wso2.org/claims/lastname");
    claimValue.setValue(newUserName + "LastName");
    FlaggedName[] allNames = userMgtClient.listUserByClaim(claimValue, newUserName, 10);
    Assert.assertTrue(nameExists(allNames, newUserName), "List user with claim value has failed");
}
Also used : UserProfileMgtServiceClient(org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient) ClaimValue(org.wso2.carbon.user.mgt.stub.types.carbon.ClaimValue) UserFieldDTO(org.wso2.carbon.identity.user.profile.stub.types.UserFieldDTO) UserProfileDTO(org.wso2.carbon.identity.user.profile.stub.types.UserProfileDTO) FlaggedName(org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName) SetEnvironment(org.wso2.carbon.automation.engine.annotations.SetEnvironment) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 5 with UserProfileMgtServiceClient

use of org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient in project product-is by wso2.

the class UserProfileAdminTestCase method testUserAccountAssociationAdd.

@Test(priority = 4, groups = "wso2.is", description = "Check Fed User Account Association")
public void testUserAccountAssociationAdd() throws Exception {
    super.init();
    userProfileMgtClient = new UserProfileMgtServiceClient(backendURL, sessionCookie);
    userMgtClient = new UserManagementClient(backendURL, sessionCookie);
    String username = "testUser2";
    String password = "passWord1@";
    String idpName = "idp1";
    // create a user
    userMgtClient.addUser(username, password, new String[] { "admin" }, "default");
    Assert.assertTrue(userMgtClient.getUserList().contains(username));
    idpMgtClient = new IdentityProviderMgtServiceClient(username, password, backendURL);
    userProfileMgtClient = new UserProfileMgtServiceClient(backendURL, username, password);
    IdentityProvider idp = new IdentityProvider();
    idp.setIdentityProviderName(idpName);
    idpMgtClient.addIdP(idp);
    Assert.assertNotNull(idpMgtClient.getIdPByName(idpName));
    // create a federated user account association
    userProfileMgtClient.addFedIdpAccountAssociation(idpName, "dummy_idp_account_1");
    userProfileMgtClient.addFedIdpAccountAssociation(idpName, "dummy_idp_account_2");
    AssociatedAccountDTO[] associatedFedUserAccountIds = userProfileMgtClient.getAssociatedFedUserAccountIds();
    Assert.assertNotNull(associatedFedUserAccountIds);
    Assert.assertEquals(associatedFedUserAccountIds.length, 2);
    // delete the user, this should clear the federated idp account associations
    userMgtClient.deleteUser(username);
    Assert.assertEquals(userMgtClient.getUserList().contains(username), false);
    // create the same user
    userMgtClient.addUser(username, password, new String[] { "admin" }, "default");
    userProfileMgtClient = new UserProfileMgtServiceClient(backendURL, username, password);
    associatedFedUserAccountIds = userProfileMgtClient.getAssociatedFedUserAccountIds();
    // assert to make sure there are no federated idp user account associations for this user
    Assert.assertEquals(associatedFedUserAccountIds == null || associatedFedUserAccountIds.length == 0, true);
}
Also used : UserProfileMgtServiceClient(org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient) AssociatedAccountDTO(org.wso2.carbon.identity.user.profile.stub.types.AssociatedAccountDTO) UserManagementClient(org.wso2.identity.integration.common.clients.UserManagementClient) IdentityProvider(org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider) IdentityProviderMgtServiceClient(org.wso2.identity.integration.common.clients.Idp.IdentityProviderMgtServiceClient) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Aggregations

UserProfileMgtServiceClient (org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient)13 BeforeClass (org.testng.annotations.BeforeClass)6 Test (org.testng.annotations.Test)5 UserProfileDTO (org.wso2.carbon.identity.user.profile.stub.types.UserProfileDTO)5 UserManagementClient (org.wso2.identity.integration.common.clients.UserManagementClient)5 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)5 UserFieldDTO (org.wso2.carbon.identity.user.profile.stub.types.UserFieldDTO)4 AuthenticatorClient (org.wso2.carbon.integration.common.admin.client.AuthenticatorClient)4 File (java.io.File)3 SetEnvironment (org.wso2.carbon.automation.engine.annotations.SetEnvironment)3 ServerConfigurationManager (org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager)3 IdentityProviderMgtServiceClient (org.wso2.identity.integration.common.clients.Idp.IdentityProviderMgtServiceClient)3 ClaimManagementServiceClient (org.wso2.identity.integration.common.clients.ClaimManagementServiceClient)2 UserInformationRecoveryServiceClient (org.wso2.identity.integration.common.clients.mgt.UserInformationRecoveryServiceClient)2 RemoteUserStoreManagerServiceClient (org.wso2.identity.integration.common.clients.usermgt.remote.RemoteUserStoreManagerServiceClient)2 OpenApiInteractionValidator (com.atlassian.oai.validator.OpenApiInteractionValidator)1 OpenApiValidationFilter (com.atlassian.oai.validator.restassured.OpenApiValidationFilter)1 StringContains.containsString (org.hamcrest.core.StringContains.containsString)1 ClaimDTO (org.wso2.carbon.claim.mgt.stub.dto.ClaimDTO)1 ClaimMappingDTO (org.wso2.carbon.claim.mgt.stub.dto.ClaimMappingDTO)1