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 4482cabeafb8b43957bfa6656e6817f2db996c94
Author: Benoit Tellier <btell...@linagora.com>
AuthorDate: Fri Aug 30 11:35:57 2019 +0700

    JAMES-2442 RemoteDelivery should not retry 5xx error codes
---
 .../james/mailets/RemoteDeliveryErrorTest.java     | 66 ++++++++++++++++++++++
 1 file changed, 66 insertions(+)

diff --git 
a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RemoteDeliveryErrorTest.java
 
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RemoteDeliveryErrorTest.java
index 5161a56..2f81bc4 100644
--- 
a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RemoteDeliveryErrorTest.java
+++ 
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RemoteDeliveryErrorTest.java
@@ -77,6 +77,24 @@ public class RemoteDeliveryErrorTest {
         "  \"response\": {\"code\":421, \"message\":\"mock response\", 
\"rejected\":true}," +
         "  \"command\": \"DATA\"" +
         "}]";
+    private static final String SINGLE_500_RCPT_BEHAVIOR = "[{" +
+        "  \"condition\": {\"operator\":\"matchAll\"}," +
+        "  \"response\": {\"code\":521, \"message\":\"mock response\", 
\"rejected\":true}," +
+        "  \"command\": \"RCPT TO\"," +
+        "  \"numberOfAnswer\": 1" +
+        "}]";
+    private static final String SINGLE_500_FROM_BEHAVIOR = "[{" +
+        "  \"condition\": {\"operator\":\"matchAll\"}," +
+        "  \"response\": {\"code\":521, \"message\":\"mock response\", 
\"rejected\":true}," +
+        "  \"command\": \"MAIL FROM\"," +
+        "  \"numberOfAnswer\": 1" +
+        "}]";
+    private static final String SINGLE_500_DATA_BEHAVIOR = "[{" +
+        "  \"condition\": {\"operator\":\"matchAll\"}," +
+        "  \"response\": {\"code\":521, \"message\":\"mock response\", 
\"rejected\":true}," +
+        "  \"command\": \"DATA\"," +
+        "  \"numberOfAnswer\": 1" +
+        "}]";
     private static final String BOUNCE_MESSAGE = "Hi. This is the James mail 
server at localhost.\n" +
         "I'm afraid I wasn't able to deliver your message to the following 
addresses.\n" +
         "This is a permanent error; I've given up. Sorry it didn't work out. 
Below\n" +
@@ -171,6 +189,54 @@ public class RemoteDeliveryErrorTest {
         
assertThat(imapMessageReader.readFirstMessage()).contains(BOUNCE_MESSAGE);
     }
 
+    @Test
+    public void remoteDeliveryShouldNotRetryWHenRCPT500() throws Exception {
+        given(requestSpecification())
+            .body(SINGLE_500_RCPT_BEHAVIOR)
+            .put("/smtpBehaviors");
+
+        messageSender.connect(LOCALHOST_IP, 
jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort())
+            .sendMessage(FROM, RECIPIENT);
+
+        imapMessageReader.connect(LOCALHOST_IP, 
jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
+            .login(FROM, PASSWORD)
+            .select(IMAPMessageReader.INBOX)
+            .awaitMessage(awaitAtMostOneMinute);
+        
assertThat(imapMessageReader.readFirstMessage()).contains(BOUNCE_MESSAGE);
+    }
+
+    @Test
+    public void remoteDeliveryShouldNotRetryWHenFROM500() throws Exception {
+        given(requestSpecification())
+            .body(SINGLE_500_FROM_BEHAVIOR)
+            .put("/smtpBehaviors");
+
+        messageSender.connect(LOCALHOST_IP, 
jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort())
+            .sendMessage(FROM, RECIPIENT);
+
+        imapMessageReader.connect(LOCALHOST_IP, 
jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
+            .login(FROM, PASSWORD)
+            .select(IMAPMessageReader.INBOX)
+            .awaitMessage(awaitAtMostOneMinute);
+        
assertThat(imapMessageReader.readFirstMessage()).contains(BOUNCE_MESSAGE);
+    }
+
+    @Test
+    public void remoteDeliveryShouldNotRetryWHenDATA500() throws Exception {
+        given(requestSpecification())
+            .body(SINGLE_500_DATA_BEHAVIOR)
+            .put("/smtpBehaviors");
+
+        messageSender.connect(LOCALHOST_IP, 
jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort())
+            .sendMessage(FROM, RECIPIENT);
+
+        imapMessageReader.connect(LOCALHOST_IP, 
jamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
+            .login(FROM, PASSWORD)
+            .select(IMAPMessageReader.INBOX)
+            .awaitMessage(awaitAtMostOneMinute);
+        
assertThat(imapMessageReader.readFirstMessage()).contains(BOUNCE_MESSAGE);
+    }
+
     private ProcessorConfiguration.Builder directResolutionTransport() {
         return ProcessorConfiguration.transport()
             .addMailet(MailetConfiguration.BCC_STRIPPER)


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

Reply via email to