You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2023/06/14 06:59:45 UTC

[james-project] 23/28: JAMES-3914 Sieve Redirect: support several recipients

This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch 3.8.x
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit e4fe48829088789b6cfe852d2e533b2778302ef7
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Jun 12 16:00:24 2023 +0700

    JAMES-3914 Sieve Redirect: support several recipients
---
 .../mailets/delivery/SieveIntegrationTest.java       | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SieveIntegrationTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SieveIntegrationTest.java
index 2b7bd165ae..8ea6611774 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SieveIntegrationTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/SieveIntegrationTest.java
@@ -463,6 +463,26 @@ class SieveIntegrationTest {
             .containsExactly(expectedSentMail);
     }
 
+    @Test
+    void redirectShouldWorkWhenSeveralRecipients() throws Exception {
+        prepareTestUsingScript("org/apache/james/transport/mailets/delivery/redirect.script");
+        when(usersRepository.getUsername(new MailAddress("other@domain.tld"))).thenReturn(Username.of("other@domain.tld"));
+        when(resourceLocator.get(new MailAddress("other@domain.tld"))).thenThrow(new ScriptNotFoundException());
+
+        FakeMail mail = createMail();
+        mail.setRecipients(ImmutableList.of(new MailAddress(RECEIVER_DOMAIN_COM), new MailAddress("other@domain.tld")));
+        testee.service(mail);
+
+        assertThat(mail.getRecipients()).containsOnly(new MailAddress("other@domain.tld"));
+        FakeMailContext.SentMail expectedSentMail = FakeMailContext.sentMailBuilder()
+            .sender("sender@any.com")
+            .recipient(new MailAddress("redirect@apache.org"))
+            .fromMailet()
+            .build();
+        assertThat(fakeMailContext.getSentMails())
+            .containsExactly(expectedSentMail);
+    }
+
     @Test
     void addressCcAllShouldNotMatchOtherHeaders() throws Exception {
         prepareTestUsingScript("org/apache/james/transport/mailets/delivery/addressAllCc.script");


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org