This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit e5167a8c5a093c79b2aa921e1564e906c37e89f9
Author: Andriy Redko <[email protected]>
AuthorDate: Fri Dec 16 20:47:32 2022 -0500

    CXF-8809: Migrate LDAP systest cases from ApacheDS to UnboundID LDAP (#1042)
    
    (cherry picked from commit 360f80381d8fc44045a5dcf8fa276f56709d383d)
    
    # Conflicts:
    #       parent/pom.xml
    (cherry picked from commit 6ae75647f08feeec514f343845d9f394d7fa5553)
    
    # Conflicts:
    #       parent/pom.xml
    (cherry picked from commit 33b943951c5150b5270e6865a8ba32c158d7210d)
---
 parent/pom.xml                                     |  5 +-
 systests/ldap/pom.xml                              | 36 +++----------
 .../cxf/systest/ldap/jaxrs/JAXRSLDAPUserTest.java  | 59 +++++++---------------
 .../cxf/systest/ldap/sts/LDAPClaimsTest.java       | 54 +++++---------------
 .../systest/ldap/xkms/LDAPCertificateRepoTest.java | 55 ++++++--------------
 systests/ldap/src/test/resources/ldap.xml          |  2 +-
 6 files changed, 57 insertions(+), 154 deletions(-)

diff --git a/parent/pom.xml b/parent/pom.xml
index 040e3f7f4b..f99a801812 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -80,7 +80,7 @@
         <cxf.abdera.version>1.1.3</cxf.abdera.version>
         <cxf.activemq.version>5.16.5</cxf.activemq.version>
         <cxf.ahc.version>2.12.3</cxf.ahc.version>
-        <cxf.apacheds.version>2.0.0.AM26</cxf.apacheds.version>
+        <cxf.arquillian.version>1.6.0.Final</cxf.arquillian.version>
         <cxf.arquillian.version>1.1.14.Final</cxf.arquillian.version>
         
<cxf.arquillian.weld.container.version>2.0.1.Final</cxf.arquillian.weld.container.version>
         <cxf.aspectj.version>1.9.1</cxf.aspectj.version>
@@ -165,6 +165,7 @@
         <cxf.jsr250.api.version>1.0</cxf.jsr250.api.version>
         <cxf.junit.version>4.13.2</cxf.junit.version>
         <cxf.kerby.version>2.0.2</cxf.kerby.version>
+        <cxf.ldapsdk.version>6.0.7</cxf.ldapsdk.version>
         <cxf.littleproxy.version>1.1.2</cxf.littleproxy.version>
         <cxf.logback.classic.version>1.2.10</cxf.logback.classic.version>
         <cxf.lucene.version>8.11.2</cxf.lucene.version>
@@ -2438,7 +2439,7 @@
             <properties>
                 <!-- EasyMock stills uses JDK Internal APIs: see please 
https://bugs.openjdk.java.net/browse/JDK-8255363 -->
                 <!-- JAXB: see please 
https://github.com/javaee/jaxb-v2/issues/1184 -->
-                <cxf.surefire.fork.vmargs>-ea --add-opens 
java.base/java.lang=ALL-UNNAMED --add-opens 
java.xml/javax.xml.namespace=ALL-UNNAMED  --add-opens 
java.base/sun.security.x509=ALL-UNNAMED --add-opens 
java.base/sun.security.util=ALL-UNNAMED --add-opens 
java.xml/com.sun.org.apache.xerces.internal.dom=ALL-UNNAMED --add-opens 
java.base/java.net=ALL-UNNAMED  --add-opens 
java.base/sun.net.www.protocol.https=ALL-UNNAMED</cxf.surefire.fork.vmargs>
+                <cxf.surefire.fork.vmargs>-ea --add-opens 
java.base/java.lang=ALL-UNNAMED --add-opens 
java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens 
java.xml/com.sun.org.apache.xerces.internal.dom=ALL-UNNAMED --add-opens 
java.base/java.net=ALL-UNNAMED  --add-opens 
java.base/sun.net.www.protocol.https=ALL-UNNAMED</cxf.surefire.fork.vmargs>
             </properties>
         </profile>
     </profiles>
diff --git a/systests/ldap/pom.xml b/systests/ldap/pom.xml
index 28df93ddb1..c259d6498d 100644
--- a/systests/ldap/pom.xml
+++ b/systests/ldap/pom.xml
@@ -197,40 +197,16 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.apache.directory.server</groupId>
-            <artifactId>apacheds-core-annotations</artifactId>
-            <version>${cxf.apacheds.version}</version>
+            <groupId>com.unboundid</groupId>
+            <artifactId>unboundid-ldapsdk</artifactId>
+            <version>${cxf.ldapsdk.version}</version>
             <scope>test</scope>
-            <exclusions>
-                <exclusion>
-                    <groupId>bouncycastle</groupId>
-                    <artifactId>bcprov-jdk15</artifactId>
-                </exclusion>
-            </exclusions>
         </dependency>
         <dependency>
-            <groupId>org.apache.directory.server</groupId>
-            <artifactId>apacheds-core-integ</artifactId>
-            <version>${cxf.apacheds.version}</version>
+            <groupId>org.zapodot</groupId>
+            <artifactId>embedded-ldap-junit</artifactId>
+            <version>0.9.0</version>
             <scope>test</scope>
-            <exclusions>
-                <exclusion>
-                    <groupId>bouncycastle</groupId>
-                    <artifactId>bcprov-jdk15</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.directory.server</groupId>
-            <artifactId>apacheds-protocol-shared</artifactId>
-            <version>${cxf.apacheds.version}</version>
-            <scope>test</scope>
-            <exclusions>
-                <exclusion>
-                    <groupId>bouncycastle</groupId>
-                    <artifactId>bcprov-jdk15</artifactId>
-                </exclusion>
-            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.springframework.ldap</groupId>
diff --git 
a/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/jaxrs/JAXRSLDAPUserTest.java
 
b/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/jaxrs/JAXRSLDAPUserTest.java
index 372a3d79bc..db6738cc4d 100644
--- 
a/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/jaxrs/JAXRSLDAPUserTest.java
+++ 
b/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/jaxrs/JAXRSLDAPUserTest.java
@@ -29,56 +29,33 @@ import javax.ws.rs.InternalServerErrorException;
 
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.testutil.common.AbstractClientServerTestBase;
-import org.apache.directory.server.annotations.CreateLdapServer;
-import org.apache.directory.server.annotations.CreateTransport;
-import org.apache.directory.server.core.annotations.ApplyLdifFiles;
-import org.apache.directory.server.core.annotations.CreateDS;
-import org.apache.directory.server.core.annotations.CreateIndex;
-import org.apache.directory.server.core.annotations.CreatePartition;
-import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
-import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.zapodot.junit.ldap.EmbeddedLdapRule;
+import org.zapodot.junit.ldap.EmbeddedLdapRuleBuilder;
 
+import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.BeforeClass;
+import org.junit.ClassRule;
 import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(FrameworkRunner.class)
-
-//Define the DirectoryService
-@CreateDS(name = "JAXRSLDAPUserTest-class",
-    enableAccessControl = false,
-    allowAnonAccess = false,
-    enableChangeLog = true,
-    partitions = {
-        @CreatePartition(
-            name = "example",
-            suffix = "dc=example,dc=com",
-            indexes = {
-                @CreateIndex(attribute = "objectClass"),
-                @CreateIndex(attribute = "dc"),
-                @CreateIndex(attribute = "ou")
-            }
-        ) 
-    }
-)
-
-@CreateLdapServer(
-    transports = {
-        @CreateTransport(protocol = "LDAP", address = "localhost")
-    }
-)
-
-//Inject an file containing entries
-@ApplyLdifFiles("ldap.ldif")
 
 /**
  * Add a test for JAX-RS search using the LdapQueryVisitor.
  */
-public class JAXRSLDAPUserTest extends AbstractLdapTestUnit {
+public class JAXRSLDAPUserTest {
     public static final String PORT = UserLDAPServer.PORT;
     public static final String PORT2 = UserLDAPServer.PORT2;
+
+    @ClassRule
+    public static EmbeddedLdapRule embeddedLdapRule = EmbeddedLdapRuleBuilder
+        .newInstance()
+        .bindingToAddress("localhost")
+        .usingBindCredentials("ldap_su")
+        .usingBindDSN("UID=admin,DC=example,DC=com")
+        .usingDomainDsn("dc=example,dc=com")
+        .importingLdifs("ldap.ldif")
+        .build();
+
     private static boolean portUpdated;
 
     @BeforeClass
@@ -104,7 +81,7 @@ public class JAXRSLDAPUserTest extends AbstractLdapTestUnit {
             // Read in ldap.xml and substitute in the correct port
             Path path = FileSystems.getDefault().getPath(basedir, 
"/src/test/resources/ldap-jaxrs.xml");
             String content = new String(Files.readAllBytes(path), 
StandardCharsets.UTF_8);
-            content = content.replaceAll("portno", 
Integer.toString(super.getLdapServer().getPort()));
+            content = content.replaceAll("portno", 
Integer.toString(embeddedLdapRule.embeddedServerPort()));
 
             Path path2 = FileSystems.getDefault().getPath(basedir, 
"/target/test-classes/ldap-jaxrsport.xml");
             Files.write(path2, content.getBytes());
@@ -114,7 +91,7 @@ public class JAXRSLDAPUserTest extends AbstractLdapTestUnit {
 
     }
 
-    @org.junit.AfterClass
+    @AfterClass
     public static void cleanup() throws Exception {
         AbstractClientServerTestBase.stopAllServers();
     }
diff --git 
a/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/sts/LDAPClaimsTest.java
 
b/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/sts/LDAPClaimsTest.java
index 5a96136c5c..d259a0d700 100644
--- 
a/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/sts/LDAPClaimsTest.java
+++ 
b/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/sts/LDAPClaimsTest.java
@@ -45,55 +45,29 @@ import org.apache.cxf.sts.claims.LdapGroupClaimsHandler;
 import org.apache.cxf.sts.claims.ProcessedClaim;
 import org.apache.cxf.sts.claims.ProcessedClaimCollection;
 import org.apache.cxf.ws.security.sts.provider.STSException;
-import org.apache.directory.server.annotations.CreateLdapServer;
-import org.apache.directory.server.annotations.CreateTransport;
-import org.apache.directory.server.core.annotations.ApplyLdifFiles;
-import org.apache.directory.server.core.annotations.CreateDS;
-import org.apache.directory.server.core.annotations.CreateIndex;
-import org.apache.directory.server.core.annotations.CreatePartition;
-import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
-import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.wss4j.common.principal.CustomTokenPrincipal;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.zapodot.junit.ldap.EmbeddedLdapRule;
+import org.zapodot.junit.ldap.EmbeddedLdapRuleBuilder;
 
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.BeforeClass;
-import org.junit.runner.RunWith;
-
-@RunWith(FrameworkRunner.class)
-
-//Define the DirectoryService
-@CreateDS(name = "LDAPClaimsTest-class",
-    enableAccessControl = false,
-    allowAnonAccess = false,
-    enableChangeLog = true,
-    partitions = {
-        @CreatePartition(
-            name = "example",
-            suffix = "dc=example,dc=com",
-            indexes = {
-                @CreateIndex(attribute = "objectClass"),
-                @CreateIndex(attribute = "dc"),
-                @CreateIndex(attribute = "ou")
-            }
-        ) 
-    }
-)
-
-@CreateLdapServer(
-    transports = {
-        @CreateTransport(protocol = "LDAP", address = "localhost")
-    }
-)
-
-//Inject an file containing entries
-@ApplyLdifFiles("ldap.ldif")
+import org.junit.ClassRule;
 
 /**
  * Test the LdapClaimsHandler that ships with the STS
  */
-public class LDAPClaimsTest extends AbstractLdapTestUnit {
+public class LDAPClaimsTest {
+    @ClassRule
+    public static EmbeddedLdapRule embeddedLdapRule = EmbeddedLdapRuleBuilder
+        .newInstance()
+        .bindingToAddress("localhost")
+        .usingBindCredentials("ldap_su")
+        .usingBindDSN("UID=admin,DC=example,DC=com")
+        .usingDomainDsn("dc=example,dc=com")
+        .importingLdifs("ldap.ldif")
+        .build();
 
     private static Properties props;
     private static boolean portUpdated;
@@ -122,7 +96,7 @@ public class LDAPClaimsTest extends AbstractLdapTestUnit {
             // Read in ldap.xml and substitute in the correct port
             Path path = FileSystems.getDefault().getPath(basedir, 
"/src/test/resources/ldap.xml");
             String content = new String(Files.readAllBytes(path), 
StandardCharsets.UTF_8);
-            content = content.replaceAll("portno", 
Integer.toString(super.getLdapServer().getPort()));
+            content = content.replaceAll("portno", 
Integer.toString(embeddedLdapRule.embeddedServerPort()));
 
             Path path2 = FileSystems.getDefault().getPath(basedir, 
"/target/test-classes/ldapport.xml");
             Files.write(path2, content.getBytes());
diff --git 
a/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/xkms/LDAPCertificateRepoTest.java
 
b/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/xkms/LDAPCertificateRepoTest.java
index b1e8fb711b..9b0d0d381d 100644
--- 
a/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/xkms/LDAPCertificateRepoTest.java
+++ 
b/systests/ldap/src/test/java/org/apache/cxf/systest/ldap/xkms/LDAPCertificateRepoTest.java
@@ -34,54 +34,29 @@ import org.apache.cxf.xkms.x509.repo.CertificateRepo;
 import org.apache.cxf.xkms.x509.repo.ldap.LdapCertificateRepo;
 import org.apache.cxf.xkms.x509.repo.ldap.LdapSchemaConfig;
 import org.apache.cxf.xkms.x509.repo.ldap.LdapSearch;
-import org.apache.directory.server.annotations.CreateLdapServer;
-import org.apache.directory.server.annotations.CreateTransport;
-import org.apache.directory.server.core.annotations.ApplyLdifFiles;
-import org.apache.directory.server.core.annotations.CreateDS;
-import org.apache.directory.server.core.annotations.CreateIndex;
-import org.apache.directory.server.core.annotations.CreatePartition;
-import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
-import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.zapodot.junit.ldap.EmbeddedLdapRule;
+import org.zapodot.junit.ldap.EmbeddedLdapRuleBuilder;
 
+import org.junit.ClassRule;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
-@RunWith(FrameworkRunner.class)
-
-//Define the DirectoryService
-@CreateDS(name = "LDAPCertificateRepoTest-class",
-    enableAccessControl = false,
-    allowAnonAccess = false,
-    enableChangeLog = true,
-    partitions = {
-        @CreatePartition(
-            name = "example",
-            suffix = "dc=example,dc=com",
-            indexes = {
-                @CreateIndex(attribute = "objectClass"),
-                @CreateIndex(attribute = "dc"),
-                @CreateIndex(attribute = "ou")
-            }
-        ) 
-    }
-)
-
-@CreateLdapServer(
-    transports = {
-        @CreateTransport(protocol = "LDAP", address = "localhost")
-    }
-)
-
-//Inject an file containing entries
-@ApplyLdifFiles("ldap.ldif")
-
 /**
  * Add a test for the XKMS LDAP CertificateRepo
  */
-public class LDAPCertificateRepoTest extends AbstractLdapTestUnit {
+public class LDAPCertificateRepoTest {
+    @ClassRule
+    public static EmbeddedLdapRule embeddedLdapRule = EmbeddedLdapRuleBuilder
+        .newInstance()
+        .bindingToAddress("localhost")
+        .usingBindCredentials("ldap_su")
+        .usingBindDSN("UID=admin,DC=example,DC=com")
+        .usingDomainDsn("dc=example,dc=com")
+        .importingLdifs("ldap.ldif")
+        .build();
+
     private static final String EXPECTED_SUBJECT_DN = "cn=dave,ou=users";
     private static final String ROOT_DN = "dc=example,dc=com";
     private static final String EXPECTED_SUBJECT_DN2 = "cn=newuser,ou=users";
@@ -160,7 +135,7 @@ public class LDAPCertificateRepoTest extends 
AbstractLdapTestUnit {
     }
 
     private CertificateRepo createLdapCertificateRepo() throws 
CertificateException {
-        LdapSearch ldapSearch = new LdapSearch("ldap://localhost:"; + 
super.getLdapServer().getPort(),
+        LdapSearch ldapSearch = new LdapSearch("ldap://localhost:"; + 
embeddedLdapRule.embeddedServerPort(),
             "UID=admin,DC=example,DC=com", "ldap_su", 2);
 
         LdapSchemaConfig ldapSchemaConfig = new LdapSchemaConfig();
diff --git a/systests/ldap/src/test/resources/ldap.xml 
b/systests/ldap/src/test/resources/ldap.xml
index 4703f8ccd0..a3ba45a2e3 100644
--- a/systests/ldap/src/test/resources/ldap.xml
+++ b/systests/ldap/src/test/resources/ldap.xml
@@ -36,7 +36,7 @@
         <entry 
key="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname"; value="sn"/>
         <entry 
key="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"; 
value="mail"/>
         <entry 
key="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/country"; value="c"/>
-        <entry key="http://custom/x509"; value="usercertificate"/>
+        <entry key="http://custom/x509"; value="userCertificate"/>
     </util:map>
     <bean id="testClaimsHandler" 
class="org.apache.cxf.sts.claims.LdapClaimsHandler">
         <property name="ldapTemplate" ref="ldapTemplate" />

Reply via email to