GroupManagerTestCase.java revision 9aa1482c49865483f798f91ef7d16f03cc3ec811
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2015 ForgeRock AS
*/
/**
* A set of test cases that involve the use of groups and the Directory Server
* Group Manager.
*/
public class GroupManagerTestCase
extends CoreTestCase
{
/**
* Ensures that the Directory Server is running.
*
* @throws Exception If an unexpected problem occurs.
*/
public void startServer()
throws Exception
{
}
public void cleanUp() {
}
/**
* Tests the {@code GroupManager.getGroupImplementations} method to ensure
* that it contains the appropriate set of values.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testGetGroupImplementations()
throws Exception
{
{
}
"Unexpected group class(es) registered: " + groupClasses);
}
/**
* Test static group nesting with some of the groups pointing to each
* other in a circular fashion. Once this situation is detected the
* membership check should return false.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testStaticGroupCircularNested() throws Exception {
//Add circular nested group definition by adding group 1 to group 3
//nested list. Group 1 contains group 2, which contains group 3, which
//contains group 1.
//Search for DN not in any of the groups/
}
/**
* Test static group nesting wit one of the nested groups being a
* dynamic group.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testStaticGroupDynamicNested() throws Exception {
//User 5 is not added to any group, it matches the URL of the dynamic
//group "group 4".
//Group 4 is a dynamic group.
//Dynamic group 4 is added to nested list of group 3.
//Check membership of user 5 through group 1. User 5 is a member of the
//dynamic group "group 4" which is nested.
}
/**
* Invokes membership and nested group APIs using a group instance that has
* been changed by the group manager via ldap modify.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testStaticGroupInstanceChange() throws Exception {
//Add even numbered groups.
//Add even numbered members.
//Switch things around, change groups and members to odd numbered nested
//groups and odd numbered members via ldap modify.
//Delete even groups and users.
//Add odd groups and users.
//Check that the user membership changes were picked up.
//Check get members picked up everything.
while (memberList.hasMoreMembers())
{
}
//Check that the nested group changes were picked up.
}
/**
* Invokes membership and nested group APIs using a group instance that has
* been removed from the group manager via ldap delete.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testStaticGroupInstanceInvalid() throws Exception {
//Add some nested groups and members.
//Delete the group.
//Membership check should throw an exception.
try
{
throw new AssertionError("Expected isMember to fail but " +
"it didn't");
} catch (DirectoryException ex) {}
//Nested groups should be empty.
try
{
fail("getMembers)() should have thrown a DirectoryException");
} catch (DirectoryException ex) {}
}
/**
* Invokes nested group API methods on various nested group
* scenerios.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testStaticGroupNestedAPI() throws Exception {
//These casts are needed so there isn't a unchecked assignment
//compile warning in the getNestedGroupDNs calls below. Some IDEs
//will give a unchecked cast warning.
//Add nested groups.
//Add some members.
//Check if group 3 shows up in the group 2 membership list.
boolean found=false;
while (memberList.hasMoreMembers())
{
found=true;
break;
}
}
//Check membership via group 1 using nesting of group 2 and group 3.
//User 5 is in group 3.
//Check group 3 is removed from group 2 membership list.
found=false;
while (memberList.hasMoreMembers())
{
found=true;
break;
}
}
//Check membership via group 1 should fail now, since nested group 3
//was removed from group 2.
//Check remove member call also removes DN from nested group list.
//Add nested groups to group 1
//Check get nested groups DNs list returns correct DN list.
//Check removing a group not in the nested group list fails.
try
{
throw new AssertionError("Expected removeNestedGroup to fail but " +
"it didn't");
} catch (DirectoryException ex) {}
//Check adding a nested group already in the nested group list fails.
try
{
throw new AssertionError("Expected addNestedGroup to fail but " +
"it didn't");
} catch (DirectoryException ex) {}
//Modify list via ldap modify.
//Check removing a group already removed via ldap modify fails.
try
{
throw new AssertionError("Expected removeNestedGroup to fail but " +
"it didn't");
} catch (DirectoryException ex) {}
//Check adding a group added via ldap modify fails.
try
{
throw new AssertionError("Expected addNestedGroup to fail but " +
"it didn't");
} catch (DirectoryException ex) {}
}
/**
* Invokes general group API methods on a static group.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testGenericStaticGroupAPI()
throws Exception
{
"dn: ou=People,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: People",
"",
"dn: ou=Groups,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: Groups",
"",
"dn: uid=user.1,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.1",
"givenName: User",
"sn: 1",
"cn: User 1",
"userPassword: password",
"",
"dn: uid=user.2,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.2",
"givenName: User",
"sn: 2",
"cn: User 2",
"userPassword: password",
"",
"dn: uid=user.3,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.3",
"givenName: User",
"sn: 3",
"cn: User 3",
"userPassword: password",
"",
"dn: cn=Test Group of Names,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfNames",
"cn: Test Group of Unique Names",
"member: uid=user.1,ou=People,o=test",
"member: uid=user.2,ou=People,o=test");
try
{
} catch (DirectoryException ex) {
throw new AssertionError("Expected addNestedGroup to succeed but" +
" it didn't");
}
try
{
} catch (DirectoryException ex) {
throw new AssertionError("Expected removeNestedGroup to succeed " +
"but it didn't");
}
}
/**
* Tests that the server properly handles adding, deleting, and modifying a
* static group based on the groupOfNames object class where that group
* contains valid members.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testValidPopulatedGroupOfNames()
throws Exception
{
"dn: ou=People,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: People",
"",
"dn: ou=Groups,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: Groups",
"",
"dn: uid=user.1,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.1",
"givenName: User",
"sn: 1",
"cn: User 1",
"userPassword: password",
"",
"dn: uid=user.2,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.2",
"givenName: User",
"sn: 2",
"cn: User 2",
"userPassword: password",
"",
"dn: uid=user.3,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.3",
"givenName: User",
"sn: 3",
"cn: User 3",
"userPassword: password");
// Make sure that there aren't any groups registered with the server.
// Add a new static group to the server and make sure it gets registered
// with the group manager.
"dn: cn=Test Group of Names,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfNames",
"cn: Test Group of Names",
"member: uid=user.1,ou=People,o=test",
"member: uid=user.2,ou=People,o=test");
// Perform a basic set of validation on the group itself.
while (memberList.hasMoreMembers())
{
}
// Modify the group and make sure the group manager gets updated accordingly
// Delete the group and make sure the group manager gets updated accordingly
}
/**
* Tests that the server properly handles a groupOfNames object that doesn't
* contain any members.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testValidEmptyGroupOfNames()
throws Exception
{
"dn: ou=Groups,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: Groups");
// Make sure that there aren't any groups registered with the server.
// Add a new static group to the server and make sure it gets registered
// with the group manager.
"dn: cn=Test Group of Names,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfNames",
"cn: Test Group of Names");
// Make sure that the group exists but doesn't have any members.
// Delete the group and make sure the group manager gets updated accordingly
}
/**
* Tests that the server properly handles adding, deleting, and modifying a
* static group based on the groupOfUniqueNames object class where that group
* contains valid members.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testValidPopulatedGroupOfUniqueNames()
throws Exception
{
"dn: ou=People,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: People",
"",
"dn: ou=Groups,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: Groups",
"",
"dn: uid=user.1,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.1",
"givenName: User",
"sn: 1",
"cn: User 1",
"userPassword: password",
"",
"dn: uid=user.2,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.2",
"givenName: User",
"sn: 2",
"cn: User 2",
"userPassword: password",
"",
"dn: uid=user.3,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.3",
"givenName: User",
"sn: 3",
"cn: User 3",
"userPassword: password");
// Make sure that there aren't any groups registered with the server.
// Add a new static group to the server and make sure it gets registered
// with the group manager.
"dn: cn=Test Group of Unique Names,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfUniqueNames",
"cn: Test Group of Unique Names",
"uniqueMember: uid=user.1,ou=People,o=test",
"uniqueMember: uid=user.2,ou=People,o=test");
// Perform a basic set of validation on the group itself.
while (memberList.hasMoreMembers())
{
}
// Modify the group and make sure the group manager gets updated accordingly
// Delete the group and make sure the group manager gets updated accordingly
}
/**
* Tests that the server properly handles a groupOfUniqueNames object that
* doesn't contain any members.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testValidEmptyGroupOfUniqueNames()
throws Exception
{
"dn: ou=Groups,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: Groups");
// Make sure that there aren't any groups registered with the server.
// Add a new static group to the server and make sure it gets registered
// with the group manager.
"dn: cn=Test Group of Unique Names,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfUniqueNames",
"cn: Test Group of Names");
// Make sure that the group exists but doesn't have any members.
// Delete the group and make sure the group manager gets updated accordingly
}
/**
* Tests that the server properly handles adding, deleting, and modifying a
* static group based on the groupOfEntries object class where that group
* contains valid members.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testValidPopulatedGroupOfEntries()
throws Exception
{
"dn: ou=People,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: People",
"",
"dn: ou=Groups,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: Groups",
"",
"dn: uid=user.1,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.1",
"givenName: User",
"sn: 1",
"cn: User 1",
"userPassword: password",
"",
"dn: uid=user.2,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.2",
"givenName: User",
"sn: 2",
"cn: User 2",
"userPassword: password",
"",
"dn: uid=user.3,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.3",
"givenName: User",
"sn: 3",
"cn: User 3",
"userPassword: password");
// Make sure that there aren't any groups registered with the server.
// Add a new static group to the server and make sure it gets registered
// with the group manager.
"dn: cn=Test Group of Entries,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfEntries",
"cn: Test Group of Entries",
"member: uid=user.1,ou=People,o=test",
"member: uid=user.2,ou=People,o=test");
// Perform a basic set of validation on the group itself.
while (memberList.hasMoreMembers())
{
}
// Modify the group and make sure the group manager gets updated accordingly
// Delete the group and make sure the group manager gets updated accordingly
}
/**
* Tests that the server properly handles a groupOfEntries object that doesn't
* contain any members.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testValidEmptyGroupOfEntries()
throws Exception
{
"dn: ou=Groups,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: Groups");
// Make sure that there aren't any groups registered with the server.
// Add a new static group to the server and make sure it gets registered
// with the group manager.
"dn: cn=Test Group of Entries,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfEntries",
"cn: Test Group of Names");
// Make sure that the group exists but doesn't have any members.
// Delete the group and make sure the group manager gets updated accordingly
}
/**
* Verifies that the group manager properly handles modify DN operations on
* static group entries.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testRenameStaticGroup()
throws Exception
{
"dn: ou=People,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: People",
"",
"dn: ou=Groups,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: Groups",
"",
"dn: uid=user.1,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.1",
"givenName: User",
"sn: 1",
"cn: User 1",
"userPassword: password");
// Make sure that there aren't any groups registered with the server.
// Add a new static group to the server and make sure it gets registered
// with the group manager.
"dn: cn=Test Group of Unique Names,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfUniqueNames",
"cn: Test Group of Unique Names",
"uniqueMember: uid=user.1,ou=People,o=test");
// Perform a basic set of validation on the group itself.
// Rename the group and make sure the old one no longer exists but the new
// one does.
// Delete the group and make sure the group manager gets updated accordingly
}
/**
* Tests the methods related to static group membership in the
* {@code ClientConnection} class.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testStaticClientConnectionMembership()
throws Exception
{
"dn: ou=People,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: People",
"",
"dn: ou=Groups,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: Groups",
"",
"dn: uid=user.1,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.1",
"givenName: User",
"sn: 1",
"cn: User 1",
"userPassword: password",
"",
"dn: uid=user.2,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.2",
"givenName: User",
"sn: 2",
"cn: User 2",
"userPassword: password",
"",
"dn: uid=user.3,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.3",
"givenName: User",
"sn: 3",
"cn: User 3",
"userPassword: password",
"",
"dn: cn=Group 1,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfNames",
"cn: Group 1",
"member: uid=user.1,ou=People,o=test",
"member: uid=user.2,ou=People,o=test",
"",
"dn: cn=Group 2,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfUniqueNames",
"cn: Group 3",
"uniqueMember: uid=user.2,ou=People,o=test",
"uniqueMember: uid=user.3,ou=People,o=test",
"",
"dn: cn=Group 3,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfUniqueNames",
"cn: Group 3",
"uniqueMember: uid=user.1,ou=People,o=test",
"uniqueMember: uid=user.3,ou=People,o=test",
"",
"dn: cn=Group 4,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfEntries",
"cn: Group 4",
"member: uid=user.1,ou=People,o=test",
"member: uid=user.2,ou=People,o=test");
// Perform basic validation on the groups.
// Get a client connection authenticated as user1 and make sure it handles
// group operations correctly.
// Get a client connection authenticated as user1 and make sure it handles
// group operations correctly.
// Get a client connection authenticated as user2 and make sure it handles
// group operations correctly.
// Get a client connection authenticated as user3 and make sure it handles
// group operations correctly.
// Delete all of the groups and make sure the group manager gets updated accordingly
}
{
}
/**
* Tests operations involving static group member lists.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testStaticMemberList()
throws Exception
{
"dn: ou=People,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: People",
"",
"dn: ou=Groups,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: Groups",
"",
"dn: uid=user.1,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.1",
"givenName: User",
"sn: 1",
"cn: User 1",
"userPassword: password",
"",
"dn: uid=user.2,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.2",
"givenName: User",
"sn: 2",
"cn: User 2",
"userPassword: password",
"",
"dn: uid=user.3,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.3",
"givenName: User",
"sn: 3",
"cn: User 3",
"userPassword: password",
"",
"dn: cn=Test Group of Unique Names,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfUniqueNames",
"cn: Test Group of Unique Names",
"uniqueMember: uid=user.1,ou=People,o=test",
"uniqueMember: uid=user.2,ou=People,o=test",
"uniqueMember: uid=user.3,ou=People,o=test",
"uniqueMember: uid=nonexistentUser,ou=People,o=test");
// Get the group instance.
// Use a member list to iterate across the member DNs with no filter.
while (memberList.hasMoreMembers())
{
try
{
} catch (MembershipException me) {}
}
memberList.close();
// Perform a filtered iteration across the member DNs.
while (memberList.hasMoreMembers())
{
try
{
} catch (MembershipException me) {}
}
memberList.close();
// Use a member list to iterate across the member entries with no filter.
while (memberList.hasMoreMembers())
{
try
{
} catch (MembershipException me) {}
}
memberList.close();
// Perform a filtered iteration across the member entries.
while (memberList.hasMoreMembers())
{
try
{
} catch (MembershipException me) {}
}
memberList.close();
// Delete the group and make sure the group manager gets updated accordingly
}
/**
* Invokes general group API methods on a dynamic group.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testGenericDynamicGroupAPI()
throws Exception
{
"dn: ou=People,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: People",
"",
"dn: ou=Groups,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: Groups",
"",
"dn: uid=user.1,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.1",
"givenName: User",
"sn: 1",
"cn: User 1",
"userPassword: password",
"",
"dn: uid=user.2,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.2",
"givenName: User",
"sn: 2",
"cn: User 2",
"userPassword: password",
"",
"dn: uid=user.3,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.3",
"givenName: User",
"sn: 3",
"cn: User 3",
"userPassword: password",
"",
"dn: cn=Test Group of URLs,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfURLs",
"cn: Test Group of URLs",
"memberURL: ldap:///o=test??sub?(sn<=2)");
try
{
throw new AssertionError("Expected addNestedGroup to fail but it " +
"didn't");
} catch (UnsupportedOperationException uoe) {}
try
{
throw new AssertionError("Expected removeNestedGroup to fail but " +
"it didn't");
} catch (UnsupportedOperationException uoe) {}
try
{
throw new AssertionError("Expected addMember to fail but it didn't");
} catch (UnsupportedOperationException uoe) {}
try
{
throw new AssertionError("Expected removeMember to fail but it didn't");
} catch (UnsupportedOperationException uoe) {}
}
/**
* Tests to ensure that an attempt to add a dynamic group with a malformed URL
* will cause it to be decoded as a group but any operations attempted with it
* will fail with an exception.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testDynamicGroupMalformedURL()
throws Exception
{
"dn: ou=People,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: People",
"",
"dn: ou=Groups,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: Groups",
"",
"dn: uid=user.1,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.1",
"givenName: User",
"sn: 1",
"cn: User 1",
"userPassword: password",
"",
"dn: cn=Test Malformed URL,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfURLs",
"cn: Test Malformed URL",
"memberURL: ldap:///o=test??sub?(malformed)");
}
/**
* Tests the {@code getMembers()} method for a dynamic group, using the
* variant that doesn't take any arguments.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testGetMembersSimple()
throws Exception
{
"dn: ou=People,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: People",
"",
"dn: ou=Groups,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: Groups",
"",
"dn: uid=user.1,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.1",
"givenName: User",
"sn: 1",
"cn: User 1",
"userPassword: password",
"",
"dn: uid=user.2,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.2",
"givenName: User",
"sn: 2",
"cn: User 2",
"userPassword: password",
"",
"dn: uid=user.3,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.3",
"givenName: User",
"sn: 3",
"cn: User 3",
"userPassword: password",
"",
"dn: cn=Test Group of URLs,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfURLs",
"cn: Test Group of URLs",
"memberURL: ldap:///o=test??sub?(sn<=2)");
while (memberList.hasMoreMembers())
{
"Returned unexpected member " + memberDN);
}
memberList.close();
"Expected member set to be empty but it was not: " + memberSet);
}
/**
* Tests the {@code getMembers()} method for a dynamic group, using the
* variant that takes base, scope, and filter arguments.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testGetMembersComplex()
throws Exception
{
"dn: ou=People,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: People",
"",
"dn: ou=Groups,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: Groups",
"",
"dn: uid=user.1,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.1",
"givenName: User",
"sn: 1",
"cn: User 1",
"userPassword: password",
"",
"dn: uid=user.2,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.2",
"givenName: User",
"sn: 2",
"cn: User 2",
"userPassword: password",
"",
"dn: uid=user.3,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.3",
"givenName: User",
"sn: 3",
"cn: User 3",
"userPassword: password",
"",
"dn: cn=Test Group of URLs,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfURLs",
"cn: Test Group of URLs",
"memberURL: ldap:///o=test??sub?(sn<=2)");
while (memberList.hasMoreMembers())
{
"Returned unexpected member " + memberDN);
}
memberList.close();
"Expected member set to be empty but it was not: " + memberSet);
}
/**
* Tests the {@code getMembers()} method for a dynamic group that contains
* multiple member URLs containing non-overlapping criteria.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testGetMembersMultipleDistinctURLs()
throws Exception
{
"dn: ou=People,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: People",
"",
"dn: ou=Groups,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: Groups",
"",
"dn: uid=user.1,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.1",
"givenName: User",
"sn: 1",
"cn: User 1",
"userPassword: password",
"",
"dn: uid=user.2,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.2",
"givenName: User",
"sn: 2",
"cn: User 2",
"userPassword: password",
"",
"dn: uid=user.3,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.3",
"givenName: User",
"sn: 3",
"cn: User 3",
"userPassword: password",
"",
"dn: cn=Test Group of URLs,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfURLs",
"cn: Test Group of URLs",
"memberURL: ldap:///o=test??sub?(sn=1)",
"memberURL: ldap:///o=test??sub?(sn=2)");
while (memberList.hasMoreMembers())
{
"Returned unexpected member " + memberDN);
}
memberList.close();
"Expected member set to be empty but it was not: " + memberSet);
}
/**
* Tests the {@code getMembers()} method for a dynamic group that contains
* multiple member URLs containing overlapping criteria.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testGetMembersMultipleOverlappingURLs()
throws Exception
{
"dn: ou=People,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: People",
"",
"dn: ou=Groups,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: Groups",
"",
"dn: uid=user.1,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.1",
"givenName: User",
"sn: 1",
"cn: User 1",
"userPassword: password",
"",
"dn: uid=user.2,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.2",
"givenName: User",
"sn: 2",
"cn: User 2",
"userPassword: password",
"",
"dn: uid=user.3,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.3",
"givenName: User",
"sn: 3",
"cn: User 3",
"userPassword: password",
"",
"dn: cn=Test Group of URLs,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfURLs",
"cn: Test Group of URLs",
"memberURL: ldap:///dc=example,dc=com??sub?(cn=nonexistent)",
"memberURL: ldap:///uid=user.2,ou=People,o=test??sub?(sn=2)",
"memberURL: ldap:///o=test??sub?(sn=1)",
"memberURL: ldap:///ou=People,o=test??subordinate?(!(sn=3))");
while (memberList.hasMoreMembers())
{
"Returned unexpected member " + memberDN);
}
memberList.close();
"Expected member set to be empty but it was not: " + memberSet);
}
/**
* Tests subtree delete operation on groups tree.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSubtreeDelete() throws Exception {
// Get a client connection authenticated as user1 and make sure it handles
// group operations correctly.
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"--noPropertiesFile",
"ou=groups,dc=example,dc=com"
};
}
/**
* Tests subtree modify operation on groups tree.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSubtreeModify() throws Exception {
// Get a client connection authenticated as user1 and make sure it handles
// group operations correctly.
"dn: ou=groups,dc=example,dc=com",
"changetype: moddn",
"newRDN: ou=newgroups",
"deleteOldRDN: 1");
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"--noPropertiesFile",
"-f", path
};
}
/**
* Adds nested group entries.
*
* @throws Exception If a problem adding the entries occurs.
*/
private void addNestedGroupTestEntries() throws Exception {
"dn: ou=People,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: People",
"",
"dn: ou=Groups,o=test",
"objectClass: top",
"objectClass: organizationalUnit",
"ou: Groups",
"",
"dn: cn=group 1,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfNames",
"cn: group 1",
"",
"dn: cn=group 2,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfNames",
"cn: group 2",
"",
"dn: cn=group 3,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfNames",
"cn: group 3",
"",
"dn: cn=group 4,ou=Groups,o=test",
"objectClass: top",
"objectClass: groupOfURLs",
"cn: group 4",
"memberURL: ldap:///ou=people,o=test??sub?(sn>=5)",
"",
"dn: uid=user.1,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.1",
"givenName: User",
"sn: 1",
"cn: User 1",
"userPassword: password",
"",
"dn: uid=user.2,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.2",
"givenName: User",
"sn: 2",
"cn: User 2",
"userPassword: password",
"",
"dn: uid=user.3,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.3",
"givenName: User",
"sn: 3",
"cn: User 3",
"userPassword: password",
"",
"dn: uid=user.4,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.4",
"givenName: User",
"sn: 4",
"cn: User 4",
"userPassword: password",
"",
"dn: uid=user.5,ou=People,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: user.5",
"givenName: User",
"sn: 5",
"cn: User 5",
"userPassword: password");
}
/**
* Adds entries for subtree operations tests.
*
* @throws Exception If a problem adding the entries occurs.
*/
private void addSubtreeGroupTestEntries() throws Exception {
"dn: ou=people,dc=example,dc=com",
"objectClass: organizationalUnit",
"objectClass: top",
"ou: people",
"",
"dn: uid=test1,ou=people,dc=example,dc=com",
"objectClass: person",
"objectClass: inetOrgPerson",
"objectClass: organizationalPerson",
"objectClass: top",
"uid: test1",
"cn: test",
"sn: test",
"userPassword: password",
"",
"dn: ou=groups,dc=example,dc=com",
"objectClass: organizationalUnit",
"objectClass: top",
"ou: groups",
"",
"dn: cn=group1,ou=groups,dc=example,dc=com",
"objectClass: groupOfNames",
"objectClass: top",
"member: uid=test1,ou=people,dc=example,dc=com",
"cn: group1",
"",
"dn: cn=group2,ou=groups,dc=example,dc=com",
"objectClass: groupOfNames",
"objectClass: top",
"member: uid=test1,ou=people,dc=example,dc=com",
"cn: group2",
"",
"dn: ou=moregroups,dc=example,dc=com",
"objectClass: organizationalUnit",
"objectClass: top",
"ou: moregroups",
"",
"dn: cn=group1,ou=moregroups,dc=example,dc=com",
"objectClass: groupOfNames",
"objectClass: top",
"member: uid=test1,ou=people,dc=example,dc=com",
"cn: group1"
);
}
}