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 bt...@apache.org on 2019/12/19 10:38:41 UTC
[james-project] 07/14: JAMES-3012 Split webadmin-integration-test
into common, memory, distributed
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 8c29dd3fdde217a8ee90e933d79f9a6cbcb57a72
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Mon Dec 16 19:26:56 2019 +0700
JAMES-3012 Split webadmin-integration-test into common, memory,
distributed
This is an attempt to setup the test model alike jmap integration test
structure. There are some tests have been disabled with a JIRA ticket
to fix them in the future. They are not the priority for now
---
pom.xml | 5 +
.../distributed-webadmin-integration-test/pom.xml | 94 ++++++++++
.../rabbitmq/RabbitMQAuthorizedEndpointsTest.java} | 37 ++--
.../RabbitMQEventDeadLettersIntegrationTest.java} | 27 +--
.../rabbitmq/RabbitMQForwardIntegrationTest.java} | 39 ++--
.../rabbitmq/RabbitMQJmapExtension.java} | 9 +-
.../RabbitMQJwtFilterIntegrationTest.java} | 40 ++--
...abbitMQReindexingWithEventDeadLettersTest.java} | 22 ++-
.../RabbitMQUnauthorizedEndpointsTest.java | 120 ++++++++++++
.../RabbitMQWebAdminServerIntegrationTest.java | 154 +++++++++++++++
...minServerTaskSerializationIntegrationTest.java} | 12 +-
...RabbitMQDeletedMessageVaultIntegrationTest.java | 54 ++++++
...LinshareBlobExportMechanismIntegrationTest.java | 59 ++++++
.../src/test/resources/dnsservice.xml | 0
.../src/test/resources/domainlist.xml | 0
.../src/test/resources/imapserver.xml | 0
.../src/test/resources/jwt_publickey | 0
.../src/test/resources/keystore | Bin
.../src/test/resources/listeners.xml} | 38 +++-
.../src/test/resources/lmtpserver.xml | 0
.../src/test/resources/mailetcontainer.xml | 0
.../src/test/resources/mailrepositorystore.xml | 0
.../src/test/resources/managesieveserver.xml | 0
.../src/test/resources/pop3server.xml | 0
.../src/test/resources/smtpserver.xml | 0
.../memory-webadmin-integration-test/pom.xml | 66 +++++++
.../memory/MemoryAuthorizedEndpointsTest.java} | 35 ++--
.../memory/MemoryForwardIntegrationTest.java} | 35 ++--
.../memory/MemoryJwtFilterIntegrationTest.java} | 38 ++--
.../memory/MemoryUnauthorizedEndpointsTest.java | 46 +++++
.../MemoryWebAdminServerIntegrationTest.java} | 33 ++--
.../MemoryDeletedMessageVaultIntegrationTest.java} | 41 ++--
...LinshareBlobExportMechanismIntegrationTest.java | 48 +++++
.../src/test/resources/dnsservice.xml | 0
.../src/test/resources/domainlist.xml | 0
.../src/test/resources/imapserver.xml | 0
.../src/test/resources/jwt_publickey | 0
.../src/test/resources/keystore | Bin
.../src/test/resources/listeners.xml} | 35 +++-
.../src/test/resources/lmtpserver.xml | 0
.../src/test/resources/mailetcontainer.xml | 6 +-
.../src/test/resources/mailrepositorystore.xml | 4 +-
.../src/test/resources/managesieveserver.xml | 0
.../src/test/resources/pop3server.xml | 0
.../src/test/resources/smtpserver.xml | 0
server/protocols/webadmin-integration-test/pom.xml | 174 ++---------------
.../integration/UnauthorizedEndpointsTest.java | 206 ---------------------
.../{ => webadmin-integration-test-common}/pom.xml | 97 +++-------
.../integration/AuthorizedEndpointsTest.java | 15 +-
.../integration/ForwardIntegrationTest.java | 15 +-
.../integration/JwtFilterIntegrationTest.java | 19 +-
.../integration/UnauthorizedEndpointsTest.java | 197 ++++++++++++++++++++
.../webadmin/integration/UnauthorizedModule.java | 0
.../integration/WebAdminServerIntegrationTest.java | 123 +-----------
.../vault/DeletedMessageVaultIntegrationTest.java | 40 ++--
.../vault/DeletedMessagesVaultRequests.java | 0
.../webadmin/integration/vault/ExportRequest.java | 0
...LinshareBlobExportMechanismIntegrationTest.java | 35 +---
58 files changed, 1155 insertions(+), 863 deletions(-)
diff --git a/pom.xml b/pom.xml
index e60eb90..1245413 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1818,6 +1818,11 @@
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
+ <artifactId>james-server-webadmin-integration-test-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
<artifactId>james-server-webadmin-mailbox</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/pom.xml b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/pom.xml
new file mode 100644
index 0000000..8c2b542
--- /dev/null
+++ b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/pom.xml
@@ -0,0 +1,94 @@
+<?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>
+ <groupId>org.apache.james</groupId>
+ <artifactId>webadmin-integration-test</artifactId>
+ <version>3.5.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>rabbitmq-webadmin-integration-test</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Apache James :: Server :: Web Admin server integration tests :: Distributed</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>apache-james-backends-cassandra</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>apache-james-backends-rabbitmq</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>apache-james-mailbox-elasticsearch</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>blob-objectstorage</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>blob-objectstorage-guice</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>james-server-cassandra-guice</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>james-server-cassandra-rabbitmq-guice</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>james-server-cassandra-rabbitmq-guice</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>james-server-webadmin-cassandra-data</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>james-server-webadmin-integration-test-common</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQAuthorizedEndpointsTest.java
similarity index 56%
copy from server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java
copy to server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQAuthorizedEndpointsTest.java
index ecd725a..56f2c6c 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java
+++ b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQAuthorizedEndpointsTest.java
@@ -16,32 +16,29 @@
* specific language governing permissions and limitations *
* under the License. *
****************************************************************/
-package org.apache.james.webadmin.integration;
-import static spark.Spark.halt;
+package org.apache.james.webadmin.integration.rabbitmq;
-import org.apache.james.webadmin.authentication.AuthenticationFilter;
-import org.eclipse.jetty.http.HttpStatus;
+import org.apache.james.CassandraRabbitMQAwsS3JmapTestRule;
+import org.apache.james.DockerCassandraRule;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.junit.categories.BasicFeature;
+import org.apache.james.webadmin.integration.AuthorizedEndpointsTest;
+import org.apache.james.webadmin.integration.UnauthorizedModule;
+import org.junit.Rule;
+import org.junit.experimental.categories.Category;
-import com.google.inject.AbstractModule;
-import com.google.inject.Scopes;
+@Category(BasicFeature.class)
+public class RabbitMQAuthorizedEndpointsTest extends AuthorizedEndpointsTest {
-import spark.Request;
-import spark.Response;
+ @Rule
+ public DockerCassandraRule cassandra = new DockerCassandraRule();
-public class UnauthorizedModule extends AbstractModule {
+ @Rule
+ public CassandraRabbitMQAwsS3JmapTestRule jamesTestRule = CassandraRabbitMQAwsS3JmapTestRule.defaultTestRule();
@Override
- protected void configure() {
- bind(UnauthorizedModule.UnauthorizedFilter.class).in(Scopes.SINGLETON);
- bind(AuthenticationFilter.class).to(UnauthorizedModule.UnauthorizedFilter.class);
- }
-
- private static class UnauthorizedFilter implements AuthenticationFilter {
-
- @Override
- public void handle(Request request, Response response) throws Exception {
- halt(HttpStatus.UNAUTHORIZED_401, "Unauthorize every endpoints.");
- }
+ protected GuiceJamesServer createJamesServer() throws Exception {
+ return jamesTestRule.jmapServer(cassandra.getModule(), new UnauthorizedModule());
}
}
\ No newline at end of file
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/EventDeadLettersIntegrationTest.java b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQEventDeadLettersIntegrationTest.java
similarity index 97%
rename from server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/EventDeadLettersIntegrationTest.java
rename to server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQEventDeadLettersIntegrationTest.java
index 1550438..d9990fc 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/EventDeadLettersIntegrationTest.java
+++ b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQEventDeadLettersIntegrationTest.java
@@ -17,7 +17,7 @@
* under the License. *
****************************************************************/
-package org.apache.james.webadmin.integration;
+package org.apache.james.webadmin.integration.rabbitmq;
import static io.restassured.RestAssured.given;
import static io.restassured.RestAssured.when;
@@ -27,7 +27,6 @@ import static org.awaitility.Duration.ONE_MINUTE;
import static org.awaitility.Duration.TEN_SECONDS;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.hasSize;
import java.util.ArrayList;
@@ -41,6 +40,7 @@ import org.apache.james.CassandraRabbitMQAwsS3JmapTestRule;
import org.apache.james.DockerCassandraRule;
import org.apache.james.GuiceJamesServer;
import org.apache.james.core.Username;
+import org.apache.james.junit.categories.BasicFeature;
import org.apache.james.mailbox.DefaultMailboxes;
import org.apache.james.mailbox.events.Event;
import org.apache.james.mailbox.events.Group;
@@ -63,14 +63,15 @@ import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.experimental.categories.Category;
import com.google.inject.multibindings.Multibinder;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
-public class EventDeadLettersIntegrationTest {
-
+@Category(BasicFeature.class)
+public class RabbitMQEventDeadLettersIntegrationTest {
public static class RetryEventsListenerGroup extends Group {
}
@@ -140,6 +141,11 @@ public class EventDeadLettersIntegrationTest {
private static final MailboxPath BOB_INBOX_PATH = MailboxPath.inbox(Username.of(BOB));
+ @Rule
+ public DockerCassandraRule cassandra = new DockerCassandraRule();
+ @Rule
+ public CassandraRabbitMQAwsS3JmapTestRule jamesTestRule = CassandraRabbitMQAwsS3JmapTestRule.defaultTestRule();
+
private Duration slowPacedPollInterval = ONE_HUNDRED_MILLISECONDS;
private ConditionFactory calmlyAwait = Awaitility.with()
.pollInterval(slowPacedPollInterval)
@@ -149,13 +155,6 @@ public class EventDeadLettersIntegrationTest {
.await();
private ConditionFactory awaitAtMostTenSeconds = calmlyAwait.atMost(10, TimeUnit.SECONDS);
private RetryEventsListener retryEventsListener;
-
- @Rule
- public DockerCassandraRule cassandra = new DockerCassandraRule();
-
- @Rule
- public CassandraRabbitMQAwsS3JmapTestRule jamesTestRule = CassandraRabbitMQAwsS3JmapTestRule.defaultTestRule();
-
private GuiceJamesServer guiceJamesServer;
private MailboxProbeImpl mailboxProbe;
@@ -163,7 +162,9 @@ public class EventDeadLettersIntegrationTest {
public void setUp() throws Exception {
retryEventsListener = new RetryEventsListener();
guiceJamesServer = jamesTestRule.jmapServer(cassandra.getModule())
- .overrideWith(binder -> Multibinder.newSetBinder(binder, MailboxListener.GroupMailboxListener.class).addBinding().toInstance(retryEventsListener));
+ .overrideWith(binder -> Multibinder.newSetBinder(binder, MailboxListener.GroupMailboxListener.class)
+ .addBinding()
+ .toInstance(retryEventsListener));
guiceJamesServer.start();
DataProbe dataProbe = guiceJamesServer.getProbe(DataProbeImpl.class);
@@ -357,6 +358,7 @@ public class EventDeadLettersIntegrationTest {
.statusCode(HttpStatus.NOT_FOUND_404);
}
+ @Category(BasicFeature.class)
@Test
public void failedEventShouldBeCorrectlyProcessedByListenerAfterSuccessfulRedelivery() throws InterruptedException {
retryEventsListener.callsPerEventBeforeSuccess(MAX_RETRIES + 1);
@@ -505,6 +507,7 @@ public class EventDeadLettersIntegrationTest {
.body(".", hasSize(0));
}
+ @Category(BasicFeature.class)
@Test
public void multipleFailedEventsShouldBeCorrectlyProcessedByListenerAfterSuccessfulAllRedelivery() {
retryEventsListener.callsPerEventBeforeSuccess(MAX_RETRIES + 1);
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQForwardIntegrationTest.java
similarity index 57%
copy from server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java
copy to server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQForwardIntegrationTest.java
index ecd725a..2631c15 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java
+++ b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQForwardIntegrationTest.java
@@ -16,32 +16,29 @@
* specific language governing permissions and limitations *
* under the License. *
****************************************************************/
-package org.apache.james.webadmin.integration;
-import static spark.Spark.halt;
+package org.apache.james.webadmin.integration.rabbitmq;
-import org.apache.james.webadmin.authentication.AuthenticationFilter;
-import org.eclipse.jetty.http.HttpStatus;
+import java.io.IOException;
-import com.google.inject.AbstractModule;
-import com.google.inject.Scopes;
+import org.apache.james.CassandraRabbitMQAwsS3JmapTestRule;
+import org.apache.james.DockerCassandraRule;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.webadmin.WebAdminConfiguration;
+import org.apache.james.webadmin.integration.ForwardIntegrationTest;
+import org.junit.Rule;
-import spark.Request;
-import spark.Response;
+public class RabbitMQForwardIntegrationTest extends ForwardIntegrationTest {
-public class UnauthorizedModule extends AbstractModule {
+ @Rule
+ public DockerCassandraRule cassandra = new DockerCassandraRule();
+ @Rule
+ public CassandraRabbitMQAwsS3JmapTestRule rule = CassandraRabbitMQAwsS3JmapTestRule.defaultTestRule();
@Override
- protected void configure() {
- bind(UnauthorizedModule.UnauthorizedFilter.class).in(Scopes.SINGLETON);
- bind(AuthenticationFilter.class).to(UnauthorizedModule.UnauthorizedFilter.class);
+ public GuiceJamesServer createJmapServer() throws IOException {
+ return rule.jmapServer(cassandra.getModule(),
+ binder -> binder.bind(WebAdminConfiguration.class)
+ .toInstance(WebAdminConfiguration.TEST_CONFIGURATION));
}
-
- private static class UnauthorizedFilter implements AuthenticationFilter {
-
- @Override
- public void handle(Request request, Response response) throws Exception {
- halt(HttpStatus.UNAUTHORIZED_401, "Unauthorize every endpoints.");
- }
- }
-}
\ No newline at end of file
+}
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/CassandraJmapExtension.java b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQJmapExtension.java
similarity index 96%
rename from server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/CassandraJmapExtension.java
rename to server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQJmapExtension.java
index 2316abd..1751b99 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/CassandraJmapExtension.java
+++ b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQJmapExtension.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations *
* under the License. *
****************************************************************/
-package org.apache.james.webadmin.integration;
+package org.apache.james.webadmin.integration.rabbitmq;
import java.io.IOException;
import java.util.Optional;
@@ -39,6 +39,7 @@ import org.apache.james.server.core.configuration.Configuration;
import org.apache.james.util.FunctionalUtils;
import org.apache.james.util.Runnables;
import org.apache.james.webadmin.WebAdminConfiguration;
+import org.apache.james.webadmin.integration.UnauthorizedModule;
import org.junit.jupiter.api.extension.AfterAllCallback;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeAllCallback;
@@ -51,7 +52,7 @@ import org.junit.rules.TemporaryFolder;
import com.github.fge.lambdas.Throwing;
-public class CassandraJmapExtension implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback, ParameterResolver {
+public class RabbitMQJmapExtension implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback, ParameterResolver {
public interface JamesLifeCyclePolicy {
JamesLifeCyclePolicy FOR_EACH_TEST = serverSupplier -> JamesLifecycleHandler.builder()
@@ -136,11 +137,11 @@ public class CassandraJmapExtension implements BeforeAllCallback, AfterAllCallba
private final JamesLifecycleHandler jamesLifecycleHandler;
private GuiceJamesServer james;
- public CassandraJmapExtension() {
+ public RabbitMQJmapExtension() {
this(JamesLifeCyclePolicy.FOR_EACH_TEST);
}
- public CassandraJmapExtension(JamesLifeCyclePolicy jamesLifeCyclePolicy) {
+ public RabbitMQJmapExtension(JamesLifeCyclePolicy jamesLifeCyclePolicy) {
this.temporaryFolder = new TemporaryFolder();
this.cassandra = new DockerCassandraRule();
this.elasticSearchRule = new DockerElasticSearchRule();
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQJwtFilterIntegrationTest.java
similarity index 54%
copy from server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java
copy to server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQJwtFilterIntegrationTest.java
index ecd725a..77a1e38 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java
+++ b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQJwtFilterIntegrationTest.java
@@ -16,32 +16,30 @@
* specific language governing permissions and limitations *
* under the License. *
****************************************************************/
-package org.apache.james.webadmin.integration;
-import static spark.Spark.halt;
+package org.apache.james.webadmin.integration.rabbitmq;
+import org.apache.james.CassandraRabbitMQAwsS3JmapTestRule;
+import org.apache.james.DockerCassandraRule;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.jwt.JwtConfiguration;
import org.apache.james.webadmin.authentication.AuthenticationFilter;
-import org.eclipse.jetty.http.HttpStatus;
+import org.apache.james.webadmin.authentication.JwtFilter;
+import org.apache.james.webadmin.integration.JwtFilterIntegrationTest;
+import org.junit.Rule;
-import com.google.inject.AbstractModule;
-import com.google.inject.Scopes;
+public class RabbitMQJwtFilterIntegrationTest extends JwtFilterIntegrationTest {
-import spark.Request;
-import spark.Response;
-
-public class UnauthorizedModule extends AbstractModule {
+ @Rule
+ public DockerCassandraRule cassandra = new DockerCassandraRule();
+
+ @Rule
+ public CassandraRabbitMQAwsS3JmapTestRule jamesTestRule = CassandraRabbitMQAwsS3JmapTestRule.defaultTestRule();
@Override
- protected void configure() {
- bind(UnauthorizedModule.UnauthorizedFilter.class).in(Scopes.SINGLETON);
- bind(AuthenticationFilter.class).to(UnauthorizedModule.UnauthorizedFilter.class);
- }
-
- private static class UnauthorizedFilter implements AuthenticationFilter {
-
- @Override
- public void handle(Request request, Response response) throws Exception {
- halt(HttpStatus.UNAUTHORIZED_401, "Unauthorize every endpoints.");
- }
+ protected GuiceJamesServer createJamesServer(JwtConfiguration jwtConfiguration) throws Exception {
+ return jamesTestRule.jmapServer(cassandra.getModule())
+ .overrideWith(binder -> binder.bind(AuthenticationFilter.class).to(JwtFilter.class),
+ binder -> binder.bind(JwtConfiguration.class).toInstance(jwtConfiguration));
}
-}
\ No newline at end of file
+}
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/ReindexingWithEventDeadLettersTest.java b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQReindexingWithEventDeadLettersTest.java
similarity index 92%
rename from server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/ReindexingWithEventDeadLettersTest.java
rename to server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQReindexingWithEventDeadLettersTest.java
index 3a8da2b..d5aeafd 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/ReindexingWithEventDeadLettersTest.java
+++ b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQReindexingWithEventDeadLettersTest.java
@@ -17,7 +17,7 @@
* under the License. *
****************************************************************/
-package org.apache.james.webadmin.integration;
+package org.apache.james.webadmin.integration.rabbitmq;
import static io.restassured.RestAssured.with;
import static org.apache.james.jmap.HttpJmapAuthentication.authenticateJamesUser;
@@ -42,6 +42,7 @@ import org.apache.james.jmap.AccessToken;
import org.apache.james.jmap.LocalHostURIBuilder;
import org.apache.james.jmap.draft.JmapGuiceProbe;
import org.apache.james.jmap.draft.JmapJamesServerContract;
+import org.apache.james.junit.categories.BasicFeature;
import org.apache.james.modules.AwsS3BlobStoreExtension;
import org.apache.james.modules.RabbitMQExtension;
import org.apache.james.modules.TestJMAPServerModule;
@@ -54,6 +55,7 @@ import org.apache.james.webadmin.WebAdminUtils;
import org.awaitility.Awaitility;
import org.awaitility.Duration;
import org.awaitility.core.ConditionFactory;
+import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@@ -63,8 +65,8 @@ import io.restassured.RestAssured;
import io.restassured.parsing.Parser;
import io.restassured.specification.RequestSpecification;
-class ReindexingWithEventDeadLettersTest {
- private static final int LIMIT_TO_10_MESSAGES = 10;
+class RabbitMQReindexingWithEventDeadLettersTest {
+
private static final String ELASTICSEARCH_LISTENER_GROUP = "org.apache.james.mailbox.elasticsearch.events.ElasticSearchListeningMessageSearchIndex$ElasticSearchListeningMessageSearchIndexGroup";
private static final ConditionFactory CALMLY_AWAIT = Awaitility
@@ -73,7 +75,10 @@ class ReindexingWithEventDeadLettersTest {
.atMost(Duration.ONE_MINUTE)
.await();
- private static final DockerElasticSearchExtension dockerElasticSearch = new DockerElasticSearchExtension().withRequestTimeout(java.time.Duration.ofSeconds(1));
+ private static final DockerElasticSearchExtension dockerElasticSearch =
+ new DockerElasticSearchExtension().withRequestTimeout(java.time.Duration.ofSeconds(1));
+
+ private static final int LIMIT_TO_10_MESSAGES = 10;
private static final JamesServerBuilder.ServerProvider CONFIGURATION_BUILDER = configuration -> GuiceJamesServer
.forConfiguration(configuration)
@@ -84,7 +89,7 @@ class ReindexingWithEventDeadLettersTest {
.toInstance(WebAdminConfiguration.TEST_CONFIGURATION));
@RegisterExtension
- JamesServerExtension testExtension = new JamesServerBuilder()
+ static JamesServerExtension testExtension = new JamesServerBuilder()
.extension(dockerElasticSearch)
.extension(new CassandraExtension())
.extension(new RabbitMQExtension())
@@ -118,7 +123,7 @@ class ReindexingWithEventDeadLettersTest {
@Disabled("JAMES-3011 It's already fails for a long time, but CI didn't detect this when it's not marked as BasicFeature")
@Test
- void indexationShouldBeFailingWhenElasticSearchContainerIsPaused() throws Exception {
+ protected void indexationShouldBeFailingWhenElasticSearchContainerIsPaused() throws Exception {
aliceSavesADraft();
CALMLY_AWAIT.until(() -> listElasticSearchFailedEvents().size() == 1);
@@ -127,8 +132,9 @@ class ReindexingWithEventDeadLettersTest {
assertThat(listMessageIdsForAccount(aliceAccessToken)).isEmpty();
}
+ @Category(BasicFeature.class)
@Test
- void redeliverShouldReIndexFailedMessages() throws Exception {
+ protected void redeliverShouldReIndexFailedMessages() throws Exception {
aliceSavesADraft();
CALMLY_AWAIT.until(() -> listElasticSearchFailedEvents().size() == 1);
@@ -139,7 +145,7 @@ class ReindexingWithEventDeadLettersTest {
}
@Test
- void redeliverShouldCleanEventDeadLetter() throws Exception {
+ protected void redeliverShouldCleanEventDeadLetter() throws Exception {
aliceSavesADraft();
CALMLY_AWAIT.until(() -> listElasticSearchFailedEvents().size() == 1);
diff --git a/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQUnauthorizedEndpointsTest.java b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQUnauthorizedEndpointsTest.java
new file mode 100644
index 0000000..a5d757b
--- /dev/null
+++ b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQUnauthorizedEndpointsTest.java
@@ -0,0 +1,120 @@
+/****************************************************************
+ * 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.webadmin.integration.rabbitmq;
+
+import static io.restassured.RestAssured.when;
+
+import org.apache.james.webadmin.integration.UnauthorizedEndpointsTest;
+import org.apache.james.webadmin.routes.AliasRoutes;
+import org.apache.james.webadmin.routes.CassandraMappingsRoutes;
+import org.apache.james.webadmin.routes.CassandraMigrationRoutes;
+import org.apache.james.webadmin.routes.DLPConfigurationRoutes;
+import org.apache.james.webadmin.routes.DomainMappingsRoutes;
+import org.apache.james.webadmin.routes.DomainQuotaRoutes;
+import org.apache.james.webadmin.routes.DomainsRoutes;
+import org.apache.james.webadmin.routes.EventDeadLettersRoutes;
+import org.apache.james.webadmin.routes.ForwardRoutes;
+import org.apache.james.webadmin.routes.GlobalQuotaRoutes;
+import org.apache.james.webadmin.routes.GroupsRoutes;
+import org.apache.james.webadmin.routes.MailQueueRoutes;
+import org.apache.james.webadmin.routes.MailRepositoriesRoutes;
+import org.apache.james.webadmin.routes.SieveQuotaRoutes;
+import org.apache.james.webadmin.routes.TasksRoutes;
+import org.apache.james.webadmin.routes.UserMailboxesRoutes;
+import org.apache.james.webadmin.routes.UserQuotaRoutes;
+import org.apache.james.webadmin.routes.UserRoutes;
+import org.apache.james.webadmin.vault.routes.DeletedMessagesVaultRoutes;
+import org.eclipse.jetty.http.HttpStatus;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+class RabbitMQUnauthorizedEndpointsTest extends UnauthorizedEndpointsTest {
+
+ @RegisterExtension
+ static RabbitMQJmapExtension rabbitMQJmapExtension = new RabbitMQJmapExtension(RabbitMQJmapExtension.JamesLifeCyclePolicy.COMMON_TO_ALL_TESTS);
+
+ @ParameterizedTest
+ @ValueSource(strings = {
+ CassandraMigrationRoutes.VERSION_BASE,
+ CassandraMigrationRoutes.VERSION_BASE + "/latest",
+ DLPConfigurationRoutes.BASE_PATH + "/james.org",
+ DomainMappingsRoutes.DOMAIN_MAPPINGS,
+ DomainMappingsRoutes.DOMAIN_MAPPINGS + "/from.com",
+ DomainQuotaRoutes.BASE_PATH + "/james.org",
+ DomainQuotaRoutes.BASE_PATH + "/james.org/count",
+ DomainQuotaRoutes.BASE_PATH + "/james.org/size",
+ DomainsRoutes.DOMAINS,
+ UserMailboxesRoutes.USERS_BASE + "/someuser/mailboxes",
+ UserMailboxesRoutes.USERS_BASE + "/someuser/mailboxes/mymailbox",
+ UserQuotaRoutes.USERS_QUOTA_ENDPOINT,
+ UserQuotaRoutes.USERS_QUOTA_ENDPOINT + "/joe@perdu.com",
+ UserQuotaRoutes.USERS_QUOTA_ENDPOINT + "/joe@perdu.com/count",
+ UserQuotaRoutes.USERS_QUOTA_ENDPOINT + "/joe@perdu.com/size",
+ UserRoutes.USERS,
+ ForwardRoutes.ROOT_PATH,
+ ForwardRoutes.ROOT_PATH + "/alice@james.org",
+ AliasRoutes.ROOT_PATH,
+ AliasRoutes.ROOT_PATH + "/bob@james.org",
+ GlobalQuotaRoutes.QUOTA_ENDPOINT,
+ GlobalQuotaRoutes.QUOTA_ENDPOINT + "/count",
+ GlobalQuotaRoutes.QUOTA_ENDPOINT + "/size",
+ GroupsRoutes.ROOT_PATH,
+ GroupsRoutes.ROOT_PATH + "/group@james.org",
+ MailQueueRoutes.BASE_URL + "/first_queue",
+ MailRepositoriesRoutes.MAIL_REPOSITORIES,
+ MailRepositoriesRoutes.MAIL_REPOSITORIES + "/myRepo",
+ MailRepositoriesRoutes.MAIL_REPOSITORIES + "/myRepo/mails",
+ MailRepositoriesRoutes.MAIL_REPOSITORIES + "/myRepo/mails/1",
+ SieveQuotaRoutes.DEFAULT_QUOTA_PATH,
+ SieveQuotaRoutes.ROOT_PATH + "/users/user@james.org",
+ TasksRoutes.BASE,
+ TasksRoutes.BASE + "/taskId",
+ TasksRoutes.BASE + "/taskId/await",
+ EventDeadLettersRoutes.BASE_PATH + "/groups",
+ EventDeadLettersRoutes.BASE_PATH + "/groups/group@james.org",
+ EventDeadLettersRoutes.BASE_PATH + "/groups/group@james.org/1"
+ })
+ @Override
+ public void checkUrlProtectionOnGet(String url) {
+ when()
+ .get(url)
+ .then()
+ .statusCode(HttpStatus.UNAUTHORIZED_401);
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {
+ CassandraMigrationRoutes.VERSION_BASE + "/upgrade",
+ CassandraMigrationRoutes.VERSION_BASE + "/upgrade/latest",
+ DeletedMessagesVaultRoutes.ROOT_PATH + "/joe@perdu.com",
+ CassandraMappingsRoutes.ROOT_PATH,
+ EventDeadLettersRoutes.BASE_PATH,
+ EventDeadLettersRoutes.BASE_PATH + "/groups/group@james.org",
+ EventDeadLettersRoutes.BASE_PATH + "/groups/group@james.org/1"
+ })
+ @Override
+ public void checkUrlProtectionOnPost(String url) {
+ when()
+ .post(url)
+ .then()
+ .statusCode(HttpStatus.UNAUTHORIZED_401);
+ }
+}
\ No newline at end of file
diff --git a/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQWebAdminServerIntegrationTest.java b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQWebAdminServerIntegrationTest.java
new file mode 100644
index 0000000..a291a06
--- /dev/null
+++ b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQWebAdminServerIntegrationTest.java
@@ -0,0 +1,154 @@
+/****************************************************************
+ * 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.webadmin.integration.rabbitmq;
+
+import static io.restassured.RestAssured.given;
+import static io.restassured.RestAssured.when;
+import static io.restassured.RestAssured.with;
+import static org.apache.james.webadmin.Constants.JSON_CONTENT_TYPE;
+import static org.apache.james.webadmin.Constants.SEPARATOR;
+import static org.hamcrest.CoreMatchers.hasItems;
+import static org.hamcrest.Matchers.is;
+
+import org.apache.james.CassandraRabbitMQAwsS3JmapTestRule;
+import org.apache.james.DockerCassandraRule;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.backends.cassandra.versions.CassandraSchemaVersionManager;
+import org.apache.james.webadmin.integration.WebAdminServerIntegrationTest;
+import org.apache.james.webadmin.routes.AliasRoutes;
+import org.apache.james.webadmin.routes.CassandraMappingsRoutes;
+import org.apache.james.webadmin.routes.TasksRoutes;
+import org.awaitility.Awaitility;
+import org.awaitility.Duration;
+import org.eclipse.jetty.http.HttpStatus;
+import org.junit.Rule;
+import org.junit.Test;
+
+import io.restassured.http.ContentType;
+
+public class RabbitMQWebAdminServerIntegrationTest extends WebAdminServerIntegrationTest {
+
+ private static final String VERSION = "/cassandra/version";
+ private static final String VERSION_LATEST = VERSION + "/latest";
+ private static final String UPGRADE_VERSION = VERSION + "/upgrade";
+ private static final String UPGRADE_TO_LATEST_VERSION = UPGRADE_VERSION + "/latest";
+
+ @Rule
+ public DockerCassandraRule cassandra = new DockerCassandraRule();
+ @Rule
+ public CassandraRabbitMQAwsS3JmapTestRule jamesTestRule = CassandraRabbitMQAwsS3JmapTestRule.defaultTestRule();
+
+ @Override
+ protected GuiceJamesServer createJamesServer() throws Exception {
+ return jamesTestRule.jmapServer(cassandra.getModule());
+ }
+
+ @Test
+ public void getCurrentVersionShouldReturnNullForCurrentVersionAsBeginning() {
+ when()
+ .get(VERSION)
+ .then()
+ .statusCode(HttpStatus.OK_200)
+ .contentType(JSON_CONTENT_TYPE)
+ .body(is("{\"version\":null}"));
+ }
+
+ @Test
+ public void getLatestVersionShouldReturnTheConfiguredLatestVersion() {
+ when()
+ .get(VERSION_LATEST)
+ .then()
+ .statusCode(HttpStatus.OK_200)
+ .contentType(JSON_CONTENT_TYPE)
+ .body(is("{\"version\":" + CassandraSchemaVersionManager.MAX_VERSION.getValue() + "}"));
+ }
+
+ @Test
+ public void postShouldDoMigrationAndUpdateCurrentVersion() {
+ String taskId = with()
+ .body(String.valueOf(CassandraSchemaVersionManager.MAX_VERSION.getValue()))
+ .post(UPGRADE_VERSION)
+ .jsonPath()
+ .get("taskId");
+
+ with()
+ .get("/tasks/" + taskId + "/await")
+ .then()
+ .body("status", is("completed"));
+
+ Awaitility.await()
+ .atMost(Duration.TEN_SECONDS)
+ .await()
+ .untilAsserted(() ->
+ when()
+ .get(VERSION)
+ .then()
+ .statusCode(HttpStatus.OK_200)
+ .contentType(JSON_CONTENT_TYPE)
+ .body(is("{\"version\":" + CassandraSchemaVersionManager.MAX_VERSION.getValue() + "}")));
+ }
+
+ @Test
+ public void postShouldDoMigrationAndUpdateToTheLatestVersion() {
+ String taskId = with().post(UPGRADE_TO_LATEST_VERSION)
+ .jsonPath()
+ .get("taskId");
+
+ with()
+ .get("/tasks/" + taskId + "/await")
+ .then()
+ .body("status", is("completed"));
+
+ when()
+ .get(VERSION)
+ .then()
+ .statusCode(HttpStatus.OK_200)
+ .contentType(JSON_CONTENT_TYPE)
+ .body(is("{\"version\":" + CassandraSchemaVersionManager.MAX_VERSION.getValue() + "}"));
+ }
+
+ @Test
+ public void cassandraMappingsEndpointShouldKeepDataConsistencyWhenDataValid() {
+ with()
+ .put(AliasRoutes.ROOT_PATH + SEPARATOR + USERNAME + "/sources/" + ALIAS_1);
+ with()
+ .put(AliasRoutes.ROOT_PATH + SEPARATOR + USERNAME + "/sources/" + ALIAS_2);
+
+ String taskId = with()
+ .queryParam("action", "SolveInconsistencies")
+ .post(CassandraMappingsRoutes.ROOT_PATH)
+ .jsonPath()
+ .get("taskId");
+
+ given()
+ .basePath(TasksRoutes.BASE)
+ .when()
+ .get(taskId + "/await")
+ .then()
+ .body("status", is("completed"));
+
+ when()
+ .get(AliasRoutes.ROOT_PATH + SEPARATOR + USERNAME)
+ .then()
+ .contentType(ContentType.JSON)
+ .statusCode(HttpStatus.OK_200)
+ .body("source", hasItems(ALIAS_1, ALIAS_2));
+ }
+}
\ No newline at end of file
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerTaskSerializationIntegrationTest.java b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQWebAdminServerTaskSerializationIntegrationTest.java
similarity index 99%
rename from server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerTaskSerializationIntegrationTest.java
rename to server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQWebAdminServerTaskSerializationIntegrationTest.java
index 1b1f007..6afa076 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerTaskSerializationIntegrationTest.java
+++ b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/RabbitMQWebAdminServerTaskSerializationIntegrationTest.java
@@ -17,7 +17,7 @@
* under the License. *
****************************************************************/
-package org.apache.james.webadmin.integration;
+package org.apache.james.webadmin.integration.rabbitmq;
import static io.restassured.RestAssured.given;
import static io.restassured.RestAssured.when;
@@ -26,10 +26,10 @@ import static org.apache.james.webadmin.Constants.SEPARATOR;
import static org.apache.james.webadmin.vault.routes.DeletedMessagesVaultRoutes.MESSAGE_PATH_PARAM;
import static org.apache.james.webadmin.vault.routes.DeletedMessagesVaultRoutes.USERS;
import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.Matchers.anEmptyMap;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
+import static org.hamcrest.collection.IsMapWithSize.anEmptyMap;
import java.io.ByteArrayInputStream;
import java.util.Date;
@@ -85,10 +85,7 @@ import org.junit.Test;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
-public class WebAdminServerTaskSerializationIntegrationTest {
-
- private static final String DOMAIN = "domain";
- private static final String USERNAME = "username@" + DOMAIN;
+public class RabbitMQWebAdminServerTaskSerializationIntegrationTest {
@Rule
public DockerCassandraRule cassandra = new DockerCassandraRule();
@@ -96,6 +93,9 @@ public class WebAdminServerTaskSerializationIntegrationTest {
@Rule
public CassandraRabbitMQAwsS3JmapTestRule jamesTestRule = CassandraRabbitMQAwsS3JmapTestRule.defaultTestRule();
+ private static final String DOMAIN = "domain";
+ private static final String USERNAME = "username@" + DOMAIN;
+
private GuiceJamesServer guiceJamesServer;
private DataProbe dataProbe;
private MailboxProbe mailboxProbe;
diff --git a/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/vault/RabbitMQDeletedMessageVaultIntegrationTest.java b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/vault/RabbitMQDeletedMessageVaultIntegrationTest.java
new file mode 100644
index 0000000..81f1c16
--- /dev/null
+++ b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/vault/RabbitMQDeletedMessageVaultIntegrationTest.java
@@ -0,0 +1,54 @@
+/****************************************************************
+ * 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.webadmin.integration.rabbitmq.vault;
+
+import java.io.IOException;
+import java.time.Clock;
+
+import org.apache.james.CassandraRabbitMQAwsS3JmapTestRule;
+import org.apache.james.DockerCassandraRule;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.filesystem.api.FileSystem;
+import org.apache.james.modules.vault.TestDeleteMessageVaultPreDeletionHookModule;
+import org.apache.james.webadmin.WebAdminConfiguration;
+import org.apache.james.webadmin.integration.vault.DeletedMessageVaultIntegrationTest;
+import org.junit.Rule;
+
+public class RabbitMQDeletedMessageVaultIntegrationTest extends DeletedMessageVaultIntegrationTest {
+
+ @Rule
+ public DockerCassandraRule cassandra = new DockerCassandraRule();
+ @Rule
+ public CassandraRabbitMQAwsS3JmapTestRule rule = CassandraRabbitMQAwsS3JmapTestRule.defaultTestRule();
+
+ @Override
+ public GuiceJamesServer createJmapServer(FileSystem fileSystem, Clock clock) throws IOException {
+ return rule.jmapServer(cassandra.getModule(),
+ new TestDeleteMessageVaultPreDeletionHookModule(),
+ binder -> binder.bind(WebAdminConfiguration.class).toInstance(WebAdminConfiguration.TEST_CONFIGURATION),
+ binder -> binder.bind(FileSystem.class).toInstance(fileSystem),
+ binder -> binder.bind(Clock.class).toInstance(clock));
+ }
+
+ @Override
+ protected void awaitSearchUpToDate() {
+ rule.await();
+ }
+}
diff --git a/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/vault/RabbitMQLinshareBlobExportMechanismIntegrationTest.java b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/vault/RabbitMQLinshareBlobExportMechanismIntegrationTest.java
new file mode 100644
index 0000000..4dc3e32
--- /dev/null
+++ b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/rabbitmq/vault/RabbitMQLinshareBlobExportMechanismIntegrationTest.java
@@ -0,0 +1,59 @@
+/****************************************************************
+ * 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.webadmin.integration.rabbitmq.vault;
+
+import org.apache.james.CassandraExtension;
+import org.apache.james.CassandraRabbitMQJamesServerMain;
+import org.apache.james.DockerElasticSearchExtension;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.JamesServerBuilder;
+import org.apache.james.JamesServerExtension;
+import org.apache.james.backends.rabbitmq.DockerRabbitMQSingleton;
+import org.apache.james.mailbox.extractor.TextExtractor;
+import org.apache.james.mailbox.store.search.PDFTextExtractor;
+import org.apache.james.modules.AwsS3BlobStoreExtension;
+import org.apache.james.modules.RabbitMQExtension;
+import org.apache.james.modules.TestJMAPServerModule;
+import org.apache.james.modules.TestRabbitMQModule;
+import org.apache.james.modules.vault.TestDeleteMessageVaultPreDeletionHookModule;
+import org.apache.james.webadmin.WebAdminConfiguration;
+import org.apache.james.webadmin.integration.vault.LinshareBlobExportMechanismIntegrationTest;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+class RabbitMQLinshareBlobExportMechanismIntegrationTest extends LinshareBlobExportMechanismIntegrationTest {
+
+ private static final int LIMIT_TO_20_MESSAGES = 20;
+
+ @RegisterExtension
+ static JamesServerExtension testExtension = new JamesServerBuilder()
+ .extension(new DockerElasticSearchExtension())
+ .extension(new CassandraExtension())
+ .extension(new RabbitMQExtension())
+ .extension(new AwsS3BlobStoreExtension())
+ .extension(LinshareBlobExportMechanismIntegrationTest.linshareGuiceExtension)
+ .server(configuration -> GuiceJamesServer.forConfiguration(configuration)
+ .combineWith(CassandraRabbitMQJamesServerMain.MODULES)
+ .overrideWith(binder -> binder.bind(TextExtractor.class).to(PDFTextExtractor.class))
+ .overrideWith(new TestJMAPServerModule(LIMIT_TO_20_MESSAGES))
+ .overrideWith(new TestRabbitMQModule(DockerRabbitMQSingleton.SINGLETON))
+ .overrideWith(binder -> binder.bind(WebAdminConfiguration.class).toInstance(WebAdminConfiguration.TEST_CONFIGURATION))
+ .overrideWith(new TestDeleteMessageVaultPreDeletionHookModule()))
+ .build();
+}
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/dnsservice.xml b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/dnsservice.xml
similarity index 100%
copy from server/protocols/webadmin-integration-test/src/test/resources/dnsservice.xml
copy to server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/dnsservice.xml
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/domainlist.xml b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/domainlist.xml
similarity index 100%
copy from server/protocols/webadmin-integration-test/src/test/resources/domainlist.xml
copy to server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/domainlist.xml
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/imapserver.xml b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/imapserver.xml
similarity index 100%
copy from server/protocols/webadmin-integration-test/src/test/resources/imapserver.xml
copy to server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/imapserver.xml
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/jwt_publickey b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/jwt_publickey
similarity index 100%
copy from server/protocols/webadmin-integration-test/src/test/resources/jwt_publickey
copy to server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/jwt_publickey
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/keystore b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/keystore
similarity index 100%
copy from server/protocols/webadmin-integration-test/src/test/resources/keystore
copy to server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/keystore
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/dnsservice.xml b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/listeners.xml
similarity index 54%
copy from server/protocols/webadmin-integration-test/src/test/resources/dnsservice.xml
copy to server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/listeners.xml
index 0978a00..ff2e517 100644
--- a/server/protocols/webadmin-integration-test/src/test/resources/dnsservice.xml
+++ b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/listeners.xml
@@ -18,12 +18,32 @@
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>
+<listeners>
+ <listener>
+ <class>org.apache.james.mailbox.cassandra.MailboxOperationLoggingListener</class>
+ </listener>
+ <listener>
+ <class>org.apache.james.mailbox.quota.mailing.listeners.QuotaThresholdCrossingListener</class>
+ <group>QuotaThresholdCrossingListener-lower-threshold</group>
+ <configuration>
+ <thresholds>
+ <threshold>
+ <value>0.1</value>
+ </threshold>
+ </thresholds>
+ <name>first</name>
+ </configuration>
+ </listener>
+ <listener>
+ <class>org.apache.james.mailbox.quota.mailing.listeners.QuotaThresholdCrossingListener</class>
+ <group>QuotaThresholdCrossingListener-upper-threshold</group>
+ <configuration>
+ <thresholds>
+ <threshold>
+ <value>0.2</value>
+ </threshold>
+ </thresholds>
+ <name>second</name>
+ </configuration>
+ </listener>
+</listeners>
\ No newline at end of file
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/lmtpserver.xml b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/lmtpserver.xml
similarity index 100%
copy from server/protocols/webadmin-integration-test/src/test/resources/lmtpserver.xml
copy to server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/lmtpserver.xml
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/mailetcontainer.xml b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/mailetcontainer.xml
similarity index 100%
copy from server/protocols/webadmin-integration-test/src/test/resources/mailetcontainer.xml
copy to server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/mailetcontainer.xml
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/mailrepositorystore.xml b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/mailrepositorystore.xml
similarity index 100%
copy from server/protocols/webadmin-integration-test/src/test/resources/mailrepositorystore.xml
copy to server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/mailrepositorystore.xml
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/managesieveserver.xml b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/managesieveserver.xml
similarity index 100%
copy from server/protocols/webadmin-integration-test/src/test/resources/managesieveserver.xml
copy to server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/managesieveserver.xml
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/pop3server.xml b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/pop3server.xml
similarity index 100%
copy from server/protocols/webadmin-integration-test/src/test/resources/pop3server.xml
copy to server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/pop3server.xml
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/smtpserver.xml b/server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/smtpserver.xml
similarity index 100%
copy from server/protocols/webadmin-integration-test/src/test/resources/smtpserver.xml
copy to server/protocols/webadmin-integration-test/distributed-webadmin-integration-test/src/test/resources/smtpserver.xml
diff --git a/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/pom.xml b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/pom.xml
new file mode 100644
index 0000000..a7c1310
--- /dev/null
+++ b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/pom.xml
@@ -0,0 +1,66 @@
+<?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>
+ <groupId>org.apache.james</groupId>
+ <artifactId>webadmin-integration-test</artifactId>
+ <version>3.5.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>memory-webadmin-integration-test</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Apache James :: Server :: Web Admin server integration tests :: Memory</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>james-server-memory-guice</artifactId>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>james-server-memory-guice</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>james-server-webadmin-integration-test-common</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <reuseForks>true</reuseForks>
+ <forkCount>1C</forkCount>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/MemoryAuthorizedEndpointsTest.java
similarity index 58%
copy from server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java
copy to server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/MemoryAuthorizedEndpointsTest.java
index ecd725a..a4aa5b9 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java
+++ b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/MemoryAuthorizedEndpointsTest.java
@@ -16,32 +16,25 @@
* specific language governing permissions and limitations *
* under the License. *
****************************************************************/
-package org.apache.james.webadmin.integration;
-import static spark.Spark.halt;
+package org.apache.james.webadmin.integration.memory;
-import org.apache.james.webadmin.authentication.AuthenticationFilter;
-import org.eclipse.jetty.http.HttpStatus;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.MemoryJmapTestRule;
+import org.apache.james.webadmin.WebAdminConfiguration;
+import org.apache.james.webadmin.integration.AuthorizedEndpointsTest;
+import org.apache.james.webadmin.integration.UnauthorizedModule;
+import org.junit.Rule;
-import com.google.inject.AbstractModule;
-import com.google.inject.Scopes;
+public class MemoryAuthorizedEndpointsTest extends AuthorizedEndpointsTest {
-import spark.Request;
-import spark.Response;
-
-public class UnauthorizedModule extends AbstractModule {
+ @Rule
+ public MemoryJmapTestRule memoryJmap = new MemoryJmapTestRule();
@Override
- protected void configure() {
- bind(UnauthorizedModule.UnauthorizedFilter.class).in(Scopes.SINGLETON);
- bind(AuthenticationFilter.class).to(UnauthorizedModule.UnauthorizedFilter.class);
- }
-
- private static class UnauthorizedFilter implements AuthenticationFilter {
-
- @Override
- public void handle(Request request, Response response) throws Exception {
- halt(HttpStatus.UNAUTHORIZED_401, "Unauthorize every endpoints.");
- }
+ protected GuiceJamesServer createJamesServer() throws Exception {
+ return memoryJmap.jmapServer(
+ binder -> binder.bind(WebAdminConfiguration.class).toInstance(WebAdminConfiguration.TEST_CONFIGURATION),
+ new UnauthorizedModule());
}
}
\ No newline at end of file
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/MemoryForwardIntegrationTest.java
similarity index 58%
copy from server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java
copy to server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/MemoryForwardIntegrationTest.java
index ecd725a..545529e 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java
+++ b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/MemoryForwardIntegrationTest.java
@@ -16,32 +16,25 @@
* specific language governing permissions and limitations *
* under the License. *
****************************************************************/
-package org.apache.james.webadmin.integration;
-import static spark.Spark.halt;
+package org.apache.james.webadmin.integration.memory;
-import org.apache.james.webadmin.authentication.AuthenticationFilter;
-import org.eclipse.jetty.http.HttpStatus;
+import java.io.IOException;
-import com.google.inject.AbstractModule;
-import com.google.inject.Scopes;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.MemoryJmapTestRule;
+import org.apache.james.webadmin.WebAdminConfiguration;
+import org.apache.james.webadmin.integration.ForwardIntegrationTest;
+import org.junit.Rule;
-import spark.Request;
-import spark.Response;
+public class MemoryForwardIntegrationTest extends ForwardIntegrationTest {
-public class UnauthorizedModule extends AbstractModule {
+ @Rule
+ public MemoryJmapTestRule memoryJmap = new MemoryJmapTestRule();
@Override
- protected void configure() {
- bind(UnauthorizedModule.UnauthorizedFilter.class).in(Scopes.SINGLETON);
- bind(AuthenticationFilter.class).to(UnauthorizedModule.UnauthorizedFilter.class);
+ public GuiceJamesServer createJmapServer() throws IOException {
+ return memoryJmap.jmapServer(binder -> binder.bind(WebAdminConfiguration.class)
+ .toInstance(WebAdminConfiguration.TEST_CONFIGURATION));
}
-
- private static class UnauthorizedFilter implements AuthenticationFilter {
-
- @Override
- public void handle(Request request, Response response) throws Exception {
- halt(HttpStatus.UNAUTHORIZED_401, "Unauthorize every endpoints.");
- }
- }
-}
\ No newline at end of file
+}
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/MemoryJwtFilterIntegrationTest.java
similarity index 56%
copy from server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java
copy to server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/MemoryJwtFilterIntegrationTest.java
index ecd725a..44dbbe9 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java
+++ b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/MemoryJwtFilterIntegrationTest.java
@@ -16,32 +16,28 @@
* specific language governing permissions and limitations *
* under the License. *
****************************************************************/
-package org.apache.james.webadmin.integration;
-import static spark.Spark.halt;
+package org.apache.james.webadmin.integration.memory;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.MemoryJmapTestRule;
+import org.apache.james.jwt.JwtConfiguration;
+import org.apache.james.webadmin.WebAdminConfiguration;
import org.apache.james.webadmin.authentication.AuthenticationFilter;
-import org.eclipse.jetty.http.HttpStatus;
+import org.apache.james.webadmin.authentication.JwtFilter;
+import org.apache.james.webadmin.integration.JwtFilterIntegrationTest;
+import org.junit.Rule;
-import com.google.inject.AbstractModule;
-import com.google.inject.Scopes;
+public class MemoryJwtFilterIntegrationTest extends JwtFilterIntegrationTest {
-import spark.Request;
-import spark.Response;
-
-public class UnauthorizedModule extends AbstractModule {
+ @Rule
+ public MemoryJmapTestRule memoryJmap = new MemoryJmapTestRule();
@Override
- protected void configure() {
- bind(UnauthorizedModule.UnauthorizedFilter.class).in(Scopes.SINGLETON);
- bind(AuthenticationFilter.class).to(UnauthorizedModule.UnauthorizedFilter.class);
- }
-
- private static class UnauthorizedFilter implements AuthenticationFilter {
-
- @Override
- public void handle(Request request, Response response) throws Exception {
- halt(HttpStatus.UNAUTHORIZED_401, "Unauthorize every endpoints.");
- }
+ protected GuiceJamesServer createJamesServer(JwtConfiguration jwtConfiguration) throws Exception {
+ return memoryJmap.jmapServer(
+ binder -> binder.bind(AuthenticationFilter.class).to(JwtFilter.class),
+ binder -> binder.bind(JwtConfiguration.class).toInstance(jwtConfiguration),
+ binder -> binder.bind(WebAdminConfiguration.class).toInstance(WebAdminConfiguration.TEST_CONFIGURATION));
}
-}
\ No newline at end of file
+}
diff --git a/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/MemoryUnauthorizedEndpointsTest.java b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/MemoryUnauthorizedEndpointsTest.java
new file mode 100644
index 0000000..b1262bf
--- /dev/null
+++ b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/MemoryUnauthorizedEndpointsTest.java
@@ -0,0 +1,46 @@
+/****************************************************************
+ * 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.webadmin.integration.memory;
+
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.JamesServerBuilder;
+import org.apache.james.JamesServerExtension;
+import org.apache.james.MemoryJamesServerMain;
+import org.apache.james.modules.TestJMAPServerModule;
+import org.apache.james.modules.vault.TestDeleteMessageVaultPreDeletionHookModule;
+import org.apache.james.webadmin.WebAdminConfiguration;
+import org.apache.james.webadmin.integration.UnauthorizedEndpointsTest;
+import org.apache.james.webadmin.integration.UnauthorizedModule;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+class MemoryUnauthorizedEndpointsTest extends UnauthorizedEndpointsTest {
+
+ private static final int LIMIT_TO_10_MESSAGES = 10;
+
+ @RegisterExtension
+ static JamesServerExtension jamesServerExtension = new JamesServerBuilder()
+ .server(configuration -> GuiceJamesServer.forConfiguration(configuration)
+ .combineWith(MemoryJamesServerMain.IN_MEMORY_SERVER_AGGREGATE_MODULE)
+ .overrideWith(new TestJMAPServerModule(LIMIT_TO_10_MESSAGES))
+ .overrideWith(new TestDeleteMessageVaultPreDeletionHookModule())
+ .overrideWith(new UnauthorizedModule())
+ .overrideWith(binder -> binder.bind(WebAdminConfiguration.class).toInstance(WebAdminConfiguration.TEST_CONFIGURATION)))
+ .build();
+}
\ No newline at end of file
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/MemoryWebAdminServerIntegrationTest.java
similarity index 58%
copy from server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java
copy to server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/MemoryWebAdminServerIntegrationTest.java
index ecd725a..119bec7 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java
+++ b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/MemoryWebAdminServerIntegrationTest.java
@@ -16,32 +16,23 @@
* specific language governing permissions and limitations *
* under the License. *
****************************************************************/
-package org.apache.james.webadmin.integration;
-import static spark.Spark.halt;
+package org.apache.james.webadmin.integration.memory;
-import org.apache.james.webadmin.authentication.AuthenticationFilter;
-import org.eclipse.jetty.http.HttpStatus;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.MemoryJmapTestRule;
+import org.apache.james.webadmin.WebAdminConfiguration;
+import org.apache.james.webadmin.integration.WebAdminServerIntegrationTest;
+import org.junit.Rule;
-import com.google.inject.AbstractModule;
-import com.google.inject.Scopes;
+public class MemoryWebAdminServerIntegrationTest extends WebAdminServerIntegrationTest {
-import spark.Request;
-import spark.Response;
-
-public class UnauthorizedModule extends AbstractModule {
+ @Rule
+ public MemoryJmapTestRule memoryJmap = new MemoryJmapTestRule();
@Override
- protected void configure() {
- bind(UnauthorizedModule.UnauthorizedFilter.class).in(Scopes.SINGLETON);
- bind(AuthenticationFilter.class).to(UnauthorizedModule.UnauthorizedFilter.class);
- }
-
- private static class UnauthorizedFilter implements AuthenticationFilter {
-
- @Override
- public void handle(Request request, Response response) throws Exception {
- halt(HttpStatus.UNAUTHORIZED_401, "Unauthorize every endpoints.");
- }
+ protected GuiceJamesServer createJamesServer() throws Exception {
+ return memoryJmap.jmapServer(binder -> binder.bind(WebAdminConfiguration.class)
+ .toInstance(WebAdminConfiguration.TEST_CONFIGURATION));
}
}
\ No newline at end of file
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/vault/MemoryDeletedMessageVaultIntegrationTest.java
similarity index 50%
copy from server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java
copy to server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/vault/MemoryDeletedMessageVaultIntegrationTest.java
index ecd725a..d722825 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java
+++ b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/vault/MemoryDeletedMessageVaultIntegrationTest.java
@@ -16,32 +16,35 @@
* specific language governing permissions and limitations *
* under the License. *
****************************************************************/
-package org.apache.james.webadmin.integration;
-import static spark.Spark.halt;
+package org.apache.james.webadmin.integration.memory.vault;
-import org.apache.james.webadmin.authentication.AuthenticationFilter;
-import org.eclipse.jetty.http.HttpStatus;
+import java.io.IOException;
+import java.time.Clock;
-import com.google.inject.AbstractModule;
-import com.google.inject.Scopes;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.MemoryJmapTestRule;
+import org.apache.james.filesystem.api.FileSystem;
+import org.apache.james.modules.vault.TestDeleteMessageVaultPreDeletionHookModule;
+import org.apache.james.webadmin.WebAdminConfiguration;
+import org.apache.james.webadmin.integration.vault.DeletedMessageVaultIntegrationTest;
+import org.junit.Rule;
-import spark.Request;
-import spark.Response;
+public class MemoryDeletedMessageVaultIntegrationTest extends DeletedMessageVaultIntegrationTest {
-public class UnauthorizedModule extends AbstractModule {
+ @Rule
+ public MemoryJmapTestRule memoryJmap = new MemoryJmapTestRule();
@Override
- protected void configure() {
- bind(UnauthorizedModule.UnauthorizedFilter.class).in(Scopes.SINGLETON);
- bind(AuthenticationFilter.class).to(UnauthorizedModule.UnauthorizedFilter.class);
+ protected GuiceJamesServer createJmapServer(FileSystem fileSystem, Clock clock) throws IOException {
+ return memoryJmap.jmapServer(
+ new TestDeleteMessageVaultPreDeletionHookModule(),
+ binder -> binder.bind(WebAdminConfiguration.class).toInstance(WebAdminConfiguration.TEST_CONFIGURATION),
+ binder -> binder.bind(FileSystem.class).toInstance(fileSystem),
+ binder -> binder.bind(Clock.class).toInstance(clock));
}
- private static class UnauthorizedFilter implements AuthenticationFilter {
-
- @Override
- public void handle(Request request, Response response) throws Exception {
- halt(HttpStatus.UNAUTHORIZED_401, "Unauthorize every endpoints.");
- }
+ @Override
+ protected void awaitSearchUpToDate() {
}
-}
\ No newline at end of file
+}
diff --git a/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/vault/MemoryLinshareBlobExportMechanismIntegrationTest.java b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/vault/MemoryLinshareBlobExportMechanismIntegrationTest.java
new file mode 100644
index 0000000..77f27f3
--- /dev/null
+++ b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/vault/MemoryLinshareBlobExportMechanismIntegrationTest.java
@@ -0,0 +1,48 @@
+/****************************************************************
+ * 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.webadmin.integration.memory.vault;
+
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.JamesServerBuilder;
+import org.apache.james.JamesServerExtension;
+import org.apache.james.MemoryJamesServerMain;
+import org.apache.james.modules.LinshareGuiceExtension;
+import org.apache.james.modules.TestJMAPServerModule;
+import org.apache.james.modules.vault.TestDeleteMessageVaultPreDeletionHookModule;
+import org.apache.james.webadmin.WebAdminConfiguration;
+import org.apache.james.webadmin.integration.vault.LinshareBlobExportMechanismIntegrationTest;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+class MemoryLinshareBlobExportMechanismIntegrationTest extends LinshareBlobExportMechanismIntegrationTest {
+
+ private static final int LIMIT_TO_10_MESSAGES = 10;
+
+ private static final LinshareGuiceExtension linshareGuiceExtension = new LinshareGuiceExtension();
+
+ @RegisterExtension
+ static JamesServerExtension jamesServerExtension = new JamesServerBuilder()
+ .extension(linshareGuiceExtension)
+ .server(configuration -> GuiceJamesServer.forConfiguration(configuration)
+ .combineWith(MemoryJamesServerMain.IN_MEMORY_SERVER_AGGREGATE_MODULE)
+ .overrideWith(new TestJMAPServerModule(LIMIT_TO_10_MESSAGES))
+ .overrideWith(new TestDeleteMessageVaultPreDeletionHookModule())
+ .overrideWith(binder -> binder.bind(WebAdminConfiguration.class).toInstance(WebAdminConfiguration.TEST_CONFIGURATION)))
+ .build();
+}
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/dnsservice.xml b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/dnsservice.xml
similarity index 100%
copy from server/protocols/webadmin-integration-test/src/test/resources/dnsservice.xml
copy to server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/dnsservice.xml
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/domainlist.xml b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/domainlist.xml
similarity index 100%
rename from server/protocols/webadmin-integration-test/src/test/resources/domainlist.xml
rename to server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/domainlist.xml
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/imapserver.xml b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/imapserver.xml
similarity index 100%
rename from server/protocols/webadmin-integration-test/src/test/resources/imapserver.xml
rename to server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/imapserver.xml
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/jwt_publickey b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/jwt_publickey
similarity index 100%
rename from server/protocols/webadmin-integration-test/src/test/resources/jwt_publickey
rename to server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/jwt_publickey
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/keystore b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/keystore
similarity index 100%
rename from server/protocols/webadmin-integration-test/src/test/resources/keystore
rename to server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/keystore
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/dnsservice.xml b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/listeners.xml
similarity index 58%
rename from server/protocols/webadmin-integration-test/src/test/resources/dnsservice.xml
rename to server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/listeners.xml
index 0978a00..59e3fec 100644
--- a/server/protocols/webadmin-integration-test/src/test/resources/dnsservice.xml
+++ b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/listeners.xml
@@ -18,12 +18,29 @@
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>
+<listeners>
+ <listener>
+ <class>org.apache.james.mailbox.quota.mailing.listeners.QuotaThresholdCrossingListener</class>
+ <group>QuotaThresholdCrossingListener-lower-threshold</group>
+ <configuration>
+ <thresholds>
+ <threshold>
+ <value>0.1</value>
+ </threshold>
+ </thresholds>
+ <name>first</name>
+ </configuration>
+ </listener>
+ <listener>
+ <class>org.apache.james.mailbox.quota.mailing.listeners.QuotaThresholdCrossingListener</class>
+ <group>QuotaThresholdCrossingListener-upper-threshold</group>
+ <configuration>
+ <thresholds>
+ <threshold>
+ <value>0.2</value>
+ </threshold>
+ </thresholds>
+ <name>second</name>
+ </configuration>
+ </listener>
+</listeners>
\ No newline at end of file
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/lmtpserver.xml b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/lmtpserver.xml
similarity index 100%
rename from server/protocols/webadmin-integration-test/src/test/resources/lmtpserver.xml
rename to server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/lmtpserver.xml
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/mailetcontainer.xml b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/mailetcontainer.xml
similarity index 94%
rename from server/protocols/webadmin-integration-test/src/test/resources/mailetcontainer.xml
rename to server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/mailetcontainer.xml
index f4c8937..9a5c42d 100644
--- a/server/protocols/webadmin-integration-test/src/test/resources/mailetcontainer.xml
+++ b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/mailetcontainer.xml
@@ -41,7 +41,7 @@
<processor state="error" enableJmx="false">
<mailet match="All" class="Bounce"/>
<mailet match="All" class="ToRepository">
- <repositoryPath>cassandra://var/mail/error/</repositoryPath>
+ <repositoryPath>memory://var/mail/error/</repositoryPath>
</mailet>
</processor>
@@ -86,7 +86,7 @@
<attachment>none</attachment>
</mailet>
<mailet match="All" class="ToRepository">
- <repositoryPath>cassandra://var/mail/address-error/</repositoryPath>
+ <repositoryPath>memory://var/mail/address-error/</repositoryPath>
</mailet>
</processor>
@@ -95,7 +95,7 @@
<attachment>none</attachment>
</mailet>
<mailet match="All" class="ToRepository">
- <repositoryPath>cassandra://var/mail/relay-denied/</repositoryPath>
+ <repositoryPath>memory://var/mail/relay-denied/</repositoryPath>
<notice>Warning: You are sending an e-mail to a remote server. You must be authentified to perform such an operation</notice>
</mailet>
</processor>
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/mailrepositorystore.xml b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/mailrepositorystore.xml
similarity index 87%
rename from server/protocols/webadmin-integration-test/src/test/resources/mailrepositorystore.xml
rename to server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/mailrepositorystore.xml
index 626e0a2..ed3e003 100644
--- a/server/protocols/webadmin-integration-test/src/test/resources/mailrepositorystore.xml
+++ b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/mailrepositorystore.xml
@@ -21,9 +21,9 @@
<mailrepositorystore>
<mailrepositories>
- <mailrepository class="org.apache.james.mailrepository.cassandra.CassandraMailRepository">
+ <mailrepository class="org.apache.james.mailrepository.memory.MemoryMailRepository">
<protocols>
- <protocol>cassandra</protocol>
+ <protocol>memory</protocol>
</protocols>
</mailrepository>
</mailrepositories>
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/managesieveserver.xml b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/managesieveserver.xml
similarity index 100%
rename from server/protocols/webadmin-integration-test/src/test/resources/managesieveserver.xml
rename to server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/managesieveserver.xml
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/pop3server.xml b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/pop3server.xml
similarity index 100%
rename from server/protocols/webadmin-integration-test/src/test/resources/pop3server.xml
rename to server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/pop3server.xml
diff --git a/server/protocols/webadmin-integration-test/src/test/resources/smtpserver.xml b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/smtpserver.xml
similarity index 100%
rename from server/protocols/webadmin-integration-test/src/test/resources/smtpserver.xml
rename to server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/smtpserver.xml
diff --git a/server/protocols/webadmin-integration-test/pom.xml b/server/protocols/webadmin-integration-test/pom.xml
index 4a48fe4..e48ce2f 100644
--- a/server/protocols/webadmin-integration-test/pom.xml
+++ b/server/protocols/webadmin-integration-test/pom.xml
@@ -18,6 +18,7 @@
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>
@@ -27,162 +28,23 @@
<relativePath>../../pom.xml</relativePath>
</parent>
- <artifactId>james-server-webadmin-integration-test</artifactId>
- <packaging>jar</packaging>
-
+ <artifactId>webadmin-integration-test</artifactId>
+ <packaging>pom</packaging>
<name>Apache James :: Server :: Web Admin server integration tests</name>
- <dependencies>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>apache-james-backends-rabbitmq</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>apache-james-backends-cassandra</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>apache-james-backends-es</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>apache-james-mailbox-elasticsearch</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>apache-james-mailbox-memory</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>apache-james-mailbox-scanning-search</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>apache-james-linshare</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>backup</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>blob-export-guice</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>blob-objectstorage</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>blob-objectstorage-guice</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>james-server-cassandra-guice</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>james-server-cassandra-rabbitmq-guice</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>james-server-cassandra-rabbitmq-guice</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>james-server-guice-common</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>james-server-guice-jmap-draft</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>james-server-mailbox-plugin-deleted-messages-vault-guice</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>james-server-testing</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>james-server-webadmin-core</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>james-server-webadmin-cassandra-data</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>james-server-webadmin-data</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>james-server-webadmin-mailbox</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>testing-base</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>io.rest-assured</groupId>
- <artifactId>rest-assured</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-params</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.testcontainers</groupId>
- <artifactId>testcontainers</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ <modules>
+ <module>distributed-webadmin-integration-test</module>
+ <module>memory-webadmin-integration-test</module>
+ <module>webadmin-integration-test-common</module>
+ </modules>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedEndpointsTest.java b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedEndpointsTest.java
deleted file mode 100644
index c320895..0000000
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedEndpointsTest.java
+++ /dev/null
@@ -1,206 +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.webadmin.integration;
-
-import static io.restassured.RestAssured.when;
-
-import org.apache.james.utils.WebAdminGuiceProbe;
-import org.apache.james.webadmin.WebAdminUtils;
-import org.apache.james.webadmin.routes.AliasRoutes;
-import org.apache.james.webadmin.routes.CassandraMappingsRoutes;
-import org.apache.james.webadmin.routes.CassandraMigrationRoutes;
-import org.apache.james.webadmin.routes.DLPConfigurationRoutes;
-import org.apache.james.webadmin.routes.DomainMappingsRoutes;
-import org.apache.james.webadmin.routes.DomainQuotaRoutes;
-import org.apache.james.webadmin.routes.DomainsRoutes;
-import org.apache.james.webadmin.routes.EventDeadLettersRoutes;
-import org.apache.james.webadmin.routes.ForwardRoutes;
-import org.apache.james.webadmin.routes.GlobalQuotaRoutes;
-import org.apache.james.webadmin.routes.GroupsRoutes;
-import org.apache.james.webadmin.routes.MailQueueRoutes;
-import org.apache.james.webadmin.routes.MailRepositoriesRoutes;
-import org.apache.james.webadmin.routes.SieveQuotaRoutes;
-import org.apache.james.webadmin.routes.TasksRoutes;
-import org.apache.james.webadmin.routes.UserMailboxesRoutes;
-import org.apache.james.webadmin.routes.UserQuotaRoutes;
-import org.apache.james.webadmin.routes.UserRoutes;
-import org.apache.james.webadmin.vault.routes.DeletedMessagesVaultRoutes;
-import org.eclipse.jetty.http.HttpStatus;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.extension.RegisterExtension;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
-
-import io.restassured.RestAssured;
-
-class UnauthorizedEndpointsTest {
- @RegisterExtension
- static CassandraJmapExtension cassandraJmapExtension = new CassandraJmapExtension(CassandraJmapExtension.JamesLifeCyclePolicy.COMMON_TO_ALL_TESTS);
-
- @BeforeEach
- void setup() {
- WebAdminGuiceProbe webAdminGuiceProbe = cassandraJmapExtension.getJames().getProbe(WebAdminGuiceProbe.class);
-
- RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminGuiceProbe.getWebAdminPort())
- .build();
- }
-
- @ParameterizedTest
- @ValueSource(strings = {
- CassandraMigrationRoutes.VERSION_BASE,
- CassandraMigrationRoutes.VERSION_BASE + "/latest",
- DLPConfigurationRoutes.BASE_PATH + "/james.org",
- DomainMappingsRoutes.DOMAIN_MAPPINGS,
- DomainMappingsRoutes.DOMAIN_MAPPINGS + "/from.com",
- DomainQuotaRoutes.BASE_PATH + "/james.org",
- DomainQuotaRoutes.BASE_PATH + "/james.org/count",
- DomainQuotaRoutes.BASE_PATH + "/james.org/size",
- DomainsRoutes.DOMAINS,
- UserMailboxesRoutes.USERS_BASE + "/someuser/mailboxes",
- UserMailboxesRoutes.USERS_BASE + "/someuser/mailboxes/mymailbox",
- UserQuotaRoutes.USERS_QUOTA_ENDPOINT,
- UserQuotaRoutes.USERS_QUOTA_ENDPOINT + "/joe@perdu.com",
- UserQuotaRoutes.USERS_QUOTA_ENDPOINT + "/joe@perdu.com/count",
- UserQuotaRoutes.USERS_QUOTA_ENDPOINT + "/joe@perdu.com/size",
- UserRoutes.USERS,
- ForwardRoutes.ROOT_PATH,
- ForwardRoutes.ROOT_PATH + "/alice@james.org",
- AliasRoutes.ROOT_PATH,
- AliasRoutes.ROOT_PATH + "/bob@james.org",
- GlobalQuotaRoutes.QUOTA_ENDPOINT,
- GlobalQuotaRoutes.QUOTA_ENDPOINT + "/count",
- GlobalQuotaRoutes.QUOTA_ENDPOINT + "/size",
- GroupsRoutes.ROOT_PATH,
- GroupsRoutes.ROOT_PATH + "/group@james.org",
- MailQueueRoutes.BASE_URL + "/first_queue",
- MailRepositoriesRoutes.MAIL_REPOSITORIES,
- MailRepositoriesRoutes.MAIL_REPOSITORIES + "/myRepo",
- MailRepositoriesRoutes.MAIL_REPOSITORIES + "/myRepo/mails",
- MailRepositoriesRoutes.MAIL_REPOSITORIES + "/myRepo/mails/1",
- SieveQuotaRoutes.DEFAULT_QUOTA_PATH,
- SieveQuotaRoutes.ROOT_PATH + "/users/user@james.org",
- TasksRoutes.BASE,
- TasksRoutes.BASE + "/taskId",
- TasksRoutes.BASE + "/taskId/await",
- EventDeadLettersRoutes.BASE_PATH + "/groups",
- EventDeadLettersRoutes.BASE_PATH + "/groups/group@james.org",
- EventDeadLettersRoutes.BASE_PATH + "/groups/group@james.org/1"
- })
- void checkUrlProtectionOnGet(String url) {
- when()
- .get(url)
- .then()
- .statusCode(HttpStatus.UNAUTHORIZED_401);
- }
-
- @ParameterizedTest
- @ValueSource(strings = {
- CassandraMigrationRoutes.VERSION_BASE + "/upgrade",
- CassandraMigrationRoutes.VERSION_BASE + "/upgrade/latest",
- DeletedMessagesVaultRoutes.ROOT_PATH + "/joe@perdu.com",
- CassandraMappingsRoutes.ROOT_PATH,
- EventDeadLettersRoutes.BASE_PATH,
- EventDeadLettersRoutes.BASE_PATH + "/groups/group@james.org",
- EventDeadLettersRoutes.BASE_PATH + "/groups/group@james.org/1"
- })
- void checkUrlProtectionOnPost(String url) {
- when()
- .post(url)
- .then()
- .statusCode(HttpStatus.UNAUTHORIZED_401);
- }
-
- @ParameterizedTest
- @ValueSource(strings = {
- DLPConfigurationRoutes.BASE_PATH + "/james.org",
- DomainMappingsRoutes.DOMAIN_MAPPINGS + "/from.com",
- DomainQuotaRoutes.BASE_PATH + "/james.org/count",
- DomainQuotaRoutes.BASE_PATH + "/james.org/size",
- DomainQuotaRoutes.BASE_PATH + "/james.org",
- DomainsRoutes.DOMAINS + "/james.org",
- UserMailboxesRoutes.USERS_BASE + "/someuser/mailboxes/mymailbox",
- UserQuotaRoutes.USERS_QUOTA_ENDPOINT + "/joe@perdu.com",
- UserQuotaRoutes.USERS_QUOTA_ENDPOINT + "/joe@perdu.com/count",
- UserQuotaRoutes.USERS_QUOTA_ENDPOINT + "/joe@perdu.com/size",
- UserRoutes.USERS + "/user@james.org",
- ForwardRoutes.ROOT_PATH + "/alice@james.org/bob@james.org",
- AliasRoutes.ROOT_PATH + "/bob@james.org/sources/bob-alias@james.org",
- GlobalQuotaRoutes.QUOTA_ENDPOINT + "/count",
- GlobalQuotaRoutes.QUOTA_ENDPOINT + "/size",
- GlobalQuotaRoutes.QUOTA_ENDPOINT,
- GroupsRoutes.ROOT_PATH + "/group@james.org/user@james.org",
- MailRepositoriesRoutes.MAIL_REPOSITORIES + "/myRepo",
- SieveQuotaRoutes.DEFAULT_QUOTA_PATH,
- SieveQuotaRoutes.ROOT_PATH + "/users/user@james.org"
- })
- void checkUrlProtectionOnPut(String url) {
- when()
- .put(url)
- .then()
- .statusCode(HttpStatus.UNAUTHORIZED_401);
- }
-
- @ParameterizedTest
- @ValueSource(strings = {
- DLPConfigurationRoutes.BASE_PATH + "/james.org",
- DomainQuotaRoutes.BASE_PATH + "/james.org/count",
- DomainQuotaRoutes.BASE_PATH + "/james.org/size",
- DomainMappingsRoutes.DOMAIN_MAPPINGS + "/from.com",
- DomainsRoutes.DOMAINS + "/james.org",
- UserMailboxesRoutes.USERS_BASE + "/someuser/mailboxes",
- UserMailboxesRoutes.USERS_BASE + "/someuser/mailboxes/mymailbox",
- UserQuotaRoutes.USERS_QUOTA_ENDPOINT + "/joe@perdu.com/count",
- UserQuotaRoutes.USERS_QUOTA_ENDPOINT + "/joe@perdu.com/size",
- UserRoutes.USERS + "/user@james.org",
- ForwardRoutes.ROOT_PATH + "/alice@james.org/bob@james.org",
- AliasRoutes.ROOT_PATH + "/bob@james.org/sources/bob-alias@james.org",
- GlobalQuotaRoutes.QUOTA_ENDPOINT + "/count",
- GlobalQuotaRoutes.QUOTA_ENDPOINT + "/size",
- GroupsRoutes.ROOT_PATH + "/group@james.org/user@james.org",
- MailQueueRoutes.BASE_URL,
- MailQueueRoutes.BASE_URL + "/first_queue/mails",
- MailQueueRoutes.BASE_URL + "/second_queue/mails",
- MailRepositoriesRoutes.MAIL_REPOSITORIES + "/myRepo/mails/1",
- MailRepositoriesRoutes.MAIL_REPOSITORIES + "/myRepo/mails",
- SieveQuotaRoutes.DEFAULT_QUOTA_PATH,
- SieveQuotaRoutes.ROOT_PATH + "/users/user@james.org",
- TasksRoutes.BASE + "/taskId",
- EventDeadLettersRoutes.BASE_PATH + "/groups/group@james.org/1"
- })
- void checkUrlProtectionOnDelete(String url) {
- when()
- .delete(url)
- .then()
- .statusCode(HttpStatus.UNAUTHORIZED_401);
- }
-
- @ParameterizedTest
- @ValueSource(strings = {
- MailQueueRoutes.BASE_URL + "/first_queue/mails",
- MailRepositoriesRoutes.MAIL_REPOSITORIES + "/myRepo/mails",
- MailRepositoriesRoutes.MAIL_REPOSITORIES + "/myRepo/mails/name1"
- })
- void checkUrlProtectionOnPath(String url) {
- when()
- .patch(url)
- .then()
- .statusCode(HttpStatus.UNAUTHORIZED_401);
- }
-}
\ No newline at end of file
diff --git a/server/protocols/webadmin-integration-test/pom.xml b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/pom.xml
similarity index 71%
copy from server/protocols/webadmin-integration-test/pom.xml
copy to server/protocols/webadmin-integration-test/webadmin-integration-test-common/pom.xml
index 4a48fe4..501cd3b 100644
--- a/server/protocols/webadmin-integration-test/pom.xml
+++ b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/pom.xml
@@ -22,167 +22,130 @@
<parent>
<groupId>org.apache.james</groupId>
- <artifactId>james-server</artifactId>
+ <artifactId>webadmin-integration-test</artifactId>
<version>3.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
+ <relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>james-server-webadmin-integration-test</artifactId>
+ <artifactId>james-server-webadmin-integration-test-common</artifactId>
<packaging>jar</packaging>
- <name>Apache James :: Server :: Web Admin server integration tests</name>
+ <name>Apache James :: Server :: Web Admin server integration tests :: Common</name>
<dependencies>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>apache-james-backends-rabbitmq</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
- <artifactId>apache-james-backends-cassandra</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${james.groupId}</groupId>
<artifactId>apache-james-backends-es</artifactId>
<type>test-jar</type>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>apache-james-mailbox-elasticsearch</artifactId>
+ <artifactId>apache-james-linshare</artifactId>
<type>test-jar</type>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
<artifactId>apache-james-mailbox-memory</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
<artifactId>apache-james-mailbox-scanning-search</artifactId>
<type>test-jar</type>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>apache-james-linshare</artifactId>
+ <artifactId>backup</artifactId>
<type>test-jar</type>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>backup</artifactId>
+ <artifactId>blob-export-guice</artifactId>
<type>test-jar</type>
- <scope>test</scope>
</dependency>
+ <!--<dependency>-->
+ <!--<groupId>${james.groupId}</groupId>-->
+ <!--<artifactId>james-server-cassandra-guice</artifactId>-->
+ <!--<type>test-jar</type>-->
+ <!--</dependency>-->
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>blob-export-guice</artifactId>
+ <artifactId>james-server-guice-common</artifactId>
<type>test-jar</type>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>blob-objectstorage</artifactId>
+ <artifactId>james-server-guice-jmap-draft</artifactId>
<type>test-jar</type>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>blob-objectstorage-guice</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
+ <artifactId>james-server-guice-imap</artifactId>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>james-server-cassandra-guice</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
+ <artifactId>james-server-guice-jmap-draft</artifactId>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>james-server-cassandra-rabbitmq-guice</artifactId>
- <scope>test</scope>
+ <artifactId>james-server-guice-mailbox</artifactId>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>james-server-cassandra-rabbitmq-guice</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
+ <artifactId>james-server-guice-webadmin</artifactId>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>james-server-guice-common</artifactId>
+ <artifactId>james-server-mailbox-plugin-deleted-messages-vault-guice</artifactId>
<type>test-jar</type>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>james-server-guice-jmap-draft</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
+ <artifactId>james-server-testing</artifactId>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>james-server-mailbox-plugin-deleted-messages-vault-guice</artifactId>
+ <artifactId>james-server-webadmin-core</artifactId>
<type>test-jar</type>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>james-server-testing</artifactId>
- <scope>test</scope>
+ <artifactId>james-server-webadmin-data</artifactId>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>james-server-webadmin-core</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
+ <artifactId>james-server-webadmin-mailbox</artifactId>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>james-server-webadmin-cassandra-data</artifactId>
- <scope>test</scope>
+ <artifactId>james-server-webadmin-mailqueue</artifactId>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>james-server-webadmin-data</artifactId>
- <scope>test</scope>
+ <artifactId>james-server-webadmin-mailrepository</artifactId>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
- <artifactId>james-server-webadmin-mailbox</artifactId>
- <scope>test</scope>
+ <artifactId>james-server-webadmin-swagger</artifactId>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
<artifactId>testing-base</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-params</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>java-hamcrest</artifactId>
- <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-params</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
- <scope>test</scope>
</dependency>
</dependencies>
</project>
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/AuthorizedEndpointsTest.java b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/AuthorizedEndpointsTest.java
similarity index 84%
rename from server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/AuthorizedEndpointsTest.java
rename to server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/AuthorizedEndpointsTest.java
index 01f0907..7d7d86a 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/AuthorizedEndpointsTest.java
+++ b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/AuthorizedEndpointsTest.java
@@ -22,8 +22,6 @@ package org.apache.james.webadmin.integration;
import static io.restassured.RestAssured.when;
import static org.hamcrest.core.IsNot.not;
-import org.apache.james.CassandraRabbitMQAwsS3JmapTestRule;
-import org.apache.james.DockerCassandraRule;
import org.apache.james.GuiceJamesServer;
import org.apache.james.utils.WebAdminGuiceProbe;
import org.apache.james.webadmin.WebAdminUtils;
@@ -32,24 +30,17 @@ import org.apache.james.webadmin.swagger.routes.SwaggerRoutes;
import org.eclipse.jetty.http.HttpStatus;
import org.junit.After;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
import io.restassured.RestAssured;
-public class AuthorizedEndpointsTest {
-
- @Rule
- public DockerCassandraRule cassandra = new DockerCassandraRule();
-
- @Rule
- public CassandraRabbitMQAwsS3JmapTestRule jamesTestRule = CassandraRabbitMQAwsS3JmapTestRule.defaultTestRule();
+public abstract class AuthorizedEndpointsTest {
private GuiceJamesServer guiceJamesServer;
@Before
public void setUp() throws Exception {
- guiceJamesServer = jamesTestRule.jmapServer(cassandra.getModule(), new UnauthorizedModule());
+ guiceJamesServer = createJamesServer();
guiceJamesServer.start();
WebAdminGuiceProbe webAdminGuiceProbe = guiceJamesServer.getProbe(WebAdminGuiceProbe.class);
@@ -62,6 +53,8 @@ public class AuthorizedEndpointsTest {
guiceJamesServer.stop();
}
+ protected abstract GuiceJamesServer createJamesServer() throws Exception;
+
@Test
public void getHealthchecksShouldNotNeedAuthentication() {
when()
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/ForwardIntegrationTest.java b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/ForwardIntegrationTest.java
similarity index 95%
rename from server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/ForwardIntegrationTest.java
rename to server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/ForwardIntegrationTest.java
index 9360240..3b8e236 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/ForwardIntegrationTest.java
+++ b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/ForwardIntegrationTest.java
@@ -42,8 +42,6 @@ import static org.hamcrest.Matchers.hasSize;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
-import org.apache.james.CassandraRabbitMQAwsS3JmapTestRule;
-import org.apache.james.DockerCassandraRule;
import org.apache.james.GuiceJamesServer;
import org.apache.james.jmap.AccessToken;
import org.apache.james.jmap.draft.JmapGuiceProbe;
@@ -52,7 +50,6 @@ import org.apache.james.util.Port;
import org.apache.james.utils.DataProbeImpl;
import org.apache.james.utils.SMTPMessageSender;
import org.apache.james.utils.WebAdminGuiceProbe;
-import org.apache.james.webadmin.WebAdminConfiguration;
import org.apache.james.webadmin.WebAdminUtils;
import org.awaitility.Duration;
import org.junit.After;
@@ -63,13 +60,9 @@ import org.junit.Test;
import io.restassured.RestAssured;
import io.restassured.specification.RequestSpecification;
-public class ForwardIntegrationTest {
+public abstract class ForwardIntegrationTest {
@Rule
- public DockerCassandraRule cassandra = new DockerCassandraRule();
- @Rule
- public CassandraRabbitMQAwsS3JmapTestRule rule = CassandraRabbitMQAwsS3JmapTestRule.defaultTestRule();
- @Rule
public SMTPMessageSender messageSender = new SMTPMessageSender(DOMAIN);
private GuiceJamesServer jmapServer;
@@ -97,11 +90,7 @@ public class ForwardIntegrationTest {
.getJmapPort());
}
- private GuiceJamesServer createJmapServer() throws IOException {
- return rule.jmapServer(cassandra.getModule(),
- binder -> binder.bind(WebAdminConfiguration.class)
- .toInstance(WebAdminConfiguration.TEST_CONFIGURATION));
- }
+ protected abstract GuiceJamesServer createJmapServer() throws IOException;
@After
public void tearDown() {
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/JwtFilterIntegrationTest.java b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/JwtFilterIntegrationTest.java
similarity index 86%
rename from server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/JwtFilterIntegrationTest.java
rename to server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/JwtFilterIntegrationTest.java
index 578dcf0..709124e 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/JwtFilterIntegrationTest.java
+++ b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/JwtFilterIntegrationTest.java
@@ -25,26 +25,21 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.Optional;
-import org.apache.james.CassandraRabbitMQAwsS3JmapTestRule;
-import org.apache.james.DockerCassandraRule;
import org.apache.james.GuiceJamesServer;
import org.apache.james.jwt.JwtConfiguration;
import org.apache.james.util.ClassLoaderUtils;
import org.apache.james.utils.DataProbeImpl;
import org.apache.james.utils.WebAdminGuiceProbe;
import org.apache.james.webadmin.WebAdminUtils;
-import org.apache.james.webadmin.authentication.AuthenticationFilter;
-import org.apache.james.webadmin.authentication.JwtFilter;
import org.apache.james.webadmin.routes.DomainsRoutes;
import org.eclipse.jetty.http.HttpStatus;
import org.junit.After;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
import io.restassured.RestAssured;
-public class JwtFilterIntegrationTest {
+public abstract class JwtFilterIntegrationTest {
private static final String DOMAIN = "domain";
private static final String SPECIFIC_DOMAIN = DomainsRoutes.DOMAINS + SEPARATOR + DOMAIN;
@@ -59,12 +54,6 @@ public class JwtFilterIntegrationTest {
"xtedOK2JnQZn7t9sUzSrcyjWverm7gZkPptkIVoS8TsEeMMME5vFXe_nqkEG69q3kuBUm_33tbR5oNS0ZGZKlG9r41lHBjyf9J1xN4UYV8n866d" +
"a7RPPCzshIWUtO0q9T2umWTnp-6OnOdBCkndrZmRR6pPxsD5YL0_77Wq8KT_5__fGA";
- @Rule
- public DockerCassandraRule cassandra = new DockerCassandraRule();
-
- @Rule
- public CassandraRabbitMQAwsS3JmapTestRule jamesTestRule = CassandraRabbitMQAwsS3JmapTestRule.defaultTestRule();
-
private GuiceJamesServer guiceJamesServer;
private DataProbeImpl dataProbe;
private WebAdminGuiceProbe webAdminGuiceProbe;
@@ -74,9 +63,7 @@ public class JwtFilterIntegrationTest {
JwtConfiguration jwtConfiguration = new JwtConfiguration(
Optional.of(ClassLoaderUtils.getSystemResourceAsString("jwt_publickey")));
- guiceJamesServer = jamesTestRule.jmapServer(cassandra.getModule())
- .overrideWith(binder -> binder.bind(AuthenticationFilter.class).to(JwtFilter.class),
- binder -> binder.bind(JwtConfiguration.class).toInstance(jwtConfiguration));
+ guiceJamesServer = createJamesServer(jwtConfiguration);
guiceJamesServer.start();
dataProbe = guiceJamesServer.getProbe(DataProbeImpl.class);
webAdminGuiceProbe = guiceJamesServer.getProbe(WebAdminGuiceProbe.class);
@@ -89,6 +76,8 @@ public class JwtFilterIntegrationTest {
guiceJamesServer.stop();
}
+ protected abstract GuiceJamesServer createJamesServer(JwtConfiguration jwtConfiguration) throws Exception;
+
@Test
public void jwtAuthenticationShouldWork() throws Exception {
given()
diff --git a/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/UnauthorizedEndpointsTest.java b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/UnauthorizedEndpointsTest.java
new file mode 100644
index 0000000..dbf6075
--- /dev/null
+++ b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/UnauthorizedEndpointsTest.java
@@ -0,0 +1,197 @@
+/****************************************************************
+ * 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.webadmin.integration;
+
+import static io.restassured.RestAssured.when;
+
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.utils.WebAdminGuiceProbe;
+import org.apache.james.webadmin.WebAdminUtils;
+import org.apache.james.webadmin.routes.AliasRoutes;
+import org.apache.james.webadmin.routes.DLPConfigurationRoutes;
+import org.apache.james.webadmin.routes.DomainMappingsRoutes;
+import org.apache.james.webadmin.routes.DomainQuotaRoutes;
+import org.apache.james.webadmin.routes.DomainsRoutes;
+import org.apache.james.webadmin.routes.EventDeadLettersRoutes;
+import org.apache.james.webadmin.routes.ForwardRoutes;
+import org.apache.james.webadmin.routes.GlobalQuotaRoutes;
+import org.apache.james.webadmin.routes.GroupsRoutes;
+import org.apache.james.webadmin.routes.MailQueueRoutes;
+import org.apache.james.webadmin.routes.MailRepositoriesRoutes;
+import org.apache.james.webadmin.routes.SieveQuotaRoutes;
+import org.apache.james.webadmin.routes.TasksRoutes;
+import org.apache.james.webadmin.routes.UserMailboxesRoutes;
+import org.apache.james.webadmin.routes.UserQuotaRoutes;
+import org.apache.james.webadmin.routes.UserRoutes;
+import org.apache.james.webadmin.vault.routes.DeletedMessagesVaultRoutes;
+import org.eclipse.jetty.http.HttpStatus;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import io.restassured.RestAssured;
+
+public abstract class UnauthorizedEndpointsTest {
+
+ @BeforeEach
+ void setup(GuiceJamesServer jamesServer) {
+ WebAdminGuiceProbe webAdminGuiceProbe = jamesServer.getProbe(WebAdminGuiceProbe.class);
+
+ RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminGuiceProbe.getWebAdminPort())
+ .build();
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {
+ DLPConfigurationRoutes.BASE_PATH + "/james.org",
+ DomainMappingsRoutes.DOMAIN_MAPPINGS,
+ DomainMappingsRoutes.DOMAIN_MAPPINGS + "/from.com",
+ DomainQuotaRoutes.BASE_PATH + "/james.org",
+ DomainQuotaRoutes.BASE_PATH + "/james.org/count",
+ DomainQuotaRoutes.BASE_PATH + "/james.org/size",
+ DomainsRoutes.DOMAINS,
+ UserMailboxesRoutes.USERS_BASE + "/someuser/mailboxes",
+ UserMailboxesRoutes.USERS_BASE + "/someuser/mailboxes/mymailbox",
+ UserQuotaRoutes.USERS_QUOTA_ENDPOINT,
+ UserQuotaRoutes.USERS_QUOTA_ENDPOINT + "/joe@perdu.com",
+ UserQuotaRoutes.USERS_QUOTA_ENDPOINT + "/joe@perdu.com/count",
+ UserQuotaRoutes.USERS_QUOTA_ENDPOINT + "/joe@perdu.com/size",
+ UserRoutes.USERS,
+ ForwardRoutes.ROOT_PATH,
+ ForwardRoutes.ROOT_PATH + "/alice@james.org",
+ AliasRoutes.ROOT_PATH,
+ AliasRoutes.ROOT_PATH + "/bob@james.org",
+ GlobalQuotaRoutes.QUOTA_ENDPOINT,
+ GlobalQuotaRoutes.QUOTA_ENDPOINT + "/count",
+ GlobalQuotaRoutes.QUOTA_ENDPOINT + "/size",
+ GroupsRoutes.ROOT_PATH,
+ GroupsRoutes.ROOT_PATH + "/group@james.org",
+ MailQueueRoutes.BASE_URL + "/first_queue",
+ MailRepositoriesRoutes.MAIL_REPOSITORIES,
+ MailRepositoriesRoutes.MAIL_REPOSITORIES + "/myRepo",
+ MailRepositoriesRoutes.MAIL_REPOSITORIES + "/myRepo/mails",
+ MailRepositoriesRoutes.MAIL_REPOSITORIES + "/myRepo/mails/1",
+ SieveQuotaRoutes.DEFAULT_QUOTA_PATH,
+ SieveQuotaRoutes.ROOT_PATH + "/users/user@james.org",
+ TasksRoutes.BASE,
+ TasksRoutes.BASE + "/taskId",
+ TasksRoutes.BASE + "/taskId/await",
+ EventDeadLettersRoutes.BASE_PATH + "/groups",
+ EventDeadLettersRoutes.BASE_PATH + "/groups/group@james.org",
+ EventDeadLettersRoutes.BASE_PATH + "/groups/group@james.org/1"
+ })
+ protected void checkUrlProtectionOnGet(String url) {
+ when()
+ .get(url)
+ .then()
+ .statusCode(HttpStatus.UNAUTHORIZED_401);
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {
+ DeletedMessagesVaultRoutes.ROOT_PATH + "/joe@perdu.com",
+ EventDeadLettersRoutes.BASE_PATH,
+ EventDeadLettersRoutes.BASE_PATH + "/groups/group@james.org",
+ EventDeadLettersRoutes.BASE_PATH + "/groups/group@james.org/1"
+ })
+ protected void checkUrlProtectionOnPost(String url) {
+ when()
+ .post(url)
+ .then()
+ .statusCode(HttpStatus.UNAUTHORIZED_401);
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {
+ DLPConfigurationRoutes.BASE_PATH + "/james.org",
+ DomainMappingsRoutes.DOMAIN_MAPPINGS + "/from.com",
+ DomainQuotaRoutes.BASE_PATH + "/james.org/count",
+ DomainQuotaRoutes.BASE_PATH + "/james.org/size",
+ DomainQuotaRoutes.BASE_PATH + "/james.org",
+ DomainsRoutes.DOMAINS + "/james.org",
+ UserMailboxesRoutes.USERS_BASE + "/someuser/mailboxes/mymailbox",
+ UserQuotaRoutes.USERS_QUOTA_ENDPOINT + "/joe@perdu.com",
+ UserQuotaRoutes.USERS_QUOTA_ENDPOINT + "/joe@perdu.com/count",
+ UserQuotaRoutes.USERS_QUOTA_ENDPOINT + "/joe@perdu.com/size",
+ UserRoutes.USERS + "/user@james.org",
+ ForwardRoutes.ROOT_PATH + "/alice@james.org/bob@james.org",
+ AliasRoutes.ROOT_PATH + "/bob@james.org/sources/bob-alias@james.org",
+ GlobalQuotaRoutes.QUOTA_ENDPOINT + "/count",
+ GlobalQuotaRoutes.QUOTA_ENDPOINT + "/size",
+ GlobalQuotaRoutes.QUOTA_ENDPOINT,
+ GroupsRoutes.ROOT_PATH + "/group@james.org/user@james.org",
+ MailRepositoriesRoutes.MAIL_REPOSITORIES + "/myRepo",
+ SieveQuotaRoutes.DEFAULT_QUOTA_PATH,
+ SieveQuotaRoutes.ROOT_PATH + "/users/user@james.org"
+ })
+ void checkUrlProtectionOnPut(String url) {
+ when()
+ .put(url)
+ .then()
+ .statusCode(HttpStatus.UNAUTHORIZED_401);
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {
+ DLPConfigurationRoutes.BASE_PATH + "/james.org",
+ DomainQuotaRoutes.BASE_PATH + "/james.org/count",
+ DomainQuotaRoutes.BASE_PATH + "/james.org/size",
+ DomainMappingsRoutes.DOMAIN_MAPPINGS + "/from.com",
+ DomainsRoutes.DOMAINS + "/james.org",
+ UserMailboxesRoutes.USERS_BASE + "/someuser/mailboxes",
+ UserMailboxesRoutes.USERS_BASE + "/someuser/mailboxes/mymailbox",
+ UserQuotaRoutes.USERS_QUOTA_ENDPOINT + "/joe@perdu.com/count",
+ UserQuotaRoutes.USERS_QUOTA_ENDPOINT + "/joe@perdu.com/size",
+ UserRoutes.USERS + "/user@james.org",
+ ForwardRoutes.ROOT_PATH + "/alice@james.org/bob@james.org",
+ AliasRoutes.ROOT_PATH + "/bob@james.org/sources/bob-alias@james.org",
+ GlobalQuotaRoutes.QUOTA_ENDPOINT + "/count",
+ GlobalQuotaRoutes.QUOTA_ENDPOINT + "/size",
+ GroupsRoutes.ROOT_PATH + "/group@james.org/user@james.org",
+ MailQueueRoutes.BASE_URL,
+ MailQueueRoutes.BASE_URL + "/first_queue/mails",
+ MailQueueRoutes.BASE_URL + "/second_queue/mails",
+ MailRepositoriesRoutes.MAIL_REPOSITORIES + "/myRepo/mails/1",
+ MailRepositoriesRoutes.MAIL_REPOSITORIES + "/myRepo/mails",
+ SieveQuotaRoutes.DEFAULT_QUOTA_PATH,
+ SieveQuotaRoutes.ROOT_PATH + "/users/user@james.org",
+ TasksRoutes.BASE + "/taskId",
+ EventDeadLettersRoutes.BASE_PATH + "/groups/group@james.org/1"
+ })
+ void checkUrlProtectionOnDelete(String url) {
+ when()
+ .delete(url)
+ .then()
+ .statusCode(HttpStatus.UNAUTHORIZED_401);
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {
+ MailQueueRoutes.BASE_URL + "/first_queue/mails",
+ MailRepositoriesRoutes.MAIL_REPOSITORIES + "/myRepo/mails",
+ MailRepositoriesRoutes.MAIL_REPOSITORIES + "/myRepo/mails/name1"
+ })
+ void checkUrlProtectionOnPath(String url) {
+ when()
+ .patch(url)
+ .then()
+ .statusCode(HttpStatus.UNAUTHORIZED_401);
+ }
+}
\ No newline at end of file
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/UnauthorizedModule.java
similarity index 100%
rename from server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/UnauthorizedModule.java
rename to server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/UnauthorizedModule.java
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
similarity index 73%
rename from server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
rename to server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
index e60e848..1ffe07b 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
+++ b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/WebAdminServerIntegrationTest.java
@@ -25,74 +25,55 @@ import static io.restassured.RestAssured.with;
import static org.apache.james.webadmin.Constants.JSON_CONTENT_TYPE;
import static org.apache.james.webadmin.Constants.SEPARATOR;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.hamcrest.CoreMatchers.hasItems;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import java.util.List;
-import org.apache.james.CassandraRabbitMQAwsS3JmapTestRule;
-import org.apache.james.DockerCassandraRule;
import org.apache.james.GuiceJamesServer;
-import org.apache.james.backends.cassandra.versions.CassandraSchemaVersionManager;
import org.apache.james.modules.MailboxProbeImpl;
import org.apache.james.probe.DataProbe;
import org.apache.james.utils.DataProbeImpl;
import org.apache.james.utils.WebAdminGuiceProbe;
import org.apache.james.webadmin.WebAdminUtils;
import org.apache.james.webadmin.routes.AliasRoutes;
-import org.apache.james.webadmin.routes.CassandraMappingsRoutes;
import org.apache.james.webadmin.routes.DomainsRoutes;
import org.apache.james.webadmin.routes.ForwardRoutes;
import org.apache.james.webadmin.routes.GroupsRoutes;
import org.apache.james.webadmin.routes.HealthCheckRoutes;
import org.apache.james.webadmin.routes.MailQueueRoutes;
import org.apache.james.webadmin.routes.MailRepositoriesRoutes;
-import org.apache.james.webadmin.routes.TasksRoutes;
import org.apache.james.webadmin.routes.UserMailboxesRoutes;
import org.apache.james.webadmin.routes.UserRoutes;
import org.apache.james.webadmin.swagger.routes.SwaggerRoutes;
-import org.awaitility.Awaitility;
-import org.awaitility.Duration;
import org.eclipse.jetty.http.HttpStatus;
import org.junit.After;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
import io.restassured.RestAssured;
-import io.restassured.http.ContentType;
-public class WebAdminServerIntegrationTest {
+public abstract class WebAdminServerIntegrationTest {
private static final String DOMAIN = "domain";
- private static final String USERNAME = "username@" + DOMAIN;
+ protected static final String USERNAME = "username@" + DOMAIN;
private static final String USERNAME_2 = "username2@" + DOMAIN;
- private static final String ALIAS_1 = "alias1@" + DOMAIN;
- private static final String ALIAS_2 = "alias2@" + DOMAIN;
private static final String GROUP = "group@" + DOMAIN;
private static final String SPECIFIC_DOMAIN = DomainsRoutes.DOMAINS + SEPARATOR + DOMAIN;
private static final String SPECIFIC_USER = UserRoutes.USERS + SEPARATOR + USERNAME;
private static final String MAILBOX = "mailbox";
private static final String SPECIFIC_MAILBOX = SPECIFIC_USER + SEPARATOR + UserMailboxesRoutes.MAILBOXES + SEPARATOR + MAILBOX;
- private static final String VERSION = "/cassandra/version";
- private static final String VERSION_LATEST = VERSION + "/latest";
- private static final String UPGRADE_VERSION = VERSION + "/upgrade";
- private static final String UPGRADE_TO_LATEST_VERSION = UPGRADE_VERSION + "/latest";
- @Rule
- public DockerCassandraRule cassandra = new DockerCassandraRule();
-
- @Rule
- public CassandraRabbitMQAwsS3JmapTestRule jamesTestRule = CassandraRabbitMQAwsS3JmapTestRule.defaultTestRule();
+ protected static final String ALIAS_1 = "alias1@" + DOMAIN;
+ protected static final String ALIAS_2 = "alias2@" + DOMAIN;
private GuiceJamesServer guiceJamesServer;
private DataProbe dataProbe;
@Before
public void setUp() throws Exception {
- guiceJamesServer = jamesTestRule.jmapServer(cassandra.getModule());
+ guiceJamesServer = createJamesServer();
guiceJamesServer.start();
dataProbe = guiceJamesServer.getProbe(DataProbeImpl.class);
dataProbe.addDomain(DOMAIN);
@@ -107,6 +88,8 @@ public class WebAdminServerIntegrationTest {
guiceJamesServer.stop();
}
+ protected abstract GuiceJamesServer createJamesServer() throws Exception;
+
@Test
public void postShouldAddTheGivenDomain() throws Exception {
when()
@@ -240,70 +223,6 @@ public class WebAdminServerIntegrationTest {
}
@Test
- public void getCurrentVersionShouldReturnNullForCurrentVersionAsBeginning() {
- when()
- .get(VERSION)
- .then()
- .statusCode(HttpStatus.OK_200)
- .contentType(JSON_CONTENT_TYPE)
- .body(is("{\"version\":null}"));
- }
-
- @Test
- public void getLatestVersionShouldReturnTheConfiguredLatestVersion() {
- when()
- .get(VERSION_LATEST)
- .then()
- .statusCode(HttpStatus.OK_200)
- .contentType(JSON_CONTENT_TYPE)
- .body(is("{\"version\":" + CassandraSchemaVersionManager.MAX_VERSION.getValue() + "}"));
- }
-
- @Test
- public void postShouldDoMigrationAndUpdateCurrentVersion() {
- String taskId = with()
- .body(String.valueOf(CassandraSchemaVersionManager.MAX_VERSION.getValue()))
- .post(UPGRADE_VERSION)
- .jsonPath()
- .get("taskId");
-
- with()
- .get("/tasks/" + taskId + "/await")
- .then()
- .body("status", is("completed"));
-
- Awaitility.await()
- .atMost(Duration.TEN_SECONDS)
- .await()
- .untilAsserted(() ->
- when()
- .get(VERSION)
- .then()
- .statusCode(HttpStatus.OK_200)
- .contentType(JSON_CONTENT_TYPE)
- .body(is("{\"version\":" + CassandraSchemaVersionManager.MAX_VERSION.getValue() + "}")));
- }
-
- @Test
- public void postShouldDoMigrationAndUpdateToTheLatestVersion() {
- String taskId = with().post(UPGRADE_TO_LATEST_VERSION)
- .jsonPath()
- .get("taskId");
-
- with()
- .get("/tasks/" + taskId + "/await")
- .then()
- .body("status", is("completed"));
-
- when()
- .get(VERSION)
- .then()
- .statusCode(HttpStatus.OK_200)
- .contentType(JSON_CONTENT_TYPE)
- .body(is("{\"version\":" + CassandraSchemaVersionManager.MAX_VERSION.getValue() + "}"));
- }
-
- @Test
public void addressGroupsEndpointShouldHandleRequests() throws Exception {
with()
.put(GroupsRoutes.ROOT_PATH + SEPARATOR + GROUP + SEPARATOR + USERNAME);
@@ -391,32 +310,4 @@ public class WebAdminServerIntegrationTest {
.then()
.statusCode(HttpStatus.OK_200);
}
-
- @Test
- public void cassandraMappingsEndpointShouldKeepDataConsistencyWhenDataValid() {
- with()
- .put(AliasRoutes.ROOT_PATH + SEPARATOR + USERNAME + "/sources/" + ALIAS_1);
- with()
- .put(AliasRoutes.ROOT_PATH + SEPARATOR + USERNAME + "/sources/" + ALIAS_2);
-
- String taskId = with()
- .queryParam("action", "SolveInconsistencies")
- .post(CassandraMappingsRoutes.ROOT_PATH)
- .jsonPath()
- .get("taskId");
-
- given()
- .basePath(TasksRoutes.BASE)
- .when()
- .get(taskId + "/await")
- .then()
- .body("status", is("completed"));
-
- when()
- .get(AliasRoutes.ROOT_PATH + SEPARATOR + USERNAME)
- .then()
- .contentType(ContentType.JSON)
- .statusCode(HttpStatus.OK_200)
- .body("source", hasItems(ALIAS_1, ALIAS_2));
- }
}
\ No newline at end of file
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/vault/DeletedMessageVaultIntegrationTest.java b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/vault/DeletedMessageVaultIntegrationTest.java
similarity index 97%
rename from server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/vault/DeletedMessageVaultIntegrationTest.java
rename to server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/vault/DeletedMessageVaultIntegrationTest.java
index 7d1767f..cd9c8aa 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/vault/DeletedMessageVaultIntegrationTest.java
+++ b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/vault/DeletedMessageVaultIntegrationTest.java
@@ -49,8 +49,6 @@ import java.time.Clock;
import java.time.ZonedDateTime;
import java.util.List;
-import org.apache.james.CassandraRabbitMQAwsS3JmapTestRule;
-import org.apache.james.DockerCassandraRule;
import org.apache.james.GuiceJamesServer;
import org.apache.james.core.Username;
import org.apache.james.filesystem.api.FileSystem;
@@ -63,7 +61,6 @@ import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.probe.MailboxProbe;
import org.apache.james.modules.MailboxProbeImpl;
import org.apache.james.modules.protocols.ImapGuiceProbe;
-import org.apache.james.modules.vault.TestDeleteMessageVaultPreDeletionHookModule;
import org.apache.james.probe.DataProbe;
import org.apache.james.server.core.JamesServerResourceLoader;
import org.apache.james.server.core.filesystem.FileSystemImpl;
@@ -72,7 +69,6 @@ import org.apache.james.utils.DataProbeImpl;
import org.apache.james.utils.IMAPMessageReader;
import org.apache.james.utils.UpdatableTickingClock;
import org.apache.james.utils.WebAdminGuiceProbe;
-import org.apache.james.webadmin.WebAdminConfiguration;
import org.apache.james.webadmin.WebAdminUtils;
import org.awaitility.Duration;
import org.awaitility.core.ConditionFactory;
@@ -90,7 +86,7 @@ import io.restassured.config.ParamConfig;
import io.restassured.parsing.Parser;
import io.restassured.specification.RequestSpecification;
-public class DeletedMessageVaultIntegrationTest {
+public abstract class DeletedMessageVaultIntegrationTest {
private static final ZonedDateTime NOW = ZonedDateTime.now();
private static final ZonedDateTime TWO_MONTH_AFTER_ONE_YEAR_EXPIRATION = NOW.plusYears(1).plusMonths(2);
@@ -116,11 +112,7 @@ public class DeletedMessageVaultIntegrationTest {
.userExportFrom(JACK)
.exportTo(HOMER)
.query(MATCH_ALL_QUERY);
-
- @Rule
- public DockerCassandraRule cassandra = new DockerCassandraRule();
- @Rule
- public CassandraRabbitMQAwsS3JmapTestRule rule = CassandraRabbitMQAwsS3JmapTestRule.defaultTestRule();
+
@Rule
public IMAPMessageReader imapMessageReader = new IMAPMessageReader();
@Rule
@@ -165,25 +157,17 @@ public class DeletedMessageVaultIntegrationTest {
.config(WebAdminUtils.defaultConfig()
.paramConfig(new ParamConfig(REPLACE, REPLACE, REPLACE)));
}
-
- private GuiceJamesServer createJmapServer(FileSystem fileSystem, Clock clock) throws IOException {
- return rule.jmapServer(cassandra.getModule(),
- new TestDeleteMessageVaultPreDeletionHookModule(),
- binder -> binder.bind(WebAdminConfiguration.class).toInstance(WebAdminConfiguration.TEST_CONFIGURATION),
- binder -> binder.bind(FileSystem.class).toInstance(fileSystem),
- binder -> binder.bind(Clock.class).toInstance(clock));
- }
- private void awaitSearchUpToDate() {
- rule.await();
- }
-
+ protected abstract GuiceJamesServer createJmapServer(FileSystem fileSystem, Clock clock) throws IOException;
+
+ protected abstract void awaitSearchUpToDate();
+
@After
public void tearDown() throws Exception {
jmapServer.stop();
}
-
+
@Test
public void vaultEndpointShouldRestoreJmapDeletedEmail() {
bartSendMessageToHomer();
@@ -206,7 +190,7 @@ public class DeletedMessageVaultIntegrationTest {
.log().ifValidationFails()
.body(ARGUMENTS + ".list.subject", hasItem(SUBJECT));
}
-
+
@Test
public void vaultEndpointShouldRestoreImapDeletedEmail() throws Exception {
bartSendMessageToHomer();
@@ -235,7 +219,7 @@ public class DeletedMessageVaultIntegrationTest {
.body(ARGUMENTS + ".list.subject", hasItem(SUBJECT));
}
-
+
@Test
public void vaultEndpointShouldRestoreImapDeletedMailbox() throws Exception {
bartSendMessageToHomer();
@@ -479,7 +463,7 @@ public class DeletedMessageVaultIntegrationTest {
.body(ARGUMENTS + ".list.subject", hasItem(SUBJECT));
}
-
+
@Test
public void vaultExportShouldExportZipContainsVaultMessagesToShareeWhenJmapDeleteMessage() throws Exception {
bartSendMessageToHomer();
@@ -497,7 +481,7 @@ public class DeletedMessageVaultIntegrationTest {
}
}
-
+
@Test
public void vaultExportShouldExportZipContainsVaultMessagesToShareeWhenImapDeleteMessage() throws Exception {
bartSendMessageToHomer();
@@ -520,7 +504,7 @@ public class DeletedMessageVaultIntegrationTest {
}
}
-
+
@Test
public void vaultExportShouldExportZipContainsVaultMessagesToShareeWhenImapDeletedMailbox() throws Exception {
bartSendMessageToHomer();
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/vault/DeletedMessagesVaultRequests.java b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/vault/DeletedMessagesVaultRequests.java
similarity index 100%
rename from server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/vault/DeletedMessagesVaultRequests.java
rename to server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/vault/DeletedMessagesVaultRequests.java
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/vault/ExportRequest.java b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/vault/ExportRequest.java
similarity index 100%
rename from server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/vault/ExportRequest.java
rename to server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/vault/ExportRequest.java
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/vault/LinshareBlobExportMechanismIntegrationTest.java b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/vault/LinshareBlobExportMechanismIntegrationTest.java
similarity index 87%
rename from server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/vault/LinshareBlobExportMechanismIntegrationTest.java
rename to server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/vault/LinshareBlobExportMechanismIntegrationTest.java
index 3f4b3b6..1bcfdec 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/vault/LinshareBlobExportMechanismIntegrationTest.java
+++ b/server/protocols/webadmin-integration-test/webadmin-integration-test-common/src/main/java/org/apache/james/webadmin/integration/vault/LinshareBlobExportMechanismIntegrationTest.java
@@ -43,13 +43,7 @@ import static org.hamcrest.Matchers.hasSize;
import java.io.ByteArrayInputStream;
import java.util.List;
-import org.apache.james.CassandraExtension;
-import org.apache.james.CassandraRabbitMQJamesServerMain;
-import org.apache.james.DockerElasticSearchExtension;
import org.apache.james.GuiceJamesServer;
-import org.apache.james.JamesServerBuilder;
-import org.apache.james.JamesServerExtension;
-import org.apache.james.backends.rabbitmq.DockerRabbitMQSingleton;
import org.apache.james.core.Username;
import org.apache.james.jmap.AccessToken;
import org.apache.james.jmap.draft.JmapGuiceProbe;
@@ -57,23 +51,15 @@ import org.apache.james.linshare.client.Document;
import org.apache.james.linshare.client.LinshareAPI;
import org.apache.james.mailbox.DefaultMailboxes;
import org.apache.james.mailbox.backup.ZipAssert;
-import org.apache.james.mailbox.extractor.TextExtractor;
import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailbox.probe.MailboxProbe;
-import org.apache.james.mailbox.store.search.PDFTextExtractor;
-import org.apache.james.modules.AwsS3BlobStoreExtension;
import org.apache.james.modules.LinshareGuiceExtension;
import org.apache.james.modules.MailboxProbeImpl;
-import org.apache.james.modules.RabbitMQExtension;
-import org.apache.james.modules.TestJMAPServerModule;
-import org.apache.james.modules.TestRabbitMQModule;
import org.apache.james.modules.protocols.ImapGuiceProbe;
-import org.apache.james.modules.vault.TestDeleteMessageVaultPreDeletionHookModule;
import org.apache.james.util.Port;
import org.apache.james.utils.DataProbeImpl;
import org.apache.james.utils.IMAPMessageReader;
import org.apache.james.utils.WebAdminGuiceProbe;
-import org.apache.james.webadmin.WebAdminConfiguration;
import org.apache.james.webadmin.WebAdminUtils;
import org.awaitility.Duration;
import org.awaitility.core.ConditionFactory;
@@ -85,7 +71,7 @@ import io.restassured.RestAssured;
import io.restassured.parsing.Parser;
import io.restassured.specification.RequestSpecification;
-class LinshareBlobExportMechanismIntegrationTest {
+public abstract class LinshareBlobExportMechanismIntegrationTest {
private static final String HOMER = "homer@" + DOMAIN;
private static final String BART = "bart@" + DOMAIN;
@@ -98,24 +84,7 @@ class LinshareBlobExportMechanismIntegrationTest {
.exportTo(USER_1.getUsername())
.query(MATCH_ALL_QUERY);
- private static final int LIMIT_TO_20_MESSAGES = 20;
-
- private static final LinshareGuiceExtension linshareGuiceExtension = new LinshareGuiceExtension();
- @RegisterExtension
- static JamesServerExtension testExtension = new JamesServerBuilder()
- .extension(new DockerElasticSearchExtension())
- .extension(new CassandraExtension())
- .extension(new RabbitMQExtension())
- .extension(new AwsS3BlobStoreExtension())
- .extension(linshareGuiceExtension)
- .server(configuration -> GuiceJamesServer.forConfiguration(configuration)
- .combineWith(CassandraRabbitMQJamesServerMain.MODULES)
- .overrideWith(binder -> binder.bind(TextExtractor.class).to(PDFTextExtractor.class))
- .overrideWith(new TestJMAPServerModule(LIMIT_TO_20_MESSAGES))
- .overrideWith(new TestRabbitMQModule(DockerRabbitMQSingleton.SINGLETON))
- .overrideWith(binder -> binder.bind(WebAdminConfiguration.class).toInstance(WebAdminConfiguration.TEST_CONFIGURATION))
- .overrideWith(new TestDeleteMessageVaultPreDeletionHookModule()))
- .build();
+ protected static final LinshareGuiceExtension linshareGuiceExtension = new LinshareGuiceExtension();
@RegisterExtension
IMAPMessageReader imapMessageReader = new IMAPMessageReader();
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org