You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by tr...@apache.org on 2005/06/10 17:42:45 UTC

svn commit: r189975 - in /directory/apacheds/branches/direve-158/core/src: main/java/org/apache/ldap/server/ main/java/org/apache/ldap/server/authn/ main/java/org/apache/ldap/server/configuration/ main/java/org/apache/ldap/server/prefs/ test/org/apache/ldap/server/authn/ test/org/apache/ldap/server/jndi/

Author: trustin
Date: Fri Jun 10 08:42:43 2005
New Revision: 189975

URL: http://svn.apache.org/viewcvs?rev=189975&view=rev
Log:
* Fixed all tests to pass
* Removed unused tests

Removed:
    directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/ServiceRegistryPassthruTest.java
Modified:
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/AbstractCoreTest.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/GenericAuthenticatorContext.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/ConfigurationUtil.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/StartupConfiguration.java
    directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/prefs/ServerSystemPreferences.java
    directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authn/SimpleAuthenticationTest.java
    directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/AbstractMultiUserJndiTest.java

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/AbstractCoreTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/AbstractCoreTest.java?rev=189975&r1=189974&r2=189975&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/AbstractCoreTest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/AbstractCoreTest.java Fri Jun 10 08:42:43 2005
@@ -292,5 +292,7 @@
         ldifPath = null;
 
         loadClass = null;
+        
+        configuration = new MutableStartupConfiguration();
     }
 }

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/GenericAuthenticatorContext.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/GenericAuthenticatorContext.java?rev=189975&r1=189974&r2=189975&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/GenericAuthenticatorContext.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/authn/GenericAuthenticatorContext.java Fri Jun 10 08:42:43 2005
@@ -43,10 +43,6 @@
             AuthenticatorConfiguration configuration,
             PartitionNexus partitionNexus )
     {
-        assert rootConfiguration != null;
-        assert configuration != null;
-        assert partitionNexus != null;
-
         this.rootConfiguration = rootConfiguration;
         this.configuration = configuration;
         this.partitionNexus = partitionNexus;

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/ConfigurationUtil.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/ConfigurationUtil.java?rev=189975&r1=189974&r2=189975&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/ConfigurationUtil.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/ConfigurationUtil.java Fri Jun 10 08:42:43 2005
@@ -22,6 +22,8 @@
 import java.util.Iterator;
 import java.util.Set;
 
+import javax.naming.directory.Attributes;
+
 /**
  * A utility class that provides common functionality while validating configuration.
  * 
@@ -64,6 +66,20 @@
         return newSet;
     }
     
+    /**
+     * Returns the deep clone of the specified {@link Attributes} set.
+     */
+    static Set getClonedAttributesSet( Set set )
+    {
+        Set newSet = new HashSet();
+        Iterator i = set.iterator();
+        while( i.hasNext() )
+        {
+            newSet.add( ( ( Attributes ) i.next() ).clone() );
+        }
+        return newSet;
+    }
+
     static void validatePortNumber( int port )
     {
         if( port < 0 || port > 65535 )

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/StartupConfiguration.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/StartupConfiguration.java?rev=189975&r1=189974&r2=189975&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/StartupConfiguration.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/configuration/StartupConfiguration.java Fri Jun 10 08:42:43 2005
@@ -40,7 +40,8 @@
 
 /**
  * A {@link Configuration} that starts up ApacheDS.
- *
+ * TODO Move ldapPort, ldapsPort, enableKerberos, minaServiceRegistry to apacheds/main
+ * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
@@ -278,7 +279,7 @@
      */
     public Set getTestEntries()
     {
-        return ConfigurationUtil.getClonedSet( testEntries );
+        return ConfigurationUtil.getClonedAttributesSet( testEntries );
     }
 
     /**
@@ -287,8 +288,20 @@
      */
     protected void setTestEntries( Set testEntries )
     {
-        this.testEntries = ConfigurationUtil.getTypeSafeSet(
-                testEntries, Attributes.class );
+         testEntries = ConfigurationUtil.getClonedAttributesSet(
+                ConfigurationUtil.getTypeSafeSet( testEntries, Attributes.class ) );
+         
+         Iterator i = testEntries.iterator();
+         while( i.hasNext() )
+         {
+             Attributes entry = ( Attributes ) i.next();
+             if( entry.get( "dn" ) == null )
+             {
+                 throw new ConfigurationException( "Test entries must have DN attributes" );
+             }
+         }
+
+         this.testEntries = testEntries;
     }
 
     /**

Modified: directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/prefs/ServerSystemPreferences.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/prefs/ServerSystemPreferences.java?rev=189975&r1=189974&r2=189975&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/prefs/ServerSystemPreferences.java (original)
+++ directory/apacheds/branches/direve-158/core/src/main/java/org/apache/ldap/server/prefs/ServerSystemPreferences.java Fri Jun 10 08:42:43 2005
@@ -17,22 +17,32 @@
 package org.apache.ldap.server.prefs;
 
 
-import org.apache.ldap.common.Lockable;
-import org.apache.ldap.common.message.LockableAttributeImpl;
-import org.apache.ldap.common.message.LockableAttributesImpl;
-import org.apache.ldap.common.util.PreferencesDictionary;
-import org.apache.ldap.server.jndi.CoreContextFactory;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.prefs.AbstractPreferences;
+import java.util.prefs.BackingStoreException;
 
 import javax.naming.Context;
 import javax.naming.NameClassPair;
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
-import javax.naming.directory.*;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.ModificationItem;
 import javax.naming.ldap.InitialLdapContext;
 import javax.naming.ldap.LdapContext;
-import java.util.*;
-import java.util.prefs.AbstractPreferences;
-import java.util.prefs.BackingStoreException;
+
+import org.apache.ldap.common.Lockable;
+import org.apache.ldap.common.message.LockableAttributeImpl;
+import org.apache.ldap.common.message.LockableAttributesImpl;
+import org.apache.ldap.common.util.PreferencesDictionary;
+import org.apache.ldap.server.configuration.MutableStartupConfiguration;
+import org.apache.ldap.server.jndi.CoreContextFactory;
 
 
 /**
@@ -70,7 +80,9 @@
 
         super.newNode = false;
 
-        Hashtable env = new Hashtable();
+        MutableStartupConfiguration cfg = new MutableStartupConfiguration();
+        cfg.setAllowAnonymousAccess( true );
+        Hashtable env = new Hashtable( cfg.toJndiEnvironment() );
 
         env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
 

Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authn/SimpleAuthenticationTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authn/SimpleAuthenticationTest.java?rev=189975&r1=189974&r2=189975&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authn/SimpleAuthenticationTest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/authn/SimpleAuthenticationTest.java Fri Jun 10 08:42:43 2005
@@ -141,7 +141,7 @@
 
     public void test3UseAkarasulu() throws NamingException
     {
-        Hashtable env = new Hashtable();
+        Hashtable env = new Hashtable( configuration.toJndiEnvironment() );
         env.put( Context.PROVIDER_URL, "ou=system" );
         env.put( Context.SECURITY_PRINCIPAL, "uid=akarasulu,ou=users,ou=system" );
         env.put( Context.SECURITY_CREDENTIALS, "test" );
@@ -183,7 +183,7 @@
         // clean out the database
         tearDown();
         doDelete( new File( "target" + File.separator + "eve" ) );
-        Hashtable env = new Hashtable();
+        Hashtable env = new Hashtable( configuration.toJndiEnvironment() );
         env.put( Context.SECURITY_AUTHENTICATION, "none" );
         
         configuration.setAllowAnonymousAccess( false );
@@ -199,11 +199,9 @@
         }
 
         // ok this should start up the system now as admin
-        Hashtable anonymous = new Hashtable();
+        configuration.setAllowAnonymousAccess( true );
 
-        configuration.setLdapPort( AvailablePortFinder.getNextAvailable( 1024 ) );
-
-        InitialLdapContext ctx = ( InitialLdapContext ) setSysRoot( anonymous );
+        InitialLdapContext ctx = ( InitialLdapContext ) setSysRoot( env );
         assertNotNull( ctx );
 
         // now go in as anonymous user and we should be wh
@@ -241,7 +239,7 @@
         // clean out the database
         tearDown();
         doDelete( new File( "target" + File.separator + "eve" ) );
-        Hashtable env = new Hashtable();
+        Hashtable env = new Hashtable( configuration.toJndiEnvironment() );
         env.put( Context.SECURITY_AUTHENTICATION, "none" );
         env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
 
@@ -270,7 +268,7 @@
         // clean out the database
         tearDown();
         doDelete( new File( "target" + File.separator + "eve" ) );
-        Hashtable env = new Hashtable();
+        Hashtable env = new Hashtable( configuration.toJndiEnvironment() );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
         env.put( Context.SECURITY_PRINCIPAL, "uid=akarasulu,ou=users,ou=system" );
 
@@ -293,7 +291,7 @@
      */
     public void test8PassPrincAuthTypeSimple() throws Exception
     {
-        Hashtable env = new Hashtable();
+        Hashtable env = new Hashtable( configuration.toJndiEnvironment() );
         env.put( Context.PROVIDER_URL, "ou=system" );
         env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
         env.put( Context.SECURITY_CREDENTIALS, "secret" );
@@ -311,7 +309,7 @@
      */
     public void test10TestNonAdminUser() throws Exception
     {
-        Hashtable env = new Hashtable();
+        Hashtable env = new Hashtable( configuration.toJndiEnvironment() );
         env.put( Context.PROVIDER_URL, "ou=system" );
         env.put( Context.SECURITY_PRINCIPAL, "uid=akarasulu,ou=users,ou=system" );
         env.put( Context.SECURITY_CREDENTIALS, "test" );

Modified: directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/AbstractMultiUserJndiTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/AbstractMultiUserJndiTest.java?rev=189975&r1=189974&r2=189975&view=diff
==============================================================================
--- directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/AbstractMultiUserJndiTest.java (original)
+++ directory/apacheds/branches/direve-158/core/src/test/org/apache/ldap/server/jndi/AbstractMultiUserJndiTest.java Fri Jun 10 08:42:43 2005
@@ -48,7 +48,7 @@
 
         // authenticate as akarasulu
 
-        Hashtable env = new Hashtable( );
+        Hashtable env = new Hashtable( configuration.toJndiEnvironment() );
 
         env.put( Context.PROVIDER_URL, "ou=system" );