JAMES-1862 Add starttls SMTP command integration tests

Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/e0315c4f
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/e0315c4f
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/e0315c4f

Branch: refs/heads/master
Commit: e0315c4f6491e9e5730b4359ef8445bf8f0681d0
Parents: dedad3f
Author: Antoine Duprat <adup...@apache.org>
Authored: Thu Dec 1 13:34:36 2016 +0100
Committer: Antoine Duprat <adup...@linagora.com>
Committed: Tue Dec 6 11:31:26 2016 +0100

----------------------------------------------------------------------
 .../apache/james/mpt/smtp/StarttlsSmtpTest.java | 33 ++++++++++
 .../james/mpt/smtp/StarttlsSmtpTestModule.java  | 32 ++++++++++
 .../cassandra/src/test/resources/smtpserver.xml |  4 +-
 .../james/mpt/smtp/SmtpStarttlsCommandTest.java | 65 ++++++++++++++++++++
 .../org/apache/james/smtp/scripts/starttls.test | 11 ++++
 .../smtp/scripts/starttls_with_injection.test   | 11 ++++
 6 files changed, 154 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/e0315c4f/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/StarttlsSmtpTest.java
----------------------------------------------------------------------
diff --git 
a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/StarttlsSmtpTest.java
 
b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/StarttlsSmtpTest.java
new file mode 100644
index 0000000..376579f
--- /dev/null
+++ 
b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/StarttlsSmtpTest.java
@@ -0,0 +1,33 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+package org.apache.james.mpt.smtp;
+
+import org.apache.james.mpt.onami.test.OnamiSuite;
+import org.apache.james.mpt.onami.test.annotation.GuiceModules;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(OnamiSuite.class)
+@Suite.SuiteClasses({
+    SmtpStarttlsCommandTest.class
+})
+@GuiceModules({ StarttlsSmtpTestModule.class })
+public class StarttlsSmtpTest {
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0315c4f/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/StarttlsSmtpTestModule.java
----------------------------------------------------------------------
diff --git 
a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/StarttlsSmtpTestModule.java
 
b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/StarttlsSmtpTestModule.java
new file mode 100644
index 0000000..88b44d5
--- /dev/null
+++ 
b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/StarttlsSmtpTestModule.java
@@ -0,0 +1,32 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+package org.apache.james.mpt.smtp;
+
+import org.apache.james.mpt.smtp.host.CassandraJamesSmtpHostSystem;
+
+import com.google.inject.AbstractModule;
+
+public class StarttlsSmtpTestModule extends AbstractModule {
+
+    @Override
+    protected void configure() {
+        bind(SmtpHostSystem.class).toInstance(new 
CassandraJamesSmtpHostSystem(1587));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0315c4f/mpt/impl/smtp/cassandra/src/test/resources/smtpserver.xml
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/src/test/resources/smtpserver.xml 
b/mpt/impl/smtp/cassandra/src/test/resources/smtpserver.xml
index 0eaeb3d..c2b31b5 100644
--- a/mpt/impl/smtp/cassandra/src/test/resources/smtpserver.xml
+++ b/mpt/impl/smtp/cassandra/src/test/resources/smtpserver.xml
@@ -77,8 +77,8 @@
         <jmxName>smtpserver-authenticated</jmxName>
         <bind>0.0.0.0:1587</bind>
         <connectionBacklog>200</connectionBacklog>
-        <tls socketTLS="false" startTLS="false">
-            <keystore>file://conf/keystore</keystore>
+        <tls socketTLS="false" startTLS="true">
+            <keystore>keystore</keystore>
             <secret>james72laBalle</secret>
             
<provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
             <algorithm>SunX509</algorithm>

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0315c4f/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpStarttlsCommandTest.java
----------------------------------------------------------------------
diff --git 
a/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpStarttlsCommandTest.java
 
b/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpStarttlsCommandTest.java
new file mode 100644
index 0000000..2dd7246
--- /dev/null
+++ 
b/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpStarttlsCommandTest.java
@@ -0,0 +1,65 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+package org.apache.james.mpt.smtp;
+
+import java.util.Locale;
+
+import javax.inject.Inject;
+
+import org.apache.james.mpt.script.AbstractSimpleScriptedTestProtocol;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.RuleChain;
+import org.junit.rules.TemporaryFolder;
+
+public class SmtpStarttlsCommandTest extends 
AbstractSimpleScriptedTestProtocol {
+
+    public static final String USER = "bob";
+    public static final String DOMAIN = "mydomain.tld";
+    public static final String USER_AT_DOMAIN = USER + "@" + DOMAIN;
+    public static final String PASSWORD = "secret";
+
+    private final TemporaryFolder folder = new TemporaryFolder();
+    
+    @Rule
+    public final RuleChain chain = RuleChain.outerRule(folder);
+
+    @Inject
+    private static SmtpHostSystem hostSystem;
+
+    public SmtpStarttlsCommandTest() throws Exception {
+        super(hostSystem, USER_AT_DOMAIN, PASSWORD, 
"/org/apache/james/smtp/scripts/");
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+    }
+
+    @Test
+    public void starttlsShouldWork() throws Exception {
+        scriptTest("starttls", Locale.US);
+    }
+
+    @Test
+    public void starttlsShouldBeRejectedWhenFollowedByCommand() throws 
Exception {
+        scriptTest("starttls_with_injection", Locale.US);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0315c4f/mpt/impl/smtp/core/src/main/resources/org/apache/james/smtp/scripts/starttls.test
----------------------------------------------------------------------
diff --git 
a/mpt/impl/smtp/core/src/main/resources/org/apache/james/smtp/scripts/starttls.test
 
b/mpt/impl/smtp/core/src/main/resources/org/apache/james/smtp/scripts/starttls.test
new file mode 100644
index 0000000..abcb5c9
--- /dev/null
+++ 
b/mpt/impl/smtp/core/src/main/resources/org/apache/james/smtp/scripts/starttls.test
@@ -0,0 +1,11 @@
+S: 220 mydomain.tld smtp
+
+C: ehlo yopmail.com
+S: 250.*
+S: 250-PIPELINING
+S: 250-ENHANCEDSTATUSCODES
+S: 250-8BITMIME
+S: 250 STARTTLS
+
+C: starttls
+S: 220 2.0.0 Ready to start TLS

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0315c4f/mpt/impl/smtp/core/src/main/resources/org/apache/james/smtp/scripts/starttls_with_injection.test
----------------------------------------------------------------------
diff --git 
a/mpt/impl/smtp/core/src/main/resources/org/apache/james/smtp/scripts/starttls_with_injection.test
 
b/mpt/impl/smtp/core/src/main/resources/org/apache/james/smtp/scripts/starttls_with_injection.test
new file mode 100644
index 0000000..5c09717
--- /dev/null
+++ 
b/mpt/impl/smtp/core/src/main/resources/org/apache/james/smtp/scripts/starttls_with_injection.test
@@ -0,0 +1,11 @@
+S: 220 mydomain.tld smtp
+
+C: ehlo yopmail.com
+S: 250.*
+S: 250-PIPELINING
+S: 250-ENHANCEDSTATUSCODES
+S: 250-8BITMIME
+S: 250 STARTTLS
+
+C: starttls\r\nmail from:<matth...@yopmail.com>\r\n
+S: 451 Unable to process request


---------------------------------------------------------------------
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