You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pp...@apache.org on 2023/02/08 10:00:44 UTC

[camel-quarkus] 30/40: MailTest.receiveSecured fails on Camel 4/Quarkus 3: Can't verify identity of server: localhost #4493

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

ppalaga pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit f4d04fb1a8a3cefc95771ed9ab58e10972bbac3b
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Tue Feb 7 14:46:11 2023 +0100

    MailTest.receiveSecured fails on Camel 4/Quarkus 3: Can't verify
    identity of server: localhost #4493
---
 .../quarkus/component/mail/MailTestResource.java    |  18 ++++++++++--------
 .../mail/src/test/resources/Dockerfile              |  20 ++++++++++++++++++++
 .../mail/src/test/resources/README.adoc             |  12 ++++++++++++
 .../mail/src/test/resources/greenmail.p12           | Bin 0 -> 4077 bytes
 4 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/integration-tests/mail/src/test/java/org/apache/camel/quarkus/component/mail/MailTestResource.java b/integration-tests/mail/src/test/java/org/apache/camel/quarkus/component/mail/MailTestResource.java
index f7e6abb497..bf857427ca 100644
--- a/integration-tests/mail/src/test/java/org/apache/camel/quarkus/component/mail/MailTestResource.java
+++ b/integration-tests/mail/src/test/java/org/apache/camel/quarkus/component/mail/MailTestResource.java
@@ -22,21 +22,23 @@ import java.util.Map;
 import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
 import org.testcontainers.containers.GenericContainer;
 import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;
-import org.testcontainers.utility.DockerImageName;
+import org.testcontainers.images.builder.ImageFromDockerfile;
 
 public class MailTestResource implements QuarkusTestResourceLifecycleManager {
 
-    private static final String GREENMAIL_IMAGE_NAME = "greenmail/standalone:1.6.7";
     private GenericContainer<?> container;
 
     @Override
     public Map<String, String> start() {
-        container = new GenericContainer<>(DockerImageName.parse(GREENMAIL_IMAGE_NAME))
-                .withExposedPorts(MailProtocol.allPorts())
-                .waitingFor(new HttpWaitStrategy()
-                        .forPort(MailProtocol.API.getPort())
-                        .forPath("/api/service/readiness")
-                        .forStatusCode(200));
+        //Dockerfile with ImageFromDockerfile is used, because ownership of the certificate has to be changed
+        container = new GenericContainer<>(new ImageFromDockerfile()
+                .withFileFromClasspath("Dockerfile", "Dockerfile")
+                .withFileFromClasspath("greenmail.p12", "greenmail.p12"))
+                        .withExposedPorts(MailProtocol.allPorts())
+                        .waitingFor(new HttpWaitStrategy()
+                                .forPort(MailProtocol.API.getPort())
+                                .forPath("/api/service/readiness")
+                                .forStatusCode(200));
 
         container.start();
 
diff --git a/integration-tests/mail/src/test/resources/Dockerfile b/integration-tests/mail/src/test/resources/Dockerfile
new file mode 100644
index 0000000000..ec0b378fee
--- /dev/null
+++ b/integration-tests/mail/src/test/resources/Dockerfile
@@ -0,0 +1,20 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+FROM greenmail/standalone:1.6.8
+
+COPY --chown=greenmail:greenmail greenmail.p12 /home/greenmail/greenmail.p12
diff --git a/integration-tests/mail/src/test/resources/README.adoc b/integration-tests/mail/src/test/resources/README.adoc
new file mode 100644
index 0000000000..13229af1aa
--- /dev/null
+++ b/integration-tests/mail/src/test/resources/README.adoc
@@ -0,0 +1,12 @@
+Out of the box docker greenmail does not work with SSL/TLS.
+Certificate has to be created - the guide can be seen in the issue https://github.com/greenmail-mail-test/greenmail/issues/448[#448].
+
+Following steps were used for certificate creation.
+
+```
+openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \
+ -keyout greenmail.key -out greenmail.crt -subj "/CN=localhost" \
+ -addext "subjectAltName=DNS:localhost,IP:127.0.0.1"
+
+openssl pkcs12 -export -out greenmail.p12 -inkey greenmail.key -in greenmail.crt
+```
diff --git a/integration-tests/mail/src/test/resources/greenmail.p12 b/integration-tests/mail/src/test/resources/greenmail.p12
new file mode 100644
index 0000000000..de455f1a73
Binary files /dev/null and b/integration-tests/mail/src/test/resources/greenmail.p12 differ