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

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

commit e7e2c912d9ca59c6f4cc6c8b75ce4994038c08f7
Author: Benoit Tellier <[email protected]>
AuthorDate: Tue Dec 7 11:48:13 2021 +0700

    JAMES-3680 Tests for authentication announces
---
 .../src/test/resources/smtpserver.xml              |   4 +-
 .../apache/james/smtpserver/netty/SMTPServer.java  |  10 +-
 .../{DSNTest.java => AuthAnnounceTest.java}        | 189 +++++----------------
 .../java/org/apache/james/smtpserver/DSNTest.java  |   7 +-
 .../apache/james/smtpserver/SMTPServerTest.java    |   7 +-
 .../resources/smtpserver-authAnnounceAlways.xml    |  41 +++++
 .../resources/smtpserver-authAnnounceNever.xml     |  41 +++++
 .../smtpserver-authAnnounceSometimeMatching.xml    |  48 ++++++
 .../smtpserver-authAnnounceSometimeNotMatching.xml |  42 +++++
 .../src/test/resources/smtpserver-noauth.xml       |  39 +++++
 .../src/test/resources/smtpserver-requireSSL.xml   |  43 +++++
 11 files changed, 306 insertions(+), 165 deletions(-)

diff --git 
a/server/apps/cli-integration-tests/src/test/resources/smtpserver.xml 
b/server/apps/cli-integration-tests/src/test/resources/smtpserver.xml
index 1193b94..1b30236 100644
--- a/server/apps/cli-integration-tests/src/test/resources/smtpserver.xml
+++ b/server/apps/cli-integration-tests/src/test/resources/smtpserver.xml
@@ -61,7 +61,7 @@
         <connectionLimit>0</connectionLimit>
         <connectionLimitPerIP>0</connectionLimitPerIP>
         <auth>
-            <announce>true</announce>
+            <announce>always</announce>
             <requireSSL>false</requireSSL>
         </auth>
         <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
@@ -89,7 +89,7 @@
         <connectionLimit>0</connectionLimit>
         <connectionLimitPerIP>0</connectionLimitPerIP>
         <auth>
-            <announce>true</announce>
+            <announce>always</announce>
             <requireSSL>false</requireSSL>
         </auth>
         <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
diff --git 
a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/netty/SMTPServer.java
 
b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/netty/SMTPServer.java
index bc9c8ef..490bfb2 100644
--- 
a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/netty/SMTPServer.java
+++ 
b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/netty/SMTPServer.java
@@ -87,17 +87,11 @@ public class SMTPServer extends AbstractProtocolAsyncServer 
implements SMTPServe
 
     public static class AuthenticationConfiguration {
         public static AuthenticationConfiguration 
parse(HierarchicalConfiguration<ImmutableNode> configuration) {
-            return Optional.ofNullable(configuration.configurationAt("auth"))
-                .map(authConfiguration -> parse(configuration, 
authConfiguration))
-                .orElseGet(() -> new 
AuthenticationConfiguration(fallbackAuthenticationAnnounceMode(configuration), 
false));
-        }
-
-        private static AuthenticationConfiguration 
parse(HierarchicalConfiguration<ImmutableNode> configuration, 
HierarchicalConfiguration<ImmutableNode> authConfiguration) {
             return new AuthenticationConfiguration(
-                Optional.ofNullable(authConfiguration.getString("announce", 
null))
+                Optional.ofNullable(configuration.getString("auth.announce", 
null))
                     .map(AuthenticationAnnounceMode::parse)
                     .orElseGet(() -> 
fallbackAuthenticationAnnounceMode(configuration)),
-                Optional.ofNullable(authConfiguration.getBoolean("requireSSL", 
null))
+                
Optional.ofNullable(configuration.getBoolean("auth.requireSSL", null))
                     .orElse(false));
         }
 
diff --git 
a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/DSNTest.java
 
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/AuthAnnounceTest.java
similarity index 58%
copy from 
server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/DSNTest.java
copy to 
server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/AuthAnnounceTest.java
index d2d0285..95c81b3 100644
--- 
a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/DSNTest.java
+++ 
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/AuthAnnounceTest.java
@@ -18,24 +18,15 @@
  ****************************************************************/
 package org.apache.james.smtpserver;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.apache.mailet.DsnParameters.Notify.DELAY;
-import static org.apache.mailet.DsnParameters.Notify.FAILURE;
-import static org.apache.mailet.DsnParameters.Notify.SUCCESS;
-import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import java.io.IOException;
 import java.net.InetSocketAddress;
-import java.util.Base64;
-import java.util.EnumSet;
 
 import org.apache.commons.configuration2.BaseHierarchicalConfiguration;
 import org.apache.commons.net.smtp.SMTPClient;
 import org.apache.james.UserEntityValidator;
 import org.apache.james.core.Domain;
-import org.apache.james.core.MailAddress;
 import org.apache.james.core.Username;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.api.InMemoryDNSService;
@@ -72,8 +63,6 @@ import org.apache.james.smtpserver.netty.SMTPServer;
 import org.apache.james.smtpserver.netty.SmtpMetricsImpl;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.memory.MemoryUsersRepository;
-import org.apache.mailet.DsnParameters;
-import org.apache.mailet.Mail;
 import org.assertj.core.api.SoftAssertions;
 import org.jboss.netty.util.HashedWheelTimer;
 import org.junit.jupiter.api.AfterEach;
@@ -83,7 +72,7 @@ import org.junit.jupiter.api.Test;
 import com.google.common.collect.ImmutableList;
 import com.google.inject.TypeLiteral;
 
-class DSNTest {
+class AuthAnnounceTest {
     public static final String LOCAL_DOMAIN = "example.local";
     public static final Username BOB = Username.of("bob@localhost");
     public static final String PASSWORD = "bobpwd";
@@ -103,18 +92,12 @@ class DSNTest {
 
     @BeforeEach
     void setUp() throws Exception {
-        domainList = new MemoryDomainList(new InMemoryDNSService()
-            .registerMxRecord(Domain.LOCALHOST.asString(), "127.0.0.1")
-            .registerMxRecord(Domain.LOCALHOST.asString(), "127.0.0.1")
-            .registerMxRecord(LOCAL_DOMAIN, "127.0.0.1")
-            .registerMxRecord("examplebis.local", "127.0.0.1")
-            .registerMxRecord("127.0.0.1", "127.0.0.1"));
+        domainList = new MemoryDomainList(new InMemoryDNSService());
         domainList.configure(DomainListConfiguration.DEFAULT);
 
         domainList.addDomain(Domain.of(LOCAL_DOMAIN));
         domainList.addDomain(Domain.of("examplebis.local"));
         usersRepository = MemoryUsersRepository.withVirtualHosting(domainList);
-        usersRepository.addUser(BOB, PASSWORD);
 
         createMailRepositoryStore();
 
@@ -187,191 +170,111 @@ class DSNTest {
     }
 
     @Test
-    void ehloShouldAdvertiseDsnExtension() throws Exception {
+    void authAnnounceAlwaysShouldAnnounceAuth() throws Exception {
         smtpServer.configure(FileConfigurationProvider.getConfig(
-            ClassLoader.getSystemResourceAsStream("smtpserver-dsn.xml")));
+            
ClassLoader.getSystemResourceAsStream("smtpserver-authAnnounceAlways.xml")));
         smtpServer.init();
 
         SMTPClient smtpProtocol = new SMTPClient();
         InetSocketAddress bindedAddress = new 
ProtocolServerUtils(smtpServer).retrieveBindedAddress();
         smtpProtocol.connect(bindedAddress.getAddress().getHostAddress(), 
bindedAddress.getPort());
-        authenticate(smtpProtocol);
         smtpProtocol.sendCommand("EHLO localhost");
 
         SoftAssertions.assertSoftly(softly -> {
             softly.assertThat(smtpProtocol.getReplyCode()).isEqualTo(250);
-            softly.assertThat(smtpProtocol.getReplyString()).contains("250 
DSN");
+            softly.assertThat(smtpProtocol.getReplyString())
+                .contains("250-AUTH LOGIN PLAIN");
         });
     }
 
-    private void authenticate(SMTPClient smtpProtocol) throws IOException {
-        smtpProtocol.sendCommand("AUTH PLAIN");
-        smtpProtocol.sendCommand(Base64.getEncoder().encodeToString(("\0" + 
BOB.asString() + "\0" + PASSWORD + "\0").getBytes(UTF_8)));
-        assertThat(smtpProtocol.getReplyCode())
-            .as("authenticated")
-            .isEqualTo(235);
-    }
-
     @Test
-    void dsnParametersShouldBeSetOnTheFinalEmail() throws Exception {
+    void authAnnounceSometimeShouldNotAnnounceAuthWhenMatching() throws 
Exception {
         smtpServer.configure(FileConfigurationProvider.getConfig(
-            ClassLoader.getSystemResourceAsStream("smtpserver-dsn.xml")));
+            
ClassLoader.getSystemResourceAsStream("smtpserver-authAnnounceSometimeMatching.xml")));
         smtpServer.init();
 
         SMTPClient smtpProtocol = new SMTPClient();
         InetSocketAddress bindedAddress = new 
ProtocolServerUtils(smtpServer).retrieveBindedAddress();
         smtpProtocol.connect(bindedAddress.getAddress().getHostAddress(), 
bindedAddress.getPort());
-        authenticate(smtpProtocol);
-
         smtpProtocol.sendCommand("EHLO localhost");
-        smtpProtocol.sendCommand("MAIL FROM: <bob@localhost> RET=HDRS 
ENVID=QQ314159");
-        smtpProtocol.sendCommand("RCPT TO:<rcpt@localhost> 
NOTIFY=SUCCESS,FAILURE,DELAY ORCPT=rfc822;orcpt@localhost");
-        smtpProtocol.sendShortMessageData("Subject: test mail\r\n\r\nTest body 
testSimpleMailSendWithDSN\r\n.\r\n");
-
-        Mail lastMail = queue.getLastMail();
-        assertThat(lastMail.dsnParameters())
-            .contains(DsnParameters.builder()
-                .envId(DsnParameters.EnvId.of("QQ314159"))
-                .ret(DsnParameters.Ret.HDRS)
-                .addRcptParameter(new MailAddress("rcpt@localhost"), 
DsnParameters.RecipientDsnParameters.of(
-                    EnumSet.of(SUCCESS, FAILURE, DELAY),
-                    new MailAddress("orcpt@localhost")
-                )).build().get());
-    }
-
-    @Test
-    void multipleRecipientsShouldBeSupported() throws Exception {
-        smtpServer.configure(FileConfigurationProvider.getConfig(
-            ClassLoader.getSystemResourceAsStream("smtpserver-dsn.xml")));
-        smtpServer.init();
-
-        SMTPClient smtpProtocol = new SMTPClient();
-        InetSocketAddress bindedAddress = new 
ProtocolServerUtils(smtpServer).retrieveBindedAddress();
-        smtpProtocol.connect(bindedAddress.getAddress().getHostAddress(), 
bindedAddress.getPort());
-        authenticate(smtpProtocol);
 
-        smtpProtocol.sendCommand("EHLO localhost");
-        smtpProtocol.sendCommand("MAIL FROM: <bob@localhost> RET=HDRS 
ENVID=QQ314159");
-        smtpProtocol.sendCommand("RCPT TO:<rcpt1@localhost> 
NOTIFY=SUCCESS,FAILURE,DELAY ORCPT=rfc822;orcpt1@localhost");
-        smtpProtocol.sendCommand("RCPT TO:<rcpt2@localhost> 
NOTIFY=SUCCESS,FAILURE,DELAY ORCPT=rfc822;orcpt2@localhost");
-        smtpProtocol.sendCommand("RCPT TO:<rcpt@localhost>");
-        smtpProtocol.sendShortMessageData("Subject: test mail\r\n\r\nTest body 
testSimpleMailSendWithDSN\r\n.\r\n");
-
-        Mail lastMail = queue.getLastMail();
-        assertThat(lastMail.dsnParameters())
-            .contains(DsnParameters.builder()
-                .envId(DsnParameters.EnvId.of("QQ314159"))
-                .ret(DsnParameters.Ret.HDRS)
-                .addRcptParameter(new MailAddress("rcpt1@localhost"), 
DsnParameters.RecipientDsnParameters.of(
-                    EnumSet.of(SUCCESS, FAILURE, DELAY),
-                    new MailAddress("orcpt1@localhost")))
-                .addRcptParameter(new MailAddress("rcpt2@localhost"), 
DsnParameters.RecipientDsnParameters.of(
-                    EnumSet.of(SUCCESS, FAILURE, DELAY),
-                    new MailAddress("orcpt2@localhost")
-                )).build().get());
+        SoftAssertions.assertSoftly(softly -> {
+            softly.assertThat(smtpProtocol.getReplyCode()).isEqualTo(250);
+            softly.assertThat(smtpProtocol.getReplyString())
+                .doesNotContain("250-AUTH LOGIN PLAIN");
+        });
     }
 
     @Test
-    void notifyCanBeOmitted() throws Exception {
+    void authAnnounceSometimeShouldAnnounceAuthWhenNotMatching() throws 
Exception {
         smtpServer.configure(FileConfigurationProvider.getConfig(
-            ClassLoader.getSystemResourceAsStream("smtpserver-dsn.xml")));
+            
ClassLoader.getSystemResourceAsStream("smtpserver-authAnnounceSometimeNotMatching.xml")));
         smtpServer.init();
 
         SMTPClient smtpProtocol = new SMTPClient();
         InetSocketAddress bindedAddress = new 
ProtocolServerUtils(smtpServer).retrieveBindedAddress();
         smtpProtocol.connect(bindedAddress.getAddress().getHostAddress(), 
bindedAddress.getPort());
-        authenticate(smtpProtocol);
-
         smtpProtocol.sendCommand("EHLO localhost");
-        smtpProtocol.sendCommand("MAIL FROM: <bob@localhost> RET=HDRS 
ENVID=QQ314159");
-        smtpProtocol.sendCommand("RCPT TO:<rcpt@localhost> 
ORCPT=rfc822;orcpt@localhost");
-        smtpProtocol.sendShortMessageData("Subject: test mail\r\n\r\nTest body 
testSimpleMailSendWithDSN\r\n.\r\n");
-
-        Mail lastMail = queue.getLastMail();
-        assertThat(lastMail.dsnParameters())
-            .contains(DsnParameters.builder()
-                .envId(DsnParameters.EnvId.of("QQ314159"))
-                .ret(DsnParameters.Ret.HDRS)
-                .addRcptParameter(new MailAddress("rcpt@localhost"), 
DsnParameters.RecipientDsnParameters.of(
-                    new MailAddress("orcpt@localhost")))
-                .build().get());
+
+        SoftAssertions.assertSoftly(softly -> {
+            softly.assertThat(smtpProtocol.getReplyCode()).isEqualTo(250);
+            softly.assertThat(smtpProtocol.getReplyString())
+                .contains("250-AUTH LOGIN PLAIN");
+        });
     }
 
     @Test
-    void orcptCanBeOmitted() throws Exception {
+    void authAnnounceNeverShouldNotAnnounceAuth() throws Exception {
         smtpServer.configure(FileConfigurationProvider.getConfig(
-            ClassLoader.getSystemResourceAsStream("smtpserver-dsn.xml")));
+            
ClassLoader.getSystemResourceAsStream("smtpserver-authAnnounceNever.xml")));
         smtpServer.init();
 
         SMTPClient smtpProtocol = new SMTPClient();
         InetSocketAddress bindedAddress = new 
ProtocolServerUtils(smtpServer).retrieveBindedAddress();
         smtpProtocol.connect(bindedAddress.getAddress().getHostAddress(), 
bindedAddress.getPort());
-        authenticate(smtpProtocol);
-
         smtpProtocol.sendCommand("EHLO localhost");
-        smtpProtocol.sendCommand("MAIL FROM: <bob@localhost> RET=HDRS 
ENVID=QQ314159");
-        smtpProtocol.sendCommand("RCPT TO:<rcpt@localhost> 
NOTIFY=SUCCESS,FAILURE,DELAY");
-        smtpProtocol.sendShortMessageData("Subject: test mail\r\n\r\nTest body 
testSimpleMailSendWithDSN\r\n.\r\n");
-
-        Mail lastMail = queue.getLastMail();
-        assertThat(lastMail.dsnParameters())
-            .contains(DsnParameters.builder()
-                .envId(DsnParameters.EnvId.of("QQ314159"))
-                .ret(DsnParameters.Ret.HDRS)
-                .addRcptParameter(new MailAddress("rcpt@localhost"), 
DsnParameters.RecipientDsnParameters.of(
-                    EnumSet.of(SUCCESS, FAILURE, DELAY)))
-                .build().get());
+
+        SoftAssertions.assertSoftly(softly -> {
+            softly.assertThat(smtpProtocol.getReplyCode()).isEqualTo(250);
+            softly.assertThat(smtpProtocol.getReplyString())
+                .doesNotContain("250-AUTH LOGIN PLAIN");
+        });
     }
 
     @Test
-    void retCanBeOmitted() throws Exception {
+    void authShouldNotBeAnnouncedOnPlainChannelsWhenRequireSSL() throws 
Exception {
         smtpServer.configure(FileConfigurationProvider.getConfig(
-            ClassLoader.getSystemResourceAsStream("smtpserver-dsn.xml")));
+            
ClassLoader.getSystemResourceAsStream("smtpserver-requireSSL.xml")));
         smtpServer.init();
 
         SMTPClient smtpProtocol = new SMTPClient();
         InetSocketAddress bindedAddress = new 
ProtocolServerUtils(smtpServer).retrieveBindedAddress();
         smtpProtocol.connect(bindedAddress.getAddress().getHostAddress(), 
bindedAddress.getPort());
-        authenticate(smtpProtocol);
-
         smtpProtocol.sendCommand("EHLO localhost");
-        smtpProtocol.sendCommand("MAIL FROM: <bob@localhost> ENVID=QQ314159");
-        smtpProtocol.sendCommand("RCPT TO:<rcpt@localhost> 
NOTIFY=SUCCESS,FAILURE,DELAY ORCPT=rfc822;orcpt@localhost");
-        smtpProtocol.sendShortMessageData("Subject: test mail\r\n\r\nTest body 
testSimpleMailSendWithDSN\r\n.\r\n");
-
-        Mail lastMail = queue.getLastMail();
-        assertThat(lastMail.dsnParameters())
-            .contains(DsnParameters.builder()
-                .envId(DsnParameters.EnvId.of("QQ314159"))
-                .addRcptParameter(new MailAddress("rcpt@localhost"), 
DsnParameters.RecipientDsnParameters.of(
-                    EnumSet.of(SUCCESS, FAILURE, DELAY),
-                    new MailAddress("orcpt@localhost")))
-                .build().get());
+
+        SoftAssertions.assertSoftly(softly -> {
+            softly.assertThat(smtpProtocol.getReplyCode()).isEqualTo(250);
+            softly.assertThat(smtpProtocol.getReplyString())
+                .doesNotContain("250-AUTH LOGIN PLAIN");
+        });
     }
 
     @Test
-    void envIdCanBeOmitted() throws Exception {
+    void shouldStartWithPreviousConfiguration() throws Exception {
         smtpServer.configure(FileConfigurationProvider.getConfig(
-            ClassLoader.getSystemResourceAsStream("smtpserver-dsn.xml")));
+            ClassLoader.getSystemResourceAsStream("smtpserver-noauth.xml")));
         smtpServer.init();
 
         SMTPClient smtpProtocol = new SMTPClient();
         InetSocketAddress bindedAddress = new 
ProtocolServerUtils(smtpServer).retrieveBindedAddress();
         smtpProtocol.connect(bindedAddress.getAddress().getHostAddress(), 
bindedAddress.getPort());
-        authenticate(smtpProtocol);
-
         smtpProtocol.sendCommand("EHLO localhost");
-        smtpProtocol.sendCommand("MAIL FROM: <bob@localhost> RET=HDRS");
-        smtpProtocol.sendCommand("RCPT TO:<rcpt@localhost> 
NOTIFY=SUCCESS,FAILURE,DELAY ORCPT=rfc822;orcpt@localhost");
-        smtpProtocol.sendShortMessageData("Subject: test mail\r\n\r\nTest body 
testSimpleMailSendWithDSN\r\n.\r\n");
-
-        Mail lastMail = queue.getLastMail();
-        assertThat(lastMail.dsnParameters())
-            .contains(DsnParameters.builder()
-                .ret(DsnParameters.Ret.HDRS)
-                .addRcptParameter(new MailAddress("rcpt@localhost"), 
DsnParameters.RecipientDsnParameters.of(
-                    EnumSet.of(SUCCESS, FAILURE, DELAY),
-                    new MailAddress("orcpt@localhost")
-                )).build().get());
+
+        SoftAssertions.assertSoftly(softly -> {
+            softly.assertThat(smtpProtocol.getReplyCode()).isEqualTo(250);
+            softly.assertThat(smtpProtocol.getReplyString())
+                // SSL is required
+                .doesNotContain("250-AUTH LOGIN PLAIN");
+        });
     }
 }
diff --git 
a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/DSNTest.java
 
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/DSNTest.java
index d2d0285..8fc9c6d 100644
--- 
a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/DSNTest.java
+++ 
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/DSNTest.java
@@ -103,12 +103,7 @@ class DSNTest {
 
     @BeforeEach
     void setUp() throws Exception {
-        domainList = new MemoryDomainList(new InMemoryDNSService()
-            .registerMxRecord(Domain.LOCALHOST.asString(), "127.0.0.1")
-            .registerMxRecord(Domain.LOCALHOST.asString(), "127.0.0.1")
-            .registerMxRecord(LOCAL_DOMAIN, "127.0.0.1")
-            .registerMxRecord("examplebis.local", "127.0.0.1")
-            .registerMxRecord("127.0.0.1", "127.0.0.1"));
+        domainList = new MemoryDomainList(new InMemoryDNSService());
         domainList.configure(DomainListConfiguration.DEFAULT);
 
         domainList.addDomain(Domain.of(LOCAL_DOMAIN));
diff --git 
a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
 
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
index df69548..303119d 100644
--- 
a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
+++ 
b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
@@ -147,12 +147,7 @@ public class SMTPServerTest {
                 throw new UnknownHostException();
             }
 
-            if ("128.0.0.1".equals(host) || "192.168.0.1".equals(host) || 
"127.0.0.1".equals(host) || "127.0.0.0".equals(
-                    host) || "255.0.0.0".equals(host) || 
"255.255.255.255".equals(host)) {
-                return InetAddress.getByName(host);
-            }
-
-            throw new UnsupportedOperationException("getByName not implemented 
in mock for host: " + host);
+            return InetAddress.getByName(host);
         }
 
         @Override
diff --git 
a/server/protocols/protocols-smtp/src/test/resources/smtpserver-authAnnounceAlways.xml
 
b/server/protocols/protocols-smtp/src/test/resources/smtpserver-authAnnounceAlways.xml
new file mode 100644
index 0000000..676dc7b
--- /dev/null
+++ 
b/server/protocols/protocols-smtp/src/test/resources/smtpserver-authAnnounceAlways.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+ -->
+
+    <smtpserver enabled="true">
+        <bind>0.0.0.0:0</bind>
+        <tls socketTLS="false" startTLS="false">
+            <keystore>file://conf/keystore</keystore>
+            <secret>james72laBalle</secret>
+            
<provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+            <algorithm>SunX509</algorithm>
+        </tls>
+        <auth>
+            <announce>always</announce>
+            <requireSSL>false</requireSSL>
+        </auth>
+        <verifyIdentity>true</verifyIdentity>
+        <smtpGreeting>Apache JAMES awesome SMTP Server</smtpGreeting>
+        <handlerchain>
+            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+        </handlerchain>
+    </smtpserver>
+
+
diff --git 
a/server/protocols/protocols-smtp/src/test/resources/smtpserver-authAnnounceNever.xml
 
b/server/protocols/protocols-smtp/src/test/resources/smtpserver-authAnnounceNever.xml
new file mode 100644
index 0000000..bdfb5a6
--- /dev/null
+++ 
b/server/protocols/protocols-smtp/src/test/resources/smtpserver-authAnnounceNever.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+ -->
+
+    <smtpserver enabled="true">
+        <bind>0.0.0.0:0</bind>
+        <tls socketTLS="false" startTLS="false">
+            <keystore>file://conf/keystore</keystore>
+            <secret>james72laBalle</secret>
+            
<provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+            <algorithm>SunX509</algorithm>
+        </tls>
+        <auth>
+            <announce>never</announce>
+            <requireSSL>false</requireSSL>
+        </auth>
+        <verifyIdentity>false</verifyIdentity>
+        <smtpGreeting>Apache JAMES awesome SMTP Server</smtpGreeting>
+        <handlerchain>
+            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+        </handlerchain>
+    </smtpserver>
+
+
diff --git 
a/server/protocols/protocols-smtp/src/test/resources/smtpserver-authAnnounceSometimeMatching.xml
 
b/server/protocols/protocols-smtp/src/test/resources/smtpserver-authAnnounceSometimeMatching.xml
new file mode 100644
index 0000000..bb2d6ac
--- /dev/null
+++ 
b/server/protocols/protocols-smtp/src/test/resources/smtpserver-authAnnounceSometimeMatching.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+ -->
+
+    <smtpserver enabled="true">
+        <bind>0.0.0.0:0</bind>
+        <connectionBacklog>200</connectionBacklog>
+        <tls socketTLS="false" startTLS="false">
+            <keystore>file://conf/keystore</keystore>
+            <secret>james72laBalle</secret>
+            
<provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+            <algorithm>SunX509</algorithm>
+        </tls>
+        <connectiontimeout>360</connectiontimeout>
+        <connectionLimit>0</connectionLimit>
+        <connectionLimitPerIP>0</connectionLimitPerIP>
+        <auth>
+            <announce>forUnauthorizedAddresses</announce>
+            <requireSSL>false</requireSSL>
+        </auth>
+        <authorizedAddresses>0.0.0.0/0.0.0.0</authorizedAddresses>
+        <verifyIdentity>true</verifyIdentity>
+        <maxmessagesize>0</maxmessagesize>
+        <addressBracketsEnforcement>true</addressBracketsEnforcement>
+        <smtpGreeting>Apache JAMES awesome SMTP Server</smtpGreeting>
+        <handlerchain>
+            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+        </handlerchain>
+    </smtpserver>
+
+
diff --git 
a/server/protocols/protocols-smtp/src/test/resources/smtpserver-authAnnounceSometimeNotMatching.xml
 
b/server/protocols/protocols-smtp/src/test/resources/smtpserver-authAnnounceSometimeNotMatching.xml
new file mode 100644
index 0000000..73227b2
--- /dev/null
+++ 
b/server/protocols/protocols-smtp/src/test/resources/smtpserver-authAnnounceSometimeNotMatching.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+ -->
+
+    <smtpserver enabled="true">
+        <bind>0.0.0.0:0</bind>
+        <tls socketTLS="false" startTLS="false">
+            <keystore>file://conf/keystore</keystore>
+            <secret>james72laBalle</secret>
+            
<provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+            <algorithm>SunX509</algorithm>
+        </tls>
+        <auth>
+            <announce>forUnauthorizedAddresses</announce>
+            <requireSSL>false</requireSSL>
+        </auth>
+        <authorizedAddresses>192.168.0.1</authorizedAddresses>
+        <verifyIdentity>true</verifyIdentity>
+        <smtpGreeting>Apache JAMES awesome SMTP Server</smtpGreeting>
+        <handlerchain>
+            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+        </handlerchain>
+    </smtpserver>
+
+
diff --git 
a/server/protocols/protocols-smtp/src/test/resources/smtpserver-noauth.xml 
b/server/protocols/protocols-smtp/src/test/resources/smtpserver-noauth.xml
new file mode 100644
index 0000000..827e2e5
--- /dev/null
+++ b/server/protocols/protocols-smtp/src/test/resources/smtpserver-noauth.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+ -->
+
+<!-- Read 
https://james.apache.org/server/config-smtp-lmtp.html#SMTP_Configuration for 
further details -->
+
+    <smtpserver enabled="true">
+        <bind>0.0.0.0:0</bind>
+        <tls socketTLS="false" startTLS="false">
+            <keystore>file://conf/keystore</keystore>
+            <secret>james72laBalle</secret>
+            
<provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+            <algorithm>SunX509</algorithm>
+        </tls>
+        <verifyIdentity>false</verifyIdentity>
+        <smtpGreeting>Apache JAMES awesome SMTP Server</smtpGreeting>
+        <handlerchain>
+            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+        </handlerchain>
+    </smtpserver>
+
+
diff --git 
a/server/protocols/protocols-smtp/src/test/resources/smtpserver-requireSSL.xml 
b/server/protocols/protocols-smtp/src/test/resources/smtpserver-requireSSL.xml
new file mode 100644
index 0000000..83ee50d
--- /dev/null
+++ 
b/server/protocols/protocols-smtp/src/test/resources/smtpserver-requireSSL.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+ -->
+
+<!-- Read 
https://james.apache.org/server/config-smtp-lmtp.html#SMTP_Configuration for 
further details -->
+
+    <smtpserver enabled="true">
+        <bind>0.0.0.0:0</bind>
+        <tls socketTLS="false" startTLS="false">
+            <keystore>file://conf/keystore</keystore>
+            <secret>james72laBalle</secret>
+            
<provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+            <algorithm>SunX509</algorithm>
+        </tls>
+        <auth>
+            <announce>always</announce>
+            <requireSSL>true</requireSSL>
+        </auth>
+        <verifyIdentity>true</verifyIdentity>
+        <smtpGreeting>Apache JAMES awesome SMTP Server</smtpGreeting>
+        <handlerchain>
+            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+        </handlerchain>
+    </smtpserver>
+
+

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to