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 de31e0dfcb76..a121a51cbb35 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 @@ -26,13 +26,16 @@ import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; import org.apache.commons.io.FileUtils; import org.eclipse.microprofile.config.ConfigProvider; +import org.jboss.logging.Logger; import org.testcontainers.DockerClientFactory; +import org.testcontainers.containers.Container.ExecResult; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.wait.strategy.HttpWaitStrategy; import org.testcontainers.images.builder.Transferable; import org.testcontainers.utility.MountableFile; public class MailTestResource implements QuarkusTestResourceLifecycleManager { + private static final Logger LOG = Logger.getLogger(MailTestResource.class); private static final String GREENMAIL_IMAGE_NAME = ConfigProvider.getConfig().getValue("greenmail.container.image", String.class); private static final String GREENMAIL_CERTIFICATE_STORE_FILE = "greenmail.p12"; @@ -109,8 +112,14 @@ private void regenerateCertificatesForDockerHost() { container.copyFileToContainer( MountableFile.forClasspathResource(GENERATE_CERTIFICATE_SCRIPT), "/" + GENERATE_CERTIFICATE_SCRIPT); - container.execInContainer("/bin/bash", "/" + GENERATE_CERTIFICATE_SCRIPT, host, - "DNS:%s,IP:%s".formatted(host, host)); + ExecResult result = container.execInContainer("/bin/bash", "/" + GENERATE_CERTIFICATE_SCRIPT, host, + "DNS:%s,IP:%s".formatted(host, host), "/" + GREENMAIL_CERTIFICATE_STORE_FILE); + + LOG.info(GENERATE_CERTIFICATE_SCRIPT + " - STDOUT:"); + LOG.info(result.getStdout()); + LOG.info(GENERATE_CERTIFICATE_SCRIPT + " - STDERR:"); + LOG.info(result.getStderr()); + container.copyFileFromContainer("/" + GREENMAIL_CERTIFICATE_STORE_FILE, certificateStoreLocation.resolve(GREENMAIL_CERTIFICATE_STORE_FILE).toString()); } catch (Exception e) { diff --git a/integration-tests/mail/src/test/resources/generate-certificates.sh b/integration-tests/mail/src/test/resources/generate-certificates.sh index 1312616071d7..d36cf81c9afe 100755 --- a/integration-tests/mail/src/test/resources/generate-certificates.sh +++ b/integration-tests/mail/src/test/resources/generate-certificates.sh @@ -19,8 +19,14 @@ export CN=${1:-localhost} export SUBJECT_ALT_NAMES=${2:-"DNS:localhost,IP:127.0.0.1"} +export CERT_OUTPUT_FILE=${3:-greenmail.p12} + +echo "====> PWD = ${PWD}" +echo "====> CN = ${CN}" +echo "====> SUBJECT_ALT_NAMES = ${SUBJECT_ALT_NAMES}" +echo "====> CERT_OUTPUT_FILE = ${CERT_OUTPUT_FILE}" openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout greenmail.key -out greenmail.crt -subj "/CN=${CN}" -addext "subjectAltName=${SUBJECT_ALT_NAMES}" -openssl pkcs12 -export -out greenmail.p12 -inkey greenmail.key -in greenmail.crt -password pass:changeit +openssl pkcs12 -export -out ${CERT_OUTPUT_FILE} -inkey greenmail.key -in greenmail.crt -password pass:changeit rm -f *.crt *.key