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 bt...@apache.org on 2019/10/08 04:17:05 UTC

[james-project] 01/03: JAMES-2913 RemoteDelivery do not handle PerRecipientsHeaders

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

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

commit 7a32cd3b8e9b2846816356457071146f0027018e
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Oct 7 12:42:21 2019 +0700

    JAMES-2913 RemoteDelivery do not handle PerRecipientsHeaders
---
 ...ectResolutionRemoteDeliveryIntegrationTest.java | 56 ++++++++++++++++------
 1 file changed, 42 insertions(+), 14 deletions(-)

diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/DirectResolutionRemoteDeliveryIntegrationTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/DirectResolutionRemoteDeliveryIntegrationTest.java
index 964f41a..71e345e 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/DirectResolutionRemoteDeliveryIntegrationTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/DirectResolutionRemoteDeliveryIntegrationTest.java
@@ -36,11 +36,11 @@ import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.api.InMemoryDNSService;
 import org.apache.james.mailets.configuration.CommonProcessors;
 import org.apache.james.mailets.configuration.MailetConfiguration;
-import org.apache.james.mailets.configuration.MailetContainer;
 import org.apache.james.mailets.configuration.ProcessorConfiguration;
 import org.apache.james.modules.protocols.ImapGuiceProbe;
 import org.apache.james.modules.protocols.SmtpGuiceProbe;
 import org.apache.james.probe.DataProbe;
+import org.apache.james.transport.mailets.AddDeliveredToHeader;
 import org.apache.james.transport.matchers.All;
 import org.apache.james.utils.DataProbeImpl;
 import org.apache.james.utils.FakeSmtp;
@@ -48,6 +48,7 @@ import org.apache.james.utils.IMAPMessageReader;
 import org.apache.james.utils.SMTPMessageSender;
 import org.junit.After;
 import org.junit.ClassRule;
+import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
@@ -96,9 +97,7 @@ public class DirectResolutionRemoteDeliveryIntegrationTest {
         jamesServer = TemporaryJamesServer.builder()
             .withBase(SMTP_ONLY_MODULE)
             .withOverrides(binder -> binder.bind(DNSService.class).toInstance(inMemoryDNSService))
-            .withMailetContainer(MailetContainer.builder()
-                .putProcessor(CommonProcessors.simpleRoot())
-                .putProcessor(CommonProcessors.error())
+            .withMailetContainer(TemporaryJamesServer.SIMPLE_MAILET_CONTAINER_CONFIGURATION
                 .putProcessor(directResolutionTransport())
                 .putProcessor(CommonProcessors.bounces()))
             .build(temporaryFolder.newFolder());
@@ -124,9 +123,7 @@ public class DirectResolutionRemoteDeliveryIntegrationTest {
         jamesServer = TemporaryJamesServer.builder()
             .withBase(SMTP_ONLY_MODULE)
             .withOverrides(binder -> binder.bind(DNSService.class).toInstance(inMemoryDNSService))
-            .withMailetContainer(MailetContainer.builder()
-                .putProcessor(CommonProcessors.simpleRoot())
-                .putProcessor(CommonProcessors.error())
+            .withMailetContainer(TemporaryJamesServer.SIMPLE_MAILET_CONTAINER_CONFIGURATION
                 .putProcessor(directResolutionTransport())
                 .putProcessor(CommonProcessors.bounces()))
             .build(temporaryFolder.newFolder());
@@ -150,9 +147,7 @@ public class DirectResolutionRemoteDeliveryIntegrationTest {
         jamesServer = TemporaryJamesServer.builder()
             .withBase(SMTP_AND_IMAP_MODULE)
             .withOverrides(binder -> binder.bind(DNSService.class).toInstance(inMemoryDNSService))
-            .withMailetContainer(MailetContainer.builder()
-                .putProcessor(CommonProcessors.simpleRoot())
-                .putProcessor(CommonProcessors.error())
+            .withMailetContainer(TemporaryJamesServer.SIMPLE_MAILET_CONTAINER_CONFIGURATION
                 .putProcessor(transport())
                 .putProcessor(CommonProcessors.bounces()))
             .build(temporaryFolder.newFolder());
@@ -178,9 +173,7 @@ public class DirectResolutionRemoteDeliveryIntegrationTest {
         jamesServer = TemporaryJamesServer.builder()
             .withBase(SMTP_AND_IMAP_MODULE)
             .withOverrides(binder -> binder.bind(DNSService.class).toInstance(inMemoryDNSService))
-            .withMailetContainer(MailetContainer.builder()
-                .putProcessor(CommonProcessors.simpleRoot())
-                .putProcessor(CommonProcessors.error())
+            .withMailetContainer(TemporaryJamesServer.SIMPLE_MAILET_CONTAINER_CONFIGURATION
                 .putProcessor(transport())
                 .putProcessor(CommonProcessors.bounces()))
             .build(temporaryFolder.newFolder());
@@ -198,6 +191,42 @@ public class DirectResolutionRemoteDeliveryIntegrationTest {
             .awaitMessage(awaitAtMostOneMinute);
     }
 
+    @Ignore("JAMES-2913 PerRecipientHeaders are not handled by RemoteDelivery")
+    @Test
+    public void remoteDeliveryShouldAddPerRecipientHeaders() throws Exception {
+        InMemoryDNSService inMemoryDNSService = new InMemoryDNSService()
+            .registerMxRecord(JAMES_ANOTHER_DOMAIN, fakeSmtp.getContainer().getContainerIp());
+
+        jamesServer = TemporaryJamesServer.builder()
+            .withBase(SMTP_AND_IMAP_MODULE)
+            .withOverrides(binder -> binder.bind(DNSService.class).toInstance(inMemoryDNSService))
+            .withMailetContainer(TemporaryJamesServer.SIMPLE_MAILET_CONTAINER_CONFIGURATION
+                .putProcessor(ProcessorConfiguration.transport()
+                    .addMailet(MailetConfiguration.BCC_STRIPPER)
+                    .addMailet(LOCAL_DELIVERY)
+                    .addMailet(MailetConfiguration.builder()
+                        .matcher(All.class)
+                        .mailet(AddDeliveredToHeader.class)
+                        .build())
+                    .addMailet(MailetConfiguration.remoteDeliveryBuilder()
+                        .matcher(All.class)))
+                .putProcessor(CommonProcessors.bounces()))
+            .build(temporaryFolder.newFolder());
+
+        dataProbe = jamesServer.getProbe(DataProbeImpl.class);
+        dataProbe.addDomain(DEFAULT_DOMAIN);
+        dataProbe.addUser(FROM, PASSWORD);
+
+        messageSender.connect(LOCALHOST_IP, jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort())
+            .sendMessage(FROM, RECIPIENT);
+
+        awaitAtMostOneMinute
+            .untilAsserted(this::assertMessageReceivedByTheSmtpServer);
+
+        fakeSmtp.assertEmailReceived(response -> response
+            .body("[0].headers.delivered-to", equalTo(FROM)));
+    }
+
     private void assertMessageReceivedByTheSmtpServer() {
         fakeSmtp.assertEmailReceived(response -> response
             .body("", hasSize(1))
@@ -219,5 +248,4 @@ public class DirectResolutionRemoteDeliveryIntegrationTest {
             .addMailet(MailetConfiguration.remoteDeliveryBuilder()
                 .matcher(All.class));
     }
-
 }


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