LDAPCompareTestCase.java revision d20053afa42700e3ec7a6f6fb474622e8680f4cc
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * CDDL HEADER START
7c74e180c206e6ed99e8beb820da5f399d845c3eDavid Lawrence * The contents of this file are subject to the terms of the
7c74e180c206e6ed99e8beb820da5f399d845c3eDavid Lawrence * Common Development and Distribution License, Version 1.0 only
7c74e180c206e6ed99e8beb820da5f399d845c3eDavid Lawrence * (the "License"). You may not use this file except in compliance
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * with the License.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * You can obtain a copy of the license at
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * trunk/opends/resource/legal-notices/OpenDS.LICENSE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * See the License for the specific language governing permissions
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * and limitations under the License.
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence * When distributing Covered Code, include this CDDL HEADER in each
866d106459313499d0ca7bfccb4b2d23d5e4377cDavid Lawrence * file and include the License file at
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
866d106459313499d0ca7bfccb4b2d23d5e4377cDavid Lawrence * add the following below this CDDL HEADER, with the fields enclosed
866d106459313499d0ca7bfccb4b2d23d5e4377cDavid Lawrence * by brackets "[]" replaced with your own identifying information:
7c74e180c206e6ed99e8beb820da5f399d845c3eDavid Lawrence * Portions Copyright [yyyy] [name of copyright owner]
ea31416b4fcdf23732355a8002f93f29e3b3d2dbAndreas Gustafsson * CDDL HEADER END
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * Portions Copyright 2006-2007 Sun Microsystems, Inc.
03e200df5dc283f24a6a349f0b31d3eab26da893Mark Andrewsimport org.opends.server.protocols.internal.InternalClientConnection;
75a4dd0d377dca2f85cea44e28bf110314c1fe8cDavid Lawrenceimport static org.opends.server.util.ServerConstants.*;
91306d962f9d147d94b82fb14edb28f8d907cae7Andreas Gustafsson * A set of test cases for the LDAPCompare tool.
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence // The path to a file containing an invalid bind password.
e893dce91279d7313a579f72caae3941f6dc5a27David Lawrence // The path to a file containing a valid bind password.
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley * Ensures that the Directory Server is running and performs other necessary
ce8c568e0d6106bb87069453505e09bc66754b40Andreas Gustafsson * @throws Exception If an unexpected problem occurs.
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley File pwFile = File.createTempFile("valid-bind-password-", ".txt");
3b77946b751f39bd4db5a7d1fe48a81e6b1e7a28Bob Halley fileWriter.write("password" + System.getProperty("line.separator"));
8e06cea14c857429ab7e7299af2dce5eeeaa5ff0Michael Graff pwFile = File.createTempFile("invalid-bind-password-", ".txt");
3ecf3394e37dc2848a09ffc643565d454e9e6974Andreas Gustafsson fileWriter.write("wrongPassword" + System.getProperty("line.separator"));
3ecf3394e37dc2848a09ffc643565d454e9e6974Andreas Gustafsson invalidPasswordFile = pwFile.getAbsolutePath();
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence * Retrieves sets of invalid arguments that may not be used to initialize
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence * the LDAPCompare tool.
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence * @return Sets of invalid arguments that may not be used to initialize the
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence * LDAPCompare tool.
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence ArrayList<String[]> argLists = new ArrayList<String[]>();
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence ArrayList<String> reasonList = new ArrayList<String>();
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence reasonList.add("No value for '-D' argument");
ae4cbb69eef32ced103fe4561e8d2031ee4c3497David Lawrence reasonList.add("No value for '-w' argument");
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence reasonList.add("No value for '-j' argument");
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence reasonList.add("No value for '-i' argument");
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence reasonList.add("No value for '-K' argument");
0293ad13207aa29bd5844cdc87d085ffc009d749David Lawrence reasonList.add("No value for '-P' argument");
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence reasonList.add("No value for '-W' argument");
1ce985ab3c6670662d555c108b35fed84a6a1001David Lawrence reasonList.add("No value for '-h' argument");
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence reasonList.add("No value for '-p' argument");
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence reasonList.add("No value for '-V' argument");
4bcaefbcd3ced942139fdc830e007c6ea2b8d2feDavid Lawrence reasonList.add("No value for '-f' argument");
641da3ca1184d9951d5cf91538524a345bf5f271Mark Andrews "--assertionFilter",
641da3ca1184d9951d5cf91538524a345bf5f271Mark Andrews reasonList.add("No value for '--assertionFilter' argument");
9fe28a624c659e380d47dbf45527637dab03b998Mark Andrews "--invalidLongArgument"
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews "uid:test.user",
774c3a62d9adca187b44fe90919bb409a43a2f2aMark Andrews "uid=test.user,o=test"
39b973d8873996c3bfb6e5b4cc69731f6c3b77b5Mark Andrews "uid:test.user",
6342df69b05f2f62d060fd4affdf536e51504084Mark Andrews "uid=test.user,o=test"
6342df69b05f2f62d060fd4affdf536e51504084Mark Andrews reasonList.add("Invalid bind password file path");
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson "uid:test.user",
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson "uid=test.user,o=test"
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson reasonList.add("Both bind password and password file");
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington "uid:test.user",
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington "uid=test.user,o=test"
47fd46791da765e3dbedd987e9b263b3bee25986Brian Wellington reasonList.add("Non-numeric LDAP version");
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson "uid:test.user",
6fcb2f0faad67a6d2cb2e30ec57157d75fbfe58fAndreas Gustafsson "uid=test.user,o=test"
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews "uid:test.user",
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews "uid=test.user,o=test"
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews "uid:test.user",
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews "uid=test.user,o=test"
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson reasonList.add("Invalid control criticality");
754cca729dd82ae8363917dc00ad44f9d900635bMark Andrews "uid:test.user",
754cca729dd82ae8363917dc00ad44f9d900635bMark Andrews "uid=test.user,o=test"
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews "uid:test.user",
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews "uid=test.user,o=test"
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews "uid:test.user",
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews "uid=test.user,o=test"
40dd9cb8cc240c33d820fe79f176ed51e4c06a1aMark Andrews reasonList.add("SASL external without SSL or StartTLS");
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson "uid:test.user",
963c48ba4d06a112c70d50328e827749e95f58dbMark Andrews "uid=test.user,o=test"
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson reasonList.add("SASL external without keystore file");
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson "uid:test.user"
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson reasonList.add("Only one trailing argument");
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson "uid=test.user,o=test"
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson reasonList.add("Malformed attribute-value assertion");
5ff133b82082d82f0ba89b7c999c6b62b6298e46Andreas Gustafsson Object[][] returnArray = new Object[argLists.size()][2];
13faa8b6a2d0d45e0659049983928366252ab3faMichael Graff * Tests the LDAPCompare tool with sets of invalid arguments.
61d5bfc06be978ea962b1c64309894ac80351771Mark Andrews * @param args The set of arguments to use for the LDAPCompare
13faa8b6a2d0d45e0659049983928366252ab3faMichael Graff * @param invalidReason The reason the provided set of arguments is invalid.
a53259c4cc558f86dd008eccc60cc89b6734a03cMark Andrews public void testInvalidArguments(String[] args, String invalidReason)
a53259c4cc558f86dd008eccc60cc89b6734a03cMark Andrews assertFalse(LDAPCompare.mainCompare(args, false, null, null) == 0,
a53259c4cc558f86dd008eccc60cc89b6734a03cMark Andrews "Should have been invalid because: " + invalidReason);
a53259c4cc558f86dd008eccc60cc89b6734a03cMark Andrews * Tests a simple LDAPv2 compare.
5f9e583552f53de12062bfff12e47250abce378fBrian Wellington * @throws Exception If an unexpectd problem occurs.
a53259c4cc558f86dd008eccc60cc89b6734a03cMark Andrews "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
68f72235f8f41fa949823551d8e6476057ec5bd6Andreas Gustafsson assertEquals(LDAPCompare.mainCompare(args, false, null, System.err), 0);
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson * Tests a simple LDAPv3 compare in which the assertion is true.
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson * @throws Exception If an unexpectd problem occurs.
c5826852e6c789f59b301f8197e65a1dd4e09a44Mark Andrews "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
c5826852e6c789f59b301f8197e65a1dd4e09a44Mark Andrews assertEquals(LDAPCompare.mainCompare(args, false, null, System.err), 0);
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson * Tests a simple LDAPv3 compare in which the assertion is false.
bc53aacc6e9302b1f8d01467fc39585584652782Andreas Gustafsson * @throws Exception If an unexpectd problem occurs.
bc53aacc6e9302b1f8d01467fc39585584652782Andreas Gustafsson public void testSimpleLDAPv3CompareFalse()
bc53aacc6e9302b1f8d01467fc39585584652782Andreas Gustafsson TestCaseUtils.initializeTestBackend(true);
2995f8205eaa0d4bc3a57900a413b5cfdb83564fAndreas Gustafsson "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
d73de275987d29627dc11d5bd4a22874a29f7874Mark Andrews "o:nottest",
d73de275987d29627dc11d5bd4a22874a29f7874Mark Andrews assertEquals(LDAPCompare.mainCompare(args, false, null, System.err), 0);
d73de275987d29627dc11d5bd4a22874a29f7874Mark Andrews * Tests a simple compare using SSL with blind trust.
d73de275987d29627dc11d5bd4a22874a29f7874Mark Andrews * @throws Exception If an unexpectd problem occurs.
25c18fded02c5df8391a333e90ea776b52bff079Mark Andrews "-p", String.valueOf(TestCaseUtils.getServerLdapsPort()),
7f32428506d55083fe5ac9aa515294bdef7c6e27Mark Andrews assertEquals(LDAPCompare.mainCompare(args, false, null, System.err), 0);
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson * Tests a simple compare using SSL with a trust store.
7f32428506d55083fe5ac9aa515294bdef7c6e27Mark Andrews * @throws Exception If an unexpectd problem occurs.
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson TestCaseUtils.initializeTestBackend(true);
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson String trustStorePath = DirectoryServer.getServerRoot() + File.separator +
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson "config" + File.separator + "client.truststore";
7f32428506d55083fe5ac9aa515294bdef7c6e27Mark Andrews "-p", String.valueOf(TestCaseUtils.getServerLdapsPort()),
7f32428506d55083fe5ac9aa515294bdef7c6e27Mark Andrews assertEquals(LDAPCompare.mainCompare(args, false, null, System.err), 0);
7f32428506d55083fe5ac9aa515294bdef7c6e27Mark Andrews * Tests a simple compare using StartTLS with blind trust.
7f32428506d55083fe5ac9aa515294bdef7c6e27Mark Andrews * @throws Exception If an unexpectd problem occurs.
5989aea4bbe79e09290792f04aeb557e2b2da02eAndreas Gustafsson "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
08a768e82ad64ede97f640c88e02984b59122753Michael Graff assertEquals(LDAPCompare.mainCompare(args, false, null, System.err), 0);
3ec6b563d7b6cb11a047f23faa2a0f206ccd93e7Brian Wellington * Tests a simple compare using StartTLS with a trust store.
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington * @throws Exception If an unexpectd problem occurs.
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington String trustStorePath = DirectoryServer.getServerRoot() + File.separator +
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington "config" + File.separator + "client.truststore";
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
fee5012c43744322c1785e5c3e0c322443faa304Brian Wellington assertEquals(LDAPCompare.mainCompare(args, false, null, System.err), 0);
0e40083fdd5445703bd30e46e5bfe7d047bced12Brian Wellington * Tests a simple LDAP compare over SSL using a trust store and SASL EXTERNAL
0e40083fdd5445703bd30e46e5bfe7d047bced12Brian Wellington * authentication.
0e40083fdd5445703bd30e46e5bfe7d047bced12Brian Wellington * @throws Exception If an unexpected problem occurs.
0e40083fdd5445703bd30e46e5bfe7d047bced12Brian Wellington public void testSimpleCompareSSLTrustStoreSASLExternal()
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington "dn: cn=Test User,o=test",
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington "objectClass: top",
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington "objectClass: person",
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington "objectClass: organizationalPerson",
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington "objectClass: inetOrgPerson",
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington "cn: Test User",
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington "givenName: Test",
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington "ds-privilege-name: bypass-acl",
d0fbcfeee1c1dbdb079231545de3a0c58248202fMark Andrews "sn: User");
af5ad488cbf17988fbd36a25c908737412ccd382Brian Wellington InternalClientConnection.getRootConnection();
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington conn.processAdd(e.getDN(), e.getObjectClasses(), e.getUserAttributes(),
af5ad488cbf17988fbd36a25c908737412ccd382Brian Wellington assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington String keyStorePath = DirectoryServer.getServerRoot() + File.separator +
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington "config" + File.separator + "client.keystore";
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington String trustStorePath = DirectoryServer.getServerRoot() + File.separator +
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington "config" + File.separator + "client.truststore";
529ff4b4959fb157194f985394951108ff5286e4Brian Wellington "-p", String.valueOf(TestCaseUtils.getServerLdapsPort()),
5b76a09697bfc76f5acefd65d5b37b1214d271a8Mark Andrews "cn:Test User",
5b76a09697bfc76f5acefd65d5b37b1214d271a8Mark Andrews "cn=Test User,o=test"
9738408dcbd4c1f7eb2b105c83388608fafd7808Mark Andrews assertEquals(LDAPCompare.mainCompare(args, false, null, System.err), 0);
2271edc0b4ba96e69a283eced420b94ffb678beeBrian Wellington * Tests a simple LDAP compare over SSL using a trust store and SASL EXTERNAL
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson * authentication when explicitly specifying a valid client certificate.
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson * @throws Exception If an unexpected problem occurs.
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson public void testSimpleCompareSSLTrustStoreSASLExternalValidClientCert()
3184ff5e45c8f821e5165ea60d674bfb87faf5b8Mark Andrews "dn: cn=Test User,o=test",
3184ff5e45c8f821e5165ea60d674bfb87faf5b8Mark Andrews "objectClass: top",
3184ff5e45c8f821e5165ea60d674bfb87faf5b8Mark Andrews "objectClass: person",
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson "objectClass: organizationalPerson",
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson "objectClass: inetOrgPerson",
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson "cn: Test User",
9ceaa92a8ca8a0270ba296d44599e94d95033759Andreas Gustafsson "givenName: Test",
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson "ds-privilege-name: bypass-acl",
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson InternalClientConnection.getRootConnection();
16ee4fe11bad616a76c79e9f626a7e04a88ef4abMark Andrews conn.processAdd(e.getDN(), e.getObjectClasses(), e.getUserAttributes(),
16ee4fe11bad616a76c79e9f626a7e04a88ef4abMark Andrews assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
70e854766f5304f43e94212dc38ebaefe214148cMark Andrews String keyStorePath = DirectoryServer.getServerRoot() + File.separator +
70e854766f5304f43e94212dc38ebaefe214148cMark Andrews String trustStorePath = DirectoryServer.getServerRoot() + File.separator +
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson "config" + File.separator + "client.truststore";
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson "-p", String.valueOf(TestCaseUtils.getServerLdapsPort()),
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson "cn:Test User",
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson "cn=Test User,o=test"
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson assertEquals(LDAPCompare.mainCompare(args, false, null, System.err), 0);
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson * Tests a simple LDAP compare over SSL using a trust store and SASL EXTERNAL
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson * authentication when explicitly specifying an invalid client certificate.
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson * @throws Exception If an unexpected problem occurs.
3fafd7c0c42134ff2964b74a31500465a96dee90Andreas Gustafsson public void testSimpleCompareSSLTrustStoreSASLExternalInvalidClientCert()
9ceaa92a8ca8a0270ba296d44599e94d95033759Andreas Gustafsson TestCaseUtils.initializeTestBackend(true);
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson "dn: cn=Test User,o=test",
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson "objectClass: top",
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson "objectClass: person",
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson "objectClass: organizationalPerson",
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson "objectClass: inetOrgPerson",
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson "cn: Test User",
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson "givenName: Test",
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson "ds-privilege-name: bypass-acl",
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson InternalClientConnection.getRootConnection();
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson conn.processAdd(e.getDN(), e.getObjectClasses(), e.getUserAttributes(),
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson String keyStorePath = DirectoryServer.getServerRoot() + File.separator +
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson "config" + File.separator + "client.keystore";
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson String trustStorePath = DirectoryServer.getServerRoot() + File.separator +
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson "config" + File.separator + "client.truststore";
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence "-p", String.valueOf(TestCaseUtils.getServerLdapsPort()),
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson "cn:Test User",
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson "cn=Test User,o=test"
aa30ee42c4b6da9bab4fb84d6cbbda6036a4d426Mark Andrews assertFalse(LDAPCompare.mainCompare(args, false, null, null) == 0);
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson * Tests a simple LDAP compare using StartTLS with a trust store and SASL
a1884b96ef53efc8b4e14be173aaee552ca0213aAndreas Gustafsson * EXTERNAL authentication.
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence * @throws Exception If an unexpected problem occurs.
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence public void testSimpleCompareStartTLSTrustStoreSASLExternal()
9ceaa92a8ca8a0270ba296d44599e94d95033759Andreas Gustafsson TestCaseUtils.initializeTestBackend(true);
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence "dn: cn=Test User,o=test",
fafb62400d2f1b1da4f3908447e1f3935fc5155bBrian Wellington "objectClass: top",
fafb62400d2f1b1da4f3908447e1f3935fc5155bBrian Wellington "objectClass: person",
fafb62400d2f1b1da4f3908447e1f3935fc5155bBrian Wellington "objectClass: organizationalPerson",
23ac30603a7639bea1d331537634b079b046b122Mark Andrews "objectClass: inetOrgPerson",
23ac30603a7639bea1d331537634b079b046b122Mark Andrews "cn: Test User",
23ac30603a7639bea1d331537634b079b046b122Mark Andrews "givenName: Test",
23ac30603a7639bea1d331537634b079b046b122Mark Andrews "ds-privilege-name: bypass-acl",
23ac30603a7639bea1d331537634b079b046b122Mark Andrews "sn: User");
64b92523f9333ba053f4b2860335583be455b0b3Brian Wellington InternalClientConnection.getRootConnection();
3f123dcc2fe5d2cd08ca91b732741d86a4036906Brian Wellington conn.processAdd(e.getDN(), e.getObjectClasses(), e.getUserAttributes(),
64b92523f9333ba053f4b2860335583be455b0b3Brian Wellington assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence String keyStorePath = DirectoryServer.getServerRoot() + File.separator +
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence "config" + File.separator + "client.keystore";
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence String trustStorePath = DirectoryServer.getServerRoot() + File.separator +
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence "config" + File.separator + "client.truststore";
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
03f4c76f95f75e2b0d1206e784e35bed6041305cBob Halley "cn:Test User",
03f4c76f95f75e2b0d1206e784e35bed6041305cBob Halley "cn=Test User,o=test"
03f4c76f95f75e2b0d1206e784e35bed6041305cBob Halley assertEquals(LDAPCompare.mainCompare(args, false, null, System.err), 0);
03f4c76f95f75e2b0d1206e784e35bed6041305cBob Halley * Tests a simple compare operation using CRAM-MD5 authentication.
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence * @throws Exception If an unexpected problem occurs.
3ea6d4dc33482a752553c59ed94bcecd23d254b0Mark Andrews "dn: uid=test.user,o=test",
3ea6d4dc33482a752553c59ed94bcecd23d254b0Mark Andrews "objectClass: top",
8af4e7aa4e2a6fe84bf4ebe09ca1d4ef1d8ab593Mark Andrews "objectClass: person",
3ea6d4dc33482a752553c59ed94bcecd23d254b0Mark Andrews "objectClass: organizationalPerson",
3ea6d4dc33482a752553c59ed94bcecd23d254b0Mark Andrews "objectClass: inetOrgPerson",
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence "uid: test.user",
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence "givenName: Test",
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence "cn: Test User",
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence "ds-privilege-name: bypass-acl",
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence "userPassword: password",
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence "cn=Password Policies,cn=config");
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence InternalClientConnection.getRootConnection();
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence conn.processAdd(e.getDN(), e.getObjectClasses(), e.getUserAttributes(),
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence "givenName:Test",
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence "uid=test.user,o=test"
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence assertEquals(LDAPCompare.mainCompare(args, false, null, System.err), 0);
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence * Tests a simple compare operation using DIGEST-MD5 authentication.
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence * @throws Exception If an unexpected problem occurs.
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence "dn: uid=test.user,o=test",
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence "objectClass: top",
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence "objectClass: person",
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence "objectClass: organizationalPerson",
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence "objectClass: inetOrgPerson",
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence "uid: test.user",
9a2574531e3d2ced31072200b416467fdee0c29cDavid Lawrence "givenName: Test",
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence "cn: Test User",
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence "ds-privilege-name: bypass-acl",
d8dcd6ad4617cc8d7df979bd62101fa9c4bac1bcBob Halley "userPassword: password",
d8dcd6ad4617cc8d7df979bd62101fa9c4bac1bcBob Halley "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence "cn=Password Policies,cn=config");
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence InternalClientConnection.getRootConnection();
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence conn.processAdd(e.getDN(), e.getObjectClasses(), e.getUserAttributes(),
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
882350d11c90de9de6fc1cead25690c8114b0b95Michael Graff "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
d901b2252d664a5b96bae117416f8ee822dc6691Stephen Jacob "givenName:Test",
d901b2252d664a5b96bae117416f8ee822dc6691Stephen Jacob "uid=test.user,o=test"
d901b2252d664a5b96bae117416f8ee822dc6691Stephen Jacob assertEquals(LDAPCompare.mainCompare(args, false, null, System.err), 0);
d901b2252d664a5b96bae117416f8ee822dc6691Stephen Jacob * Tests a simple compare operation using PLAIN authentication.
d901b2252d664a5b96bae117416f8ee822dc6691Stephen Jacob * @throws Exception If an unexpected problem occurs.
d901b2252d664a5b96bae117416f8ee822dc6691Stephen Jacob "dn: uid=test.user,o=test",
d901b2252d664a5b96bae117416f8ee822dc6691Stephen Jacob "objectClass: top",
d901b2252d664a5b96bae117416f8ee822dc6691Stephen Jacob "objectClass: person",
d901b2252d664a5b96bae117416f8ee822dc6691Stephen Jacob "objectClass: organizationalPerson",
d901b2252d664a5b96bae117416f8ee822dc6691Stephen Jacob "objectClass: inetOrgPerson",
d901b2252d664a5b96bae117416f8ee822dc6691Stephen Jacob "uid: test.user",
d901b2252d664a5b96bae117416f8ee822dc6691Stephen Jacob "givenName: Test",
d901b2252d664a5b96bae117416f8ee822dc6691Stephen Jacob "cn: Test User",
d901b2252d664a5b96bae117416f8ee822dc6691Stephen Jacob "userPassword: password");
d901b2252d664a5b96bae117416f8ee822dc6691Stephen Jacob conn.processAdd(e.getDN(), e.getObjectClasses(), e.getUserAttributes(),
d901b2252d664a5b96bae117416f8ee822dc6691Stephen Jacob assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley "givenName:Test",
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley "uid=test.user,o=test"
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley assertEquals(LDAPCompare.mainCompare(args, false, null, System.err), 0);
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews * Tests a a comparison in which the assertion value is base64-encoded with a
aceae69c7f3e76e8842de178851928619c65b61cMark Andrews * valid encoding.
aceae69c7f3e76e8842de178851928619c65b61cMark Andrews * @throws Exception If an unexpectd problem occurs.
c64aeaf419a7ef156b4aabfa2a913831e773157eBob Halley "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
aceae69c7f3e76e8842de178851928619c65b61cMark Andrews "o::" + Base64.encode("test".getBytes("UTF-8")),
193738b819e3c699f9edd18864a6810fcfcec855Andreas Gustafsson assertEquals(LDAPCompare.mainCompare(args, false, null, System.err), 0);
193738b819e3c699f9edd18864a6810fcfcec855Andreas Gustafsson * Tests a a comparison in which the assertion value should be base64-encoded
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley * but uses an incorrect encoding.
193738b819e3c699f9edd18864a6810fcfcec855Andreas Gustafsson * @throws Exception If an unexpectd problem occurs.
74cb99072c4b0ebd2ccafcfa284288fa760f7a1aMark Andrews public void testCompareInvalidBase64Assertion()
9ed37e8b9ccd53bc37b546fffe487b9547dda3a0Mark Andrews "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
9ed37e8b9ccd53bc37b546fffe487b9547dda3a0Mark Andrews "o::***invalidencoding***",
9ed37e8b9ccd53bc37b546fffe487b9547dda3a0Mark Andrews assertFalse(LDAPCompare.mainCompare(args, false, null, null) == 0);
905e0c15332d3209dd73ff8b2334f6b80f7fe3a6David Lawrence * Tests a a comparison in which the assertion value is contained in a file.
905e0c15332d3209dd73ff8b2334f6b80f7fe3a6David Lawrence * @throws Exception If an unexpectd problem occurs.
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence public void testCompareAssertionValueFromFile()
4108eed5092156cf0407a97a9bd8ab7775164694Brian Wellington File f = File.createTempFile("testCompareAssertionValueFromFile", ".txt");
df3c4c7988b9bae7d121a8ac9ed17a23366a948dDavid Lawrence "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
4108eed5092156cf0407a97a9bd8ab7775164694Brian Wellington assertEquals(LDAPCompare.mainCompare(args, false, null, System.err), 0);
0adde9f4f9369b23c67b9a29e824dda09b19022fDavid Lawrence * Tests a a comparison in which the assertion value is contained in a file
0adde9f4f9369b23c67b9a29e824dda09b19022fDavid Lawrence * that does not exist.
0adde9f4f9369b23c67b9a29e824dda09b19022fDavid Lawrence * @throws Exception If an unexpectd problem occurs.
0adde9f4f9369b23c67b9a29e824dda09b19022fDavid Lawrence public void testCompareAssertionValueFromNonExistentFile()
0adde9f4f9369b23c67b9a29e824dda09b19022fDavid Lawrence "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
0adde9f4f9369b23c67b9a29e824dda09b19022fDavid Lawrence "o:<does.not.exist",
0adde9f4f9369b23c67b9a29e824dda09b19022fDavid Lawrence assertFalse(LDAPCompare.mainCompare(args, false, null, null) == 0);
0adde9f4f9369b23c67b9a29e824dda09b19022fDavid Lawrence * Tests a a comparison using the LDAP assertion control in which the
0adde9f4f9369b23c67b9a29e824dda09b19022fDavid Lawrence * assertion is true.
0adde9f4f9369b23c67b9a29e824dda09b19022fDavid Lawrence * @throws Exception If an unexpectd problem occurs.
0adde9f4f9369b23c67b9a29e824dda09b19022fDavid Lawrence public void testCompareLDAPAssertionControlTrue()
0adde9f4f9369b23c67b9a29e824dda09b19022fDavid Lawrence "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
dc97fe4ed08488d314ab5bc8e99ed839542cf411David Lawrence assertEquals(LDAPCompare.mainCompare(args, false, null, System.err), 0);
0adde9f4f9369b23c67b9a29e824dda09b19022fDavid Lawrence * Tests a a comparison using the LDAP assertion control in which the
0adde9f4f9369b23c67b9a29e824dda09b19022fDavid Lawrence * assertion is not true.
0adde9f4f9369b23c67b9a29e824dda09b19022fDavid Lawrence * @throws Exception If an unexpectd problem occurs.
0adde9f4f9369b23c67b9a29e824dda09b19022fDavid Lawrence public void testCompareLDAPAssertionControlNotTrue()
aa30ee42c4b6da9bab4fb84d6cbbda6036a4d426Mark Andrews "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
dc97fe4ed08488d314ab5bc8e99ed839542cf411David Lawrence assertFalse(LDAPCompare.mainCompare(args, false, null, null) == 0);
7bb707a34778fc4bd9624d6c5de95675424ea59fDavid Lawrence * Tests a a compare operation reading the DNs to compare from a file. Some
7bb707a34778fc4bd9624d6c5de95675424ea59fDavid Lawrence * of the compares will succeed and others will not.
35c842e05dc6382ce1d9161a658d3ff4b2c3d4c9Bob Halley * @throws Exception If an unexpectd problem occurs.
19cfe6a53b6b932a375299ff8d82dbd66e54b5fdMark Andrews "dc=example,dc=com",
19cfe6a53b6b932a375299ff8d82dbd66e54b5fdMark Andrews "o=nonexistentsuffix",
19cfe6a53b6b932a375299ff8d82dbd66e54b5fdMark Andrews "malformed",
19cfe6a53b6b932a375299ff8d82dbd66e54b5fdMark Andrews "o=nonexistent,o=test");
19cfe6a53b6b932a375299ff8d82dbd66e54b5fdMark Andrews "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
19cfe6a53b6b932a375299ff8d82dbd66e54b5fdMark Andrews LDAPCompare.mainCompare(args, false, null, null);
435532822dc571a904207d8176e063cc8731eef5Bob Halley * Tests a a compare operation reading the DNs to compare from a file that
ed71ea51c6ecb5d7d659b6e6a20f6b3f5c2678c6David Lawrence * doesn't exist.
8313838954d67250d0ed7edf67fba5da0790d1a7Michael Graff * @throws Exception If an unexpectd problem occurs.
9f6c66e1b3902b61256267d124f1b9cd61402e76Andreas Gustafsson public void testCompareDNsFromNonExistentFile()
9f6c66e1b3902b61256267d124f1b9cd61402e76Andreas Gustafsson TestCaseUtils.initializeTestBackend(true);
9f6c66e1b3902b61256267d124f1b9cd61402e76Andreas Gustafsson "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
8313838954d67250d0ed7edf67fba5da0790d1a7Michael Graff assertFalse(LDAPCompare.mainCompare(args, false, null, null) == 0);
8313838954d67250d0ed7edf67fba5da0790d1a7Michael Graff * Tests the LDAPCompare tool with the "--help" option.
8313838954d67250d0ed7edf67fba5da0790d1a7Michael Graff assertEquals(LDAPCompare.mainCompare(args, false, null, null), 0);
ece3d6c35693f9e2145434b0bf14e8b752cdeee8Michael Graff assertEquals(LDAPCompare.mainCompare(args, false, null, null), 0);
ece3d6c35693f9e2145434b0bf14e8b752cdeee8Michael Graff assertEquals(LDAPCompare.mainCompare(args, false, null, null), 0);