PlainSASLMechanismHandlerTestCase.java revision 62625611993cc177eb95fb726fc137dbba01d6d2
2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License, Version 1.0 only
2N/A * (the "License"). You may not use this file except in compliance
2N/A * with the License.
2N/A *
2N/A * You can obtain a copy of the license at
2N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE
2N/A * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at
2N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
2N/A * add the following below this CDDL HEADER, with the fields enclosed
2N/A * by brackets "[]" replaced with your own identifying information:
2N/A * Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A *
2N/A *
2N/A * Copyright 2006-2008 Sun Microsystems, Inc.
2N/A */
2N/Apackage org.opends.server.extensions;
2N/A
2N/A
2N/A
2N/Aimport org.testng.annotations.BeforeClass;
2N/Aimport org.testng.annotations.DataProvider;
2N/Aimport org.testng.annotations.Test;
2N/A
2N/Aimport org.opends.server.TestCaseUtils;
2N/Aimport org.opends.server.api.SASLMechanismHandler;
2N/Aimport org.opends.server.core.AddOperation;
2N/Aimport org.opends.server.core.BindOperation;
2N/Aimport org.opends.server.core.DirectoryServer;
2N/Aimport org.opends.server.protocols.asn1.ASN1OctetString;
2N/Aimport org.opends.server.protocols.internal.InternalClientConnection;
2N/Aimport org.opends.server.protocols.internal.InternalSearchOperation;
2N/Aimport org.opends.server.protocols.ldap.LDAPFilter;
2N/Aimport org.opends.server.tools.LDAPSearch;
2N/Aimport org.opends.server.types.AuthenticationInfo;
2N/Aimport org.opends.server.types.ByteString;
2N/Aimport org.opends.server.types.DN;
2N/Aimport org.opends.server.types.Entry;
2N/Aimport org.opends.server.types.ResultCode;
2N/Aimport org.opends.server.types.SearchScope;
2N/Aimport org.opends.server.types.SearchFilter;
2N/A
2N/Aimport static org.testng.Assert.*;
2N/A
2N/A
2N/A
2N/A/**
2N/A * A set of test cases for the PLAIN SASL mechanism handler.
2N/A */
2N/Apublic class PlainSASLMechanismHandlerTestCase
2N/A extends ExtensionsTestCase
2N/A{
2N/A /**
2N/A * Ensures that the Directory Server is running.
2N/A *
2N/A * @throws Exception If an unexpected problem occurs.
2N/A */
2N/A @BeforeClass()
2N/A public void startServer()
2N/A throws Exception
2N/A {
2N/A TestCaseUtils.startServer();
2N/A }
2N/A
2N/A
2N/A
2N/A /**
2N/A * Tests to ensure that the SASL PLAIN mechanism is loaded and available in
2N/A * the server, and that it reports that it is password based and not secure.
2N/A *
2N/A * @throws Exception If an unexpected problem occurs.
2N/A */
2N/A @Test()
2N/A public void testSASLPlainLoaded()
2N/A {
2N/A SASLMechanismHandler handler =
2N/A DirectoryServer.getSASLMechanismHandler("PLAIN");
2N/A assertNotNull(handler);
2N/A
2N/A assertTrue(handler.isPasswordBased("PLAIN"));
2N/A assertFalse(handler.isSecure("PLAIN"));
2N/A }
2N/A
2N/A
2N/A
2N/A /**
2N/A * Tests to ensure that PLAIN is advertised as a supported SASL mechanism.
2N/A *
2N/A * @throws Exception If an unexpected problem occurs.
2N/A */
2N/A @Test()
2N/A public void testSASLPlainAdvertised()
2N/A throws Exception
2N/A {
2N/A InternalClientConnection conn =
2N/A InternalClientConnection.getRootConnection();
2N/A InternalSearchOperation op =
2N/A conn.processSearch(new ASN1OctetString(""), SearchScope.BASE_OBJECT,
2N/A LDAPFilter.decode("(supportedSASLMechanisms=PLAIN)"));
2N/A assertFalse(op.getSearchEntries().isEmpty());
2N/A }
2N/A
2N/A
2N/A
2N/A
2N/A /**
2N/A * Retrieves a set of passwords that may be used to test the password storage
2N/A * scheme.
2N/A *
2N/A * @return A set of passwords that may be used to test the password storage
2N/A * scheme.
2N/A */
2N/A @DataProvider(name = "testPasswords")
2N/A public Object[][] getTestPasswords()
2N/A {
2N/A return new Object[][]
2N/A {
2N/A new Object[] { new ASN1OctetString("a") },
2N/A new Object[] { new ASN1OctetString("ab") },
2N/A new Object[] { new ASN1OctetString("abc") },
2N/A new Object[] { new ASN1OctetString("abcd") },
2N/A new Object[] { new ASN1OctetString("abcde") },
2N/A new Object[] { new ASN1OctetString("abcdef") },
2N/A new Object[] { new ASN1OctetString("abcdefg") },
2N/A new Object[] { new ASN1OctetString("abcdefgh") },
2N/A new Object[] { new ASN1OctetString("The Quick Brown Fox Jumps Over " +
2N/A "The Lazy Dog") },
2N/A };
2N/A }
2N/A
2N/A
2N/A
2N/A /**
2N/A * Creates a test user and authenticates to the server as that user with the
2N/A * SASL PLAIN mechanism using a raw authentication ID (i.e., not prefixed by
2N/A * either "u:" or "dn:").
2N/A *
2N/A * @param password The password for the user.
2N/A *
2N/A * @throws Exception If an unexpected problem occurs.
2N/A */
2N/A @Test(dataProvider = "testPasswords")
2N/A public void testSASLPlainRawAuthID(ByteString password)
2N/A throws Exception
2N/A {
2N/A TestCaseUtils.initializeTestBackend(true);
2N/A
2N/A Entry e = TestCaseUtils.makeEntry(
2N/A "dn: uid=test.user,o=test",
2N/A "objectClass: top",
2N/A "objectClass: person",
2N/A "objectClass: organizationalPerson",
2N/A "objectClass: inetOrgPerson",
2N/A "uid: test.user",
2N/A "givenName: Test",
2N/A "sn: User",
2N/A "cn: Test User",
2N/A "userPassword: " + password.stringValue());
2N/A
2N/A InternalClientConnection conn =
2N/A InternalClientConnection.getRootConnection();
2N/A AddOperation addOperation = conn.processAdd(e.getDN(), e.getObjectClasses(),
2N/A e.getUserAttributes(),
2N/A e.getOperationalAttributes());
2N/A assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
2N/A
2N/A
2N/A byte[] saslCredBytes = new byte[11 + password.value().length];
2N/A System.arraycopy("test.user".getBytes("UTF-8"), 0, saslCredBytes, 1, 9);
2N/A System.arraycopy(password.value(), 0, saslCredBytes, 11,
2N/A password.value().length);
2N/A InternalClientConnection anonymousConn =
2N/A new InternalClientConnection(new AuthenticationInfo());
2N/A BindOperation bindOperation =
2N/A anonymousConn.processSASLBind(new ASN1OctetString(), "PLAIN",
2N/A new ASN1OctetString(saslCredBytes));
2N/A assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS);
2N/A }
2N/A
2N/A
2N/A
2N/A /**
2N/A * Creates a test user and authenticates to the server as that user with the
2N/A * SASL PLAIN mechanism using the "u:" style authentication ID.
2N/A *
2N/A * @param password The password for the user.
2N/A *
2N/A * @throws Exception If an unexpected problem occurs.
2N/A */
2N/A @Test(dataProvider = "testPasswords")
2N/A public void testSASLPlainUColon(ByteString password)
2N/A throws Exception
2N/A {
2N/A TestCaseUtils.initializeTestBackend(true);
2N/A
2N/A Entry e = TestCaseUtils.makeEntry(
2N/A "dn: uid=test.user,o=test",
2N/A "objectClass: top",
2N/A "objectClass: person",
2N/A "objectClass: organizationalPerson",
2N/A "objectClass: inetOrgPerson",
2N/A "uid: test.user",
2N/A "givenName: Test",
2N/A "sn: User",
2N/A "cn: Test User",
2N/A "userPassword: " + password.stringValue());
2N/A
2N/A InternalClientConnection conn =
2N/A InternalClientConnection.getRootConnection();
2N/A AddOperation addOperation = conn.processAdd(e.getDN(), e.getObjectClasses(),
2N/A e.getUserAttributes(),
2N/A e.getOperationalAttributes());
2N/A assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
2N/A
2N/A
2N/A byte[] saslCredBytes = new byte[13 + password.value().length];
2N/A System.arraycopy("u:test.user".getBytes("UTF-8"), 0, saslCredBytes, 1, 11);
2N/A System.arraycopy(password.value(), 0, saslCredBytes, 13,
2N/A password.value().length);
2N/A InternalClientConnection anonymousConn =
2N/A new InternalClientConnection(new AuthenticationInfo());
2N/A BindOperation bindOperation =
2N/A anonymousConn.processSASLBind(new ASN1OctetString(), "PLAIN",
2N/A new ASN1OctetString(saslCredBytes));
2N/A assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS);
2N/A }
2N/A
2N/A
2N/A
2N/A /**
2N/A * Creates a test user and authenticates to the server as that user with the
2N/A * SASL PLAIN mechanism using the "u:" style authentication ID and
2N/A * authorization ID.
2N/A *
2N/A * @param password The password for the user.
2N/A *
2N/A * @throws Exception If an unexpected problem occurs.
2N/A */
2N/A @Test(dataProvider = "testPasswords")
2N/A public void testSASLPlainUColonWithAuthZID(ByteString password)
2N/A throws Exception
2N/A {
2N/A TestCaseUtils.initializeTestBackend(true);
2N/A
2N/A Entry e = TestCaseUtils.makeEntry(
2N/A "dn: uid=test.user,o=test",
2N/A "objectClass: top",
2N/A "objectClass: person",
2N/A "objectClass: organizationalPerson",
2N/A "objectClass: inetOrgPerson",
2N/A "uid: test.user",
2N/A "givenName: Test",
2N/A "sn: User",
2N/A "cn: Test User",
2N/A "userPassword: " + password.stringValue());
2N/A
2N/A InternalClientConnection conn =
2N/A InternalClientConnection.getRootConnection();
2N/A AddOperation addOperation = conn.processAdd(e.getDN(), e.getObjectClasses(),
2N/A e.getUserAttributes(),
2N/A e.getOperationalAttributes());
2N/A assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
2N/A
2N/A
2N/A byte[] saslCredBytes = new byte[24 + password.value().length];
2N/A System.arraycopy("u:test.user".getBytes("UTF-8"), 0, saslCredBytes, 0, 11);
2N/A System.arraycopy("u:test.user".getBytes("UTF-8"), 0, saslCredBytes, 12, 11);
2N/A System.arraycopy(password.value(), 0, saslCredBytes, 24,
2N/A password.value().length);
2N/A InternalClientConnection anonymousConn =
2N/A new InternalClientConnection(new AuthenticationInfo());
2N/A BindOperation bindOperation =
2N/A anonymousConn.processSASLBind(new ASN1OctetString(), "PLAIN",
2N/A new ASN1OctetString(saslCredBytes));
2N/A assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS);
2N/A }
2N/A
2N/A
2N/A
2N/A /**
2N/A * Creates a test user and authenticates to the server as that user with the
2N/A * SASL PLAIN mechanism using the "dn:" style authentication ID.
2N/A *
2N/A * @param password The password for the user.
2N/A *
2N/A * @throws Exception If an unexpected problem occurs.
2N/A */
2N/A @Test(dataProvider = "testPasswords")
2N/A public void testSASLPlainDNColon(ByteString password)
2N/A throws Exception
2N/A {
2N/A TestCaseUtils.initializeTestBackend(true);
2N/A
2N/A Entry e = TestCaseUtils.makeEntry(
2N/A "dn: uid=test.user,o=test",
2N/A "objectClass: top",
2N/A "objectClass: person",
2N/A "objectClass: organizationalPerson",
2N/A "objectClass: inetOrgPerson",
2N/A "uid: test.user",
2N/A "givenName: Test",
2N/A "sn: User",
2N/A "cn: Test User",
2N/A "userPassword: " + password.stringValue());
2N/A
2N/A InternalClientConnection conn =
2N/A InternalClientConnection.getRootConnection();
2N/A AddOperation addOperation = conn.processAdd(e.getDN(), e.getObjectClasses(),
2N/A e.getUserAttributes(),
2N/A e.getOperationalAttributes());
2N/A assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
2N/A
2N/A
2N/A byte[] dnBytes = e.getDN().toString().getBytes("UTF-8");
2N/A byte[] saslCredBytes =
2N/A new byte[5 + dnBytes.length + password.value().length];
2N/A System.arraycopy("dn:".getBytes("UTF-8"), 0, saslCredBytes, 1, 3);
2N/A System.arraycopy(dnBytes, 0, saslCredBytes, 4, dnBytes.length);
2N/A System.arraycopy(password.value(), 0, saslCredBytes, 5 + dnBytes.length,
2N/A password.value().length);
2N/A InternalClientConnection anonymousConn =
2N/A new InternalClientConnection(new AuthenticationInfo());
2N/A BindOperation bindOperation =
2N/A anonymousConn.processSASLBind(new ASN1OctetString(), "PLAIN",
2N/A new ASN1OctetString(saslCredBytes));
2N/A assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS);
2N/A }
2N/A
2N/A
2N/A
2N/A /**
2N/A * Creates a test user and authenticates to the server as that user with the
2N/A * SASL PLAIN mechanism using the "dn:" style authentication ID and an
2N/A * authorization ID.
2N/A *
2N/A * @param password The password for the user.
2N/A *
2N/A * @throws Exception If an unexpected problem occurs.
2N/A */
2N/A @Test(dataProvider = "testPasswords")
2N/A public void testSASLPlainDNColonWithAuthZID(ByteString password)
2N/A throws Exception
2N/A {
2N/A TestCaseUtils.initializeTestBackend(true);
2N/A
2N/A Entry e = TestCaseUtils.makeEntry(
2N/A "dn: uid=test.user,o=test",
2N/A "objectClass: top",
2N/A "objectClass: person",
2N/A "objectClass: organizationalPerson",
2N/A "objectClass: inetOrgPerson",
2N/A "uid: test.user",
2N/A "givenName: Test",
2N/A "sn: User",
2N/A "cn: Test User",
2N/A "userPassword: " + password.stringValue());
2N/A
2N/A InternalClientConnection conn =
2N/A InternalClientConnection.getRootConnection();
2N/A AddOperation addOperation = conn.processAdd(e.getDN(), e.getObjectClasses(),
2N/A e.getUserAttributes(),
2N/A e.getOperationalAttributes());
2N/A assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
2N/A
2N/A
2N/A byte[] dnBytes = ("dn:" + e.getDN().toString()).getBytes("UTF-8");
2N/A byte[] saslCredBytes =
2N/A new byte[2 + (2*dnBytes.length) + password.value().length];
2N/A System.arraycopy(dnBytes, 0, saslCredBytes, 0, dnBytes.length);
2N/A System.arraycopy(dnBytes, 0, saslCredBytes, dnBytes.length+1,
2N/A dnBytes.length);
2N/A System.arraycopy(password.value(), 0, saslCredBytes,
2N/A (2*dnBytes.length + 2), password.value().length);
2N/A InternalClientConnection anonymousConn =
2N/A new InternalClientConnection(new AuthenticationInfo());
2N/A BindOperation bindOperation =
2N/A anonymousConn.processSASLBind(new ASN1OctetString(), "PLAIN",
2N/A new ASN1OctetString(saslCredBytes));
2N/A assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS);
2N/A }
2N/A
2N/A
2N/A
2N/A /**
2N/A * Ensures that SASL PLAIN authentication will work for root users.
2N/A *
2N/A * @throws Exception If an unexpected problem occurs.
2N/A */
2N/A @Test()
2N/A public void testSASLPlainAsRoot()
2N/A throws Exception
2N/A {
2N/A ASN1OctetString rootCreds =
2N/A new ASN1OctetString("\u0000dn:cn=Directory Manager\u0000password");
2N/A
2N/A InternalClientConnection anonymousConn =
2N/A new InternalClientConnection(new AuthenticationInfo());
2N/A BindOperation bindOperation =
2N/A anonymousConn.processSASLBind(new ASN1OctetString(), "PLAIN",
2N/A rootCreds);
2N/A assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS);
2N/A }
2N/A
2N/A
2N/A
2N/A /**
2N/A * Ensures that SASL PLAIN authentication works over LDAP as well as via the
2N/A * internal protocol. The authentication will be performed as the root user.
2N/A *
2N/A * @throws Exception If an unexpected problem occurs.
2N/A */
2N/A @Test()
2N/A public void testSASLPlainOverLDAP()
2N/A throws Exception
2N/A {
2N/A String[] args =
2N/A {
2N/A "--noPropertiesFile",
2N/A "-h", "127.0.0.1",
2N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
2N/A "-o", "mech=PLAIN",
2N/A "-o", "authid=dn:cn=Directory Manager",
2N/A "-w", "password",
2N/A "-b", "",
2N/A "-s", "base",
2N/A "(objectClass=*)",
2N/A "1.1"
2N/A };
2N/A
2N/A assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0);
2N/A }
2N/A
2N/A
2N/A
2N/A /**
2N/A * Retrieves sets of invalid credentials that will not succeed when using
2N/A * SASL PLAIN.
2N/A *
2N/A * @return Sets of invalid credentials that will not work when using SASL
2N/A * PLAIN.
2N/A */
2N/A @DataProvider(name = "invalidCredentials")
2N/A public Object[][] getInvalidCredentials()
2N/A {
2N/A return new Object[][]
2N/A {
2N/A new Object[] { null },
2N/A new Object[] { new ASN1OctetString() },
2N/A new Object[] { new ASN1OctetString("u:test.user") },
2N/A new Object[] { new ASN1OctetString("password") },
2N/A new Object[] { new ASN1OctetString("\u0000") },
2N/A new Object[] { new ASN1OctetString("\u0000\u0000") },
2N/A new Object[] { new ASN1OctetString("\u0000password") },
2N/A new Object[] { new ASN1OctetString("\u0000\u0000password") },
2N/A new Object[] { new ASN1OctetString("\u0000u:test.user\u0000") },
2N/A new Object[] { new ASN1OctetString("\u0000dn:\u0000password") },
2N/A new Object[] { new ASN1OctetString("\u0000dn:bogus\u0000password") },
2N/A new Object[] { new ASN1OctetString("\u0000dn:cn=no such user" +
2N/A "\u0000password") },
2N/A new Object[] { new ASN1OctetString("\u0000u:\u0000password") },
2N/A new Object[] { new ASN1OctetString("\u0000u:nosuchuser\u0000password") },
2N/A new Object[] { new ASN1OctetString("\u0000u:test.user\u0000" +
2N/A "wrongpassword") },
2N/A };
2N/A }
2N/A
2N/A
2N/A
2N/A /**
2N/A * Creates a test user and authenticates to the server as that user with the
2N/A * SASL PLAIN mechanism using the "dn:" style authentication ID.
2N/A *
2N/A * @param saslCredentials The (invalid) SASL credentials to use.
2N/A *
2N/A * @throws Exception If an unexpected problem occurs.
2N/A */
2N/A @Test(dataProvider = "invalidCredentials")
2N/A public void testInvalidCredentials(ASN1OctetString saslCredentials)
2N/A throws Exception
2N/A {
2N/A TestCaseUtils.initializeTestBackend(true);
2N/A
2N/A Entry e = TestCaseUtils.makeEntry(
2N/A "dn: uid=test.user,o=test",
2N/A "objectClass: top",
2N/A "objectClass: person",
2N/A "objectClass: organizationalPerson",
2N/A "objectClass: inetOrgPerson",
2N/A "uid: test.user",
2N/A "givenName: Test",
2N/A "sn: User",
2N/A "cn: Test User",
2N/A "userPassword: password");
2N/A
2N/A InternalClientConnection conn =
2N/A InternalClientConnection.getRootConnection();
2N/A AddOperation addOperation = conn.processAdd(e.getDN(), e.getObjectClasses(),
2N/A e.getUserAttributes(),
2N/A e.getOperationalAttributes());
2N/A assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
2N/A
2N/A
2N/A InternalClientConnection anonymousConn =
2N/A new InternalClientConnection(new AuthenticationInfo());
2N/A BindOperation bindOperation =
2N/A anonymousConn.processSASLBind(new ASN1OctetString(), "PLAIN",
2N/A saslCredentials);
2N/A assertEquals(bindOperation.getResultCode(), ResultCode.INVALID_CREDENTIALS);
2N/A }
2N/A
2N/A
2N/A
2N/A /**
2N/A * Performs a failed LDAP bind using PLAIN with an authorization ID that
2N/A * contains the DN of an entry that doesn't exist.
2N/A *
2N/A * @throws Exception If an unexpected problem occurs.
2N/A */
2N/A @Test()
2N/A public void testLDAPBindFailNonexistentAuthzDN()
2N/A throws Exception
2N/A {
2N/A TestCaseUtils.initializeTestBackend(true);
2N/A TestCaseUtils.addEntry(
2N/A "dn: uid=test.user,o=test",
2N/A "objectClass: top",
2N/A "objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: test.user",
"givenName: Test",
"sn: User",
"cn: Test User",
"userPassword: password",
"ds-privilege-name: proxied-auth");
String[] args =
{
"--noPropertiesFile",
"-h", "127.0.0.1",
"-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
"-o", "mech=PLAIN",
"-o", "authid=dn:uid=test.user,o=test",
"-o", "authzid=dn:uid=nonexistent,o=test",
"-w", "password",
"-b", "",
"-s", "base",
"(objectClass=*)"
};
assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0);
}
/**
* Performs a failed LDAP bind using PLAIN with an authorization ID that
* contains a username for an entry that doesn't exist.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testLDAPBindFailNonexistentAuthzUsername()
throws Exception
{
TestCaseUtils.initializeTestBackend(true);
TestCaseUtils.addEntry(
"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-privilege-name: proxied-auth");
String[] args =
{
"--noPropertiesFile",
"-h", "127.0.0.1",
"-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
"-o", "mech=PLAIN",
"-o", "authid=dn:uid=test.user,o=test",
"-o", "authzid=u:nonexistent",
"-w", "password",
"-b", "",
"-s", "base",
"(objectClass=*)"
};
assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0);
}
/**
* Performs a failed LDAP bind using PLAIN with an authorization ID that
* contains a malformed DN.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testLDAPBindFailMalformedAuthzDN()
throws Exception
{
TestCaseUtils.initializeTestBackend(true);
TestCaseUtils.addEntry(
"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-privilege-name: proxied-auth");
String[] args =
{
"--noPropertiesFile",
"-h", "127.0.0.1",
"-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
"-o", "mech=PLAIN",
"-o", "authid=dn:uid=test.user,o=test",
"-o", "authzid=dn:malformed",
"-w", "password",
"-b", "",
"-s", "base",
"(objectClass=*)"
};
assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0);
}
}