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");
}
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();
}
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);
}
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");
}
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");
}
Aggregations