You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ad...@apache.org on 2017/09/13 10:57:48 UTC
[22/24] james-project git commit: JAMES-2139 More IT function for RRT
with domain mapping
JAMES-2139 More IT function for RRT with domain mapping
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/3b5180de
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/3b5180de
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/3b5180de
Branch: refs/heads/master
Commit: 3b5180de4a7bd3db411f156c92d7d9cfc81d3e5a
Parents: 8706796
Author: quynhn <qn...@linagora.com>
Authored: Mon Sep 11 12:04:40 2017 +0700
Committer: Antoine Duprat <ad...@linagora.com>
Committed: Wed Sep 13 10:23:34 2017 +0200
----------------------------------------------------------------------
.../RecipientRewriteTableIntegrationTest.java | 36 +++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/3b5180de/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java
index 75ae12d..931fdfe 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java
@@ -25,8 +25,8 @@ import org.apache.james.mailets.configuration.MailetContainer;
import org.apache.james.utils.SMTPMessageSender;
import org.apache.james.modules.MailboxProbeImpl;
import org.apache.james.probe.DataProbe;
-import org.apache.james.utils.IMAPMessageReader;
import org.apache.james.utils.DataProbeImpl;
+import org.apache.james.utils.IMAPMessageReader;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -44,6 +44,7 @@ public class RecipientRewriteTableIntegrationTest {
private static final String PASSWORD = "secret";
private static final String JAMES_APACHE_ORG = "james.org";
+ private static final String JAMES_ANOTHER_DOMAIN = "james.com";
private static final String FROM = "fromUser@" + JAMES_APACHE_ORG;
private static final String RECIPIENT = "touser@" + JAMES_APACHE_ORG;
@@ -51,6 +52,8 @@ public class RecipientRewriteTableIntegrationTest {
private static final String ANY_AT_JAMES = "any@" + JAMES_APACHE_ORG;
private static final String OTHER_AT_JAMES = "other@" + JAMES_APACHE_ORG;
+ private static final String ANY_AT_ANOTHER_DOMAIN = "any@" + JAMES_ANOTHER_DOMAIN;
+
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@@ -80,6 +83,7 @@ public class RecipientRewriteTableIntegrationTest {
dataProbe = jamesServer.getProbe(DataProbeImpl.class);
dataProbe.addDomain(JAMES_APACHE_ORG);
+ dataProbe.addDomain(JAMES_ANOTHER_DOMAIN);
}
@After
@@ -149,6 +153,36 @@ public class RecipientRewriteTableIntegrationTest {
}
}
+ @Test
+ public void messageShouldRedirectToTheSameUserWhenDomainMapping() throws Exception {
+ dataProbe.addDomainAliasMapping(JAMES_APACHE_ORG, JAMES_ANOTHER_DOMAIN);
+
+ createUserInbox(ANY_AT_JAMES);
+ createUserInbox(ANY_AT_ANOTHER_DOMAIN);
+
+ try (SMTPMessageSender messageSender = SMTPMessageSender.noAuthentication(LOCALHOST_IP, SMTP_PORT, JAMES_APACHE_ORG);
+ IMAPMessageReader imapMessageReader = new IMAPMessageReader(LOCALHOST_IP, IMAP_PORT)) {
+ messageSender.sendMessage(FROM, ANY_AT_JAMES);
+ calmlyAwait.atMost(Duration.ONE_MINUTE).until(messageSender::messageHasBeenSent);
+ calmlyAwait.atMost(Duration.ONE_MINUTE).until(() -> imapMessageReader.userReceivedMessage(ANY_AT_ANOTHER_DOMAIN, PASSWORD));
+ }
+ }
+
+ @Test
+ public void messageShouldNotSendToRecipientWhenDomainMapping() throws Exception {
+ dataProbe.addDomainAliasMapping(JAMES_APACHE_ORG, JAMES_ANOTHER_DOMAIN);
+
+ createUserInbox(ANY_AT_JAMES);
+ createUserInbox(ANY_AT_ANOTHER_DOMAIN);
+
+ try (SMTPMessageSender messageSender = SMTPMessageSender.noAuthentication(LOCALHOST_IP, SMTP_PORT, JAMES_APACHE_ORG);
+ IMAPMessageReader imapMessageReader = new IMAPMessageReader(LOCALHOST_IP, IMAP_PORT)) {
+ messageSender.sendMessage(FROM, ANY_AT_JAMES);
+ calmlyAwait.atMost(Duration.ONE_MINUTE).until(messageSender::messageHasBeenSent);
+ calmlyAwait.atMost(Duration.ONE_MINUTE).until(() -> imapMessageReader.userDoesNotReceiveMessage(ANY_AT_JAMES, PASSWORD));
+ }
+ }
+
private void createUserInbox(String username) throws Exception {
dataProbe.addUser(username, PASSWORD);
jamesServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX");
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org