This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch 3.20.x in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 32680c36c212f1f44f959020fdb5f7f4609b036d Author: Jiri Ondrusek <[email protected]> AuthorDate: Wed Apr 2 18:16:38 2025 +0200 fixed #7217 ldap uses certificate-generator --- integration-tests/ldap/pom.xml | 88 ++-------------------- .../camel/quarkus/component/ldap/it/LdapTest.java | 14 +++- 2 files changed, 15 insertions(+), 87 deletions(-) diff --git a/integration-tests/ldap/pom.xml b/integration-tests/ldap/pom.xml index cfe31c4c9b..283303dd29 100644 --- a/integration-tests/ldap/pom.xml +++ b/integration-tests/ldap/pom.xml @@ -65,92 +65,14 @@ <artifactId>unboundid-ldapsdk</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-tests-support-certificate-generator</artifactId> + <scope>test</scope> + </dependency> </dependencies> <profiles> - <profile> - <id>full</id> - <activation> - <property> - <name>!quickly</name> - </property> - </activation> - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>keytool-maven-plugin</artifactId> - <configuration> - <validity>18250</validity> - <keyalg>RSA</keyalg> - <storepass>ldapPass</storepass> - <noprompt>true</noprompt> - </configuration> - <executions> - <execution> - <id>generate-keypair</id> - <phase>generate-test-resources</phase> - <goals> - <goal>clean</goal> - <goal>generateKeyPair</goal> - </goals> - <configuration> - <alias>ldap</alias> - <keysize>2048</keysize> - <dname>CN=127.0.0.1, OU=Camel Quarkus, O=Apache</dname> - <exts> - <ext>SAN=IP:127.0.0.1</ext> - </exts> - <keystore>${project.basedir}/target/test-classes/keystore.jks</keystore> - </configuration> - </execution> - <execution> - <id>export-certificate</id> - <phase>generate-test-resources</phase> - <goals> - <goal>exportCertificate</goal> - </goals> - <configuration> - <alias>ldap</alias> - <keystore>${project.basedir}/target/test-classes/keystore.jks</keystore> - <file>${basedir}/target/test-classes/ldap-cert</file> - </configuration> - </execution> - <execution> - <id>create-trusstore</id> - <phase>generate-test-resources</phase> - <goals> - <goal>importCertificate</goal> - </goals> - <configuration> - <alias>localhost</alias> - <trustcacerts>true</trustcacerts> - <keystore>${basedir}/target/test-classes/truststore.jks</keystore> - <file>${basedir}/target/test-classes/ldap-cert</file> - </configuration> - </execution> - <execution> - <id>generate-wrong-trusstore</id> - <phase>generate-sources</phase> - <goals> - <goal>clean</goal> - <goal>generateKeyPair</goal> - </goals> - <configuration> - <alias>localhost</alias> - <dname>CN=localhost, OU=eng, O=apache.org</dname> - <exts> - <ext>bc:c=ca:true,pathlen:2147483647</ext> - <ext>IssuerAlternativeName=DNS:NOT-FOR-PRODUCTION-USE</ext> - </exts> - <keystore>${project.build.outputDirectory}/truststore-wrong.jks</keystore> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> <profile> <id>virtualDependencies</id> <activation> diff --git a/integration-tests/ldap/src/test/java/org/apache/camel/quarkus/component/ldap/it/LdapTest.java b/integration-tests/ldap/src/test/java/org/apache/camel/quarkus/component/ldap/it/LdapTest.java index dc8392ed42..706273d174 100644 --- a/integration-tests/ldap/src/test/java/org/apache/camel/quarkus/component/ldap/it/LdapTest.java +++ b/integration-tests/ldap/src/test/java/org/apache/camel/quarkus/component/ldap/it/LdapTest.java @@ -35,7 +35,10 @@ import com.unboundid.util.ssl.SSLUtil; import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; import io.restassured.common.mapper.TypeRef; +import io.smallrye.certs.Format; +import io.smallrye.certs.junit5.Certificate; import jakarta.ws.rs.core.MediaType; +import org.apache.camel.quarkus.test.support.certificate.TestCertificates; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -44,11 +47,14 @@ import org.junit.jupiter.params.provider.ValueSource; import static org.junit.jupiter.api.Assertions.assertEquals; +@TestCertificates(certificates = { + @Certificate(name = "ldap", formats = { + Format.PKCS12 }, password = "changeit") }) @QuarkusTest class LdapTest { private static InMemoryDirectoryServer ldapServer = null; - private static final String truststoreFile = "target/test-classes/truststore.jks"; + private static final String truststoreFile = "target/certs/ldap-truststore.p12"; @BeforeAll public static void setUpLdapServer() throws Exception { @@ -59,7 +65,7 @@ class LdapTest { InetAddress.getLoopbackAddress(), 0, null); // The keystore is generated by the build process - Path keystoreFile = Paths.get("target/test-classes/keystore.jks"); + Path keystoreFile = Paths.get("target/certs/ldap-keystore.p12"); if (!Files.isRegularFile(keystoreFile)) { /* The test is run from a test-jar within Quarkus Platform, where the Ant script was not run * so let's copy the keystore from test-jar to the local folder */ @@ -74,7 +80,7 @@ class LdapTest { } } - SSLUtil serverSSLUtil = new SSLUtil(new KeyStoreKeyManager(keystoreFile.toFile(), "ldapPass".toCharArray()), + SSLUtil serverSSLUtil = new SSLUtil(new KeyStoreKeyManager(keystoreFile.toFile(), "changeit".toCharArray()), null); InMemoryListenerConfig sslListenerConfig = InMemoryListenerConfig.createLDAPSConfig("ldaps", InetAddress.getLoopbackAddress(), 0, serverSSLUtil.createSSLServerSocketFactory(), @@ -183,7 +189,7 @@ class LdapTest { options.put("ssl", String.valueOf(useSSL)); if (useSSL) { options.put("trustStore", truststoreFile); - options.put("trustStorePassword", "ldapPass"); + options.put("trustStorePassword", "changeit"); } RestAssured.given()
