Search in sources :

Example 26 with SetEnvironment

use of org.wso2.carbon.automation.engine.annotations.SetEnvironment in project product-is by wso2.

the class UserManagementServiceAbstractTest method testBulkImportUsers.

// todo need to fix properly
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
public // @Test(groups = "wso2.is", description = "Check importing bulk users", dependsOnMethods = "testGetRolePermissions")
void testBulkImportUsers() throws Exception {
    // ToDo:get userStoreDomain properly
    String userStoreDomain = "PRIMARY";
    File bulkUserFile = new File(getISResourceLocation() + File.separator + "userMgt" + File.separator + "bulkUserImport.csv");
    DataHandler handler = new DataHandler(new FileDataSource(bulkUserFile));
    userMgtClient.bulkImportUsers(userStoreDomain, "bulkUserImport.csv", handler, "PassWord1@");
    String[] userList = userMgtClient.listUsers("*", 100);
    Assert.assertNotNull(userList);
    Assert.assertEquals(userMgtClient.listUsers("bulkUser1", 10), new String[] { "bulkUser1" });
    Assert.assertEquals(userMgtClient.listUsers("bulkUser2", 10), new String[] { "bulkUser2" });
    Assert.assertEquals(userMgtClient.listUsers("bulkUser3", 10), new String[] { "bulkUser3" });
    userMgtClient.deleteUser("bulkUser1");
    userMgtClient.deleteUser("bulkUser2");
    userMgtClient.deleteUser("bulkUser3");
}
Also used : FileDataSource(javax.activation.FileDataSource) DataHandler(javax.activation.DataHandler) File(java.io.File) SetEnvironment(org.wso2.carbon.automation.engine.annotations.SetEnvironment)

Example 27 with SetEnvironment

use of org.wso2.carbon.automation.engine.annotations.SetEnvironment 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();
}
Also used : UserManagementClient(org.wso2.identity.integration.common.clients.UserManagementClient) SetEnvironment(org.wso2.carbon.automation.engine.annotations.SetEnvironment) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 28 with SetEnvironment

use of org.wso2.carbon.automation.engine.annotations.SetEnvironment in project product-is by wso2.

the class UserManagementServiceAbstractTest method testGetUserRealmInfo.

@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = "wso2.is", description = "Check getting user realm info", dependsOnMethods = "testSetRoleUIPermission")
public void testGetUserRealmInfo() throws Exception {
    UserRealmInfo realmInfo = userMgtClient.getUserRealmInfo();
    Assert.assertNotNull(realmInfo);
}
Also used : UserRealmInfo(org.wso2.carbon.user.mgt.stub.types.carbon.UserRealmInfo) SetEnvironment(org.wso2.carbon.automation.engine.annotations.SetEnvironment) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 29 with SetEnvironment

use of org.wso2.carbon.automation.engine.annotations.SetEnvironment in project product-is by wso2.

the class UserManagementServiceAbstractTest method testUpdateUsersOfRole.

@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = "wso2.is", description = "Check update users of role", dependsOnMethods = "testAddRemoveRolesOfUser")
public void testUpdateUsersOfRole() throws Exception {
    String[] userList = new String[] { newUserName };
    FlaggedName[] userFlagList = new FlaggedName[userList.length];
    for (int i = 0; i < userFlagList.length; i++) {
        FlaggedName flaggedName = new FlaggedName();
        flaggedName.setItemName(userList[i]);
        flaggedName.setSelected(true);
        userFlagList[i] = flaggedName;
    }
    userMgtClient.updateUsersOfRole(newUserRole, userFlagList);
    Assert.assertTrue(nameExists(userMgtClient.getUsersOfRole(newUserRole, newUserName, 0), newUserName), "Adding user to role has failed");
    // Calling with same user list should delete the users.
    for (int i = 0; i < userFlagList.length; i++) {
        userFlagList[i].setSelected(false);
    }
    userMgtClient.updateUsersOfRole(userRoleTmp, userFlagList);
    Assert.assertFalse(nameExists(userMgtClient.getUsersOfRole(userRoleTmp, newUserName, 0), newUserName), "Deleting user from role has failed");
// Assert.assertFalse(nameExists(userMgtClient.getUsersOfRole("umRole1", "user2", 0), "user2"), "Deleting user2 from role has failed");
}
Also used : 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 30 with SetEnvironment

use of org.wso2.carbon.automation.engine.annotations.SetEnvironment 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)

Aggregations

SetEnvironment (org.wso2.carbon.automation.engine.annotations.SetEnvironment)58 Test (org.testng.annotations.Test)45 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)29 Resource (org.apache.wink.client.Resource)16 BasicAuthInfo (org.wso2.identity.integration.test.utils.BasicAuthInfo)16 VerificationBean (org.wso2.carbon.identity.mgt.stub.beans.VerificationBean)14 ClientConfig (org.apache.wink.client.ClientConfig)12 RestClient (org.apache.wink.client.RestClient)12 SCIMResponseHandler (org.wso2.identity.integration.test.scim.utils.SCIMResponseHandler)12 File (java.io.File)9 BeforeClass (org.testng.annotations.BeforeClass)9 UserIdentityClaimDTO (org.wso2.carbon.identity.mgt.stub.dto.UserIdentityClaimDTO)8 AuthenticatorClient (org.wso2.carbon.integration.common.admin.client.AuthenticatorClient)7 UserManagementClient (org.wso2.identity.integration.common.clients.UserManagementClient)6 ServerConfigurationManager (org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager)5 JSONObject (org.json.simple.JSONObject)4 FlaggedName (org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName)4 SCIMClient (org.wso2.charon.core.client.SCIMClient)4 RemoteUserStoreManagerServiceClient (org.wso2.identity.integration.common.clients.usermgt.remote.RemoteUserStoreManagerServiceClient)4 ClaimValue (org.wso2.carbon.um.ws.api.stub.ClaimValue)3