JAMES-2642 add a few more alias mapping integration tests
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/1819ae1c Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/1819ae1c Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/1819ae1c Branch: refs/heads/master Commit: 1819ae1cbdf2b91e1a74ee4bbd7d2cba6a13240f Parents: a0793f5 Author: Rene Cordier <rcord...@linagora.com> Authored: Wed Jan 16 15:06:30 2019 +0700 Committer: Benoit Tellier <btell...@linagora.com> Committed: Thu Jan 17 13:49:10 2019 +0700 ---------------------------------------------------------------------- .../transport/mailets/AliasMappingTest.java | 56 ++++++++++++++++++++ 1 file changed, 56 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/1819ae1c/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AliasMappingTest.java ---------------------------------------------------------------------- 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 45f4a2f..e400712 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 @@ -136,6 +136,7 @@ public class AliasMappingTest { jamesServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, BOB_ADDRESS, "INBOX"); jamesServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, ALICE_ADDRESS, "INBOX"); + jamesServer.getProbe(MailboxProbeImpl.class).createMailbox(MailboxConstants.USER_NAMESPACE, CEDRIC_ADDRESS, "INBOX"); WebAdminGuiceProbe webAdminGuiceProbe = jamesServer.getProbe(WebAdminGuiceProbe.class); webAdminGuiceProbe.await(); @@ -285,4 +286,59 @@ public class AliasMappingTest { } + @Test + public void messageShouldRedirectFromAliasContainingSlash() throws Exception { + String aliasWithSlash = "bob/alias@" + DOMAIN; + String aliasWithEncodedSlash = "bob%2Falias@" + DOMAIN; + webAdminApi.put(AliasRoutes.ROOT_PATH + "/" + BOB_ADDRESS + "/sources/" + aliasWithEncodedSlash); + + messageSender.connect(LOCALHOST_IP, jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort()) + .sendMessage(FakeMail.builder() + .mimeMessage(message) + .sender(ALICE_ADDRESS) + .recipient(aliasWithSlash)); + + imapMessageReader.connect(LOCALHOST_IP, jamesServer.getProbe(ImapGuiceProbe.class).getImapPort()) + .login(BOB_ADDRESS, PASSWORD) + .select(IMAPMessageReader.INBOX) + .awaitMessage(awaitAtMostOneMinute); + } + + @Test + public void messageShouldRedirectToUserContainingSlash() throws Exception { + String userWithSlash = "bob/a@" + DOMAIN; + dataProbe.addUser(userWithSlash, PASSWORD); + String userWithEncodedSlash = "bob%2Fa@" + DOMAIN; + webAdminApi.put(AliasRoutes.ROOT_PATH + "/" + userWithEncodedSlash + "/sources/" + BOB_ALIAS); + + messageSender.connect(LOCALHOST_IP, jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort()) + .sendMessage(FakeMail.builder() + .mimeMessage(message) + .sender(ALICE_ADDRESS) + .recipient(BOB_ALIAS)); + + imapMessageReader.connect(LOCALHOST_IP, jamesServer.getProbe(ImapGuiceProbe.class).getImapPort()) + .login(userWithSlash, PASSWORD) + .select(IMAPMessageReader.INBOX) + .awaitMessage(awaitAtMostOneMinute); + } + + @Test + public void messageShouldRedirectToUserWhenEncodingAt() throws Exception { + String userWithEncodedAt = "bob%40" + DOMAIN; + String aliasWithEncodedAt = "bob-alias%40" + DOMAIN; + webAdminApi.put(AliasRoutes.ROOT_PATH + "/" + userWithEncodedAt + "/sources/" + aliasWithEncodedAt); + + messageSender.connect(LOCALHOST_IP, jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort()) + .sendMessage(FakeMail.builder() + .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); + } + } --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org