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 rc...@apache.org on 2019/12/13 11:23:44 UTC
[james-project] branch master updated: JAMES-2642 Add alias mapping
integration test to show that alias delivery is case-insensitive
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
The following commit(s) were added to refs/heads/master by this push:
new 24be076 JAMES-2642 Add alias mapping integration test to show that alias delivery is case-insensitive
24be076 is described below
commit 24be07682c2623923842083ad897e4a4acc79ab6
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Wed Dec 11 10:41:10 2019 +0700
JAMES-2642 Add alias mapping integration test to show that alias delivery is case-insensitive
---
.../james/transport/mailets/AliasMappingTest.java | 56 ++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AliasMappingTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AliasMappingTest.java
index 206ad9f..ab17e76 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AliasMappingTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AliasMappingTest.java
@@ -64,6 +64,7 @@ public class AliasMappingTest {
private static final String CEDRIC_USER = "cedric";
private static final String BOB_ADDRESS = BOB_USER + "@" + DOMAIN;
+ private static final String UPPER_BOB_ADDRESS = BOB_USER.toUpperCase() + "@" + DOMAIN;
private static final String ALICE_ADDRESS = ALICE_USER + "@" + DOMAIN;
private static final String CEDRIC_ADDRESS = CEDRIC_USER + "@" + DOMAIN;
@@ -72,6 +73,7 @@ public class AliasMappingTest {
private static final String BOB_ALIAS = BOB_USER + "-alias@" + DOMAIN;
private static final String BOB_ALIAS_2 = BOB_USER + "-alias2@" + DOMAIN;
+ private static final String UPPER_BOB_ALIAS = BOB_USER.toUpperCase() + "-ALIAS@" + DOMAIN;
private static final String GROUP_ALIAS = GROUP + "-alias@" + DOMAIN;
private static final String MESSAGE_CONTENT = "any text";
@@ -142,6 +144,60 @@ public class AliasMappingTest {
}
@Test
+ public void messageShouldRedirectToUserWhenSentToHisUpperCaseAlias() throws Exception {
+ webAdminApi.put(AliasRoutes.ROOT_PATH + "/" + BOB_ADDRESS + "/sources/" + BOB_ALIAS);
+
+ messageSender.connect(LOCALHOST_IP, jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort())
+ .sendMessage(FakeMail.builder()
+ .name("name")
+ .mimeMessage(message)
+ .sender(ALICE_ADDRESS)
+ .recipient(UPPER_BOB_ALIAS));
+
+ imapMessageReader.connect(LOCALHOST_IP, jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
+ .login(BOB_ADDRESS, PASSWORD)
+ .select(IMAPMessageReader.INBOX)
+ .awaitMessage(awaitAtMostOneMinute);
+ assertThat(imapMessageReader.readFirstMessage()).contains(MESSAGE_CONTENT);
+ }
+
+ @Test
+ public void messageShouldRedirectToUserWhenLowerCaseAliasMappedToUpperCaseUser() throws Exception {
+ webAdminApi.put(AliasRoutes.ROOT_PATH + "/" + UPPER_BOB_ADDRESS + "/sources/" + BOB_ALIAS);
+
+ messageSender.connect(LOCALHOST_IP, jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort())
+ .sendMessage(FakeMail.builder()
+ .name("name")
+ .mimeMessage(message)
+ .sender(ALICE_ADDRESS)
+ .recipient(BOB_ALIAS));
+
+ imapMessageReader.connect(LOCALHOST_IP, jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
+ .login(BOB_ADDRESS, PASSWORD)
+ .select(IMAPMessageReader.INBOX)
+ .awaitMessage(awaitAtMostOneMinute);
+ assertThat(imapMessageReader.readFirstMessage()).contains(MESSAGE_CONTENT);
+ }
+
+ @Test
+ public void messageShouldRedirectToUserWithUpperCaseDefinedAliasWhenSentToHisLowerCaseAlias() throws Exception {
+ webAdminApi.put(AliasRoutes.ROOT_PATH + "/" + BOB_ADDRESS + "/sources/" + UPPER_BOB_ALIAS);
+
+ messageSender.connect(LOCALHOST_IP, jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort())
+ .sendMessage(FakeMail.builder()
+ .name("name")
+ .mimeMessage(message)
+ .sender(ALICE_ADDRESS)
+ .recipient(BOB_ALIAS));
+
+ imapMessageReader.connect(LOCALHOST_IP, jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
+ .login(BOB_ADDRESS, PASSWORD)
+ .select(IMAPMessageReader.INBOX)
+ .awaitMessage(awaitAtMostOneMinute);
+ assertThat(imapMessageReader.readFirstMessage()).contains(MESSAGE_CONTENT);
+ }
+
+ @Test
public void messageShouldRedirectToForwardOfUserWhenSentToHisAlias() throws Exception {
webAdminApi.put(AliasRoutes.ROOT_PATH + "/" + BOB_ADDRESS + "/sources/" + BOB_ALIAS);
webAdminApi.put(ForwardRoutes.ROOT_PATH + "/" + BOB_ADDRESS + "/targets/" + CEDRIC_ADDRESS);
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org