JAMES-2597 Add tests with and without Swift to CassandraRabbitMQLdapServer
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/b686c7f9 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/b686c7f9 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/b686c7f9 Branch: refs/heads/master Commit: b686c7f9e8258986fd23741e85b530118c5399c3 Parents: 620576e Author: datph <[email protected]> Authored: Tue Nov 20 16:16:59 2018 +0700 Committer: Benoit Tellier <[email protected]> Committed: Mon Nov 26 16:40:45 2018 +0700 ---------------------------------------------------------------------- .../guice/cassandra-rabbitmq-ldap-guice/pom.xml | 20 ++- .../CassandraRabbitMQLdapJamesServerTest.java | 90 ------------- ...assandraRabbitMQLdapJmapJamesServerTest.java | 126 +++++++++++++++++++ .../src/test/resources/ldif-files/Dockerfile | 3 - .../src/test/resources/ldif-files/populate.ldif | 11 -- server/container/guice/pom.xml | 8 ++ 6 files changed, 152 insertions(+), 106 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/b686c7f9/server/container/guice/cassandra-rabbitmq-ldap-guice/pom.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-ldap-guice/pom.xml b/server/container/guice/cassandra-rabbitmq-ldap-guice/pom.xml index 125adbb..6ba6d33 100644 --- a/server/container/guice/cassandra-rabbitmq-ldap-guice/pom.xml +++ b/server/container/guice/cassandra-rabbitmq-ldap-guice/pom.xml @@ -1,4 +1,22 @@ <?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/xsd/maven-4.0.0.xsd"> @@ -30,7 +48,6 @@ <dependency> <groupId>org.apache.james</groupId> <artifactId>apache-james-backends-rabbitmq</artifactId> - <version>${project.version}</version> <type>test-jar</type> <scope>test</scope> </dependency> @@ -75,7 +92,6 @@ <dependency> <groupId>org.apache.james</groupId> <artifactId>james-server-data-ldap-integration-testing</artifactId> - <version>${project.version}</version> <type>test-jar</type> <scope>test</scope> </dependency> http://git-wip-us.apache.org/repos/asf/james-project/blob/b686c7f9/server/container/guice/cassandra-rabbitmq-ldap-guice/src/test/java/org/apache/james/CassandraRabbitMQLdapJamesServerTest.java ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-ldap-guice/src/test/java/org/apache/james/CassandraRabbitMQLdapJamesServerTest.java b/server/container/guice/cassandra-rabbitmq-ldap-guice/src/test/java/org/apache/james/CassandraRabbitMQLdapJamesServerTest.java deleted file mode 100644 index 2ed0203..0000000 --- a/server/container/guice/cassandra-rabbitmq-ldap-guice/src/test/java/org/apache/james/CassandraRabbitMQLdapJamesServerTest.java +++ /dev/null @@ -1,90 +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; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.awaitility.Duration.ONE_HUNDRED_MILLISECONDS; - -import java.io.IOException; - -import org.apache.commons.net.imap.IMAPClient; -import org.apache.james.core.Domain; -import org.apache.james.modules.RabbitMQExtension; -import org.apache.james.modules.SwiftBlobStoreExtension; -import org.apache.james.modules.TestJMAPServerModule; -import org.apache.james.modules.protocols.ImapGuiceProbe; -import org.apache.james.modules.protocols.SmtpGuiceProbe; -import org.apache.james.utils.IMAPMessageReader; -import org.apache.james.utils.SMTPMessageSender; -import org.apache.james.utils.SpoolerProbe; -import org.awaitility.Awaitility; -import org.awaitility.Duration; -import org.awaitility.core.ConditionFactory; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; - -public class CassandraRabbitMQLdapJamesServerTest implements JmapJamesServerContract { - private static final int LIMIT_TO_10_MESSAGES = 10; - private static final String JAMES_USER = "james-user"; - private static final String PASSWORD = "secret"; - private static Duration slowPacedPollInterval = ONE_HUNDRED_MILLISECONDS; - private static ConditionFactory calmlyAwait = Awaitility - .with().pollInterval(slowPacedPollInterval) - .and().with().pollDelay(slowPacedPollInterval) - .await(); - private IMAPClient imapClient = new IMAPClient(); - - @RegisterExtension - IMAPMessageReader imapMessageReader = new IMAPMessageReader(); - SMTPMessageSender messageSender = new SMTPMessageSender(Domain.LOCALHOST.asString()); - - @RegisterExtension - static JamesServerExtension testExtension = new JamesServerExtensionBuilder() - .extension(new EmbeddedElasticSearchExtension()) - .extension(new CassandraExtension()) - .extension(new RabbitMQExtension()) - .extension(new LdapTestExtention()) - .extension(new SwiftBlobStoreExtension()) - .server(configuration -> GuiceJamesServer.forConfiguration(configuration) - .combineWith(CassandraRabbitMQLdapJamesServerMain.MODULES) - .overrideWith(new TestJMAPServerModule(LIMIT_TO_10_MESSAGES)) - .overrideWith(DOMAIN_LIST_CONFIGURATION_MODULE)) - .build(); - - @Test - void userFromLdapShouldLoginViaImapProtocol(GuiceJamesServer server) throws IOException { - imapClient.connect(JAMES_SERVER_HOST, server.getProbe(ImapGuiceProbe.class).getImapPort()); - - assertThat(imapClient.login(JAMES_USER, PASSWORD)).isTrue(); - } - - @Test - void mailsShouldBeWellReceivedBeforeFirstUserConnectionWithLdap(GuiceJamesServer server) throws Exception { - messageSender.connect(JAMES_SERVER_HOST, server.getProbe(SmtpGuiceProbe.class).getSmtpPort()) - .sendMessage("[email protected]", JAMES_USER + "@localhost"); - - calmlyAwait.until(() -> server.getProbe(SpoolerProbe.class).processingFinished()); - - imapMessageReader.connect(JAMES_SERVER_HOST, server.getProbe(ImapGuiceProbe.class).getImapPort()) - .login(JAMES_USER, PASSWORD) - .select("INBOX") - .awaitMessage(calmlyAwait); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/b686c7f9/server/container/guice/cassandra-rabbitmq-ldap-guice/src/test/java/org/apache/james/CassandraRabbitMQLdapJmapJamesServerTest.java ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-ldap-guice/src/test/java/org/apache/james/CassandraRabbitMQLdapJmapJamesServerTest.java b/server/container/guice/cassandra-rabbitmq-ldap-guice/src/test/java/org/apache/james/CassandraRabbitMQLdapJmapJamesServerTest.java new file mode 100644 index 0000000..e79f136 --- /dev/null +++ b/server/container/guice/cassandra-rabbitmq-ldap-guice/src/test/java/org/apache/james/CassandraRabbitMQLdapJmapJamesServerTest.java @@ -0,0 +1,126 @@ +/**************************************************************** + * 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; + +import static org.apache.james.JmapJamesServerContract.JAMES_SERVER_HOST; +import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Duration.ONE_HUNDRED_MILLISECONDS; + +import java.io.IOException; + +import org.apache.commons.net.imap.IMAPClient; +import org.apache.james.core.Domain; +import org.apache.james.modules.RabbitMQExtension; +import org.apache.james.modules.SwiftBlobStoreExtension; +import org.apache.james.modules.TestJMAPServerModule; +import org.apache.james.modules.blobstore.BlobStoreChoosingConfiguration; +import org.apache.james.modules.protocols.ImapGuiceProbe; +import org.apache.james.modules.protocols.SmtpGuiceProbe; +import org.apache.james.utils.IMAPMessageReader; +import org.apache.james.utils.SMTPMessageSender; +import org.apache.james.utils.SpoolerProbe; +import org.awaitility.Awaitility; +import org.awaitility.Duration; +import org.awaitility.core.ConditionFactory; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.extension.RegisterExtension; + +class CassandraRabbitMQLdapJmapJamesServerTest { + private static final int LIMIT_TO_10_MESSAGES = 10; + private static final String JAMES_USER = "james-user"; + private static final String PASSWORD = "secret"; + private static Duration slowPacedPollInterval = ONE_HUNDRED_MILLISECONDS; + + private static ConditionFactory calmlyAwait = Awaitility + .with().pollInterval(slowPacedPollInterval) + .and().with().pollDelay(slowPacedPollInterval) + .await(); + + interface MailsShouldBeWellReceived { + @RegisterExtension + IMAPMessageReader imapMessageReader = new IMAPMessageReader(); + SMTPMessageSender messageSender = new SMTPMessageSender(Domain.LOCALHOST.asString()); + + @Test + default void mailsShouldBeWellReceived(GuiceJamesServer server) throws Exception { + messageSender.connect(JAMES_SERVER_HOST, server.getProbe(SmtpGuiceProbe.class).getSmtpPort()) + .sendMessage("[email protected]", JAMES_USER + "@localhost"); + + calmlyAwait.until(() -> server.getProbe(SpoolerProbe.class).processingFinished()); + + imapMessageReader.connect(JAMES_SERVER_HOST, server.getProbe(ImapGuiceProbe.class).getImapPort()) + .login(JAMES_USER, PASSWORD) + .select("INBOX") + .awaitMessage(calmlyAwait); + } + } + + interface UserFromLdapShouldLogin { + + @Test + default void userFromLdapShouldLoginViaImapProtocol(GuiceJamesServer server) throws IOException { + IMAPClient imapClient = new IMAPClient(); + imapClient.connect(JAMES_SERVER_HOST, server.getProbe(ImapGuiceProbe.class).getImapPort()); + + assertThat(imapClient.login(JAMES_USER, PASSWORD)).isTrue(); + } + } + + interface ContractSuite extends JmapJamesServerContract, MailsShouldBeWellReceived, UserFromLdapShouldLogin {} + + @Nested + @TestInstance(TestInstance.Lifecycle.PER_CLASS) + class WithSwift implements ContractSuite { + @RegisterExtension + JamesServerExtension testExtension = new JamesServerExtensionBuilder() + .extension(new EmbeddedElasticSearchExtension()) + .extension(new CassandraExtension()) + .extension(new RabbitMQExtension()) + .extension(new LdapTestExtention()) + .extension(new SwiftBlobStoreExtension()) + .server(configuration -> GuiceJamesServer.forConfiguration(configuration) + .combineWith(CassandraRabbitMQLdapJamesServerMain.MODULES) + .overrideWith(binder -> binder.bind(BlobStoreChoosingConfiguration.class) + .toInstance(BlobStoreChoosingConfiguration.objectStorage())) + .overrideWith(new TestJMAPServerModule(LIMIT_TO_10_MESSAGES)) + .overrideWith(JmapJamesServerContract.DOMAIN_LIST_CONFIGURATION_MODULE)) + .build(); + } + + @Nested + @TestInstance(TestInstance.Lifecycle.PER_CLASS) + class WithoutSwift implements ContractSuite { + @RegisterExtension + JamesServerExtension testExtension = new JamesServerExtensionBuilder() + .extension(new EmbeddedElasticSearchExtension()) + .extension(new CassandraExtension()) + .extension(new RabbitMQExtension()) + .extension(new LdapTestExtention()) + .server(configuration -> GuiceJamesServer.forConfiguration(configuration) + .combineWith(CassandraRabbitMQLdapJamesServerMain.MODULES) + .overrideWith(binder -> binder.bind(BlobStoreChoosingConfiguration.class) + .toInstance(BlobStoreChoosingConfiguration.cassandra())) + .overrideWith(new TestJMAPServerModule(LIMIT_TO_10_MESSAGES)) + .overrideWith(JmapJamesServerContract.DOMAIN_LIST_CONFIGURATION_MODULE)) + .build(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/b686c7f9/server/container/guice/cassandra-rabbitmq-ldap-guice/src/test/resources/ldif-files/Dockerfile ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-ldap-guice/src/test/resources/ldif-files/Dockerfile b/server/container/guice/cassandra-rabbitmq-ldap-guice/src/test/resources/ldif-files/Dockerfile deleted file mode 100644 index d889a35..0000000 --- a/server/container/guice/cassandra-rabbitmq-ldap-guice/src/test/resources/ldif-files/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM dinkel/openldap:latest - -COPY populate.ldif /etc/ldap/prepopulate/prepop.ldif http://git-wip-us.apache.org/repos/asf/james-project/blob/b686c7f9/server/container/guice/cassandra-rabbitmq-ldap-guice/src/test/resources/ldif-files/populate.ldif ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-rabbitmq-ldap-guice/src/test/resources/ldif-files/populate.ldif b/server/container/guice/cassandra-rabbitmq-ldap-guice/src/test/resources/ldif-files/populate.ldif deleted file mode 100644 index 9376a6c..0000000 --- a/server/container/guice/cassandra-rabbitmq-ldap-guice/src/test/resources/ldif-files/populate.ldif +++ /dev/null @@ -1,11 +0,0 @@ -dn: ou=people, dc=james,dc=org -ou: people -objectClass: organizationalUnit - -dn: uid=james-user, ou=people, dc=james,dc=org -objectClass: inetOrgPerson -uid: james-user -cn: james-user -sn: james-user -userPassword: secret -description: James user http://git-wip-us.apache.org/repos/asf/james-project/blob/b686c7f9/server/container/guice/pom.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/pom.xml b/server/container/guice/pom.xml index 3d2d561..fbd2fda 100644 --- a/server/container/guice/pom.xml +++ b/server/container/guice/pom.xml @@ -80,6 +80,14 @@ <artifactId>james-server-cassandra-ldap-guice</artifactId> <version>${project.version}</version> <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${james.groupId}</groupId> + <artifactId>james-server-data-ldap-integration-testing</artifactId> + <version>${project.version}</version> + <type>test-jar</type> + <scope>test</scope> </dependency> <dependency> <groupId>${james.groupId}</groupId> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
