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 2021/05/14 02:04:42 UTC

[james-project] 07/09: JAMES-3574 LMTP DATA should submit a reply by recipient

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 3543fd3d5092fe0d6776194266d6785135d708ad
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Thu May 13 12:26:22 2021 +0700

    JAMES-3574 LMTP DATA should submit a reply by recipient
    
    https://datatracker.ietf.org/doc/html/rfc2033#section-4.2
    
    ```
       [...] the server returns one reply
       for each previously successful RCPT command in the mail transaction,
       in the order that the RCPT commands were issued.  Even if there were
       multiple successful RCPT commands giving the same forward-path, there
       must be one reply for each successful RCPT command.
    ```
    
    Default implementation is compliant with this requirement.
---
 .../apache/james/lmtpserver/LmtpServerTest.java    | 29 ++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/server/protocols/protocols-lmtp/src/test/java/org/apache/james/lmtpserver/LmtpServerTest.java b/server/protocols/protocols-lmtp/src/test/java/org/apache/james/lmtpserver/LmtpServerTest.java
index e624f15..41bb558 100644
--- a/server/protocols/protocols-lmtp/src/test/java/org/apache/james/lmtpserver/LmtpServerTest.java
+++ b/server/protocols/protocols-lmtp/src/test/java/org/apache/james/lmtpserver/LmtpServerTest.java
@@ -130,6 +130,7 @@ class LmtpServerTest {
         domainList.addDomain(Domain.of("examplebis.local"));
         usersRepository = MemoryUsersRepository.withVirtualHosting(domainList);
         usersRepository.addUser(Username.of("bob@examplebis.local"), "pwd");
+        usersRepository.addUser(Username.of("cedric@examplebis.local"), "pwd");
 
         fileSystem = new FileSystemImpl(Configuration.builder()
             .workingDirectory("../")
@@ -340,6 +341,34 @@ class LmtpServerTest {
         }
 
         @Test
+        void dataShouldHaveAReturnCodePerRecipient() throws Exception {
+            SocketChannel server = SocketChannel.open();
+            server.connect(new InetSocketAddress(LOCALHOST_IP, getLmtpPort(lmtpServerFactory)));
+            readBytes(server);
+
+            server.write(ByteBuffer.wrap(("LHLO <" + DOMAIN + ">\r\n").getBytes(StandardCharsets.UTF_8)));
+            readBytes(server);
+            server.write(ByteBuffer.wrap(("MAIL FROM: <bob@" + DOMAIN + ">\r\n").getBytes(StandardCharsets.UTF_8)));
+            readBytes(server);
+            server.write(ByteBuffer.wrap(("RCPT TO: <bo...@examplebis.local>\r\n").getBytes(StandardCharsets.UTF_8)));
+            readBytes(server);
+            server.write(ByteBuffer.wrap(("RCPT TO: <ce...@examplebis.local>\r\n").getBytes(StandardCharsets.UTF_8)));
+            readBytes(server);
+            server.write(ByteBuffer.wrap(("DATA\r\n").getBytes(StandardCharsets.UTF_8)));
+            readBytes(server); // needed to synchronize
+            server.write(ByteBuffer.wrap(("header:value\r\n\r\nbody").getBytes(StandardCharsets.UTF_8)));
+            server.write(ByteBuffer.wrap(("\r\n").getBytes(StandardCharsets.UTF_8)));
+            server.write(ByteBuffer.wrap((".").getBytes(StandardCharsets.UTF_8)));
+            server.write(ByteBuffer.wrap(("\r\n").getBytes(StandardCharsets.UTF_8)));
+             byte[] dataResponse = readBytes(server);
+            server.write(ByteBuffer.wrap(("QUIT\r\n").getBytes(StandardCharsets.UTF_8)));
+
+            assertThat(new String(dataResponse, StandardCharsets.UTF_8))
+                .contains("250 2.6.0 Message received\r\n" +
+                    "250 2.6.0 Message received");
+        }
+
+        @Test
         void ehloShouldBeRejected() throws Exception {
             SocketChannel server = SocketChannel.open();
             server.connect(new InetSocketAddress(LOCALHOST_IP, getLmtpPort(lmtpServerFactory)));

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