Merge pull request #40037 from ruifigueira

* pr/40037:
  Polish "Add SslBundle support to MailSender"
  Add SslBundle support to MailSender

Closes gh-40037
This commit is contained in:
Moritz Halbritter 2024-07-04 15:44:38 +02:00
commit 1e005cace2
13 changed files with 626 additions and 8 deletions

View File

@ -27,6 +27,7 @@ dependencies {
dockerTestImplementation("org.testcontainers:neo4j")
dockerTestImplementation("org.testcontainers:pulsar")
dockerTestImplementation("org.testcontainers:testcontainers")
dockerTestImplementation("org.awaitility:awaitility")
optional("co.elastic.clients:elasticsearch-java") {
exclude group: "commons-logging", module: "commons-logging"

View File

@ -0,0 +1,219 @@
/*
* Copyright 2012-2024 the original author or authors.
*
* Licensed 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
*
* https://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.
*/
package org.springframework.boot.autoconfigure.mail;
import java.net.SocketTimeoutException;
import java.security.cert.CertPathBuilderException;
import java.time.Duration;
import java.util.Arrays;
import javax.net.ssl.SSLException;
import jakarta.mail.Folder;
import jakarta.mail.Message;
import jakarta.mail.MessagingException;
import jakarta.mail.Session;
import jakarta.mail.Store;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.MountableFile;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.testsupport.container.MailpitContainer;
import org.springframework.boot.testsupport.container.TestImage;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatException;
/**
* Integration tests for {@link MailSenderAutoConfiguration}.
*
* @author Rui Figueira
*/
@Testcontainers(disabledWithoutDocker = true)
class MailSenderAutoConfigurationIntegrationTests {
private SimpleMailMessage createMessage(String subject) {
SimpleMailMessage msg = new SimpleMailMessage();
msg.setFrom("from@example.com");
msg.setTo("to@example.com");
msg.setSubject(subject);
msg.setText("Subject: " + subject);
return msg;
}
private String getSubject(Message message) {
try {
return message.getSubject();
}
catch (MessagingException ex) {
throw new RuntimeException("Failed to get message subject", ex);
}
}
private void assertMessagesContainSubject(Session session, String subject) throws MessagingException {
try (Store store = session.getStore("pop3")) {
String host = session.getProperty("mail.pop3.host");
int port = Integer.parseInt(session.getProperty("mail.pop3.port"));
store.connect(host, port, "user", "pass");
try (Folder folder = store.getFolder("inbox")) {
folder.open(Folder.READ_ONLY);
Awaitility.await()
.atMost(Duration.ofSeconds(5))
.ignoreExceptions()
.untilAsserted(() -> assertThat(Arrays.stream(folder.getMessages()).map(this::getSubject))
.contains(subject));
}
}
}
@Nested
class ImplicitTlsTests {
@Container
private static final MailpitContainer mailpit = TestImage.container(MailpitContainer.class)
.withSmtpRequireTls(true)
.withSmtpTlsCert(MountableFile
.forClasspathResource("/org/springframework/boot/autoconfigure/mail/ssl/test-server.crt"))
.withSmtpTlsKey(MountableFile
.forClasspathResource("/org/springframework/boot/autoconfigure/mail/ssl/test-server.key"))
.withPop3Auth("user:pass");
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(MailSenderAutoConfiguration.class, SslAutoConfiguration.class));
@Test
void sendEmailWithSslEnabledAndCert() {
this.contextRunner.withPropertyValues("spring.mail.host:" + mailpit.getHost(),
"spring.mail.port:" + mailpit.getSmtpPort(), "spring.mail.ssl.enabled:true",
"spring.mail.ssl.bundle:test-bundle",
"spring.ssl.bundle.pem.test-bundle.truststore.certificate=classpath:org/springframework/boot/autoconfigure/mail/ssl/test-ca.crt",
"spring.ssl.bundle.pem.test-bundle.keystore.certificate=classpath:org/springframework/boot/autoconfigure/mail/ssl/test-client.crt",
"spring.ssl.bundle.pem.test-bundle.keystore.private-key=classpath:org/springframework/boot/autoconfigure/mail/ssl/test-client.key",
"spring.mail.properties.mail.pop3.host:" + mailpit.getHost(),
"spring.mail.properties.mail.pop3.port:" + mailpit.getPop3Port())
.run((context) -> {
JavaMailSenderImpl mailSender = context.getBean(JavaMailSenderImpl.class);
mailSender.send(createMessage("Hello World!"));
assertMessagesContainSubject(mailSender.getSession(), "Hello World!");
});
}
@Test
void sendEmailWithSslEnabledWithoutCert() {
this.contextRunner
.withPropertyValues("spring.mail.host:" + mailpit.getHost(),
"spring.mail.port:" + mailpit.getSmtpPort(), "spring.mail.ssl.enabled:true")
.run((context) -> {
JavaMailSenderImpl mailSender = context.getBean(JavaMailSenderImpl.class);
assertThatException().isThrownBy(() -> mailSender.send(createMessage("Should fail")))
.withRootCauseInstanceOf(CertPathBuilderException.class);
});
}
@Test
void sendEmailWithoutSslWithCert() {
this.contextRunner.withPropertyValues("spring.mail.host:" + mailpit.getHost(),
"spring.mail.port:" + mailpit.getSmtpPort(), "spring.mail.properties.mail.smtp.timeout:1000",
"spring.mail.ssl.bundle:test-bundle",
"spring.ssl.bundle.pem.test-bundle.truststore.certificate=classpath:org/springframework/boot/autoconfigure/mail/ssl/test-ca.crt",
"spring.ssl.bundle.pem.test-bundle.keystore.certificate=classpath:org/springframework/boot/autoconfigure/mail/ssl/test-client.crt",
"spring.ssl.bundle.pem.test-bundle.keystore.private-key=classpath:org/springframework/boot/autoconfigure/mail/ssl/test-client.key")
.run((context) -> {
JavaMailSenderImpl mailSender = context.getBean(JavaMailSenderImpl.class);
assertThatException().isThrownBy(() -> mailSender.send(createMessage("Should fail")))
.withRootCauseInstanceOf(SocketTimeoutException.class);
});
}
}
@Nested
class StarttlsTests {
@Container
private static final MailpitContainer mailpit = TestImage.container(MailpitContainer.class)
.withSmtpRequireStarttls(true)
.withSmtpTlsCert(MountableFile
.forClasspathResource("/org/springframework/boot/autoconfigure/mail/ssl/test-server.crt"))
.withSmtpTlsKey(MountableFile
.forClasspathResource("/org/springframework/boot/autoconfigure/mail/ssl/test-server.key"))
.withPop3Auth("user:pass");
final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(MailSenderAutoConfiguration.class, SslAutoConfiguration.class));
@Test
void sendEmailWithStarttlsAndCertAndSslDisabled() {
this.contextRunner.withPropertyValues("spring.mail.host:" + mailpit.getHost(),
"spring.mail.port:" + mailpit.getSmtpPort(),
"spring.mail.properties.mail.smtp.starttls.enable:true",
"spring.mail.properties.mail.smtp.starttls.required:true", "spring.mail.ssl.bundle:test-bundle",
"spring.ssl.bundle.pem.test-bundle.truststore.certificate=classpath:org/springframework/boot/autoconfigure/mail/ssl/test-ca.crt",
"spring.ssl.bundle.pem.test-bundle.keystore.certificate=classpath:org/springframework/boot/autoconfigure/mail/ssl/test-client.crt",
"spring.ssl.bundle.pem.test-bundle.keystore.private-key=classpath:org/springframework/boot/autoconfigure/mail/ssl/test-client.key",
"spring.mail.properties.mail.pop3.host:" + mailpit.getHost(),
"spring.mail.properties.mail.pop3.port:" + mailpit.getPop3Port())
.run((context) -> {
JavaMailSenderImpl mailSender = context.getBean(JavaMailSenderImpl.class);
mailSender.send(createMessage("Sent with STARTTLS"));
assertMessagesContainSubject(mailSender.getSession(), "Sent with STARTTLS");
});
}
@Test
void sendEmailWithStarttlsAndCertAndSslEnabled() {
this.contextRunner.withPropertyValues("spring.mail.host:" + mailpit.getHost(),
"spring.mail.port:" + mailpit.getSmtpPort(), "spring.mail.ssl.enabled:true",
"spring.mail.properties.mail.smtp.starttls.enable:true",
"spring.mail.properties.mail.smtp.starttls.required:true", "spring.mail.ssl.bundle:test-bundle",
"spring.ssl.bundle.pem.test-bundle.truststore.certificate=classpath:org/springframework/boot/autoconfigure/mail/ssl/test-ca.crt",
"spring.ssl.bundle.pem.test-bundle.keystore.certificate=classpath:org/springframework/boot/autoconfigure/mail/ssl/test-client.crt",
"spring.ssl.bundle.pem.test-bundle.keystore.private-key=classpath:org/springframework/boot/autoconfigure/mail/ssl/test-client.key",
"spring.mail.properties.mail.pop3.host:" + mailpit.getHost(),
"spring.mail.properties.mail.pop3.port:" + mailpit.getPop3Port())
.run((context) -> {
JavaMailSenderImpl mailSender = context.getBean(JavaMailSenderImpl.class);
assertThatException().isThrownBy(() -> mailSender.send(createMessage("Should fail")))
.withRootCauseInstanceOf(SSLException.class);
});
}
@Test
void sendEmailWithStarttlsWithoutCert() {
this.contextRunner
.withPropertyValues("spring.mail.host:" + mailpit.getHost(),
"spring.mail.port:" + mailpit.getSmtpPort(),
"spring.mail.properties.mail.smtp.starttls.enable:true",
"spring.mail.properties.mail.smtp.starttls.required:true")
.run((context) -> {
JavaMailSenderImpl mailSender = context.getBean(JavaMailSenderImpl.class);
assertThatException().isThrownBy(() -> mailSender.send(createMessage("Should fail")))
.withRootCauseInstanceOf(CertPathBuilderException.class);
});
}
}
}

View File

@ -0,0 +1,32 @@
-----BEGIN CERTIFICATE-----
MIIFhjCCA26gAwIBAgIUfIkk29IT9OpbgfjL8oRIPSLjUcAwDQYJKoZIhvcNAQEL
BQAwOzEZMBcGA1UECgwQU3ByaW5nIEJvb3QgVGVzdDEeMBwGA1UEAwwVQ2VydGlm
aWNhdGUgQXV0aG9yaXR5MB4XDTI0MDUwMTE2NTMyNVoXDTM0MDQyOTE2NTMyNVow
OzEZMBcGA1UECgwQU3ByaW5nIEJvb3QgVGVzdDEeMBwGA1UEAwwVQ2VydGlmaWNh
dGUgQXV0aG9yaXR5MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAusN2
KzQQUUxZSiI3ZZuZohFwq2KXSUNPdJ6rgD3/YKNTDSZXKZPO53kYPP0DXf0sm3CH
cyWSWVabyimZYuPWena1MElSL4ZpJ9WwkZoOQ3bPFK1utz6kMOwrgAUcky8H/rIK
j2JEBhkSHUIGr57Nj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qtboCAi
Y+doqNsCgYBE1yqmBJbZDuqfiCF2KduyA0lcmWzpIEdNw1h2ZIrwwup7dj1O2t8Y
V4lx2TdsBF4vLwli+XKRvCcovMpZaaQC70bLhSnmMxS9uS3OY+HTNTORqQfx+oLJ
1DU8Mf1b0A08LjTbLhijkASAkOuoFehMq66NR3OXIyGz2fGnHYUN+QKBgCC47SL2
X/hl7PIWVoIef/FtcXXqRKLRiPUGhA3zUwZT38K7rvSpItSPDN4UTAHFywxfEdnb
YFd0Mk6Y8aKgS8+9ynoGnzAaaJXRvKmeKdBQQvlSbNpzcnHy/IylG2xF6dfuOA7Q
MYKmk+Nc8PDPzIveIYMU58MHFn8hm12YaKOpAoGAV1CE8hFkEK9sbRGoKNJkx9nm
CZTv7PybaG/RN4ZrBSwVmnER0FEagA/Tzrlp1pi3sC8ZsC9onSOf6Btq8ZE0zbO1
vsAm3gTBXcrCJxzw0Wjt8pzEbk3yELm4WE6VDEx4da2jWocdspslpIwdjHnPwsbH
r5O3ZAgigZs/ZtKW/U4=
-----END PRIVATE KEY-----

View File

@ -76,6 +76,11 @@ public class MailProperties {
*/
private String jndiName;
/**
* SSL configuration.
*/
private final Ssl ssl = new Ssl();
public String getHost() {
return this.host;
}
@ -136,4 +141,45 @@ public class MailProperties {
return this.jndiName;
}
public Ssl getSsl() {
return this.ssl;
}
public static class Ssl {
/**
* Whether to enable SSL support. If enabled, {@code mail.<protocol>.ssl.enable}
* property is set to {@code true}.
*/
private boolean enabled = false;
/**
* SSL bundle name. If not null, {@code mail.<protocol>.ssl.socketFactory}
* property is set to a {@code SSLSocketFactory} obtained from the corresponding
* SSL bundle.
* <p>
* Note that the {@code STARTTLS} command can use the corresponding
* {@code SSLSocketFactory}, even if {@code mail.<protocol>.ssl.enable} property
* is not set.
*/
private String bundle;
public boolean isEnabled() {
return this.enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public String getBundle() {
return this.bundle;
}
public void setBundle(String bundle) {
this.bundle = bundle;
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,13 +19,18 @@ package org.springframework.boot.autoconfigure.mail;
import java.util.Map;
import java.util.Properties;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.mail.MailProperties.Ssl;
import org.springframework.boot.ssl.SslBundle;
import org.springframework.boot.ssl.SslBundles;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.MailSender;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.util.StringUtils;
/**
* Auto-configure a {@link MailSender} based on properties configuration.
@ -40,13 +45,13 @@ class MailSenderPropertiesConfiguration {
@Bean
@ConditionalOnMissingBean(JavaMailSender.class)
JavaMailSenderImpl mailSender(MailProperties properties) {
JavaMailSenderImpl mailSender(MailProperties properties, ObjectProvider<SslBundles> sslBundles) {
JavaMailSenderImpl sender = new JavaMailSenderImpl();
applyProperties(properties, sender);
applyProperties(properties, sender, sslBundles.getIfAvailable());
return sender;
}
private void applyProperties(MailProperties properties, JavaMailSenderImpl sender) {
private void applyProperties(MailProperties properties, JavaMailSenderImpl sender, SslBundles sslBundles) {
sender.setHost(properties.getHost());
if (properties.getPort() != null) {
sender.setPort(properties.getPort());
@ -57,8 +62,22 @@ class MailSenderPropertiesConfiguration {
if (properties.getDefaultEncoding() != null) {
sender.setDefaultEncoding(properties.getDefaultEncoding().name());
}
if (!properties.getProperties().isEmpty()) {
sender.setJavaMailProperties(asProperties(properties.getProperties()));
Properties javaMailProperties = asProperties(properties.getProperties());
String protocol = properties.getProtocol();
if (!StringUtils.hasLength(protocol)) {
protocol = "smtp";
}
Ssl ssl = properties.getSsl();
if (ssl.isEnabled()) {
javaMailProperties.setProperty("mail." + protocol + ".ssl.enable", "true");
}
if (ssl.getBundle() != null) {
SslBundle sslBundle = sslBundles.getBundle(ssl.getBundle());
javaMailProperties.put("mail." + protocol + ".ssl.socketFactory",
sslBundle.createSslContext().getSocketFactory());
}
if (!javaMailProperties.isEmpty()) {
sender.setJavaMailProperties(javaMailProperties);
}
}

View File

@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.mail;
import java.util.Properties;
import javax.naming.Context;
import javax.net.ssl.SSLSocketFactory;
import jakarta.mail.Session;
import org.junit.jupiter.api.AfterEach;
@ -29,6 +30,7 @@ import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.jndi.JndiPropertiesHidingClassLoader;
import org.springframework.boot.autoconfigure.jndi.TestableInitialContextFactory;
import org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -49,8 +51,9 @@ import static org.mockito.Mockito.never;
*/
class MailSenderAutoConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner().withConfiguration(
AutoConfigurations.of(MailSenderAutoConfiguration.class, MailSenderValidatorAutoConfiguration.class));
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(MailSenderAutoConfiguration.class,
MailSenderValidatorAutoConfiguration.class, SslAutoConfiguration.class));
private ClassLoader threadContextClassLoader;
@ -240,6 +243,61 @@ class MailSenderAutoConfigurationTests {
});
}
@Test
void smtpSslEnabled() {
this.contextRunner.withPropertyValues("spring.mail.host:localhost", "spring.mail.ssl.enabled:true")
.run((context) -> {
assertThat(context).hasSingleBean(JavaMailSenderImpl.class);
JavaMailSenderImpl mailSender = context.getBean(JavaMailSenderImpl.class);
assertThat(mailSender.getJavaMailProperties()).containsEntry("mail.smtp.ssl.enable", "true");
});
}
@Test
void smtpSslBundle() {
this.contextRunner
.withPropertyValues("spring.mail.host:localhost", "spring.mail.ssl.bundle:test-bundle",
"spring.ssl.bundle.jks.test-bundle.keystore.location:classpath:test.jks",
"spring.ssl.bundle.jks.test-bundle.keystore.password:secret",
"spring.ssl.bundle.jks.test-bundle.key.password:password")
.run((context) -> {
assertThat(context).hasSingleBean(JavaMailSenderImpl.class);
JavaMailSenderImpl mailSender = context.getBean(JavaMailSenderImpl.class);
assertThat(mailSender.getJavaMailProperties()).doesNotContainKey("mail.smtp.ssl.enable");
Object property = mailSender.getJavaMailProperties().get("mail.smtp.ssl.socketFactory");
assertThat(property).isInstanceOf(SSLSocketFactory.class);
});
}
@Test
void smtpsSslEnabled() {
this.contextRunner
.withPropertyValues("spring.mail.host:localhost", "spring.mail.protocol:smtps",
"spring.mail.ssl.enabled:true")
.run((context) -> {
assertThat(context).hasSingleBean(JavaMailSenderImpl.class);
JavaMailSenderImpl mailSender = context.getBean(JavaMailSenderImpl.class);
assertThat(mailSender.getJavaMailProperties()).containsEntry("mail.smtps.ssl.enable", "true");
});
}
@Test
void smtpsSslBundle() {
this.contextRunner
.withPropertyValues("spring.mail.host:localhost", "spring.mail.protocol:smtps",
"spring.mail.ssl.bundle:test-bundle",
"spring.ssl.bundle.jks.test-bundle.keystore.location:classpath:test.jks",
"spring.ssl.bundle.jks.test-bundle.keystore.password:secret",
"spring.ssl.bundle.jks.test-bundle.key.password:password")
.run((context) -> {
assertThat(context).hasSingleBean(JavaMailSenderImpl.class);
JavaMailSenderImpl mailSender = context.getBean(JavaMailSenderImpl.class);
assertThat(mailSender.getJavaMailProperties()).doesNotContainKey("mail.smtps.ssl.enable");
Object property = mailSender.getJavaMailProperties().get("mail.smtps.ssl.socketFactory");
assertThat(property).isInstanceOf(SSLSocketFactory.class);
});
}
private Session configureJndiSession(String name) {
Properties properties = new Properties();
Session session = Session.getDefaultInstance(properties);

View File

@ -0,0 +1,78 @@
/*
* Copyright 2012-2024 the original author or authors.
*
* Licensed 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
*
* https://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.
*/
package org.springframework.boot.testsupport.container;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.utility.DockerImageName;
import org.testcontainers.utility.MountableFile;
/**
* A {@link GenericContainer} for MailDev.
*
* @author Rui Figueira
*/
public class MailpitContainer extends GenericContainer<MailpitContainer> {
private static final int DEFAULT_SMTP_PORT = 1025;
private static final int DEFAULT_POP3_PORT = 1110;
public MailpitContainer(DockerImageName dockerImageName) {
super(dockerImageName);
addExposedPorts(DEFAULT_SMTP_PORT, DEFAULT_POP3_PORT);
}
public int getSmtpPort() {
return getMappedPort(DEFAULT_SMTP_PORT);
}
public int getPop3Port() {
return getMappedPort(DEFAULT_POP3_PORT);
}
public MailpitContainer withSmtpTlsCert(MountableFile cert) {
this.withCopyFileToContainer(cert, "/tmp/ssl/public.crt");
this.withEnv("MP_SMTP_TLS_CERT", "/tmp/ssl/public.crt");
return this.self();
}
public MailpitContainer withSmtpTlsKey(MountableFile key) {
this.withCopyFileToContainer(key, "/tmp/ssl/private.key");
this.withEnv("MP_SMTP_TLS_KEY", "/tmp/ssl/private.key");
return this.self();
}
public MailpitContainer withSmtpRequireTls(boolean requireTls) {
if (requireTls) {
this.withEnv("MP_SMTP_REQUIRE_TLS", "true");
}
return this.self();
}
public MailpitContainer withSmtpRequireStarttls(boolean requireStarttls) {
if (requireStarttls) {
this.withEnv("MP_SMTP_REQUIRE_STARTTLS", "true");
}
return this.self();
}
public MailpitContainer withPop3Auth(String... auths) {
this.withEnv("MP_POP3_AUTH", String.join(" ", auths));
return this.self();
}
}

View File

@ -110,6 +110,11 @@ public enum TestImage {
*/
OPEN_LDAP("osixia/openldap", "1.5.0", () -> OpenLdapContainer.class),
/**
* A container image suitable for testing SMTP.
*/
MAILPIT("axllent/mailpit", "v1.19.0", () -> MailpitContainer.class),
/**
* A container image suitable for testing MariaDB.
*/