portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r921219 - in /portals/jetspeed-2/portal/trunk: ./ components/jetspeed-security/ components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/ components/jetspeed-security/src/test/java/org/apache/jetspeed/security/ma...
Date Wed, 10 Mar 2010 03:39:27 GMT
Author: ate
Date: Wed Mar 10 03:39:27 2010
New Revision: 921219

URL: http://svn.apache.org/viewvc?rev=921219&view=rev
Log:
JS2-1124: Cleanup and upgrade LDAP configuration to ApacheDS 1.5.5
- bumping ApacheDS to latest version 1.5.5
- enabling the LDAP test cases to use an embedded ApacheDS

Added:
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup1/TestLDAP.java
  (contents, props changed)
      - copied, changed from r920746, portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup1/UserTests.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup2/TestLDAP.java
  (contents, props changed)
      - copied, changed from r920746, portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup2/UserTests.java
Removed:
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup1/UserTests.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup2/UserTests.java
Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/pom.xml
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/AbstractLDAPTest.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup2/AbstractSetup2LDAPTest.java
    portals/jetspeed-2/portal/trunk/pom.xml

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/pom.xml?rev=921219&r1=921218&r2=921219&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/pom.xml (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/pom.xml Wed Mar 10 03:39:27
2010
@@ -121,17 +121,16 @@
     </dependency>
 
     <dependency>
-      <artifactId>apacheds-server-unit</artifactId>
+      <artifactId>apacheds-all</artifactId>
       <groupId>org.apache.directory.server</groupId>
-      <version>1.5.3</version>
+      <version>${directory.version}</version>
       <scope>test</scope>
     </dependency>
 
     <!-- used by Apache DS -->
     <dependency>
-      <artifactId>slf4j-jdk14</artifactId>
+      <artifactId>slf4j-log4j12</artifactId>
       <groupId>org.slf4j</groupId>
-      <version>1.4.3</version>
       <scope>test</scope>
     </dependency>
 
@@ -145,7 +144,6 @@
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
           <excludes>
-            <exclude>**/spi/ldap/**.java</exclude>
             <exclude>**/spi/TestDefaultJetspeedSynchronizer.java</exclude>
             <exclude>**/spi/TestPasswordHistoryInterceptor.java</exclude>
             <exclude>**/spi/TestPasswordExpirationAndMaxAuthenticationFailuresInterceptor.java</exclude>

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/AbstractLDAPTest.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/AbstractLDAPTest.java?rev=921219&r1=921218&r2=921219&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/AbstractLDAPTest.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/AbstractLDAPTest.java
Wed Mar 10 03:39:27 2010
@@ -17,19 +17,20 @@
 package org.apache.jetspeed.security.mapping.ldap;
 
 import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
 
-import javax.naming.directory.DirContext;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.io.IOUtils;
+import org.apache.directory.server.core.DefaultDirectoryService;
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.partition.Partition;
+import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
+import org.apache.directory.server.ldap.LdapServer;
 import org.apache.directory.server.protocol.shared.store.LdifFileLoader;
+import org.apache.directory.server.protocol.shared.transport.TcpTransport;
+import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.jetspeed.security.mapping.ldap.dao.DefaultLDAPEntityManager;
 import org.apache.jetspeed.security.mapping.ldap.dao.LDAPEntityDAOConfiguration;
 import org.apache.jetspeed.security.mapping.model.impl.AttributeDefImpl;
+import org.apache.jetspeed.test.JetspeedTestCase;
 import org.springframework.core.io.Resource;
 import org.springframework.ldap.core.ContextSource;
 import org.springframework.ldap.core.LdapTemplate;
@@ -39,7 +40,7 @@ import org.springframework.ldap.core.sup
  * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
  * @version $Id$
  */
-public abstract class AbstractLDAPTest extends TestCase
+public abstract class AbstractLDAPTest extends JetspeedTestCase
 {
     
     public static final AttributeDefImpl CN_DEF = new AttributeDefImpl("cn",false,false).cfgRequired(true).cfgIdAttribute(true);
@@ -73,20 +74,98 @@ public abstract class AbstractLDAPTest e
     protected boolean debugMode = false;
 
     protected BasicTestCases basicTestCases;
+    
+    /** The directory service */
+    private static DirectoryService service;
+    private static LdapServer server;
+    private static boolean running;
+        
+    private static boolean deleteDir(File dir)
+    {        
+        if (dir.isDirectory())
+        {
+            String[] children = dir.list();
+            for (int i=0; i < children.length; i++)
+            {
+                if (!deleteDir(new File(dir, children[i])))
+                {
+                    return false;
+                }
+            }
+        }
+        return dir.delete();
+    }
+    
+    public void ldapTestSetup() throws Exception
+    {
+        File workingDir = new File(getBaseDir()+"target/_apacheds");
+        if (workingDir.exists() && !deleteDir(workingDir))
+        {
+            throw new Exception("Cannot delete apacheds working Directory: "+workingDir.getAbsolutePath());
+        }
+        
+        // Initialize the LDAP service
+        service = new DefaultDirectoryService();
+        
+        // Disable the ChangeLog system
+        service.getChangeLog().setEnabled( false );
+        service.setDenormalizeOpAttrsEnabled( true );
+        
+        // Create a new partition named 'foo'.
+        Partition partition = new JdbmPartition();
+        partition.setId( "sevenSeas" );
+        partition.setSuffix( "o=sevenSeas" );
+        service.addPartition( partition );
+        
+        service.setWorkingDirectory(workingDir);
+        server = new LdapServer();
+        server.setDirectoryService(service);
+        server.setTransports(new  TcpTransport(10389));
+        service.startup();
+        server.start();
+        
+        // Inject the sevenSeas root entry if it does not already exist
+        if (!service.getAdminSession().exists(partition.getSuffixDn()))
+        {
+            LdapDN dn = new LdapDN( "o=sevenSeas" );
+            ServerEntry entry = service.newEntry( dn );
+            entry.add( "objectClass", "top", "domain", "extensibleObject" );
+            entry.add( "dc", "sevenSeas" );
+            service.getAdminSession().add( entry );
+        }
+        running = true;
+    }
+    
+    public void ldapTestTeardown() throws Exception
+    {
+        server.stop();
+        service.shutdown();
+        server = null;
+        service = null;
+        File workingDir = new File(getBaseDir()+"target/_apacheds");
+        if (workingDir.exists())
+        {
+            deleteDir(workingDir);
+        }
+        running = false;
+    }
 
     public void setUp() throws Exception
     {
-        baseDN = "o=sevenSeas";
+        super.setUp();
         // TODO : move config to build environment
+        baseDN = "o=sevenSeas";
         LdapContextSource contextSource = new LdapContextSource();
-        contextSource.setUrl("ldap://localhost:389");
+        contextSource.setUrl("ldap://localhost:10389");
         contextSource.setBase(baseDN);
-        contextSource.setUserDn("cn=admin,o=sevenSeas");
+        contextSource.setUserDn("uid=admin,ou=system");
         contextSource.setPassword("secret");
         contextSource.afterPropertiesSet();
         ldapTemplate = new LdapTemplate();
         ldapTemplate.setContextSource(contextSource);
 
+        if (!running) return;
+        
         try
         {
             emptyLDAP();
@@ -97,43 +176,18 @@ public abstract class AbstractLDAPTest e
                 e.printStackTrace();
             }
         }
-
-        DirContext dirContext = ldapTemplate.getContextSource()
-                .getReadWriteContext();
-        loadLdifs(ldapTemplate.getContextSource().getReadWriteContext(),
-                initializationData());
+        Resource[] ldifs = initializationData();
+        for (int i = 0; i < ldifs.length; i++)
+        {
+            LdifFileLoader loader = new  LdifFileLoader(service.getAdminSession(), ldifs[i].getFile().getAbsolutePath());
+            loader.execute();
+        }
+        
         internalSetUp();
 
         basicTestCases = new BasicTestCases(entityManager, debugMode);
     }
 
-    public static void loadLdifs(DirContext context, Resource[] ldifFiles)
-            throws IOException
-    {
-
-        for (int i = 0; i < ldifFiles.length; i++)
-        {
-            File tempFile = File.createTempFile("spring_ldap_test", ".ldif");
-            try
-            {
-                InputStream inputStream = ldifFiles[i].getInputStream();
-                IOUtils.copy(inputStream, new FileOutputStream(tempFile));
-                LdifFileLoader fileLoader = new LdifFileLoader(context,
-                        tempFile.getAbsolutePath());
-                fileLoader.execute();
-            } finally
-            {
-                try
-                {
-                    tempFile.delete();
-                } catch (Exception e)
-                {
-                    // Ignore this
-                }
-            }
-        }
-    }
-
     private void emptyLDAP() throws Exception
     {
         ldapTemplate.unbind("", true); // recursively delete root node of ldap
@@ -143,6 +197,7 @@ public abstract class AbstractLDAPTest e
     protected void tearDown() throws Exception
     {
         super.tearDown();
+        if (!running) return;
         internaltearDown();
         emptyLDAP();
     }

Copied: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup1/TestLDAP.java
(from r920746, portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup1/UserTests.java)
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup1/TestLDAP.java?p2=portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup1/TestLDAP.java&p1=portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup1/UserTests.java&r1=920746&r2=921219&rev=921219&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup1/UserTests.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup1/TestLDAP.java
Wed Mar 10 03:39:27 2010
@@ -21,6 +21,8 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 
+import junit.framework.Test;
+
 import org.apache.jetspeed.security.mapping.model.Entity;
 import org.apache.jetspeed.security.mapping.model.impl.EntityImpl;
 
@@ -28,8 +30,22 @@ import org.apache.jetspeed.security.mapp
  * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
  * @version $Id$
  */
-public class UserTests extends AbstractSetup1LDAPTest
+public class TestLDAP extends AbstractSetup1LDAPTest
 {
+    public static Test suite()
+    {
+        return createFixturedTestSuite(TestLDAP.class, "ldapTestSetup", "ldapTestTeardown");
+    }
+    
+    public void ldapTestSetup() throws Exception
+    {
+        super.ldapTestSetup();
+    }
+    
+    public void ldapTestTeardown() throws Exception
+    {
+        super.ldapTestTeardown();
+    }
 
     public void testSingleUser() throws Exception
     {

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup1/TestLDAP.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup1/TestLDAP.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup2/AbstractSetup2LDAPTest.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup2/AbstractSetup2LDAPTest.java?rev=921219&r1=921218&r2=921219&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup2/AbstractSetup2LDAPTest.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup2/AbstractSetup2LDAPTest.java
Wed Mar 10 03:39:27 2010
@@ -36,7 +36,6 @@ import org.apache.jetspeed.security.mapp
 import org.apache.jetspeed.security.mapping.ldap.dao.impl.SpringLDAPEntityDAO;
 import org.apache.jetspeed.security.mapping.ldap.filter.SimpleFilter;
 import org.apache.jetspeed.security.mapping.model.AttributeDef;
-import org.apache.jetspeed.security.mapping.model.impl.AttributeDefImpl;
 
 /**
  * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>

Copied: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup2/TestLDAP.java
(from r920746, portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup2/UserTests.java)
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup2/TestLDAP.java?p2=portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup2/TestLDAP.java&p1=portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup2/UserTests.java&r1=920746&r2=921219&rev=921219&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup2/UserTests.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup2/TestLDAP.java
Wed Mar 10 03:39:27 2010
@@ -19,18 +19,22 @@ package org.apache.jetspeed.security.map
 import java.util.ArrayList;
 import java.util.Collection;
 
+import junit.framework.Test;
+
 import org.apache.jetspeed.security.mapping.ldap.util.DnUtils;
 import org.apache.jetspeed.security.mapping.model.Entity;
 import org.apache.jetspeed.security.mapping.model.impl.EntityImpl;
-import org.springframework.ldap.core.DistinguishedName;
-
 
 /**
  * @author <a href="mailto:ddam@apache.org">Dennis Dam</a>
  * @version $Id$
  */
-public class UserTests extends AbstractSetup2LDAPTest
+public class TestLDAP extends AbstractSetup2LDAPTest
 {
+    public static Test suite()
+    {
+        return createFixturedTestSuite(TestLDAP.class, "ldapTestSetup", "ldapTestTeardown");
+    }
 
     public void testSingleUser() throws Exception
     {

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup2/TestLDAP.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/mapping/ldap/setup2/TestLDAP.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: portals/jetspeed-2/portal/trunk/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/pom.xml?rev=921219&r1=921218&r2=921219&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/pom.xml (original)
+++ portals/jetspeed-2/portal/trunk/pom.xml Wed Mar 10 03:39:27 2010
@@ -257,7 +257,7 @@
     <commons-pool.version>1.3</commons-pool.version>
     <!-- ddlutils svn r551445 with patch applied from http://issues.apache.org/jira/browse/DDLUTILS-75#action_12521579
-->
     <ddlutils.version>r551445-patched-75</ddlutils.version>
-    <directory.version>0.9.3</directory.version>
+    <directory.version>1.5.5</directory.version>
     <dom4j.version>1.6.1</dom4j.version>
     <ehcache.version>1.7.2</ehcache.version>
     <hsqldb.version>1.8.0.2</hsqldb.version>
@@ -1172,47 +1172,6 @@
         </exclusions>
       </dependency>
 
-      <!-- LDAP -->
-      <dependency>
-        <groupId>directory</groupId>
-        <artifactId>apacheds-main</artifactId>
-        <version>${directory.version}</version>
-        <exclusions>
-          <exclusion>
-            <groupId>directory-shared</groupId>
-            <artifactId>protocol-common</artifactId>
-          </exclusion>
-          <exclusion>
-            <groupId>asn1-ber</groupId>
-            <artifactId>asn1-codec</artifactId>
-          </exclusion>
-          <exclusion>
-            <groupId>directory-shared</groupId>
-            <artifactId>ldap-common</artifactId>
-          </exclusion>
-          <exclusion>
-            <groupId>directory-shared</groupId>
-            <artifactId>kerberos-common</artifactId>
-          </exclusion>
-          <exclusion>
-            <groupId>directory-protocols</groupId>
-            <artifactId>ntp-protocol</artifactId>
-          </exclusion>
-          <exclusion>
-            <groupId>directory-protocols</groupId>
-            <artifactId>changepw-protocol</artifactId>
-          </exclusion>
-          <exclusion>
-            <groupId>directory-protocols</groupId>
-            <artifactId>kerberos-protocol</artifactId>
-          </exclusion>
-          <exclusion>
-            <groupId>directory-protocols</groupId>
-            <artifactId>ldap-protocol</artifactId>
-          </exclusion>
-        </exclusions>
-      </dependency>
-
       <!-- Email -->
       <dependency>
         <groupId>javax.mail</groupId>



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message