/*
* 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 2006-2009 Sun Microsystems, Inc.
* Portions Copyright 2011-2015 ForgeRock AS
*/
/**
* A set of test cases for the LDAPSearch tool.
*/
@SuppressWarnings("javadoc")
public class LDAPSearchTestCase
extends ToolsTestCase
{
/** The path to a file containing an invalid bind password. */
/** The path to a file containing a valid bind password. */
/**
* Ensures that the Directory Server is running and performs other necessary
* setup.
*
* @throws Exception If an unexpected problem occurs.
*/
{
"set-sasl-mechanism-handler-prop",
"--handler-name", "DIGEST-MD5",
"--set", "server-fqdn:" + "127.0.0.1");
fileWriter.close();
fileWriter.close();
}
"set-sasl-mechanism-handler-prop",
"--handler-name", "DIGEST-MD5",
"--remove", "server-fqdn:" + "127.0.0.1");
}
/**
* Retrieves sets of invalid arguments that may not be used to initialize
* the LDAPSearch tool.
*
* @return Sets of invalid arguments that may not be used to initialize the
* LDAPSearch tool.
*/
{
"-h", "-p", "-V", "-f", "-J", "-z", "-l", "-s", "-a", "-o", "-c",
"--assertionFilter", "--matchedValuesFilter");
{
}
{
"-I"
};
{
"--invalidLongArgument"
};
{
"(objectClass=*)"
};
{
"-b", ""
};
{
"-b", "",
"(invalidfilter)"
};
{
"-b", "",
"--assertionFilter", "(invalidfilter)",
"(objectClass=*)"
};
{
"-b", "",
"--matchedValuesFilter", "(invalidfilter)",
"(objectClass=*)"
};
{
"-D", "cn=Directory Manager",
"-j", "no.such.file",
"-b", "",
"(objectClass=*)"
};
{
"-D", "cn=Directory Manager",
"-w", "password",
"-j", validPasswordFile,
"-b", "",
"(objectClass=*)"
};
{
"-b", "",
"-V", "nonnumeric",
"(objectClass=*)"
};
{
"-b", "",
"-V", "1",
"(objectClass=*)"
};
{
"-b", "",
"-f", "no.such.file"
};
{
"-b", "",
"-J", "1.2.3.4:invalidcriticality",
"(objectClass=*)"
};
{
"-b", "",
"-s", "invalid",
"(objectClass=*)"
};
{
"-b", "",
"-a", "invalid",
"(objectClass=*)"
};
{
"-b", "",
"-C", "invalid",
"(objectClass=*)"
};
{
"-b", "",
"-C", "ps:invalid",
"(objectClass=*)"
};
{
"-b", "",
"-C", "ps:add,delete,modify,modifydn,invalid",
"(objectClass=*)"
};
{
"-b", "",
"-C", "ps:all:invalid",
"(objectClass=*)"
};
{
"-b", "",
"-C", "ps:all:1:invalid",
"(objectClass=*)"
};
{
"-p", "nonnumeric",
"-b", "",
"(objectClass=*)"
};
{
"-p", "999999",
"-b", "",
"(objectClass=*)"
};
{
"-z", "nonnumeric",
"-b", "",
"(objectClass=*)"
};
{
"-l", "nonnumeric",
"-b", "",
"(objectClass=*)"
};
{
"-r",
"-b", "",
"-K", "key.store.file",
"(objectClass=*)"
};
{
"-Z",
"-r",
"-b", "",
"(objectClass=*)"
};
{
}
return returnArray;
}
/**
* Tests the LDAPSearch tool with sets of invalid arguments.
*
* @param args The set of arguments to use for the LDAPSearch tool.
* @param invalidReason The reason that the set of arguments is not valid.
*/
{
"Should have been invalid because: " + invalidReason);
}
/**
* Tests a simple LDAPv2 search.
*/
@Test
public void testSimpleLDAPv2Search()
{
{
"-h", "127.0.0.1",
"-V", "2",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests a simple LDAPv3 search.
*/
@Test
public void testSimpleLDAPv3Search()
{
{
"-h", "127.0.0.1",
"-V", "3",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests a simple search with verbose output.
*/
@Test
public void testSimpleVerboseSearch()
{
{
"-h", "127.0.0.1",
"-v",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests a simple invocation using the "--dry-run" option with a valid argument
* set.
*/
@Test
public void testNoOpSearchValidArguments()
{
{
"-h", "doesnt.need.to.resolve",
"-V", "3",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "",
"-s", "base",
"--dry-run",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests a simple invocation using the "--dry-run" option with an invalid
* argument set.
*/
@Test
public void testNoOpSearchInvalidArguments()
{
{
"-h", "doesnt.need.to.resolve",
"-V", "3",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "",
"-s", "invalid",
"--dry-run",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests a simple LDAP search over SSL using blind trust.
*/
@Test
public void testSimpleSearchSSLBlindTrust()
{
{
"-h", "127.0.0.1",
"-Z",
"-X",
"-b", "",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests a simple LDAP search over SSL using a trust store.
*/
@Test
public void testSimpleSearchSSLTrustStore()
{
{
"-h", "127.0.0.1",
"-Z",
"-P", trustStorePath,
"-b", "",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests a simple LDAP search using StartTLS with blind trust.
*/
@Test
public void testSimpleSearchStartTLSBlindTrust()
{
{
"-h", "127.0.0.1",
"-q",
"-X",
"-b", "",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests a simple LDAP search using StartTLS with a trust store.
*/
@Test
public void testSimpleSearchStartTLSTrustStore()
{
{
"-h", "127.0.0.1",
"-q",
"-P", trustStorePath,
"-b", "",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests a simple LDAP search over SSL using a trust store and SASL EXTERNAL
* authentication.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSimpleSearchSSLTrustStoreSASLExternal()
throws Exception
{
"dn: cn=Test User,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"cn: Test User",
"givenName: Test",
"sn: User");
{
"-h", "127.0.0.1",
"-Z",
"-K", keyStorePath,
"-W", "password",
"-P", trustStorePath,
"-r",
"-b", "",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests a simple LDAP search over SSL using a trust store and SASL EXTERNAL
* authentication when explicitly specifying a valid client certificate.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSimpleSearchSSLTrustStoreSASLExternalValidClientCert()
throws Exception
{
"dn: cn=Test User,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"cn: Test User",
"givenName: Test",
"sn: User");
{
"-h", "127.0.0.1",
"-Z",
"-K", keyStorePath,
"-W", "password",
"-N", "client-cert",
"-P", trustStorePath,
"-r",
"-b", "",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests a simple LDAP search over SSL using a trust store and SASL EXTERNAL
* authentication when explicitly specifying an invalid client certificate.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
throws Exception
{
"dn: cn=Test User,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"cn: Test User",
"givenName: Test",
"sn: User");
{
"-h", "127.0.0.1",
"-Z",
"-K", keyStorePath,
"-W", "password",
"-N", "invalid",
"-P", trustStorePath,
"-r",
"-b", "",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests a simple LDAP search using StartTLS with a trust store and SASL
* EXTERNAL authentication.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSimpleSearchStartTLSTrustStoreSASLExternal()
throws Exception
{
"dn: cn=Test User,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"cn: Test User",
"givenName: Test",
"sn: User");
{
"-h", "127.0.0.1",
"-q",
"-K", keyStorePath,
"-W", "password",
"-P", trustStorePath,
"-r",
"-b", "",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests a simple search operation using CRAM-MD5 authentication.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testCRAMMD5()
throws Exception
{
"dn: uid=test.user,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: test.user",
"givenName: Test",
"sn: User",
"cn: Test User",
"userPassword: password",
"ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
"cn=Password Policies,cn=config");
{
"-h", "127.0.0.1",
"-o", "mech=CRAM-MD5",
"-o", "authid=u:test.user",
"-w", "password",
"-b", "",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests a simple search operation using CRAM-MD5 authentication.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testDigestMD5()
throws Exception
{
"dn: uid=test.user,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: test.user",
"givenName: Test",
"sn: User",
"cn: Test User",
"userPassword: password",
"ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
"cn=Password Policies,cn=config");
{
"-h", "127.0.0.1",
"-o", "mech=DIGEST-MD5",
"-o", "authid=u:test.user",
"-o", "authzid=u:test.user",
"-w", "password",
"-b", "",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests a simple search operation using PLAIN authentication.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testPLAIN()
throws Exception
{
{
"-h", "127.0.0.1",
"-o", "mech=PLAIN",
"-o", "authid=dn:cn=Directory Manager",
"-w", "password",
"-b", "",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests a search with a malformed bind DN.
*/
@Test
public void testMalformedBindDN()
{
{
"-h", "127.0.0.1",
"-D", "malformed",
"-w", "password",
"-b", "",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests a search with a nonexistent bind DN.
*/
@Test
public void testNonExistentBindDN()
{
{
"-h", "127.0.0.1",
"-D", "cn=Does Not Exist",
"-w", "password",
"-b", "",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests a search with an invalid password.
*/
@Test
public void testInvalidBindPassword()
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "wrongPassword",
"-b", "",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests a search with a valid password read from a file.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testValidPasswordFromFile()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-j", validPasswordFile,
"-b", "",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests a search with an invalid password read from a file.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testInvalidPasswordFromFile()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-j", invalidPasswordFile,
"-b", "",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests a search with a malformed base DN.
*/
@Test
public void testMalformedBaseDN()
{
{
"-h", "127.0.0.1",
"-b", "malformed",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests a search with a nonexistent base DN.
*/
@Test
public void testNonExistentBaseDN()
{
{
"-h", "127.0.0.1",
"-b", "o=does not exist",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Retrieves the set of valid search scopes.
*
* @return The set of valid search scopes.
*/
{
return new Object[][]
{
new Object[] { "base" },
new Object[] { "one" },
new Object[] { "sub" },
new Object[] { "subordinate" },
};
}
/**
* Tests searches with the various allowed search scopes.
*
* @param scope The scope to use for the search.
*
* @throws Exception If an unexpected problem occurs.
*/
throws Exception
{
{
"-h", "127.0.0.1",
"-b", "o=test",
"-s", scope,
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Retrieves the set of valid alias dereferencing policies.
*
* @return The set of valid alias dereferencing policies.
*/
{
return new Object[][]
{
new Object[] { "never" },
new Object[] { "always" },
new Object[] { "search" },
new Object[] { "find" },
};
}
/**
* Tests searches with the various allowed dereference policy values.
*
* @param derefPolicy The alias dereferencing policy for the search.
*
* @throws Exception If an unexpected problem occurs.
*/
throws Exception
{
{
"-h", "127.0.0.1",
"-b", "o=test",
"-s", "base",
"-a", derefPolicy,
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests with the typesOnly option.
*/
@Test
public void testTypesOnly()
throws Exception
{
{
"-h", "127.0.0.1",
"-b", "o=test",
"-s", "base",
"-A",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests with the reportAuthzID option for an unauthenticated search.
*/
@Test
public void testReportAuthzIDUnauthenticated()
throws Exception
{
{
"-h", "127.0.0.1",
"-b", "o=test",
"-s", "base",
"--reportAuthzID",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests with the reportAuthzID option for an authenticated search.
*/
@Test
public void testReportAuthzIDAuthenticated()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "o=test",
"-s", "base",
"--reportAuthzID",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests with the usePasswordPolicyControl option for an authenticated search.
*/
@Test
public void testUsePasswordPolicyControl()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "o=test",
"-s", "base",
"--usePasswordPolicyControl",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests with the account usability control for an authenticated search.
*/
@Test
public void testAccountUsabilityControl()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "o=test",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests with the account usability control with an alternate name for an
* authenticated search.
*/
@Test
public void testAccountUsabilityControlAltName()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "o=test",
"-s", "base",
"-J", "accountusable:true",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests with the LDAP assertion control in which the assertion is true.
*/
@Test
public void testLDAPAssertionControlTrue()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "o=test",
"-s", "base",
"--assertionFilter", "(objectClass=top)",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests with the LDAP assertion control in which the assertion is false.
*/
@Test
public void testLDAPAssertionControlFalse()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "o=test",
"-s", "base",
"--assertionFilter", "(objectClass=doesNotMatch)",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests with the LDAP matched values control.
*/
@Test
public void testMatchedValuesControl()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "o=test",
"-s", "base",
"--matchedValuesFilter", "(objectClass=*person)",
"--noPropertiesFile",
"(objectClass=*)",
"objectClass"
};
}
/**
* Tests the use of the LDAP subentries control.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSubentriesControl()
throws Exception
{
"objectClass: top",
"objectClass: ldapSubEntry",
"cn: test");
{
"-D", "cn=Directory Manager",
"-w", "password",
"-h", "127.0.0.1",
"-b", "o=test",
"-s", "sub",
"--countEntries",
"--noPropertiesFile",
"(objectClass=*)"
};
{
"-D", "cn=Directory Manager",
"-w", "password",
"-h", "127.0.0.1",
"-b", "o=test",
"-s", "sub",
"--countEntries",
"--noPropertiesFile",
"--subEntries",
"(objectClass=*)"
};
{
"-D", "cn=Directory Manager",
"-w", "password",
"-h", "127.0.0.1",
"-b", "cn=test,o=test",
"-s", "base",
"--countEntries",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests the inclusion of multiple arbitrary controls in the request to the
* server.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testMultipleRequestControls()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "o=test",
"-s", "base",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests the use of the simple paged results control.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSimplePagedResults()
throws Exception
{
"dn: cn=device 1,dc=example,dc=com",
"objectClass: top",
"objectClass: device",
"cn: device 1",
"",
"dn: cn=device 2,dc=example,dc=com",
"objectClass: top",
"objectClass: device",
"cn: device 2",
"",
"dn: cn=device 3,dc=example,dc=com",
"objectClass: top",
"objectClass: device",
"cn: device 3",
"",
"dn: cn=device 4,dc=example,dc=com",
"objectClass: top",
"objectClass: device",
"cn: device 4",
"",
"dn: cn=device 5,dc=example,dc=com",
"objectClass: top",
"objectClass: device",
"cn: device 5");
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "dc=example,dc=com",
"-s", "one",
"--simplePageSize", "2",
"--countEntries",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests the use of both the server-side sort control and the simple paged
* results control.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSortWithPagedResults()
throws Exception
{
"dn: uid=albert.zimmerman,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.zimmerman",
"givenName: Albert",
"sn: Zimmerman",
"cn: Albert Zimmerman",
"",
"dn: uid=albert.smith,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.smith",
"givenName: Albert",
"sn: Smith",
"cn: Albert Smith",
"",
"dn: uid=aaron.zimmerman,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.zimmerman",
"givenName: Aaron",
"givenName: Zeke",
"sn: Zimmerman",
"cn: Aaron Zimmerman",
"",
"dn: uid=mary.jones,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: mary.jones",
"givenName: Mary",
"sn: Jones",
"cn: Mary Jones",
"",
"dn: uid=margaret.jones,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: margaret.jones",
"givenName: Margaret",
"givenName: Maggie",
"sn: Jones",
"sn: Smith",
"cn: Maggie Jones-Smith",
"",
"dn: uid=aaccf.johnson,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: aaccf.johnson",
"givenName: Aaccf",
"sn: Johnson",
"cn: Aaccf Johnson",
"",
"dn: uid=sam.zweck,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: sam.zweck",
"givenName: Sam",
"sn: Zweck",
"cn: Sam Zweck",
"",
"dn: uid=lowercase.mcgee,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: lowercase.mcgee",
"givenName: lowercase",
"sn: mcgee",
"cn: lowercase mcgee",
"",
"dn: uid=zorro,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: zorro",
"sn: Zorro",
"cn: Zorro");
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "dc=example,dc=com",
"-s", "sub",
"-S", "givenName",
"--simplePageSize", "2",
"--countEntries",
"--noPropertiesFile",
"(objectClass=*)"
};
String[] unpagedArgs =
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "dc=example,dc=com",
"-s", "sub",
"-S", "givenName",
"--countEntries",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests the use of the server-side sort control with valid sort criteria.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSortValidGivenNameAscending()
throws Exception
{
"dn: uid=albert.zimmerman,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.zimmerman",
"givenName: Albert",
"sn: Zimmerman",
"cn: Albert Zimmerman",
"",
"dn: uid=albert.smith,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.smith",
"givenName: Albert",
"sn: Smith",
"cn: Albert Smith",
"",
"dn: uid=aaron.zimmerman,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.zimmerman",
"givenName: Aaron",
"givenName: Zeke",
"sn: Zimmerman",
"cn: Aaron Zimmerman");
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "dc=example,dc=com",
"-s", "sub",
"-S", "givenName",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests the use of the server-side sort control with valid sort criteria.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSortValidGivenNameDescending()
throws Exception
{
"dn: uid=albert.zimmerman,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.zimmerman",
"givenName: Albert",
"sn: Zimmerman",
"cn: Albert Zimmerman",
"",
"dn: uid=albert.smith,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.smith",
"givenName: Albert",
"sn: Smith",
"cn: Albert Smith",
"",
"dn: uid=aaron.zimmerman,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.zimmerman",
"givenName: Aaron",
"givenName: Zeke",
"sn: Zimmerman",
"cn: Aaron Zimmerman");
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "dc=example,dc=com",
"-s", "sub",
"-S", "-givenName",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests the use of the server-side sort control with valid sort criteria.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSortValidGivenNameAscendingCaseExactOrderingMatch()
throws Exception
{
"dn: uid=albert.zimmerman,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.zimmerman",
"givenName: Albert",
"sn: Zimmerman",
"cn: Albert Zimmerman",
"",
"dn: uid=albert.smith,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.smith",
"givenName: Albert",
"sn: Smith",
"cn: Albert Smith",
"",
"dn: uid=aaron.zimmerman,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.zimmerman",
"givenName: Aaron",
"givenName: Zeke",
"sn: Zimmerman",
"cn: Aaron Zimmerman");
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "dc=example,dc=com",
"-s", "sub",
"-S", "givenName:caseExactOrderingMatch",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests the use of the server-side sort control with valid sort criteria.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSortValidSnAscendingGivenNameAscending()
throws Exception
{
"dn: uid=albert.zimmerman,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.zimmerman",
"givenName: Albert",
"sn: Zimmerman",
"cn: Albert Zimmerman",
"",
"dn: uid=albert.smith,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.smith",
"givenName: Albert",
"sn: Smith",
"cn: Albert Smith",
"",
"dn: uid=aaron.zimmerman,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.zimmerman",
"givenName: Aaron",
"givenName: Zeke",
"sn: Zimmerman",
"cn: Aaron Zimmerman");
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "dc=example,dc=com",
"-s", "sub",
"-S", "sn,givenName",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests the use of the server-side sort control with valid sort criteria.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSortValidSnAscendingGivenNameDescending()
throws Exception
{
"dn: uid=albert.zimmerman,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.zimmerman",
"givenName: Albert",
"sn: Zimmerman",
"cn: Albert Zimmerman",
"",
"dn: uid=albert.smith,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.smith",
"givenName: Albert",
"sn: Smith",
"cn: Albert Smith",
"",
"dn: uid=aaron.zimmerman,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.zimmerman",
"givenName: Aaron",
"givenName: Zeke",
"sn: Zimmerman",
"cn: Aaron Zimmerman");
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "dc=example,dc=com",
"-s", "sub",
"-S", "sn,-givenName",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests the use of the server-side sort control with an empty sort order.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSortEmptySortOrder()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "dc=example,dc=com",
"-s", "sub",
"-S", "",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests the use of the server-side sort control with a sort order containing
* a key with no attribute type.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSortSortOrderMissingType()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "dc=example,dc=com",
"-s", "sub",
"-S", "-,sn",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests the use of the server-side sort control with a sort order containing
* a key with a colon but no matching rule.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSortSortOrderMissingMatchingRule()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "dc=example,dc=com",
"-s", "sub",
"-S", "-sn:",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests the use of the server-side sort control with an undefined attribute.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSortUndefinedAttribute()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "dc=example,dc=com",
"-s", "sub",
"-S", "undefined",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests the use of the server-side sort control with an undefined ordering
* rule.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSortUndefinedOrderingRule()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "dc=example,dc=com",
"-s", "sub",
"-S", "givenName:undefined",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests the use of a control with an empty value.
* We use the ManageDSAIt control for this.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testControlNoValue()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "o=test",
"-s", "base",
"-J", "managedsait:false:",
"--noPropertiesFile",
"(objectClass=*)",
"dn"
};
}
/**
* Tests the use of the virtual list view control without the server-side sort
* control.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testVLVWithoutSort()
throws Exception
{
// Test is supposed to fail in parsing arguments. But we do not
// want it to fail because there no backend to search in.
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "dc=example,dc=com",
"-s", "sub",
"-G", "0:9:1:0",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests the use of the server-side sort control with both the simple paged
* results and virtual list view controls.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSortWithVLVAndPagedResults()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "dc=example,dc=com",
"-s", "sub",
"-S", "sn,givenName",
"--simplePageSize", "2",
"-G", "0:3:1:0",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests the use of the virtual list view control with an invalid descriptor
* with no colons.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testVLVInvalidDescriptorNoColons()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "dc=example,dc=com",
"-s", "sub",
"-S", "sn,givenName",
"-G", "invalid",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests the use of the virtual list view control with an invalid descriptor
* with two colons.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testVLVInvalidDescriptorTwoColons()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "dc=example,dc=com",
"-s", "sub",
"-S", "sn,givenName",
"-G", "invalid:9:invalid",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests the use of the virtual list view control with an invalid descriptor
* with three colons.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testVLVInvalidDescriptorThreeColons()
throws Exception
{
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "dc=example,dc=com",
"-s", "sub",
"-S", "sn,givenName",
"-G", "invalid:9:1:0",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests the use of both the server-side sort control and the virtual list
* view control.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSortWithVLV()
throws Exception
{
"dn: uid=albert.zimmerman,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.zimmerman",
"givenName: Albert",
"sn: Zimmerman",
"cn: Albert Zimmerman",
"",
"dn: uid=albert.smith,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.smith",
"givenName: Albert",
"sn: Smith",
"cn: Albert Smith",
"",
"dn: uid=aaron.zimmerman,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.zimmerman",
"givenName: Aaron",
"givenName: Zeke",
"sn: Zimmerman",
"cn: Aaron Zimmerman",
"",
"dn: uid=mary.jones,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: mary.jones",
"givenName: Mary",
"sn: Jones",
"cn: Mary Jones",
"",
"dn: uid=margaret.jones,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: margaret.jones",
"givenName: Margaret",
"givenName: Maggie",
"sn: Jones",
"sn: Smith",
"cn: Maggie Jones-Smith",
"",
"dn: uid=aaccf.johnson,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: aaccf.johnson",
"givenName: Aaccf",
"sn: Johnson",
"cn: Aaccf Johnson",
"",
"dn: uid=sam.zweck,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: sam.zweck",
"givenName: Sam",
"sn: Zweck",
"cn: Sam Zweck",
"",
"dn: uid=lowercase.mcgee,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: lowercase.mcgee",
"givenName: lowercase",
"sn: mcgee",
"cn: lowercase mcgee",
"",
"dn: uid=zorro,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: zorro",
"sn: Zorro",
"cn: Zorro");
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "dc=example,dc=com",
"-s", "sub",
"-S", "givenName",
"-G", "1:3:1:0",
"--noPropertiesFile",
"(objectClass=*)"
};
}
/**
* Tests the LDAPSearch tool with the "--help" option.
*/
@Test
public void testHelp()
{
}
}