You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2021/01/18 03:25:19 UTC
[james-project] 02/03: JAMES-3489 Add integration test showing the
behavior of ValidRcptHandler in case of LDAP server not available
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 6480d63e7df55b046d7fb1270cb4e830eaf17344
Author: Raphael Ouazana <ra...@linagora.com>
AuthorDate: Thu Jan 14 17:30:04 2021 +0100
JAMES-3489 Add integration test showing the behavior of ValidRcptHandler in case of LDAP server not available
---
.../org/apache/james/CassandraLdapJamesServerTest.java | 17 ++++++++++++++++-
.../src/test/java/org/apache/james/DockerLdapRule.java | 1 +
.../test/java/org/apache/james/LdapTestExtension.java | 4 ++++
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/server/container/guice/cassandra-ldap-guice/src/test/java/org/apache/james/CassandraLdapJamesServerTest.java b/server/container/guice/cassandra-ldap-guice/src/test/java/org/apache/james/CassandraLdapJamesServerTest.java
index 35f7306..95f84da 100644
--- a/server/container/guice/cassandra-ldap-guice/src/test/java/org/apache/james/CassandraLdapJamesServerTest.java
+++ b/server/container/guice/cassandra-ldap-guice/src/test/java/org/apache/james/CassandraLdapJamesServerTest.java
@@ -22,6 +22,7 @@ package org.apache.james;
import static org.apache.james.user.ldap.DockerLdapSingleton.JAMES_USER;
import static org.apache.james.user.ldap.DockerLdapSingleton.PASSWORD;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.awaitility.Duration.ONE_HUNDRED_MILLISECONDS;
import org.apache.commons.net.imap.IMAPClient;
@@ -30,6 +31,7 @@ import org.apache.james.modules.TestJMAPServerModule;
import org.apache.james.modules.protocols.ImapGuiceProbe;
import org.apache.james.modules.protocols.SmtpGuiceProbe;
import org.apache.james.utils.SMTPMessageSender;
+import org.apache.james.utils.SMTPSendingException;
import org.apache.james.utils.SpoolerProbe;
import org.apache.james.utils.TestIMAPClient;
import org.awaitility.Awaitility;
@@ -51,12 +53,13 @@ class CassandraLdapJamesServerTest implements JamesServerContract {
@RegisterExtension
TestIMAPClient testIMAPClient = new TestIMAPClient();
SMTPMessageSender messageSender = new SMTPMessageSender(Domain.LOCALHOST.asString());
+ static LdapTestExtension ldap = new LdapTestExtension();
@RegisterExtension
static JamesServerExtension testExtension = TestingDistributedJamesServerBuilder.withSearchConfiguration(SearchConfiguration.elasticSearch())
.extension(new DockerElasticSearchExtension())
.extension(new CassandraExtension())
- .extension(new LdapTestExtension())
+ .extension(ldap)
.server(configuration -> CassandraLdapJamesServerMain.createServer(configuration)
.overrideWith(new TestJMAPServerModule()))
.build();
@@ -80,4 +83,16 @@ class CassandraLdapJamesServerTest implements JamesServerContract {
.select("INBOX")
.awaitMessage(calmlyAwait);
}
+
+ @Test
+ void receivingMailShouldIssueAnSmtpErrorWhenLdapIsNotAvailable(GuiceJamesServer server) {
+ try {
+ ldap.getLdapRule().stop();
+ assertThatThrownBy(() -> messageSender.connect(JAMES_SERVER_HOST, server.getProbe(SmtpGuiceProbe.class).getSmtpPort())
+ .sendMessage("bob@any.com", JAMES_USER.asString() + "@localhost"))
+ .isInstanceOf(SMTPSendingException.class);
+ } finally {
+ ldap.getLdapRule().start();
+ }
+ }
}
diff --git a/server/container/guice/cassandra-ldap-guice/src/test/java/org/apache/james/DockerLdapRule.java b/server/container/guice/cassandra-ldap-guice/src/test/java/org/apache/james/DockerLdapRule.java
index 0c96b67..96f937f 100644
--- a/server/container/guice/cassandra-ldap-guice/src/test/java/org/apache/james/DockerLdapRule.java
+++ b/server/container/guice/cassandra-ldap-guice/src/test/java/org/apache/james/DockerLdapRule.java
@@ -64,5 +64,6 @@ public class DockerLdapRule implements GuiceModuleTestRule {
}
public void stop() {
+ DockerLdapSingleton.ldapContainer.stop();
}
}
diff --git a/server/container/guice/cassandra-ldap-guice/src/test/java/org/apache/james/LdapTestExtension.java b/server/container/guice/cassandra-ldap-guice/src/test/java/org/apache/james/LdapTestExtension.java
index 8ac99fc..a468116 100644
--- a/server/container/guice/cassandra-ldap-guice/src/test/java/org/apache/james/LdapTestExtension.java
+++ b/server/container/guice/cassandra-ldap-guice/src/test/java/org/apache/james/LdapTestExtension.java
@@ -49,4 +49,8 @@ public class LdapTestExtension implements GuiceModuleTestExtension {
public Module getModule() {
return ldapRule.getModule();
}
+
+ public DockerLdapRule getLdapRule() {
+ return ldapRule;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org