Exemple #1
0
  @BeforeClass(alwaysRun = true)
  public void init() throws Exception {
    int userId = 1;
    UserInfo userInfo = UserListCsvReader.getUserInfo(userId);
    EnvironmentBuilder builderAdmin = new EnvironmentBuilder().greg(ProductConstant.ADMIN_USER_ID);
    ManageEnvironment adminEnvironment = builderAdmin.build();

    EnvironmentBuilder builderUser1 = new EnvironmentBuilder().greg(userId);
    ManageEnvironment user1Environment = builderUser1.build();

    adminUserManagementClient =
        new UserManagementClient(
            adminEnvironment.getGreg().getBackEndUrl(),
            adminEnvironment.getGreg().getSessionCookie());
    user1UserManagementClient =
        new UserManagementClient(
            user1Environment.getGreg().getBackEndUrl(),
            user1Environment.getGreg().getSessionCookie());
    ROLE_USERS = new String[] {userInfo.getUserNameWithoutDomain()};
    // setup roles
    adminUserManagementClient.addRole(ROLE_NAME, ROLE_USERS, SECURITY_PERMISSION_LIST);
    adminUserManagementClient.updateUserListOfRole(EXISTING_ROLE, new String[] {}, ROLE_USERS);
  }
 /**
  * @param roleName name of the role needs to be added to the current user
  * @throws Exception
  */
 private void addRole(String roleName, String userName) throws Exception {
   String[] permissions = {"/permission/admin/manage/"};
   if (!userManagementClient.roleNameExists(roleName)) {
     userManagementClient.addRole(roleName, new String[] {userName}, permissions);
   }
 }
Exemple #3
0
 @Test(dependsOnMethods = "testCreateUser")
 public void testCreateRole() throws Exception {
   user1UserManagementClient.addRole(NEW_ROLE, new String[] {}, DUMMY_ROLE_PERMISSION_LIST);
   Assert.assertTrue(adminUserManagementClient.roleNameExists(NEW_ROLE));
 }