You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2008/08/08 03:25:05 UTC
svn commit: r683786 - in /directory/apacheds/branches/bigbang:
server-integ/src/main/java/org/apache/directory/server/integ/
server-integ/src/test/java/org/apache/directory/server/operations/bind/
server-unit/src/test/java/org/apache/directory/server/
Author: akarasulu
Date: Thu Aug 7 18:25:04 2008
New Revision: 683786
URL: http://svn.apache.org/viewvc?rev=683786&view=rev
Log:
moving bad bind tests to server-integs bindIT test
Removed:
directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/BadDnTest.java
Modified:
directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java
directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java
Modified: directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java?rev=683786&r1=683785&r2=683786&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java (original)
+++ directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java Thu Aug 7 18:25:04 2008
@@ -72,6 +72,29 @@
* @return an LdapContext as the administrative user to the RootDSE
* @throws Exception if there are problems creating the context
*/
+ public static LdapContext getWiredContext( LdapServer ldapServer, String principalDn, String password )
+ throws Exception
+ {
+ LOG.debug( "Creating a wired context to local LDAP server on port {}", ldapServer.getIpPort() );
+ Hashtable<String, String> env = new Hashtable<String, String>();
+ env.put( Context.INITIAL_CONTEXT_FACTORY, CTX_FACTORY );
+ env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapServer.getIpPort() );
+ env.put( Context.SECURITY_PRINCIPAL, principalDn );
+ env.put( Context.SECURITY_CREDENTIALS, password );
+ env.put( Context.SECURITY_AUTHENTICATION, "simple" );
+ return new InitialLdapContext( env, null );
+ }
+
+
+ /**
+ * Creates a JNDI LdapContext with a connection over the wire using the
+ * SUN LDAP provider. The connection is made using the administrative
+ * user as the principalDN. The context is to the rootDSE.
+ *
+ * @param ldapServer the LDAP server to get the connection to
+ * @return an LdapContext as the administrative user to the RootDSE
+ * @throws Exception if there are problems creating the context
+ */
public static LdapContext getWiredContext( LdapServer ldapServer, Control[] controls ) throws Exception
{
LOG.debug( "Creating a wired context to local LDAP server on port {}", ldapServer.getIpPort() );
Modified: directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java?rev=683786&r1=683785&r2=683786&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java (original)
+++ directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java Thu Aug 7 18:25:04 2008
@@ -20,6 +20,8 @@
package org.apache.directory.server.operations.bind;
+import javax.naming.AuthenticationException;
+
import netscape.ldap.LDAPConnection;
import netscape.ldap.LDAPConstraints;
import netscape.ldap.LDAPControl;
@@ -28,6 +30,7 @@
import org.apache.directory.server.core.integ.Level;
import org.apache.directory.server.core.integ.annotations.ApplyLdifs;
import org.apache.directory.server.core.integ.annotations.CleanupLevel;
+import static org.apache.directory.server.integ.ServerIntegrationUtils.getWiredContext;
import org.apache.directory.server.integ.SiRunner;
import org.apache.directory.server.newldap.LdapServer;
import org.junit.Test;
@@ -79,6 +82,59 @@
public static LdapServer ldapServer;
+ /**
+ * Test with bindDn which is not even found under any namingContext of the
+ * server.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testBadBindDnNotInContext() throws Exception
+ {
+ try
+ {
+ getWiredContext( ldapServer, "cn=bogus", "blah" );
+ fail( "should never get here due to a " );
+ }
+ catch ( AuthenticationException e )
+ {
+ }
+ }
+
+
+ /**
+ * Test with bindDn that is under a naming context but points to non-existant user.
+ * @todo make this pass: see http://issues.apache.org/jira/browse/DIREVE-339
+ */
+ // public void testBadBindDnMalformed() throws Exception
+ // {
+ // try
+ // {
+ // bind( "system", "blah" );
+ // fail( "should never get here due to a " );
+ // }
+ // catch ( InvalidNameException e ){}
+ // }
+
+ /**
+ * Test with bindDn that is under a naming context but points to non-existant user.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testBadBindDnInContext() throws Exception
+ {
+ try
+ {
+ getWiredContext( ldapServer, "cn=bogus,ou=system", "blah" );
+ fail( "should never get here due to a " );
+ }
+ catch ( AuthenticationException e )
+ {
+ }
+ }
+
+
@Test
public void testConnectWithIllegalLDAPVersion() throws Exception
{