Beispiel #1
0
 @Test
 public void testRemoveUserFromGroup() throws Exception {
   LdapGroup g1 = Utils.createTestGroup(CN);
   String[] usernames = {"U1_" + System.currentTimeMillis(), "U2_" + System.currentTimeMillis()};
   if (HELPER.setGroup(g1)) {
     LOG.log(Level.INFO, "updated Group {0}", CN);
   }
   List<LdapUser> users = Utils.createTestUsers(usernames);
   for (LdapUser user : users) {
     g1.addUser(user);
   }
   HELPER.setGroup(g1);
   g1 = (LdapGroup) HELPER.getGroup(CN);
   int count = g1.getUsers().size();
   LOG.log(Level.INFO, "user count Group {0} is {1}", new Object[] {CN, count});
   g1.debug();
   assertTrue(count > 1);
   g1.rmUser(users.get(0));
   HELPER.setGroup(g1);
   g1 = (LdapGroup) HELPER.getGroup(CN);
   LOG.log(Level.INFO, "user count Group {0} is {1}", new Object[] {CN, g1.getUsers().size()});
   g1.debug();
   assertTrue(g1.getUsers().size() == (count - 1));
   Utils.removeTestGroup(g1);
   Utils.removeTestUsers(users);
 }
Beispiel #2
0
 @Test
 public void testGroupLoad() {
   LdapGroup group = (LdapGroup) HELPER.getGroup(HELPER.getAdminGroupIdentifiyer());
   group.debug();
   LOG.log(Level.INFO, "\nmembers: {0}\n", group.get(HELPER.getGroupMemberAttribut()));
   assertFalse(group.isNew());
   assertFalse(group.isEmpty());
 }
Beispiel #3
0
 @Test
 public void testAddUserToGroup() throws Exception {
   LdapGroup g1 = Utils.createTestGroup(CN);
   g1.addUser(testUser1);
   if (HELPER.setGroup(g1)) {
     LOG.log(Level.INFO, "updated Group {0}", CN);
   }
   g1 = (LdapGroup) HELPER.getGroup(CN);
   g1.debug();
   Utils.removeTestGroup(g1);
 }
Beispiel #4
0
 @Test
 public void testUpdateEmptyGroup() throws Exception {
   LdapGroup g1 = Utils.createTestGroup(CN);
   int count = g1.getUsers().size();
   LOG.log(Level.INFO, "user count Group {0} is {1}", new Object[] {CN, count});
   g1.debug();
   List<LdapUser> users = new ArrayList<LdapUser>();
   for (LdapUser user : g1.getUsers()) {
     users.add(user);
   }
   for (LdapUser user : users) {
     g1.rmUser(user);
   }
   HELPER.setGroup(g1);
   g1 = (LdapGroup) HELPER.getGroup(CN);
   count = g1.getUsers().size();
   LOG.log(Level.INFO, "user count Group {0} is {1}", new Object[] {CN, count});
   g1.debug();
   assertTrue(g1.getUsers().size() == 1);
   Utils.removeTestGroup(g1);
 }