From commits-return-4458-apmail-directory-commits-archive=directory.apache.org@directory.apache.org Thu Apr 28 20:54:20 2005 Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 87481 invoked from network); 28 Apr 2005 20:54:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 28 Apr 2005 20:54:20 -0000 Received: (qmail 47617 invoked by uid 500); 28 Apr 2005 20:55:30 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 47581 invoked by uid 500); 28 Apr 2005 20:55:29 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 47566 invoked by uid 99); 28 Apr 2005 20:55:29 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Thu, 28 Apr 2005 13:55:29 -0700 Received: (qmail 87455 invoked by uid 65534); 28 Apr 2005 20:54:17 -0000 Message-ID: <20050428205417.87454.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: svn commit: r165195 - in /directory/apacheds/trunk: core/src/main/java/org/apache/ldap/server/ core/src/test/org/apache/ldap/server/authn/ main/ main/src/test/ main/src/test/org/ main/src/test/org/apache/ main/src/test/org/apache/ldap/ main/src/test/org/apache/ldap/server/ Date: Thu, 28 Apr 2005 20:54:16 -0000 To: commits@directory.apache.org From: akarasulu@apache.org X-Mailer: svnmailer-1.0.0-dev X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: akarasulu Date: Thu Apr 28 13:54:15 2005 New Revision: 165195 URL: http://svn.apache.org/viewcvs?rev=3D165195&view=3Drev Log: changes ... =20 o moving copy of AbstractCoreTest to AbstractServerTest before major chang= es o moved test for disabling anon bind to main area since it deals with=20 seting up all the protocol providers Added: directory/apacheds/trunk/main/src/test/ directory/apacheds/trunk/main/src/test/org/ directory/apacheds/trunk/main/src/test/org/apache/ directory/apacheds/trunk/main/src/test/org/apache/ldap/ directory/apacheds/trunk/main/src/test/org/apache/ldap/server/ directory/apacheds/trunk/main/src/test/org/apache/ldap/server/AbstractS= erverTest.java - copied, changed from r165059, directory/apacheds/trunk/core/src/mai= n/java/org/apache/ldap/server/AbstractCoreTest.java directory/apacheds/trunk/main/src/test/org/apache/ldap/server/DisableAn= onBindTest.java - copied, changed from r165167, directory/apacheds/trunk/core/src/tes= t/org/apache/ldap/server/authn/SimpleAuthenticationTest.java Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/Abst= ractCoreTest.java directory/apacheds/trunk/core/src/test/org/apache/ldap/server/authn/Sim= pleAuthenticationTest.java directory/apacheds/trunk/main/project.xml Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/serve= r/AbstractCoreTest.java URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/j= ava/org/apache/ldap/server/AbstractCoreTest.java?rev=3D165195&r1=3D165194&r= 2=3D165195&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/Abst= ractCoreTest.java (original) +++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/Abst= ractCoreTest.java Thu Apr 28 13:54:15 2005 @@ -40,7 +40,7 @@ import java.io.InputStream; import java.util.Hashtable; =20 - + = =20 /** * A simple testcase for testing JNDI provider functionality. * Modified: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/aut= hn/SimpleAuthenticationTest.java URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/test/o= rg/apache/ldap/server/authn/SimpleAuthenticationTest.java?rev=3D165195&r1= =3D165194&r2=3D165195&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/apacheds/trunk/core/src/test/org/apache/ldap/server/authn/Sim= pleAuthenticationTest.java (original) +++ directory/apacheds/trunk/core/src/test/org/apache/ldap/server/authn/Sim= pleAuthenticationTest.java Thu Apr 28 13:54:15 2005 @@ -87,11 +87,6 @@ return; } =20 - if ( getName().equals( "test11DisableAnonymousBinds" ) ) - { - extras.put( EnvKeys.DISABLE_ANONYMOUS, "true" ); - } - super.setUp(); } =20 @@ -322,40 +317,5 @@ env.put( Context.SECURITY_AUTHENTICATION, "simple" ); env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.= jndi.ServerContextFactory" ); assertNotNull( new InitialContext( env ) ); - } - - - /** - * Test to make sure anonymous binds are disabled when going through - * the wire protocol. - * - * @throws Exception if anything goes wrong - */ - public void test11DisableAnonymousBinds() throws Exception - { - // Use the SUN JNDI provider to hit server port and bind as anonym= ous - - final Hashtable env =3D new Hashtable(); - - env.put( Context.PROVIDER_URL, "ldap://localhost:" + port + "/ou= =3Dsystem" ); - - env.put( Context.SECURITY_AUTHENTICATION, "none" ); - - env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapC= txFactory" ); - - InitialContext ctx =3D null; - - try - { - ctx =3D new InitialContext( env ); - - fail( "If anonymous binds are disabled we should never get her= e!" ); - } - catch ( NoPermissionException e ) - { - assertNull( ctx ); - - assertNotNull( e ); - } } } Modified: directory/apacheds/trunk/main/project.xml URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/main/project.xm= l?rev=3D165195&r1=3D165194&r2=3D165195&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/apacheds/trunk/main/project.xml (original) +++ directory/apacheds/trunk/main/project.xml Thu Apr 28 13:54:15 2005 @@ -51,6 +51,12 @@ http://jakarta.apache.org/commons/collections + commons-io + commons-io + 1.0 + http://jakarta.apache.org/commons/io + + commons-primitives commons-primitives 20041207.202534 Copied: directory/apacheds/trunk/main/src/test/org/apache/ldap/server/Abstr= actServerTest.java (from r165059, directory/apacheds/trunk/core/src/main/ja= va/org/apache/ldap/server/AbstractCoreTest.java) URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/main/src/test/o= rg/apache/ldap/server/AbstractServerTest.java?p2=3Ddirectory/apacheds/trunk= /main/src/test/org/apache/ldap/server/AbstractServerTest.java&p1=3Ddirector= y/apacheds/trunk/core/src/main/java/org/apache/ldap/server/AbstractCoreTest= .java&r1=3D165059&r2=3D165195&rev=3D165195&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/Abst= ractCoreTest.java (original) +++ directory/apacheds/trunk/main/src/test/org/apache/ldap/server/AbstractS= erverTest.java Thu Apr 28 13:54:15 2005 @@ -47,7 +47,7 @@ * @author Apache Directory Pr= oject * @version $Rev$ */ -public abstract class AbstractCoreTest extends TestCase +public abstract class AbstractServerTest extends TestCase { /** the context root for the system partition */ protected LdapContext sysRoot; Copied: directory/apacheds/trunk/main/src/test/org/apache/ldap/server/Disab= leAnonBindTest.java (from r165167, directory/apacheds/trunk/core/src/test/o= rg/apache/ldap/server/authn/SimpleAuthenticationTest.java) URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/main/src/test/o= rg/apache/ldap/server/DisableAnonBindTest.java?p2=3Ddirectory/apacheds/trun= k/main/src/test/org/apache/ldap/server/DisableAnonBindTest.java&p1=3Ddirect= ory/apacheds/trunk/core/src/test/org/apache/ldap/server/authn/SimpleAuthent= icationTest.java&r1=3D165167&r2=3D165195&rev=3D165195&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/apacheds/trunk/core/src/test/org/apache/ldap/server/authn/Sim= pleAuthenticationTest.java (original) +++ directory/apacheds/trunk/main/src/test/org/apache/ldap/server/DisableAn= onBindTest.java Thu Apr 28 13:54:15 2005 @@ -14,22 +14,12 @@ * limitations under the License. * */ -package org.apache.ldap.server.authn; +package org.apache.ldap.server; =20 =20 -import org.apache.ldap.common.exception.LdapConfigurationException; -import org.apache.ldap.common.exception.LdapNoPermissionException; -import org.apache.ldap.common.util.ArrayUtils; -import org.apache.ldap.server.AbstractCoreTest; import org.apache.ldap.server.jndi.EnvKeys; -import org.apache.mina.util.AvailablePortFinder; =20 import javax.naming.*; -import javax.naming.directory.Attribute; -import javax.naming.directory.Attributes; -import javax.naming.directory.DirContext; -import javax.naming.directory.InitialDirContext; -import javax.naming.ldap.InitialLdapContext; import java.io.File; import java.io.IOException; import java.util.Hashtable; @@ -42,52 +32,26 @@ * @author Apache Directory Pr= oject * @version $Rev$ */ -public class SimpleAuthenticationTest extends AbstractCoreTest +public class DisableAnonBindTest extends AbstractServerTest { /** * Cleans up old database files on creation. * @throws IOException=20 */ - public SimpleAuthenticationTest() throws IOException + public DisableAnonBindTest() throws IOException { - doDelete( new File( "target" + File.separator + "eve" ) ); + doDelete( new File( "target" + File.separator + "server" ) ); } =20 =20 /** * Customizes setup for each test case. * - *
    - *
  • sets doDelete to false for test1AdminAccountCreation
  • - *
  • sets doDelete to false for test2AccountExistsOnRestart
  • - *
  • sets doDelete to true for all other cases
  • - *
  • bypasses normal setup for test5BuildDbNoPassWithPrincAuthNone=
  • - *
  • bypasses normal setup for test4BuildDbNoPassNoPrincAuthNone - *
  • bypasses normal setup for test6BuildDbNoPassNotAdminPrinc
  • - *
- * * @throws Exception */ protected void setUp() throws Exception { - if ( getName().equals( "test1AdminAccountCreation" ) || - getName().equals( "test2AccountExistsOnRestart" ) ) - { - super.doDelete =3D false; - } - else - { - super.doDelete =3D true; - } - - if ( getName().equals( "test5BuildDbNoPassWithPrincAuthNone" ) || - getName().equals( "test6BuildDbNoPassNotAdminPrinc" ) || - getName().equals( "test4BuildDbNoPassNoPrincAuthNone" ) ) - { - return; - } - - if ( getName().equals( "test11DisableAnonymousBinds" ) ) + if ( getName().equals( "testDisableAnonymousBinds" ) ) { extras.put( EnvKeys.DISABLE_ANONYMOUS, "true" ); } @@ -97,241 +61,12 @@ =20 =20 /** - * Checks all attributes of the admin account entry minus the userPass= word - * attribute. - * - * @param attrs the entries attributes - */ - protected void performAdminAccountChecks( Attributes attrs ) - { - assertTrue( attrs.get( "objectClass" ).contains( "top" ) ); - assertTrue( attrs.get( "objectClass" ).contains( "person" ) ); - assertTrue( attrs.get( "objectClass" ).contains( "organizationalPe= rson" ) ); - assertTrue( attrs.get( "objectClass" ).contains( "inetOrgPerson" )= ); - assertTrue( attrs.get( "displayName" ).contains( "Directory Superu= ser" ) ); - } - - - /** - * Check the creation of the admin account. - * - * @throws NamingException if there are failures - */ - public void test1AdminAccountCreation() throws NamingException - { - DirContext ctx =3D ( DirContext ) sysRoot.lookup( "uid=3Dadmin" ); - Attributes attrs =3D ctx.getAttributes( "" ); - performAdminAccountChecks( attrs ); - assertTrue( ArrayUtils.isEquals( attrs.get( "userPassword" ).get()= , "secret".getBytes() )); - } - - - /** - * Check the creation of the admin account even after a restart. - * - * @throws NamingException if there are failures - */ - public void test2AccountExistsOnRestart() throws NamingException - { - DirContext ctx =3D ( DirContext ) sysRoot.lookup( "uid=3Dadmin" ); - Attributes attrs =3D ctx.getAttributes( "" ); - - performAdminAccountChecks( attrs ); - assertTrue( ArrayUtils.isEquals( attrs.get( "userPassword" ).get()= , "secret".getBytes() )); - } - - - public void test3UseAkarasulu() throws NamingException - { - Hashtable env =3D new Hashtable(); - env.put( Context.PROVIDER_URL, "ou=3Dsystem" ); - env.put( Context.SECURITY_PRINCIPAL, "uid=3Dakarasulu,ou=3Dusers,o= u=3Dsystem" ); - env.put( Context.SECURITY_CREDENTIALS, "test" ); - env.put( Context.SECURITY_AUTHENTICATION, "simple" ); - env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.= jndi.ServerContextFactory" ); - InitialDirContext ic =3D new InitialDirContext( env ); - Attributes attrs =3D ic.getAttributes( "uid=3Dakarasulu,ou=3Dusers= " ); - Attribute ou =3D attrs.get( "ou" ); - assertTrue( ou.contains( "Engineering" ) ); - assertTrue( ou.contains( "People" ) ); - - Attribute objectClass =3D attrs.get( "objectClass" ); - assertTrue( objectClass.contains( "top" ) ); - assertTrue( objectClass.contains( "person" ) ); - assertTrue( objectClass.contains( "organizationalPerson" ) ); - assertTrue( objectClass.contains( "inetOrgPerson" ) ); - - assertTrue( attrs.get( "telephonenumber" ).contains( "+1 408 555 4= 798" ) ); - assertTrue( attrs.get( "uid" ).contains( "akarasulu" ) ); - assertTrue( attrs.get( "givenname" ).contains( "Alex" ) ); - assertTrue( attrs.get( "mail" ).contains( "akarasulu@apache.org" )= ); - assertTrue( attrs.get( "l" ).contains( "Bogusville" ) ); - assertTrue( attrs.get( "sn" ).contains( "Karasulu" ) ); - assertTrue( attrs.get( "cn" ).contains( "Alex Karasulu" ) ); - assertTrue( attrs.get( "facsimiletelephonenumber" ).contains( "+1 = 408 555 9751" ) ); - assertTrue( attrs.get( "roomnumber" ).contains( "4612" ) ); - } - - - /** - * Tests to make sure we throw an error when Context.SECURITY_AUTHENTI= CATION - * is set to "none" when trying to bootstrap the system. Only the adm= in - * user is allowed to bootstrap. - * - * @throws Exception if anything goes wrong - */ - public void test4BuildDbNoPassNoPrincAuthNone() throws Exception - { - // clean out the database - tearDown(); - doDelete( new File( "target" + File.separator + "eve" ) ); - Hashtable env =3D new Hashtable(); - env.put( Context.SECURITY_AUTHENTICATION, "none" ); - env.put( EnvKeys.DISABLE_ANONYMOUS, "true" ); - - int port =3D AvailablePortFinder.getNextAvailable( 1024 ); - - env.put( EnvKeys.LDAP_PORT, String.valueOf( port ) ); - - try - { - setSysRoot( env ); - fail( "should not get here due to exception" ); - } - catch( LdapNoPermissionException e ) - { - } - - // ok this should start up the system now as admin - Hashtable anonymous =3D new Hashtable(); - - anonymous.put( EnvKeys.LDAP_PORT, String.valueOf( port ) ); - - InitialLdapContext ctx =3D ( InitialLdapContext ) setSysRoot( anon= ymous ); - assertNotNull( ctx ); - - // now go in as anonymous user and we should be wh - env.put( Context.PROVIDER_URL, "ou=3Dsystem" ); - env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.= jndi.ServerContextFactory" ); - - InitialLdapContext initial =3D new InitialLdapContext( env, null ); - - try - { - ctx =3D ( InitialLdapContext ) initial.lookup( "uid=3Dadmin" ); - fail( "should not get here due to exception cuz anonymous user= is " - + "not allowed read access to the admin account entry"= ); - } - catch( LdapConfigurationException e ) - { - } - catch( LdapNoPermissionException e ) - { - } - } - - - /** - * Tests to make sure we throw an error when Context.SECURITY_AUTHENTI= CATION - * is set to "none" when trying to bootstrap the system even when the - * principal is set to the admin user. Only the admin user is allowed= to - * bootstrap. This is a configuration issue or a nonsense set of prop= erty - * values. - * - * @throws Exception if anything goes wrong - */ - public void test5BuildDbNoPassWithPrincAuthNone() throws Exception - { - // clean out the database - tearDown(); - doDelete( new File( "target" + File.separator + "eve" ) ); - Hashtable env =3D new Hashtable(); - env.put( Context.SECURITY_AUTHENTICATION, "none" ); - env.put( Context.SECURITY_PRINCIPAL, "uid=3Dadmin,ou=3Dsystem" ); - - try - { - setSysRoot( env ); - fail( "should not get here due to exception" ); - } - catch( ConfigurationException e ) - { - } - } - - - /** - * Tests to make sure we throw an error when Context.SECURITY_AUTHENTI= CATION - * is set to "simple" when trying to bootstrap the system but the admi= n is - * not the principal. Only the admin user is allowed to bootstrap. - * Subsequent calls can 'bind' (authenticate in our case since there i= s no - * network connection) anonymously though. - * - * @throws Exception if anything goes wrong - */ - public void test6BuildDbNoPassNotAdminPrinc() throws Exception - { - // clean out the database - tearDown(); - doDelete( new File( "target" + File.separator + "eve" ) ); - Hashtable env =3D new Hashtable(); - env.put( Context.SECURITY_AUTHENTICATION, "simple" ); - env.put( Context.SECURITY_PRINCIPAL, "uid=3Dakarasulu,ou=3Dusers,o= u=3Dsystem" ); - - try - { - setSysRoot( env ); - fail( "should not get here due to exception" ); - } - catch( ConfigurationException e ) - { - } - } - - - /** - * Tests to make sure we can authenticate after the database has alrea= dy - * been started by the admin user when simple authentication is in eff= ect. - * - * @throws Exception if anything goes wrong - */ - public void test8PassPrincAuthTypeSimple() throws Exception - { - Hashtable env =3D new Hashtable(); - env.put( Context.PROVIDER_URL, "ou=3Dsystem" ); - env.put( Context.SECURITY_PRINCIPAL, "uid=3Dadmin,ou=3Dsystem" ); - env.put( Context.SECURITY_CREDENTIALS, "secret" ); - env.put( Context.SECURITY_AUTHENTICATION, "simple" ); - env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.= jndi.ServerContextFactory" ); - assertNotNull( new InitialContext( env ) ); - } - - - /** - * Checks to see if we can authenticate as a test user after the admin= fires - * up and builds the the system database. - * - * @throws Exception if anything goes wrong - */ - public void test10TestNonAdminUser() throws Exception - { - Hashtable env =3D new Hashtable(); - env.put( Context.PROVIDER_URL, "ou=3Dsystem" ); - env.put( Context.SECURITY_PRINCIPAL, "uid=3Dakarasulu,ou=3Dusers,o= u=3Dsystem" ); - env.put( Context.SECURITY_CREDENTIALS, "test" ); - env.put( Context.SECURITY_AUTHENTICATION, "simple" ); - env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.= jndi.ServerContextFactory" ); - assertNotNull( new InitialContext( env ) ); - } - - - /** * Test to make sure anonymous binds are disabled when going through * the wire protocol. * * @throws Exception if anything goes wrong */ - public void test11DisableAnonymousBinds() throws Exception + public void testDisableAnonymousBinds() throws Exception { // Use the SUN JNDI provider to hit server port and bind as anonym= ous =20