You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ma...@apache.org on 2016/03/23 20:46:51 UTC
[08/24] james-project git commit: JAMES-1693 implement a data memory
module for Guice
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/servers/MemoryJmapServerModule.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/servers/MemoryJmapServerModule.java b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/servers/MemoryJmapServerModule.java
new file mode 100644
index 0000000..0b9a51b
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/servers/MemoryJmapServerModule.java
@@ -0,0 +1,43 @@
+/****************************************************************
+ * 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.jmap.servers;
+
+import org.apache.james.modules.TestFilesystemModule;
+import org.apache.james.modules.TestJMAPServerModule;
+import org.junit.rules.TemporaryFolder;
+
+import com.google.inject.AbstractModule;
+
+public class MemoryJmapServerModule extends AbstractModule {
+
+ private static final int LIMIT_TO_3_MESSAGES = 3;
+ private TemporaryFolder temporaryFolder;
+
+ public MemoryJmapServerModule(TemporaryFolder temporaryFolder) {
+ this.temporaryFolder = temporaryFolder;
+ }
+
+ @Override
+ protected void configure() {
+ install(new TestFilesystemModule(temporaryFolder));
+ install(new TestJMAPServerModule(LIMIT_TO_3_MESSAGES));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/dnsservice.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/dnsservice.xml b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/dnsservice.xml
new file mode 100644
index 0000000..0978a00
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/dnsservice.xml
@@ -0,0 +1,29 @@
+<?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.
+ -->
+
+<dnsservice>
+ <servers>
+ <server>8.8.8.8</server>
+ <server>62.210.16.6</server>
+ </servers>
+ <autodiscover>false</autodiscover>
+ <authoritative>false</authoritative>
+ <maxcachesize>50000</maxcachesize>
+</dnsservice>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/imapserver.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/imapserver.xml b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/imapserver.xml
new file mode 100644
index 0000000..ff478a9
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/imapserver.xml
@@ -0,0 +1,54 @@
+<?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.
+-->
+
+
+<imapservers>
+ <imapserver enabled="true">
+ <jmxName>imapserver</jmxName>
+ <bind>0.0.0.0:1143</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ </tls>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ </imapserver>
+ <imapserver enabled="true">
+ <jmxName>imapserver-ssl</jmxName>
+ <bind>0.0.0.0:1993</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ </tls>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ </imapserver>
+</imapservers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/keystore
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/keystore b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/keystore
new file mode 100644
index 0000000..536a6c7
Binary files /dev/null and b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/keystore differ
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/lmtpserver.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/lmtpserver.xml b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/lmtpserver.xml
new file mode 100644
index 0000000..5c4a9c7
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/lmtpserver.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.
+ -->
+
+<lmtpservers>
+
+ <lmtpserver enabled="true">
+ <jmxName>lmtpserver</jmxName>
+ <!-- LMTP should not be reachable from outside your network so bind it to loopback-->
+ <bind>127.0.0.1:1024</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <connectiontimeout>1200</connectiontimeout>
+ <!-- Set the maximum simultaneous incoming connections for this service -->
+ <connectionLimit>0</connectionLimit>
+ <!-- Set the maximum simultaneous incoming connections per IP for this service -->
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <!-- This sets the maximum allowed message size (in kilobytes) for this -->
+ <!-- LMTP service. If unspecified, the value defaults to 0, which means no limit. -->
+ <maxmessagesize>0</maxmessagesize>
+ <handlerchain>
+ <handler class="org.apache.james.lmtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </lmtpserver>
+
+</lmtpservers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailetcontainer.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailetcontainer.xml b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailetcontainer.xml
new file mode 100644
index 0000000..258f264
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailetcontainer.xml
@@ -0,0 +1,103 @@
+<?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.
+ -->
+
+<mailetcontainer enableJmx="false">
+
+ <context>
+ <postmaster>postmaster@james.minet.net</postmaster>
+ </context>
+
+ <spooler>
+ <threads>20</threads>
+ </spooler>
+
+ <processors>
+ <processor state="root" enableJmx="false">
+ <mailet match="All" class="PostmasterAlias"/>
+ <mailet match="RelayLimit=30" class="Null"/>
+ <!-- Hook on sievemanager@james.linagora.com
+ Mail send to this address will get interpreted with SIEVE Manage -->
+ <mailet match="All" class="ToProcessor">
+ <processor>transport</processor>
+ </mailet>
+ </processor>
+
+ <processor state="error" enableJmx="false">
+ <mailet match="All" class="Bounce"/>
+ </processor>
+
+
+ <processor state="transport" enableJmx="false">
+ <mailet match="SMTPAuthSuccessful" class="SetMimeHeader">
+ <name>X-UserIsAuth</name>
+ <value>true</value>
+ </mailet>
+ <mailet match="All" class="RemoveMimeHeader">
+ <name>bcc</name>
+ </mailet>
+ <mailet match="RecipientIsLocal" class="LocalDelivery"/>
+ <mailet match="HostIsLocal" class="ToProcessor">
+ <processor>local-address-error</processor>
+ <notice>550 - Requested action not taken: no such user here</notice>
+ </mailet>
+ <mailet match="SMTPAuthSuccessful" class="RemoteDelivery">
+ <outgoingQueue>outgoing</outgoingQueue>
+ <delayTime>5000, 100000, 500000</delayTime>
+ <maxRetries>25</maxRetries>
+ <maxDnsProblemRetries>0</maxDnsProblemRetries>
+ <deliveryThreads>10</deliveryThreads>
+ <sendpartial>true</sendpartial>
+ <bounceProcessor>bounces</bounceProcessor>
+ </mailet>
+ <mailet match="All" class="ToProcessor">
+ <processor>relay-denied</processor>
+ </mailet>
+ </processor>
+
+ <processor state="spam" enableJmx="false">
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/spam/</repositoryPath>
+ </mailet>
+ </processor>
+
+ <processor state="local-address-error" enableJmx="false">
+ <mailet match="All" class="Bounce">
+ <attachment>none</attachment>
+ </mailet>
+ </processor>
+
+ <processor state="relay-denied" enableJmx="false">
+ <mailet match="All" class="Bounce">
+ <attachment>none</attachment>
+ </mailet>
+ </processor>
+
+ <processor state="bounces" enableJmx="false">
+ <mailet match="All" class="DSNBounce">
+ <passThrough>false</passThrough>
+ </mailet>
+ </processor>
+
+ </processors>
+
+</mailetcontainer>
+
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailrepositorystore.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailrepositorystore.xml b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailrepositorystore.xml
new file mode 100644
index 0000000..3ca4a1d
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailrepositorystore.xml
@@ -0,0 +1,31 @@
+<?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.
+ -->
+
+<mailrepositorystore>
+ <mailrepositories>
+ <mailrepository class="org.apache.james.mailrepository.file.FileMailRepository">
+ <protocols>
+ <protocol>file</protocol>
+ </protocols>
+ <config FIFO="false" CACHEKEYS="true"/>
+ </mailrepository>
+ </mailrepositories>
+</mailrepositorystore>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/managesieveserver.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/managesieveserver.xml b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/managesieveserver.xml
new file mode 100644
index 0000000..ec57e09
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/managesieveserver.xml
@@ -0,0 +1,65 @@
+<?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.
+ -->
+
+<!--
+ This template file can be used as example for James Server configuration
+ DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+-->
+
+<!-- See http://james.apache.org/server/3/config.html for usage -->
+
+<managesieveservers>
+
+ <managesieveserver enabled="true">
+
+ <jmxName>managesieveserver</jmxName>
+
+ <bind>0.0.0.0:4190</bind>
+
+ <connectionBacklog>200</connectionBacklog>
+
+ <tls socketTLS="false" startTLS="false">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <!-- The algorithm is optional and only needs to be specified when using something other
+ than the Sun JCE provider - You could use IbmX509 with IBM Java runtime. -->
+ <algorithm>SunX509</algorithm>
+ </tls>
+
+ <!-- connection timeout in secconds -->
+ <connectiontimeout>360</connectiontimeout>
+
+ <!-- Set the maximum simultaneous incoming connections for this service -->
+ <connectionLimit>0</connectionLimit>
+
+ <!-- Set the maximum simultaneous incoming connections per IP for this service -->
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+
+ </managesieveserver>
+
+</managesieveservers>
+
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/pop3server.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/pop3server.xml b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/pop3server.xml
new file mode 100644
index 0000000..e4187da
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/pop3server.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.
+ -->
+
+
+<pop3servers>
+ <pop3server enabled="true">
+ <jmxName>pop3server</jmxName>
+ <bind>0.0.0.0:1110</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <!-- To create a new keystore execute:
+ keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
+ -->
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ </tls>
+ <connectiontimeout>1200</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <handlerchain>
+ <handler class="org.apache.james.pop3server.core.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </pop3server>
+</pop3servers>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/smtpserver.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/smtpserver.xml b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/smtpserver.xml
new file mode 100644
index 0000000..a3d4b8f
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/smtpserver.xml
@@ -0,0 +1,105 @@
+<?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.
+ -->
+
+<smtpservers>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-global</jmxName>
+ <bind>0.0.0.0:1025</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>
+ <authRequired>false</authRequired>
+ <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
+ <verifyIdentity>true</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-TLS</jmxName>
+ <bind>0.0.0.0:10465</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>
+ <!--
+ Authorize only local users
+ -->
+ <authRequired>true</authRequired>
+ <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
+ <!-- Trust authenticated users -->
+ <verifyIdentity>false</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-authenticated</jmxName>
+ <bind>0.0.0.0:1587</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>
+ <!--
+ Authorize only local users
+ -->
+ <authRequired>true</authRequired>
+ <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
+ <!-- Trust authenticated users -->
+ <verifyIdentity>false</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+</smtpservers>
+
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/pom.xml b/server/protocols/jmap-integration-testing/pom.xml
deleted file mode 100644
index 9afcc41..0000000
--- a/server/protocols/jmap-integration-testing/pom.xml
+++ /dev/null
@@ -1,269 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <artifactId>james-server</artifactId>
- <groupId>org.apache.james</groupId>
- <version>3.0.0-beta5-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <artifactId>james-server-jmap-integration-testing</artifactId>
- <packaging>jar</packaging>
-
- <name>Apache James :: Server :: JMAP :: Integration testing</name>
-
- <profiles>
- <profile>
- <id>noTest</id>
- <activation>
- <os>
- <family>windows</family>
- </os>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skipTests>true</skipTests>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>disable-build-for-older-jdk</id>
- <activation>
- <jdk>(,1.8)</jdk>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <id>default-jar</id>
- <phase>none</phase>
- </execution>
- <execution>
- <id>jar</id>
- <phase>none</phase>
- </execution>
- <execution>
- <id>test-jar</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <executions>
- <execution>
- <id>default-compile</id>
- <phase>none</phase>
- </execution>
- <execution>
- <id>default-testCompile</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <executions>
- <execution>
- <id>default-test</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-install-plugin</artifactId>
- <executions>
- <execution>
- <id>default-install</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <executions>
- <execution>
- <id>default-resources</id>
- <phase>none</phase>
- </execution>
- <execution>
- <id>default-testResources</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-descriptor</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>build-for-jdk-8</id>
- <activation>
- <jdk>[1.8,)</jdk>
- </activation>
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>apache-james-mailbox-elasticsearch</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.james</groupId>
- <artifactId>james-server-cassandra-guice</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.james</groupId>
- <artifactId>james-server-cassandra-guice</artifactId>
- <scope>test</scope>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>org.apache.james</groupId>
- <artifactId>james-server-protocols-library</artifactId>
- <scope>test</scope>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>18.0</version> <!--$NO-MVN-MAN-VER$-->
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.google.inject</groupId>
- <artifactId>guice</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.inject.extensions</groupId>
- <artifactId>guice-multibindings</artifactId>
- </dependency>
- <dependency>
- <groupId>com.jayway.restassured</groupId>
- <artifactId>rest-assured</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <version>${assertj-3.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.cassandraunit</groupId>
- <artifactId>cassandra-unit</artifactId>
- <version>${cassandra-unit.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- <version>2.0.0.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.testcontainers</groupId>
- <artifactId>testcontainers</artifactId>
- <version>1.0.2</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <mainClass>fully.qualified.MainClass</mainClass>
- </manifest>
- </archive>
- <descriptorRefs>
- <descriptorRef>jar-with-dependencies</descriptorRef>
- </descriptorRefs>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>disable-animal-sniffer</id>
- <activation>
- <jdk>[1.6,)</jdk>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>animal-sniffer-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>check_java_6</id>
- <phase>none</phase>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/CassandraJmapAuthenticationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/CassandraJmapAuthenticationTest.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/CassandraJmapAuthenticationTest.java
deleted file mode 100644
index b53f416..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/CassandraJmapAuthenticationTest.java
+++ /dev/null
@@ -1,39 +0,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. *
- ****************************************************************/
-package org.apache.james.jmap;
-
-import org.apache.james.backends.cassandra.EmbeddedCassandra;
-import org.apache.james.jmap.cassandra.CassandraJmapServer;
-import org.apache.james.jmap.utils.ZonedDateTimeProvider;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
-import org.junit.rules.TemporaryFolder;
-
-import com.google.inject.util.Modules;
-
-public class CassandraJmapAuthenticationTest extends JMAPAuthenticationTest {
-
- @Override
- protected JmapServer jmapServer(TemporaryFolder temporaryFolder, EmbeddedElasticSearch embeddedElasticSearch, EmbeddedCassandra cassandra, ZonedDateTimeProvider zonedDateTimeProvider) {
- return new CassandraJmapServer(
- Modules.combine(
- CassandraJmapServer.defaultOverrideModule(temporaryFolder, embeddedElasticSearch, cassandra),
- (binder) -> binder.bind(ZonedDateTimeProvider.class).toInstance(zonedDateTimeProvider)));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/ContainerTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/ContainerTest.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/ContainerTest.java
deleted file mode 100644
index 7a8c488..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/ContainerTest.java
+++ /dev/null
@@ -1,46 +0,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. *
- ****************************************************************/
-package org.apache.james.jmap;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.io.IOException;
-import java.net.URISyntaxException;
-
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.fluent.Request;
-import org.apache.http.client.fluent.Response;
-import org.apache.http.client.utils.URIBuilder;
-import org.junit.Rule;
-import org.junit.Test;
-import org.testcontainers.containers.GenericContainer;
-
-public class ContainerTest {
-
- @Rule public GenericContainer container = new GenericContainer("nginx:1.7.1")
- .withExposedPorts(80);
-
- @Test
- public void containerShouldBeReachableOnExposedPort() throws ClientProtocolException, IOException, URISyntaxException {
- String containerIpAddress = container.getContainerIpAddress();
- Integer containerPort = container.getMappedPort(80);
- Response response = Request.Get(new URIBuilder().setScheme("http").setHost(containerIpAddress).setPort(containerPort).build()).execute();
- assertThat(response.returnResponse().getStatusLine().getStatusCode()).isEqualTo(200);
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/FixedDateZonedDateTimeProvider.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/FixedDateZonedDateTimeProvider.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/FixedDateZonedDateTimeProvider.java
deleted file mode 100644
index 3dddcec..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/FixedDateZonedDateTimeProvider.java
+++ /dev/null
@@ -1,39 +0,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. *
- ****************************************************************/
-
-package org.apache.james.jmap;
-
-import java.time.ZonedDateTime;
-
-import org.apache.james.jmap.utils.ZonedDateTimeProvider;
-
-public class FixedDateZonedDateTimeProvider implements ZonedDateTimeProvider {
-
- private ZonedDateTime zonedDateTime;
-
- public void setFixedDateTime(ZonedDateTime zonedDateTime) {
- this.zonedDateTime = zonedDateTime;
- }
-
- @Override
- public ZonedDateTime get() {
- return zonedDateTime;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JMAPAuthenticationTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JMAPAuthenticationTest.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JMAPAuthenticationTest.java
deleted file mode 100644
index a99f840..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JMAPAuthenticationTest.java
+++ /dev/null
@@ -1,478 +0,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. *
- ****************************************************************/
-package org.apache.james.jmap;
-
-import static com.jayway.restassured.RestAssured.given;
-import static com.jayway.restassured.RestAssured.with;
-import static com.jayway.restassured.config.EncoderConfig.encoderConfig;
-import static com.jayway.restassured.config.RestAssuredConfig.newConfig;
-import static org.hamcrest.Matchers.hasItem;
-import static org.hamcrest.Matchers.*;
-
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.UUID;
-
-import org.apache.james.backends.cassandra.EmbeddedCassandra;
-import org.apache.james.jmap.model.ContinuationToken;
-import org.apache.james.jmap.utils.ZonedDateTimeProvider;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TemporaryFolder;
-
-import com.google.common.base.Charsets;
-import com.jayway.restassured.RestAssured;
-import com.jayway.restassured.http.ContentType;
-
-public abstract class JMAPAuthenticationTest {
-
- private static final ZonedDateTime oldDate = ZonedDateTime.parse("2011-12-03T10:15:30+01:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME);
- private static final ZonedDateTime newDate = ZonedDateTime.parse("2011-12-03T10:16:30+01:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME);
- private static final ZonedDateTime afterExpirationDate = ZonedDateTime.parse("2011-12-03T10:30:31+01:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME);
-
- private TemporaryFolder temporaryFolder = new TemporaryFolder();
- private EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch();
- private EmbeddedCassandra cassandra = EmbeddedCassandra.createStartServer();
- private FixedDateZonedDateTimeProvider zonedDateTimeProvider = new FixedDateZonedDateTimeProvider();
- private JmapServer jmapServer = jmapServer(temporaryFolder, embeddedElasticSearch, cassandra, zonedDateTimeProvider);
-
-
-
- protected abstract JmapServer jmapServer(TemporaryFolder temporaryFolder, EmbeddedElasticSearch embeddedElasticSearch, EmbeddedCassandra cassandra, ZonedDateTimeProvider zonedDateTimeProvider);
-
- @Rule
- public RuleChain chain = RuleChain
- .outerRule(temporaryFolder)
- .around(embeddedElasticSearch)
- .around(jmapServer);
-
- private UserCredentials userCredentials;
-
- @Before
- public void setup() throws Exception {
- RestAssured.port = jmapServer.getPort();
- RestAssured.config = newConfig().encoderConfig(encoderConfig().defaultContentCharset(Charsets.UTF_8));
-
-
- userCredentials = UserCredentials.builder()
- .username("user@domain.tld")
- .password("password")
- .build();
-
-
- String domain = "domain.tld";
- jmapServer.serverProbe().addDomain(domain);
- jmapServer.serverProbe().addUser(userCredentials.getUsername(), userCredentials.getPassword());
-
- zonedDateTimeProvider.setFixedDateTime(oldDate);
- }
-
- @Test
- public void mustReturnMalformedRequestWhenContentTypeIsMissing() {
- given()
- .accept(ContentType.JSON)
- .when()
- .post("/authentication")
- .then()
- .statusCode(400);
- }
-
- @Test
- public void mustReturnMalformedRequestWhenContentTypeIsNotJson() {
- given()
- .contentType(ContentType.XML)
- .accept(ContentType.JSON)
- .when()
- .post("/authentication")
- .then()
- .statusCode(400);
- }
-
- @Test
- public void mustReturnMalformedRequestWhenAcceptIsMissing() {
- given()
- .contentType(ContentType.JSON)
- .when()
- .post("/authentication")
- .then()
- .statusCode(400);
- }
-
- @Test
- public void mustReturnMalformedRequestWhenAcceptIsNotJson() {
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.XML)
- .when()
- .post("/authentication")
- .then()
- .statusCode(400);
- }
-
- @Test
- public void mustReturnMalformedRequestWhenCharsetIsNotUTF8() {
- given()
- .contentType("application/json; charset=ISO-8859-1")
- .accept(ContentType.JSON)
- .when()
- .post("/authentication")
- .then()
- .statusCode(400);
- }
-
- @Test
- public void mustReturnMalformedRequestWhenBodyIsEmpty() {
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .when()
- .post("/authentication")
- .then()
- .statusCode(400);
- }
-
- @Test
- public void mustReturnMalformedRequestWhenBodyIsNotAcceptable() {
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"badAttributeName\": \"value\"}")
- .when()
- .post("/authentication")
- .then()
- .statusCode(400);
- }
-
- @Test
- public void mustReturnJsonResponse() throws Exception {
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"username\": \"" + userCredentials.getUsername() + "\", \"clientName\": \"Mozilla Thunderbird\", \"clientVersion\": \"42.0\", \"deviceName\": \"Joe Blogg’s iPhone\"}")
- .when()
- .post("/authentication")
- .then()
- .statusCode(200)
- .contentType(ContentType.JSON);
- }
-
- @Test
- public void methodShouldContainPasswordWhenValidResquest() throws Exception {
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"username\": \"" + userCredentials.getUsername() + "\", \"clientName\": \"Mozilla Thunderbird\", \"clientVersion\": \"42.0\", \"deviceName\": \"Joe Blogg’s iPhone\"}")
- .when()
- .post("/authentication")
- .then()
- .statusCode(200)
- .body("methods", hasItem(userCredentials.getPassword()));
- }
-
- @Test
- public void mustReturnContinuationTokenWhenValidResquest() throws Exception {
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"username\": \"" + userCredentials.getUsername() + "\", \"clientName\": \"Mozilla Thunderbird\", \"clientVersion\": \"42.0\", \"deviceName\": \"Joe Blogg’s iPhone\"}")
- .when()
- .post("/authentication")
- .then()
- .statusCode(200)
- .body("continuationToken", isA(String.class));
- }
-
- @Test
- public void mustReturnAuthenticationFailedWhenBadPassword() throws Exception {
- String continuationToken = fromGoodContinuationTokenRequest();
-
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"token\": \"" + continuationToken + "\", \"method\": \"password\", \"password\": \"badpassword\"}")
- .when()
- .post("/authentication")
- .then()
- .statusCode(401);
- }
-
- @Test
- public void mustReturnAuthenticationFailedWhenContinuationTokenIsRejectedByTheContinuationTokenManager() throws Exception {
- ContinuationToken badContinuationToken = new ContinuationToken(userCredentials.getUsername(), newDate, "badSignature");
-
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"token\": \"" + badContinuationToken.serialize() + "\", \"method\": \"password\", \"password\": \"" + userCredentials.getPassword() + "\"}")
- .when()
- .post("/authentication")
- .then()
- .statusCode(401);
- }
-
- @Test
- public void mustReturnRestartAuthenticationWhenContinuationTokenIsExpired() throws Exception {
- String continuationToken = fromGoodContinuationTokenRequest();
- zonedDateTimeProvider.setFixedDateTime(afterExpirationDate);
-
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"token\": \"" + continuationToken + "\", \"method\": \"password\", \"password\": \"" + userCredentials.getPassword() + "\"}")
- .when()
- .post("/authentication")
- .then()
- .statusCode(403);
- }
-
- @Test
- public void mustReturnAuthenticationFailedWhenUsersRepositoryException() throws Exception {
- String continuationToken = fromGoodContinuationTokenRequest();
-
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"token\": \"" + continuationToken + "\", \"method\": \"password\", \"password\": \"" + "wrong password" + "\"}")
- .when()
- .post("/authentication")
- .then()
- .statusCode(401);
- }
-
- @Test
- public void mustReturnCreatedWhenGoodPassword() throws Exception {
- String continuationToken = fromGoodContinuationTokenRequest();
- zonedDateTimeProvider.setFixedDateTime(newDate);
-
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"token\": \"" + continuationToken + "\", \"method\": \"password\", \"password\": \"" + userCredentials.getPassword() + "\"}")
- .when()
- .post("/authentication")
- .then()
- .statusCode(201);
- }
-
- @Test
- public void mustSendJsonContainingAccessTokenAndEndpointsWhenGoodPassword() throws Exception {
- String continuationToken = fromGoodContinuationTokenRequest();
- zonedDateTimeProvider.setFixedDateTime(newDate);
-
- given()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"token\": \"" + continuationToken + "\", \"method\": \"password\", \"password\": \"" + userCredentials.getPassword() + "\"}")
- .when()
- .post("/authentication")
- .then()
- .body("accessToken", isA(String.class))
- .body("api", equalTo("/jmap"))
- .body("eventSource", both(isA(String.class)).and(notNullValue()))
- .body("upload", both(isA(String.class)).and(notNullValue()))
- .body("download", both(isA(String.class)).and(notNullValue()));
- }
-
- @Test
- public void getMustReturnUnauthorizedWithoutAuthroizationHeader() throws Exception {
- given()
- .when()
- .get("/authentication")
- .then()
- .statusCode(401);
- }
-
- @Test
- public void getMustReturnUnauthorizedWithoutAValidAuthroizationHeader() throws Exception {
- given()
- .header("Authorization", UUID.randomUUID())
- .when()
- .get("/authentication")
- .then()
- .statusCode(401);
- }
-
- @Test
- public void getMustReturnEndpointsWhenValidAuthorizationHeader() throws Exception {
- String continuationToken = fromGoodContinuationTokenRequest();
- String token = fromGoodAccessTokenRequest(continuationToken);
-
- given()
- .header("Authorization", token)
- .when()
- .get("/authentication")
- .then()
- .statusCode(200)
- .body("api", equalTo("/jmap"))
- .body("eventSource", both(isA(String.class)).and(notNullValue()))
- .body("upload", both(isA(String.class)).and(notNullValue()))
- .body("download", both(isA(String.class)).and(notNullValue()));
- }
-
- @Test
- public void getMustReturnEndpointsWhenValidJwtAuthorizationHeader() throws Exception {
- String token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIn0.T04BTk" +
- "LXkJj24coSZkK13RfG25lpvmSl2MJ7N10KpBk9_-95EGYZdog-BDAn3PJzqVw52z-Bwjh4VOj1-j7cURu0cT4jXehhUrlCxS4n7QHZ" +
- "DN_bsEYGu7KzjWTpTsUiHe-rN7izXVFxDGG1TGwlmBCBnPW-EFCf9ylUsJi0r2BKNdaaPRfMIrHptH1zJBkkUziWpBN1RNLjmvlAUf" +
- "49t1Tbv21ZqYM5Ht2vrhJWczFbuC-TD-8zJkXhjTmA1GVgomIX5dx1cH-dZX1wANNmshUJGHgepWlPU-5VIYxPEhb219RMLJIELMY2" +
- "qNOR8Q31ydinyqzXvCSzVJOf6T60-w";
-
- given()
- .header("Authorization", "Bearer " + token)
- .when()
- .get("/authentication")
- .then()
- .statusCode(200);
- }
-
- @Test
- public void getMustReturnEndpointsWhenValidUnkwnonUserJwtAuthorizationHeader() throws Exception {
- String token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMzM3IiwibmFtZSI6Ik5ldyBVc2VyIn0.ci8U04EOWKpi_y"
- + "faKs8fnCBcu1mWs8fvf-t9SDP2kkvDDfD-ya4sEGn4ueCp2dA2ndefZfVu_IfvdlVtxqzSf0tQ-dFKrIe-OtSKhI2otjWctLtk9A"
- + "G7jpWkXoDgr5IOVmsqg37Zxc2bgkLkC5FJqV6oCp51TNQTH6zZbXIUeuGFbHj2-iJeX8sACKTQB0llwc6TFm7GYUF03rv4DfJjqp"
- + "Kd0g8RdnlevSOjV-gGzvKEItugtexS5pgOZ2GYcvqEUDb9EnQR7Qe2EzPAX_FCJfGhlv7bDQlTgOHHAjqw2lD4-zeAznw-3wlYLS"
- + "zhi4ivvPjT-y2T5wnnhzeeYOpYOQ";
-
- given()
- .header("Authorization", "Bearer " + token)
- .when()
- .get("/authentication")
- .then()
- .statusCode(200);
- }
-
- @Test
- public void getMustReturnBadCredentialsWhenInvalidJwtAuthorizationHeader() throws Exception {
- String token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIn0.T04BTk" +
- "LXkJj24coSZkK13RfG25lpvmSl2MJ7N10KpBk9_-95EGYZdog-BDAn3PJzqVw52z-Bwjh4VOj1-j7cURu0cT4jXehhUrlCxS4n7QHZ" +
- "EN_bsEYGu7KzjWTpTsUiHe-rN7izXVFxDGG1TGwlmBCBnPW-EFCf9ylUsJi0r2BKNdaaPRfMIrHptH1zJBkkUziWpBN1RNLjmvlAUf" +
- "49t1Tbv21ZqYM5Ht2vrhJWczFbuC-TD-8zJkXhjTmA1GVgomIX5dx1cH-dZX1wANNmshUJGHgepWlPU-5VIYxPEhb219RMLJIELMY2" +
- "qNOR8Q31ydinyqzXvCSzVJOf6T60-w";
-
- given()
- .header("Authorization", "Bearer " + token)
- .when()
- .get("/authentication")
- .then()
- .statusCode(401);
- }
-
- @Test
- public void optionsRequestsShouldNeverRequireAuthentication() {
- given()
- .when()
- .options("/authentication")
- .then()
- .statusCode(200);
- }
-
- @Test
- public void getMustReturnEndpointsWhenCorrectAuthentication() throws Exception {
- String continuationToken = fromGoodContinuationTokenRequest();
- zonedDateTimeProvider.setFixedDateTime(newDate);
-
- String accessToken = fromGoodAccessTokenRequest(continuationToken);
-
- given()
- .header("Authorization", accessToken)
- .when()
- .get("/authentication")
- .then()
- .statusCode(200)
- .body("api", isA(String.class));
- }
-
- @Test
- public void deleteMustReturnUnauthenticatedWithoutAuthorizationHeader() throws Exception {
- given()
- .when()
- .delete("/authentication")
- .then()
- .statusCode(401);
- }
-
- @Test
- public void deleteMustReturnUnauthenticatedWithoutAValidAuthroizationHeader() throws Exception {
- given()
- .header("Authorization", UUID.randomUUID())
- .when()
- .delete("/authentication")
- .then()
- .statusCode(401);
- }
-
- @Test
- public void deleteMustReturnOKNoContentOnValidAuthorizationToken() throws Exception {
- String continuationToken = fromGoodContinuationTokenRequest();
- String token = fromGoodAccessTokenRequest(continuationToken);
- given()
- .header("Authorization", token)
- .when()
- .delete("/authentication")
- .then()
- .statusCode(204);
- }
-
- @Test
- public void deleteMustInvalidAuthorizationOnCorrectAuthorization() throws Exception {
- String continuationToken = fromGoodContinuationTokenRequest();
- zonedDateTimeProvider.setFixedDateTime(newDate);
-
- String accessToken = fromGoodAccessTokenRequest(continuationToken);
-
- goodDeleteAccessTokenRequest(accessToken);
-
- given()
- .header("Authorization", accessToken)
- .when()
- .get("/authentication")
- .then()
- .statusCode(401);
- }
-
- private String fromGoodContinuationTokenRequest() {
- return with()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"username\": \"" + userCredentials.getUsername() + "\", \"clientName\": \"Mozilla Thunderbird\", \"clientVersion\": \"42.0\", \"deviceName\": \"Joe Blogg’s iPhone\"}")
- .post("/authentication")
- .body()
- .path("continuationToken")
- .toString();
- }
-
- private String fromGoodAccessTokenRequest(String continuationToken) {
- return with()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"token\": \"" + continuationToken + "\", \"method\": \"password\", \"password\": \"" + userCredentials.getPassword() + "\"}")
- .post("/authentication")
- .path("accessToken")
- .toString();
- }
-
- private void goodDeleteAccessTokenRequest(String accessToken) {
- with()
- .header("Authorization", accessToken)
- .delete("/authentication");
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JmapAuthentication.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JmapAuthentication.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JmapAuthentication.java
deleted file mode 100644
index b9fa503..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JmapAuthentication.java
+++ /dev/null
@@ -1,55 +0,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. *
- ****************************************************************/
-
-package org.apache.james.jmap;
-
-import static com.jayway.restassured.RestAssured.with;
-
-import org.apache.james.jmap.api.access.AccessToken;
-
-import com.jayway.restassured.http.ContentType;
-
-public class JmapAuthentication {
-
- public static AccessToken authenticateJamesUser(String username, String password) {
- String continuationToken = getContinuationToken(username);
-
- return AccessToken.fromString(
- with()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"token\": \"" + continuationToken + "\", \"method\": \"password\", \"password\": \"" + password + "\"}")
- .post("/authentication")
- .body()
- .jsonPath()
- .getString("accessToken")
- );
- }
-
- private static String getContinuationToken(String username) {
- return with()
- .contentType(ContentType.JSON)
- .accept(ContentType.JSON)
- .body("{\"username\": \"" + username + "\", \"clientName\": \"Mozilla Thunderbird\", \"clientVersion\": \"42.0\", \"deviceName\": \"Joe Blogg’s iPhone\"}")
- .post("/authentication")
- .body()
- .path("continuationToken")
- .toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JmapServer.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JmapServer.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JmapServer.java
deleted file mode 100644
index 69c136b..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/JmapServer.java
+++ /dev/null
@@ -1,31 +0,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. *
- ****************************************************************/
-
-package org.apache.james.jmap;
-
-import org.apache.james.utils.ExtendedServerProbe;
-import org.junit.rules.TestRule;
-
-public interface JmapServer extends TestRule {
-
- int getPort();
-
- ExtendedServerProbe serverProbe();
-
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/UserCredentials.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/UserCredentials.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/UserCredentials.java
deleted file mode 100644
index 25a1994..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/UserCredentials.java
+++ /dev/null
@@ -1,66 +0,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. *
- ****************************************************************/
-
-package org.apache.james.jmap;
-
-public class UserCredentials {
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
-
- private String username;
- private String password;
-
- private Builder() {
- }
-
- public Builder username(String username) {
- this.username = username;
- return this;
- }
-
- public Builder password(String password) {
- this.password = password;
- return this;
- }
-
- public UserCredentials build() {
- return new UserCredentials(username, password);
- }
- }
-
- private final String username;
- private final String password;
-
- private UserCredentials(String username, String password) {
- this.username = username;
- this.password = password;
- }
-
- public String getUsername() {
- return username;
- }
-
- public String getPassword() {
- return password;
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapServer.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapServer.java b/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapServer.java
deleted file mode 100644
index f81037c..0000000
--- a/server/protocols/jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapServer.java
+++ /dev/null
@@ -1,109 +0,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. *
- ****************************************************************/
-
-package org.apache.james.jmap.cassandra;
-
-import javax.inject.Singleton;
-
-import org.apache.james.CassandraJamesServer;
-import org.apache.james.CassandraJamesServerMain;
-import org.apache.james.backends.cassandra.CassandraCluster;
-import org.apache.james.backends.cassandra.EmbeddedCassandra;
-import org.apache.james.jmap.JmapServer;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
-import org.apache.james.modules.TestElasticSearchModule;
-import org.apache.james.modules.TestFilesystemModule;
-import org.apache.james.modules.TestJMAPServerModule;
-import org.apache.james.utils.ExtendedServerProbe;
-import org.junit.rules.TemporaryFolder;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Module;
-import com.google.inject.Provides;
-import com.google.inject.util.Modules;
-
-public class CassandraJmapServer implements JmapServer {
-
- private static final int LIMIT_TO_3_MESSAGES = 3;
-
- private CassandraJamesServer server;
-
- private final Module module;
-
- public static Module defaultOverrideModule(TemporaryFolder temporaryFolder, EmbeddedElasticSearch embeddedElasticSearch, EmbeddedCassandra cassandra) {
- return Modules.combine(new TestElasticSearchModule(embeddedElasticSearch),
- new TestFilesystemModule(temporaryFolder),
- new TestJMAPServerModule(LIMIT_TO_3_MESSAGES),
- new AbstractModule() {
-
- @Override
- protected void configure() {
- bind(EmbeddedCassandra.class).toInstance(cassandra);
- }
-
- @Provides
- @Singleton
- com.datastax.driver.core.Session provideSession(CassandraCluster initializedCassandra) {
- return initializedCassandra.getConf();
- }
- });
- }
-
-
- public CassandraJmapServer(Module overrideModule) {
- this.module = Modules.override(CassandraJamesServerMain.defaultModule).with(overrideModule);
- }
-
- @Override
- public Statement apply(Statement base, Description description) {
- return new Statement() {
-
- @Override
- public void evaluate() throws Throwable {
- try {
- before();
- base.evaluate();
- } finally {
- after();
- }
- }
- };
- }
-
- private void before() throws Throwable {
- server = new CassandraJamesServer(module);
- server.start();
- }
-
- private void after() {
- server.stop();
- }
-
- @Override
- public int getPort() {
- return server.getJmapPort();
- }
-
- @Override
- public ExtendedServerProbe serverProbe() {
- return server.serverProbe();
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org