Maxxx873 commented on code in PR #2460: URL: https://github.com/apache/james-project/pull/2460#discussion_r1879562389
########## server/mailet/remote-delivery-integration-testing/src/test/java/org/apache/james/smtp/tls/SmtpRequireTlsRelayTest.java: ########## @@ -244,6 +240,33 @@ void remoteDeliveryWhenShouldRequireTlsAndDsnAndMtPriorityTogether(DockerMockSmt .build())); } + @Test + void remoteDeliveryShouldFailsWhenServerNotAllowStartTls(DockerMockSmtp mockSmtp) throws Exception { + testIMAPClient.connect(LOCALHOST_IP, jamesServer.getProbe(ImapGuiceProbe.class).getImapPort()) + .login(FROM, PASSWORD); + + MockSMTPBehavior startTlsBehavior = new MockSMTPBehavior( + MAIL_FROM, + Condition.MATCH_ALL, + new Response(COMMAND_PARAMETER_NOT_IMPLEMENTED_504, "The server has not implemented a command parameter"), + MockSMTPBehavior.NumberOfAnswersPolicy.anytime()); + + mockSmtp.getConfigurationClient().setBehaviors(List.of(startTlsBehavior)); + + SMTPSClient smtpClient = initSMTPSClient(); + smtpClient.mail("<" + FROM + "> REQUIRETLS"); + smtpClient.rcpt("<" + RECIPIENT + ">"); + smtpClient.sendShortMessageData("A short message..."); + + String dsnMessage = testIMAPClient.connect(LOCALHOST_IP, jamesServer.getProbe(ImapGuiceProbe.class).getImapPort()) + .login(FROM, PASSWORD) + .select(TestIMAPClient.INBOX) + .awaitMessageCount(awaitAtMostOneMinute, 1) + .readFirstMessage(); + + Assertions.assertThat(dsnMessage).contains("504 The server has not implemented a command parameter"); + } Review Comment: > No what we want is the mock server to HIDE that it implements STARTTLS (in the EHLO capability). > > When that's the case the relay of the mail should fail. > > This is different from failing at MAIL FROM > > (What I mean is that the test is inaccurate). I agree with you, and I propose a new version of the test -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org