Ejemplo n.º 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);
 }
Ejemplo n.º 2
0
 @Test
 public void testUpdateExistingGroup() throws Exception {
   LdapGroup g1 = (LdapGroup) HELPER.getGroup("users");
   LOG.log(Level.INFO, "Group users description: {0}", g1.get("description"));
   String description = g1.get("description");
   g1.set("description", description + CN);
   HELPER.setGroup(g1);
   g1 = (LdapGroup) HELPER.getGroup("users");
   assertEquals(g1.get("description"), description + CN);
   g1.set("description", description);
   HELPER.setGroup(g1);
   g1 = (LdapGroup) HELPER.getGroup("users");
   assertEquals(g1.get("description"), description);
 }
Ejemplo n.º 3
0
 @Test
 public void testUpdateGroup() throws Exception {
   LdapGroup g1 = Utils.createTestGroup(CN);
   assertNull(g1.get("description"));
   g1.set("description", "Group " + CN);
   HELPER.setGroup(g1);
   g1 = (LdapGroup) HELPER.getGroup(CN);
   assertEquals(g1.get("description"), "Group " + CN);
   Utils.removeTestGroup(g1);
 }
Ejemplo n.º 4
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);
 }
Ejemplo n.º 5
0
 @Test
 public void testCreateGroup() throws Exception {
   Node g1 = HELPER.getGroup(CN);
   assertTrue(g1.isEmpty());
   LdapGroup t1 = Utils.getTestGroup("test");
   t1 = Utils.updatedGroup(t1, CN);
   if (HELPER.setGroup(t1)) {
     LOG.log(Level.INFO, "created Group {0}", CN);
   }
   g1 = HELPER.getGroup(CN);
   assertFalse(g1.isEmpty());
 }
Ejemplo n.º 6
0
 @Test
 public void testAddUsersToGroup() throws Exception {
   testUser2 = HELPER.getUserTemplate("U_" + System.currentTimeMillis());
   testUser2.set("cn", testUser2.getUid());
   HELPER.setUser(testUser2);
   LdapGroup g1 = Utils.createTestGroup(CN);
   g1.addUser(testUser1);
   g1.addUser(testUser2);
   HELPER.setGroup(g1);
   g1 = (LdapGroup) HELPER.getGroup(CN);
   LOG.log(Level.INFO, "user count Group {0} is {1}", new Object[] {CN, g1.getUsers().size()});
   assertTrue(g1.getUsers().size() > 2);
   Utils.removeTestGroup(g1);
 }
Ejemplo n.º 7
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);
 }