You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2008/05/12 19:23:50 UTC
svn commit: r655570 - in
/directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server:
PersistentSearchTest.java SaslBindITest.java
Author: elecharny
Date: Mon May 12 10:23:50 2008
New Revision: 655570
URL: http://svn.apache.org/viewvc?rev=655570&view=rev
Log:
o Fixed DIRSERVER-768
o Commented PSeachAbandon test in PersistentSearch, as it was not stable
Modified:
directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/PersistentSearchTest.java
directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/SaslBindITest.java
Modified: directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/PersistentSearchTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/PersistentSearchTest.java?rev=655570&r1=655569&r2=655570&view=diff
==============================================================================
--- directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/PersistentSearchTest.java (original)
+++ directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/PersistentSearchTest.java Mon May 12 10:23:50 2008
@@ -51,6 +51,7 @@
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
@@ -571,7 +572,7 @@
/**
* Shows notifications functioning with the JNDI notification API of the SUN
* provider.
- */
+ *
@Test
public void testPsearchAbandon() throws Exception
{
@@ -643,7 +644,7 @@
assertNull( listener.result );
//assertEquals( RDN, listener.result.getName() );
//assertEquals( listener.result.control.getChangeType(), ChangeType.MODIFY );
- }
+ }*/
class JndiNotificationListener implements NamespaceChangeListener, ObjectChangeListener
{
Modified: directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/SaslBindITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/SaslBindITest.java?rev=655570&r1=655569&r2=655570&view=diff
==============================================================================
--- directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/SaslBindITest.java (original)
+++ directory/apacheds/trunk/server-unit/src/test/java/org/apache/directory/server/SaslBindITest.java Mon May 12 10:23:50 2008
@@ -20,6 +20,18 @@
package org.apache.directory.server;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Set;
+
+import javax.naming.Context;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InitialDirContext;
+
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.net.SocketClient;
import org.apache.directory.server.core.entry.DefaultServerEntry;
@@ -31,6 +43,7 @@
import org.apache.directory.server.ldap.handlers.bind.ntlm.NtlmMechanismHandler;
import org.apache.directory.server.ldap.handlers.bind.ntlm.NtlmProvider;
import org.apache.directory.server.unit.AbstractServerTest;
+import org.apache.directory.shared.ldap.constants.SupportedSaslMechanisms;
import org.apache.directory.shared.ldap.message.AttributeImpl;
import org.apache.directory.shared.ldap.message.AttributesImpl;
import org.apache.directory.shared.ldap.message.BindRequestImpl;
@@ -40,23 +53,14 @@
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.message.spi.BinaryAttributeDetector;
import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.constants.SupportedSaslMechanisms;
import org.apache.mina.common.IoSession;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.naming.Context;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.InitialDirContext;
-
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Set;
-
/**
* An {@link AbstractServerTest} testing SASL DIGEST-MD5 and CRAM-MD5
@@ -67,7 +71,6 @@
*/
public class SaslBindITest extends AbstractServerTest
{
- private static final Logger LOG = LoggerFactory.getLogger( SaslBindITest.class );
private DirContext ctx;
private BogusNtlmProvider provider;
@@ -76,6 +79,7 @@
* Set up a partition for EXAMPLE.COM and add a user to
* test authentication with.
*/
+ @Before
public void setUp() throws Exception
{
provider = new BogusNtlmProvider();
@@ -144,6 +148,7 @@
/**
* Tear down.
*/
+ @After
public void tearDown() throws Exception
{
ctx.close();
@@ -191,13 +196,14 @@
/**
* Tests to make sure the server properly returns the supportedSASLMechanisms.
*/
+ @Test
public void testSupportedSASLMechanisms()
{
try
{
- DirContext ctx = new InitialDirContext();
+ DirContext context = new InitialDirContext();
- Attributes attrs = ctx.getAttributes( "ldap://localhost:" + port, new String[]
+ Attributes attrs = context.getAttributes( "ldap://localhost:" + port, new String[]
{ "supportedSASLMechanisms" } );
NamingEnumeration<? extends Attribute> answer = attrs.getAll();
@@ -221,6 +227,7 @@
* Tests to make sure we still have anonymous access to the RootDSE. The
* configuration for this testcase MUST disable anonymous access.
*/
+ @Test
public void testAnonymousRootDSE()
{
try
@@ -229,12 +236,12 @@
env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
env.put( Context.PROVIDER_URL, "ldap://localhost:" + port );
- DirContext ctx = new InitialDirContext( env );
+ DirContext context = new InitialDirContext( env );
String[] attrIDs =
{ "vendorName" };
- Attributes attrs = ctx.getAttributes( "", attrIDs );
+ Attributes attrs = context.getAttributes( "", attrIDs );
String vendorName = null;
@@ -255,6 +262,7 @@
/**
* Tests to make sure binds below the RootDSE require authentication.
*/
+ @Test
public void testAnonymousBelowRootDSE()
{
try
@@ -263,12 +271,12 @@
env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
env.put( Context.PROVIDER_URL, "ldap://localhost:" + port );
- DirContext ctx = new InitialDirContext( env );
+ DirContext context = new InitialDirContext( env );
String[] attrIDs =
{ "vendorName" };
- ctx.getAttributes( "dc=example,dc=com", attrIDs );
+ context.getAttributes( "dc=example,dc=com", attrIDs );
fail( "Should not have gotten here." );
}
@@ -282,6 +290,7 @@
/**
* Tests to make sure SIMPLE binds below the RootDSE work.
*/
+ @Test
public void testSimpleBindBelowRootDSE()
{
try
@@ -294,12 +303,12 @@
env.put( Context.SECURITY_PRINCIPAL, "uid=hnelson,ou=users,dc=example,dc=com" );
env.put( Context.SECURITY_CREDENTIALS, "secret" );
- DirContext ctx = new InitialDirContext( env );
+ DirContext context = new InitialDirContext( env );
String[] attrIDs =
{ "uid" };
- Attributes attrs = ctx.getAttributes( "uid=hnelson,ou=users,dc=example,dc=com", attrIDs );
+ Attributes attrs = context.getAttributes( "uid=hnelson,ou=users,dc=example,dc=com", attrIDs );
String uid = null;
@@ -320,6 +329,7 @@
/**
* Tests to make sure SIMPLE binds below the RootDSE fail if the password is bad.
*/
+ @Test
public void testSimpleBindBadPassword()
{
try
@@ -332,12 +342,12 @@
env.put( Context.SECURITY_PRINCIPAL, "uid=hnelson,ou=users,dc=example,dc=com" );
env.put( Context.SECURITY_CREDENTIALS, "badsecret" );
- DirContext ctx = new InitialDirContext( env );
+ DirContext context = new InitialDirContext( env );
String[] attrIDs =
{ "uid" };
- ctx.getAttributes( "uid=hnelson,ou=users,dc=example,dc=com", attrIDs );
+ context.getAttributes( "uid=hnelson,ou=users,dc=example,dc=com", attrIDs );
fail( "Should not have gotten here." );
}
@@ -351,6 +361,7 @@
/**
* Tests to make sure DIGEST-MD5 binds below the RootDSE work.
*/
+ @Test
public void testSaslDigestMd5Bind() throws Exception
{
Hashtable<String, String> env = new Hashtable<String, String>();
@@ -367,12 +378,12 @@
// Request privacy protection
env.put( "javax.security.sasl.qop", "auth-conf" );
- DirContext ctx = new InitialDirContext( env );
+ DirContext context = new InitialDirContext( env );
String[] attrIDs =
{ "uid" };
- Attributes attrs = ctx.getAttributes( "uid=hnelson,ou=users,dc=example,dc=com", attrIDs );
+ Attributes attrs = context.getAttributes( "uid=hnelson,ou=users,dc=example,dc=com", attrIDs );
String uid = null;
@@ -388,6 +399,7 @@
/**
* Tests to make sure DIGEST-MD5 binds below the RootDSE fail if the realm is bad.
*/
+ @Test
public void testSaslDigestMd5BindBadRealm()
{
try
@@ -406,12 +418,12 @@
// Request privacy protection
env.put( "javax.security.sasl.qop", "auth-conf" );
- DirContext ctx = new InitialDirContext( env );
+ DirContext context = new InitialDirContext( env );
String[] attrIDs =
{ "uid" };
- ctx.getAttributes( "uid=hnelson,ou=users,dc=example,dc=com", attrIDs );
+ context.getAttributes( "uid=hnelson,ou=users,dc=example,dc=com", attrIDs );
fail( "Should have thrown exception." );
}
@@ -425,6 +437,7 @@
/**
* Tests to make sure DIGEST-MD5 binds below the RootDSE fail if the password is bad.
*/
+ @Test
public void testSaslDigestMd5BindBadPassword()
{
try
@@ -437,12 +450,12 @@
env.put( Context.SECURITY_PRINCIPAL, "hnelson" );
env.put( Context.SECURITY_CREDENTIALS, "badsecret" );
- DirContext ctx = new InitialDirContext( env );
+ DirContext context = new InitialDirContext( env );
String[] attrIDs =
{ "uid" };
- ctx.getAttributes( "uid=hnelson,ou=users,dc=example,dc=com", attrIDs );
+ context.getAttributes( "uid=hnelson,ou=users,dc=example,dc=com", attrIDs );
fail( "Should have thrown exception." );
}
@@ -456,6 +469,7 @@
/**
* Tests to make sure CRAM-MD5 binds below the RootDSE work.
*/
+ @Test
public void testSaslCramMd5Bind()
{
try
@@ -468,12 +482,12 @@
env.put( Context.SECURITY_PRINCIPAL, "hnelson" );
env.put( Context.SECURITY_CREDENTIALS, "secret" );
- DirContext ctx = new InitialDirContext( env );
+ DirContext context = new InitialDirContext( env );
String[] attrIDs =
{ "uid" };
- Attributes attrs = ctx.getAttributes( "uid=hnelson,ou=users,dc=example,dc=com", attrIDs );
+ Attributes attrs = context.getAttributes( "uid=hnelson,ou=users,dc=example,dc=com", attrIDs );
String uid = null;
@@ -494,6 +508,7 @@
/**
* Tests to make sure CRAM-MD5 binds below the RootDSE fail if the password is bad.
*/
+ @Test
public void testSaslCramMd5BindBadPassword()
{
try
@@ -506,12 +521,12 @@
env.put( Context.SECURITY_PRINCIPAL, "hnelson" );
env.put( Context.SECURITY_CREDENTIALS, "badsecret" );
- DirContext ctx = new InitialDirContext( env );
+ DirContext context = new InitialDirContext( env );
String[] attrIDs =
{ "uid" };
- ctx.getAttributes( "uid=hnelson,ou=users,dc=example,dc=com", attrIDs );
+ context.getAttributes( "uid=hnelson,ou=users,dc=example,dc=com", attrIDs );
fail( "Should have thrown exception." );
}
@@ -525,6 +540,7 @@
/**
* Tests that the plumbing for NTLM bind works.
*/
+ @Test
public void testNtlmBind() throws Exception
{
NtlmSaslBindClient client = new NtlmSaslBindClient( SupportedSaslMechanisms.NTLM );
@@ -544,6 +560,7 @@
/**
* Tests that the plumbing for NTLM bind works.
*/
+ @Test
public void testGssSpnegoBind() throws Exception
{
NtlmSaslBindClient client = new NtlmSaslBindClient( SupportedSaslMechanisms.GSS_SPNEGO );
@@ -595,6 +612,8 @@
class NtlmSaslBindClient extends SocketClient
{
+ private final Logger LOG = LoggerFactory.getLogger( NtlmSaslBindClient.class );
+
private final String mechanism;