BindOperationTestCase.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 2006-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2015 ForgeRock AS.
*/
/**
* A set of test cases for bind operations.
*/
public class BindOperationTestCase
extends OperationTestCase
{
/**
* Retrieves a set of bind operation objects using simple authentication.
*
* @return A set of bind operation objects using simple authentication.
*
* @throws Exception If an unexpected problem occurs.
*/
public Object[][] getSimpleBindOperations()
throws Exception
{
{
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
ByteString.empty()),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
ByteString.empty()),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
noControls, "3",
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
};
{
}
return array;
}
/**
* Retrieves a set of bind operation objects using SASL authentication.
*
* @return A set of bind operation objects using SASL authentication.
*
* @throws Exception If an unexpected problem occurs.
*/
public Object[][] getSASLBindOperations()
throws Exception
{
{
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
null),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
};
{
}
return array;
}
/** {@inheritDoc} */
protected Operation[] createTestOperations()
throws Exception
{
int pos = 0;
{
}
{
}
return bindOps;
}
/**
* Tests the <CODE>getAuthenticationType</CODE> method for simple bind
* operations.
*
* @param o The bind operation to be tested.
*/
public void testGetAuthenticationTypeSimple(BindOperation o)
{
}
/**
* Tests the <CODE>getAuthenticationType</CODE> method for SASL bind
* operations.
*
* @param o The bind operation to be tested.
*/
public void testGetAuthenticationTypeSASL(BindOperation o)
{
}
/**
* Tests the <CODE>getGetProtocolVersion</CODE> method for simple bind
* operations.
*
* @param o The bind operation to be tested.
*/
public void testGetProtocolVersionSimple(BindOperation o)
{
}
/**
* Tests the <CODE>getProtocolVersion</CODE> method for SASL bind operations.
*
* @param o The bind operation to be tested.
*/
public void testGetProtocolVersionSASL(BindOperation o)
{
}
/**
* Tests the <CODE>getRawBindDN</CODE> method for simple bind operations.
*
* @param o The bind operation to be tested.
*/
public void testGetRawBindDNSimple(BindOperation o)
{
assertNotNull(o.getRawBindDN());
}
/**
* Tests the <CODE>getRawBindDN</CODE> method for SASL bind operations.
*
* @param o The bind operation to be tested.
*/
public void testGetRawBindDNSASL(BindOperation o)
{
assertNotNull(o.getRawBindDN());
}
/**
* Tests the <CODE>setRawBindDN()</CODE> method for simple bind operations.
*
* @param o The bind operation to be tested.
*/
public void testSetRawBindDNSimple(BindOperation o)
{
o.setRawBindDN(null);
}
/**
* Tests the <CODE>setRawBindDN()</CODE> method for SASL bind operations.
*
* @param o The bind operation to be tested.
*/
public void testSetRawBindDNSASL(BindOperation o)
{
o.setRawBindDN(null);
}
/**
* Tests the <CODE>getBindDN</CODE> method on bind operations using simple
* authentication.
*
* @param o The bind operation to be tested.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testGetBindDNSimple(BindOperation o)
throws Exception
{
o.getBindDN();
}
/**
* Tests the <CODE>getSimplePassword</CODE> method for bind operations using
* simple authentication.
*
* @param o The bind operation to be tested.
*/
public void testGetSimplePasswordSimple(BindOperation o)
{
}
/**
* Tests the <CODE>getSimplePassword</CODE> method for bind operations using
* SASL authentication.
*
* @param o The bind operation to be tested.
*/
public void testGetSimplePasswordSASL(BindOperation o)
{
assertNull(o.getSimplePassword());
}
/**
* Tests the <CODE>getSASLMechanism</CODE> method for bind operations using
* simple authentication.
*
* @param o The bind operation to be tested.
*/
public void testGetSASLMechanismSimple(BindOperation o)
{
assertNull(o.getSASLMechanism());
}
/**
* Tests the <CODE>getSASLMechanism</CODE> method for bind operations using
* SASL authentication.
*
* @param o The bind operation to be tested.
*/
public void testGetSASLMechanismSASL(BindOperation o)
{
}
/**
* Tests the <CODE>getSASLCredentials</CODE> method for bind operations using
* simple authentication.
*
* @param o The bind operation to be tested.
*/
public void testGetSASLCredentialsSimple(BindOperation o)
{
assertNull(o.getSASLCredentials());
}
/**
* Tests the <CODE>getSASLCredentials</CODE> method for bind operations using
* SASL authentication.
*
* @param o The bind operation to be tested.
*/
public void testGetSASLCredentialsSASL(BindOperation o)
{
// We don't know whether they should be null or not, so we'll just not
// bother checking what it returns.
o.getSASLCredentials();
}
/**
* Tests the ability to change a simple bind operation to a SASL bind
* operation and back again.
*
* @param o The bind operation to be tested.
*/
public void testChangeSimpleToSASLAndBack(BindOperation o)
{
assertNull(o.getSASLMechanism());
assertNull(o.getSASLCredentials());
assertNull(o.getSASLCredentials());
assertNull(o.getSASLMechanism());
assertNull(o.getSASLCredentials());
o.setSASLCredentials("PLAIN",
assertNull(o.getSASLMechanism());
assertNull(o.getSASLCredentials());
}
/**
* Tests the ability to change a SASL bind operation to a simple bind
* operation and back again.
*
* @param o The bind operation to be tested.
*/
public void testChangeSASLToSimpleAndBack(BindOperation o)
{
assertNull(o.getSimplePassword());
assertNull(o.getSimplePassword());
assertNull(o.getSimplePassword());
assertNull(o.getSimplePassword());
}
/**
* Tests the <CODE>getServerSASLCredentials</CODE> method for bind operations
* using simple authentication.
*
* @param o The bind operation to be tested.
*/
public void testGetServerSASLCredentialsSimple(BindOperation o)
{
}
/**
* Tests the <CODE>getServerSASLCredentials</CODE> method for bind operations
* using SASL authentication.
*
* @param o The bind operation to be tested.
*/
public void testGetServerSASLCredentialsSASL(BindOperation o)
{
}
/**
* Tests the <CODE>getSASLAuthUserEntry</CODE> method for bind operations
* using simple authentication.
*
* @param o The bind operation to be tested.
*/
public void testGetSASLAuthUserEntrySimple(BindOperation o)
{
}
/**
* Tests the <CODE>getSASLAuthUserEntry</CODE> method for bind operations
* using SASL authentication.
*
* @param o The bind operation to be tested.
*/
public void testGetSASLAuthUserEntrySASL(BindOperation o)
{
}
/**
* Tests the <CODE>getSASLAuthUserEntry</CODE> method for completed SASL bind
* operations in which this value will be set.
*/
@Test
public void testGetSASLAuthUserEntryNonNull()
{
new InternalClientConnection(new AuthenticationInfo());
}
/**
* Tests the <CODE>getUserEntryDN</CODE> method for bind operations using
* simple authentication.
*
* @param o The bind operation to be tested.
*/
public void testGetUserEntryDNSimple(BindOperation o)
{
assertNull(o.getUserEntryDN());
}
/**
* Tests the <CODE>getUserEntryDN</CODE> method for a completed bind operation
* using simple authentication in which this value will be set.
*/
@Test
public void testGetUserEntryDNSimpleNonNull()
{
new InternalClientConnection(new AuthenticationInfo());
}
/**
* Tests the <CODE>getUserEntryDN</CODE> method for bind operations using SASL
* authentication.
*
* @param o The bind operation to be tested.
*/
public void testGetUserEntryDNSASL(BindOperation o)
{
assertNull(o.getUserEntryDN());
}
/**
* Tests the <CODE>getUserEntryDN</CODE> method for a completed bind operation
* using SASL authentication in which this value will be set.
*/
@Test
public void testGetUserEntryDNSASLNonNull()
{
new InternalClientConnection(new AuthenticationInfo());
}
/**
* Tests the <CODE>getProcessingStartTime</CODE>,
* <CODE>getProcessingStopTime</CODE>, and <CODE>getProcessingTime()</CODE>
* methods for a completed bind operation using simple authentication.
*/
@Test
public void testGetProcessingStartAndStopTimesSimple()
{
new InternalClientConnection(new AuthenticationInfo());
}
/**
* Tests the <CODE>getProcessingStartTime</CODE>,
* <CODE>getProcessingStopTime</CODE>, and <CODE>getProcessingTime()</CODE>
* methods for a completed bind operation using SASL authentication.
*/
@Test
public void testGetProcessingStartAndStopTimesSASL()
{
new InternalClientConnection(new AuthenticationInfo());
}
/**
* Tests the <CODE>getOperationType</CODE> method for bind operations using
* simple authentication.
*
* @param o The bind operation to be tested.
*/
public void testGetOperationTypeSimple(BindOperation o)
{
}
/**
* Tests the <CODE>getOperationType</CODE> method for bind operations using
* SASL authentication.
*
* @param o The bind operation to be tested.
*/
public void testGetOperationTypeSASL(BindOperation o)
{
}
/**
* Tests a simple bind operation to ensure that all plugin types are invoked
* as expected.
*/
@Test
public void testAllPluginsCalledSimple()
{
new InternalClientConnection(new AuthenticationInfo());
// assertTrue(InvocationCounterPlugin.getPreParseCount() > 0);
// assertTrue(InvocationCounterPlugin.getPreOperationCount() > 0);
// assertTrue(InvocationCounterPlugin.getPostOperationCount() > 0);
// assertTrue(InvocationCounterPlugin.getPostResponseCount() > 0);
}
/**
* Tests a SASL bind operation to ensure that all plugin types are invoked
* as expected.
*/
@Test
public void testAllPluginsCalledSASL()
{
new InternalClientConnection(new AuthenticationInfo());
// assertTrue(InvocationCounterPlugin.getPreParseCount() > 0);
// assertTrue(InvocationCounterPlugin.getPreOperationCount() > 0);
// assertTrue(InvocationCounterPlugin.getPostOperationCount() > 0);
// assertTrue(InvocationCounterPlugin.getPostResponseCount() > 0);
}
/**
* Tests an anonymous simple bind operation to ensure that it's treated
* properly if the client connection is lost in pre-parse plugin processing.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testBindDisconnectInPreParseSimpleAnonymous()
throws Exception
{
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
ByteString.empty());
w.writeMessage(message);
message = r.readMessage();
{
// If we got an element back, then it must be a notice of disconnect
// unsolicited notification.
}
StaticUtils.close(s);
}
/**
* Tests an anonymous simple bind operation to ensure that it's treated
* properly if the client connection is lost in pre-operation plugin
* processing.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testBindDisconnectInPreOperationSimpleAnonymous()
throws Exception
{
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
ByteString.empty());
"PreOperation"));
w.writeMessage(message);
message = r.readMessage();
{
// If we got an element back, then it must be a notice of disconnect
// unsolicited notification.
}
StaticUtils.close(s);
}
/**
* Tests an anonymous simple bind operation to ensure that it's treated
* properly if the client connection is lost in post-operation plugin
* processing.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testBindDisconnectInPostOperationSimpleAnonymous()
throws Exception
{
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
ByteString.empty());
"PostOperation"));
w.writeMessage(message);
message = r.readMessage();
{
// If we got an element back, then it must be a notice of disconnect
// unsolicited notification.
}
StaticUtils.close(s);
}
/**
* Tests an anonymous simple bind operation to ensure that it's treated
* properly if the client connection is lost in post-response plugin
* processing.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testBindDisconnectInPostResponseSimpleAnonymous()
throws Exception
{
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
ByteString.empty());
"PostResponse"));
w.writeMessage(message);
message = r.readMessage();
{
message = r.readMessage();
}
StaticUtils.close(s);
}
/**
* Tests an authenticated simple bind operation to ensure that it's treated
* properly if the client connection is lost in pre-parse plugin processing.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testBindDisconnectInPreParseSimpleAuthenticated()
throws Exception
{
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
w.writeMessage(message);
message = r.readMessage();
{
// If we got an element back, then it must be a notice of disconnect
// unsolicited notification.
}
StaticUtils.close(s);
}
/**
* Tests an authenticated simple bind operation to ensure that it's treated
* properly if the client connection is lost in pre-operation plugin
* processing.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testBindDisconnectInPreOperationSimpleAuthenticated()
throws Exception
{
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
"PreOperation"));
w.writeMessage(message);
message = r.readMessage();
{
// If we got an element back, then it must be a notice of disconnect
// unsolicited notification.
}
StaticUtils.close(s);
}
/**
* Tests an authenticated simple bind operation to ensure that it's treated
* properly if the client connection is lost in post-operation plugin
* processing.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testBindDisconnectInPostOperationSimpleAuthenticated()
throws Exception
{
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
"PostOperation"));
w.writeMessage(message);
message = r.readMessage();
{
// If we got an element back, then it must be a notice of disconnect
// unsolicited notification.
}
StaticUtils.close(s);
}
/**
* Tests an authenticated simple bind operation to ensure that it's treated
* properly if the client connection is lost in post-response plugin
* processing.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testBindDisconnectInPostResponseSimpleAuthenticated()
throws Exception
{
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
"PostResponse"));
w.writeMessage(message);
message = r.readMessage();
{
message = r.readMessage();
}
StaticUtils.close(s);
}
/**
* Tests a SASL bind operation to ensure that it's treated properly if the
* client connection is lost in pre-parse plugin processing.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testBindDisconnectInPreParseSASL()
throws Exception
{
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
w.writeMessage(message);
message = r.readMessage();
{
// If we got an element back, then it must be a notice of disconnect
// unsolicited notification.
}
StaticUtils.close(s);
}
/**
* Tests a SASL bind operation to ensure that it's treated properly if the
* client connection is lost in pre-operation plugin processing.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testBindDisconnectInPreOperationSASL()
throws Exception
{
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
"PreOperation"));
w.writeMessage(message);
message = r.readMessage();
{
// If we got an element back, then it must be a notice of disconnect
// unsolicited notification.
}
StaticUtils.close(s);
}
/**
* Tests a SASL bind operation to ensure that it's treated properly if the
* client connection is lost in post-operation plugin processing.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testBindDisconnectInPostOperationSASL()
throws Exception
{
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
"PostOperation"));
w.writeMessage(message);
message = r.readMessage();
{
// If we got an element back, then it must be a notice of disconnect
// unsolicited notification.
}
StaticUtils.close(s);
}
/**
* Tests a SASL bind operation to ensure that it's treated properly if the
* client connection is lost in post-response plugin processing.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testBindDisconnectInPostResponseSASL()
throws Exception
{
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
"PostResponse"));
w.writeMessage(message);
message = r.readMessage();
{
message = r.readMessage();
}
StaticUtils.close(s);
}
/**
* Tests an anonymous simple bind operation to ensure that it's treated
* properly if the operation gets short-circuited in pre-parse plugin
* processing.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testBindShortCircuitInPreParseSimpleAnonymous()
throws Exception
{
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
ByteString.empty());
w.writeMessage(message);
message = r.readMessage();
StaticUtils.close(s);
}
/**
* Tests an anonymous simple bind operation to ensure that it's treated
* properly if the operation gets short-circuited in pre-operation plugin
* processing.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testBindShortCircuitInPreOperationSimpleAnonymous()
throws Exception
{
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
ByteString.empty());
"PreOperation"));
w.writeMessage(message);
message = r.readMessage();
StaticUtils.close(s);
}
/**
* Tests an authenticated simple bind operation to ensure that it's treated
* properly if the operation gets short-circuited in pre-parse plugin
* processing.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testBindShortCircuitInPreParseSimpleAuthenticated()
throws Exception
{
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
w.writeMessage(message);
message = r.readMessage();
StaticUtils.close(s);
}
/**
* Tests an authenticated simple bind operation to ensure that it's treated
* properly if the operation gets short-circuited in pre-operation plugin
* processing.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testBindShortCircuitInPreOperationSimpleAuthenticated()
throws Exception
{
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
"PreOperation"));
w.writeMessage(message);
message = r.readMessage();
StaticUtils.close(s);
}
/**
* Tests a SASL bind operation to ensure that it's treated properly if the
* operation gets short-circuited in pre-parse plugin processing.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testBindShortCircuitInPreParseSASL()
throws Exception
{
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
w.writeMessage(message);
message = r.readMessage();
StaticUtils.close(s);
}
/**
* Tests a SASL bind operation to ensure that it's treated properly if the
* operation gets short-circuited in pre-operation plugin processing.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testBindShortCircuitInPreOperationSASL()
throws Exception
{
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
"PreOperation"));
w.writeMessage(message);
message = r.readMessage();
StaticUtils.close(s);
}
/**
* Tests performing a simple bind operation with an invalid user DN.
*/
@Test
public void testSimpleBindInvalidDN()
{
new InternalClientConnection(new AuthenticationInfo());
}
/**
* Tests performing a SASL bind operation with an invalid user DN.
*/
@Test
public void testSASLBindInvalidDN()
{
new InternalClientConnection(new AuthenticationInfo());
}
/**
* Tests performing a simple bind operation with an unsupported control that
* is marked critical.
*/
@Test
public void testSimpleBindUnsupportedCriticalControl()
{
new InternalClientConnection(new AuthenticationInfo());
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
ByteString.empty());
bindOperation.run();
}
/**
* Tests performing a SASL bind operation with an unsupported control that is
* marked critical.
*/
@Test
public void testSASLBindUnsupportedCriticalControl()
{
new InternalClientConnection(new AuthenticationInfo());
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
bindOperation.run();
}
/**
* Tests performing a simple bind operation with an unsupported control that
* is not marked critical.
*/
@Test
public void testSimpleBindUnsupportedNonCriticalControl()
{
new InternalClientConnection(new AuthenticationInfo());
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
ByteString.empty());
bindOperation.run();
}
/**
* Tests performing a SASL bind operation with an unsupported control that is
* is not marked critical.
*/
@Test
public void testSASLBindUnsupportedNonCriticalControl()
{
new InternalClientConnection(new AuthenticationInfo());
new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
bindOperation.run();
}
/**
* Tests performing a simple bind operation with the DN of a user that doesn't
* exist.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSimpleBindNoSuchUser()
throws Exception
{
new InternalClientConnection(new AuthenticationInfo());
}
/**
* Tests performing a simple bind operation with the DN of a valid user but
* without including a password in the request, with the server configured to
* disallow that combination.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSimpleBindWithDNNoPasswordDisallowed()
throws Exception
{
new InternalClientConnection(new AuthenticationInfo());
ByteString.empty());
}
/**
* Tests performing a simple bind operation with the DN of a valid user but
* without including a password in the request, with the server configured to
* allow that combination.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSimpleBindWithDNNoPasswordAllowed()
throws Exception
{
ArrayList<Modification> mods = newArrayList(new Modification(REPLACE, Attributes.create(attr, "false")));
ByteString.empty());
}
/**
* Tests performing a simple bind operation as a user who doesn't have a
* password.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSimpleBindNoUserPassword()
throws Exception
{
"dn: uid=test,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: test",
"givenName: Test",
"sn: User",
"cn: Test User");
}
/**
* Tests performing a simple bind operation as a user who exists on
* another server for which a named subordinate reference exists.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testSimpleBindReferral() throws Exception
{
"dn: ou=people,dc=example,dc=com",
"objectClass: top",
"objectClass: referral",
"objectClass: extensibleObject",
"ou: people",
"ref: ldap://example.com:1389/ou=people,o=test");
}
/**
* Tests performing a simple bind operation with a valid DN but incorrect
* password.
*/
@Test
public void testSimpleBindWrongPassword()
{
new InternalClientConnection(new AuthenticationInfo());
}
/**
* Tests the behavior of the returnBindErrorMessage configuration option.
*/
@Test
public void testReturnBindErrorMessage()
{
// Make sure that the default behavior is to not include the error message.
new InternalClientConnection(new AuthenticationInfo());
// Change the server configuration so that error messages should be
// returned.
"set-global-configuration-prop",
"--set", "return-bind-error-messages:true");
// Change the configuration back and make sure that the error message goes
// away.
"set-global-configuration-prop",
"--set", "return-bind-error-messages:false");
}
/**
* Tests to ensure that performing multiple binds on a client connection will
* cause the connection to no longer be associated with the previous identity.
* This helps provide coverage for issue #1392.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testRebindClearsAuthInfo()
throws Exception
{
"dn: uid=rebind.test,o=test",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: rebind.test",
"givenName: Rebind",
"sn: Test",
"cn: Rebind Test",
"userPassword: password");
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
w.writeMessage(message);
message = r.readMessage();
1);
// We occasionally run into
// ProtocolMessages.MSGID_LDAP_CLIENT_DUPLICATE_MESSAGE_ID, so we wait
// for previous ops to complete.
bindRequest = new BindRequestProtocolOp(
w.writeMessage(message);
message = r.readMessage();
s.close();
}
/**
* Tests to ensure that performing subtree delete will
* cause the connection to no longer be associated
* with the previous identity.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testSubtreeDeleteClearsAuthInfo()
throws Exception
{
"dn: ou=people,dc=example,dc=com",
"objectClass: organizationalUnit",
"objectClass: top",
"ou: people",
"",
"dn: uid=test,ou=people,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: test",
"givenName: test",
"sn: Test",
"cn: Test",
"userPassword: password");
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
w.writeMessage(message);
message = r.readMessage();
userDN));
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"--noPropertiesFile",
"ou=people,dc=example,dc=com"
};
s.close();
}
/**
* Tests to ensure that performing subtree modify will
* cause the connection to be associated with new auth
* identity instead of the previous identity.
*
* @throws Exception If an unexpected problem occurs.
*/
public void testSubtreeModifyUpdatesAuthInfo()
throws Exception
{
"dn: ou=people,dc=example,dc=com",
"objectClass: organizationalUnit",
"objectClass: top",
"ou: people",
"",
"dn: uid=test,ou=people,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: test",
"givenName: test",
"sn: Test",
"cn: Test",
"userPassword: password");
LDAPReader r = new LDAPReader(s);
LDAPWriter w = new LDAPWriter(s);
w.writeMessage(message);
message = r.readMessage();
userDN));
"dn: ou=people,dc=example,dc=com",
"changetype: moddn",
"newRDN: ou=users",
"deleteOldRDN: 1");
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"--noPropertiesFile",
"-f", path
};
newUserDN));
s.close();
}
/**
* Tests to ensure that the "ignore" password policy state update policy
* works as expected.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testIgnoreStateUpdateFailurePolicy()
throws Exception
{
TestCaseUtils.applyModifications(false,
"dn: uid=test.user,o=test",
"changetype: add",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: test.user",
"givenName: Test",
"sn: User",
"cn: Test User",
"userPassword: password",
"",
"dn: cn=Default Password Policy,cn=Password Policies,cn=config",
"changetype: modify",
"replace: ds-cfg-last-login-time-attribute",
"ds-cfg-last-login-time-attribute: ds-pwp-last-login-time",
"-",
"replace: ds-cfg-last-login-time-format",
"ds-cfg-last-login-time-format: yyyyMMdd",
"-",
"replace: ds-cfg-state-update-failure-policy",
"ds-cfg-state-update-failure-policy: ignore",
"",
"dn: cn=config",
"changetype: modify",
"replace: ds-cfg-writability-mode",
"ds-cfg-writability-mode: disabled"
);
try
{
{
"-h", "127.0.0.1",
"-D", "uid=test.user,o=test",
"-w", "password",
"-b", "",
"-s", "base",
"(objectClass=*)"
};
0);
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "",
"-s", "base",
"(objectClass=*)"
};
0);
}
finally
{
"dn: cn=config",
"changetype: modify",
"replace: ds-cfg-writability-mode",
"ds-cfg-writability-mode: enabled",
"",
"dn: cn=Default Password Policy,cn=Password Policies,cn=config",
"changetype: modify",
"replace: ds-cfg-last-login-time-attribute",
"-",
"replace: ds-cfg-last-login-time-format",
"-",
"replace: ds-cfg-state-update-failure-policy",
"ds-cfg-state-update-failure-policy: reactive"
);
}
}
/**
* Tests to ensure that the "reactive" password policy state update policy
* works as expected.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testReactiveStateUpdateFailurePolicy()
throws Exception
{
TestCaseUtils.applyModifications(false,
"dn: uid=test.user,o=test",
"changetype: add",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: test.user",
"givenName: Test",
"sn: User",
"cn: Test User",
"userPassword: password");
"dn: cn=Default Password Policy,cn=Password Policies,cn=config",
"changetype: modify",
"replace: ds-cfg-last-login-time-attribute",
"ds-cfg-last-login-time-attribute: ds-pwp-last-login-time",
"-",
"replace: ds-cfg-last-login-time-format",
"ds-cfg-last-login-time-format: yyyyMMdd",
"-",
"replace: ds-cfg-state-update-failure-policy",
"ds-cfg-state-update-failure-policy: reactive",
"",
"dn: cn=config",
"changetype: modify",
"replace: ds-cfg-writability-mode",
"ds-cfg-writability-mode: disabled"
);
try
{
{
"-h", "127.0.0.1",
"-D", "uid=test.user,o=test",
"-w", "password",
"-b", "",
"-s", "base",
"(objectClass=*)"
};
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "",
"-s", "base",
"(objectClass=*)"
};
0);
}
finally
{
"dn: cn=config",
"changetype: modify",
"replace: ds-cfg-writability-mode",
"ds-cfg-writability-mode: enabled",
"",
"dn: cn=Default Password Policy,cn=Password Policies,cn=config",
"changetype: modify",
"replace: ds-cfg-last-login-time-attribute",
"-",
"replace: ds-cfg-last-login-time-format",
"-",
"replace: ds-cfg-state-update-failure-policy",
"ds-cfg-state-update-failure-policy: reactive"
);
}
}
/**
* Tests to ensure that the "proactive" password policy state update policy
* works as expected.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testProactiveStateUpdateFailurePolicy()
throws Exception
{
TestCaseUtils.applyModifications(false,
"dn: uid=test.user,o=test",
"changetype: add",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: test.user",
"givenName: Test",
"sn: User",
"cn: Test User",
"userPassword: password");
"dn: cn=Default Password Policy,cn=Password Policies,cn=config",
"changetype: modify",
"replace: ds-cfg-last-login-time-attribute",
"ds-cfg-last-login-time-attribute: ds-pwp-last-login-time",
"-",
"replace: ds-cfg-last-login-time-format",
"ds-cfg-last-login-time-format: yyyyMMdd",
"-",
"replace: ds-cfg-state-update-failure-policy",
"ds-cfg-state-update-failure-policy: proactive",
"",
"dn: cn=config",
"changetype: modify",
"replace: ds-cfg-writability-mode",
"ds-cfg-writability-mode: disabled"
);
try
{
{
"-h", "127.0.0.1",
"-D", "uid=test.user,o=test",
"-w", "password",
"-b", "",
"-s", "base",
"(objectClass=*)"
};
{
"-h", "127.0.0.1",
"-D", "cn=Directory Manager",
"-w", "password",
"-b", "",
"-s", "base",
"(objectClass=*)"
};
0);
}
finally
{
"dn: cn=config",
"changetype: modify",
"replace: ds-cfg-writability-mode",
"ds-cfg-writability-mode: enabled",
"",
"dn: cn=Default Password Policy,cn=Password Policies,cn=config",
"changetype: modify",
"replace: ds-cfg-last-login-time-attribute",
"-",
"replace: ds-cfg-last-login-time-format",
"-",
"replace: ds-cfg-state-update-failure-policy",
"ds-cfg-state-update-failure-policy: reactive"
);
}
}
/**
* Tests the <CODE>cancel</CODE> method to ensure that it indicates that the
* operation cannot be cancelled.
* @param bindOperation The bind operation.
*/
{
}
/**
* Tests the <CODE>getCancelRequest</CODE> method to ensure that it always
* returns <CODE>null</CODE>.
* @param bindOperation The bind operation.
*/
{
}
}