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/06/17 11:04:34 UTC
[james-project] 02/09: MAILET-136 James JMAP doesn't create new
user or mailbox when doing domain re routing
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 d81197b9555ed2f48cdcf3650ad733fde275312b
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Tue Jun 11 11:24:01 2019 +0700
MAILET-136 James JMAP doesn't create new user or mailbox when doing domain re routing
---
.../CassandraSetMessagesMethodReRoutingTest.java | 47 ++++
.../org/apache/james/jmap/JmapCommonRequests.java | 36 +++
.../integration/GetMessageListMethodTest.java | 34 +--
.../SetMessagesMethodReRoutingTest.java | 242 +++++++++++++++++++++
.../methods/integration/SetMessagesMethodTest.java | 12 +-
.../MemorySetMessagesMethodReRoutingTest.java | 42 ++++
...abbitMQAwsS3SetMessagesMethodReRoutingTest.java | 48 ++++
7 files changed, 438 insertions(+), 23 deletions(-)
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMessagesMethodReRoutingTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMessagesMethodReRoutingTest.java
new file mode 100644
index 0000000..02dcbf8
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMessagesMethodReRoutingTest.java
@@ -0,0 +1,47 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.jmap.cassandra;
+
+import java.io.IOException;
+
+import org.apache.james.CassandraJmapTestRule;
+import org.apache.james.DockerCassandraRule;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.jmap.methods.integration.SetMessagesMethodReRoutingTest;
+import org.junit.Rule;
+
+public class CassandraSetMessagesMethodReRoutingTest extends SetMessagesMethodReRoutingTest {
+
+ @Rule
+ public DockerCassandraRule cassandra = new DockerCassandraRule();
+
+ @Rule
+ public CassandraJmapTestRule rule = CassandraJmapTestRule.defaultTestRule();
+
+ @Override
+ protected GuiceJamesServer createJmapServer() throws IOException {
+ return rule.jmapServer(cassandra.getModule());
+ }
+
+ @Override
+ protected void await() {
+ rule.await();
+ }
+}
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JmapCommonRequests.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JmapCommonRequests.java
index 85e241f..7dd4c14 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JmapCommonRequests.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/JmapCommonRequests.java
@@ -36,6 +36,7 @@ import org.apache.james.mailbox.Role;
import org.apache.james.mailbox.model.MailboxId;
import io.restassured.builder.ResponseSpecBuilder;
+import io.restassured.path.json.JsonPath;
import io.restassured.specification.ResponseSpecification;
public class JmapCommonRequests {
@@ -131,6 +132,41 @@ public class JmapCommonRequests {
.path(ARGUMENTS + ".messageIds[0]");
}
+ public static String getLatestMessageId(AccessToken accessToken, Role mailbox) {
+ String inboxId = getMailboxId(accessToken, mailbox);
+ return with()
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"" + inboxId + "\"]}, \"sort\":[\"date desc\"]}, \"#0\"]]")
+ .post("/jmap")
+ .then()
+ .extract()
+ .path(ARGUMENTS + ".messageIds[0]");
+ }
+
+ public static String bodyOfMessage(AccessToken accessToken, String messageId) {
+ return getMessageContent(accessToken, messageId)
+ .get(ARGUMENTS + ".list[0].textBody");
+ }
+
+ public static List<String> receiversOfMessage(AccessToken accessToken, String messageId) {
+ return getMessageContent(accessToken, messageId)
+ .getList(ARGUMENTS + ".list[0].to.email");
+ }
+
+ private static JsonPath getMessageContent(AccessToken accessToken, String messageId) {
+ return with()
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessages\", {\"ids\": [\"" + messageId + "\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messages"))
+ .body(ARGUMENTS + ".list", hasSize(1))
+ .extract()
+ .jsonPath();
+ }
+
public static List<String> listMessageIdsInMailbox(AccessToken accessToken, String mailboxId) {
return with()
.header("Authorization", accessToken.serialize())
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
index 1ac3d65..3c38c11 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
@@ -107,7 +107,7 @@ public abstract class GetMessageListMethodTest {
private GuiceJamesServer jmapServer;
private MailboxProbeImpl mailboxProbe;
private DataProbe dataProbe;
-
+
@Before
public void setup() throws Throwable {
jmapServer = createJmapServer();
@@ -346,7 +346,7 @@ public abstract class GetMessageListMethodTest {
.body(NAME, equalTo("messageList"))
.body(ARGUMENTS + ".messageIds", hasSize(1));
}
-
+
@Test
public void getMessageListSetFlaggedFilterShouldResultFlaggedMessages() throws Exception {
mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, ALICE, "mailbox");
@@ -367,7 +367,7 @@ public abstract class GetMessageListMethodTest {
.statusCode(200)
.body(NAME, equalTo("messageList"))
.body(ARGUMENTS + ".messageIds", allOf(
- containsInAnyOrder(messageFlagged.getMessageId().serialize()),
+ containsInAnyOrder(messageFlagged.getMessageId().serialize()),
not(containsInAnyOrder(messageNotFlagged.getMessageId().serialize()))));
}
@@ -391,7 +391,7 @@ public abstract class GetMessageListMethodTest {
.statusCode(200)
.body(NAME, equalTo("messageList"))
.body(ARGUMENTS + ".messageIds", allOf(
- containsInAnyOrder(messageNotFlagged.getMessageId().serialize()),
+ containsInAnyOrder(messageNotFlagged.getMessageId().serialize()),
not(containsInAnyOrder(messageFlagged.getMessageId().serialize()))));
}
@@ -415,7 +415,7 @@ public abstract class GetMessageListMethodTest {
.statusCode(200)
.body(NAME, equalTo("messageList"))
.body(ARGUMENTS + ".messageIds", allOf(
- containsInAnyOrder(messageRead.getMessageId().serialize()),
+ containsInAnyOrder(messageRead.getMessageId().serialize()),
not(containsInAnyOrder(messageNotRead.getMessageId().serialize()))));
}
@@ -439,7 +439,7 @@ public abstract class GetMessageListMethodTest {
.statusCode(200)
.body(NAME, equalTo("messageList"))
.body(ARGUMENTS + ".messageIds", allOf(
- containsInAnyOrder(messageNotRead.getMessageId().serialize()),
+ containsInAnyOrder(messageNotRead.getMessageId().serialize()),
not(containsInAnyOrder(messageRead.getMessageId().serialize()))));
}
@@ -463,7 +463,7 @@ public abstract class GetMessageListMethodTest {
.statusCode(200)
.body(NAME, equalTo("messageList"))
.body(ARGUMENTS + ".messageIds", allOf(
- containsInAnyOrder(messageDraft.getMessageId().serialize()),
+ containsInAnyOrder(messageDraft.getMessageId().serialize()),
not(containsInAnyOrder(messageNotDraft.getMessageId().serialize()))));
}
@@ -487,7 +487,7 @@ public abstract class GetMessageListMethodTest {
.statusCode(200)
.body(NAME, equalTo("messageList"))
.body(ARGUMENTS + ".messageIds", allOf(
- containsInAnyOrder(messageNotDraft.getMessageId().serialize()),
+ containsInAnyOrder(messageNotDraft.getMessageId().serialize()),
not(containsInAnyOrder(messageDraft.getMessageId().serialize()))));
}
@@ -511,7 +511,7 @@ public abstract class GetMessageListMethodTest {
.statusCode(200)
.body(NAME, equalTo("messageList"))
.body(ARGUMENTS + ".messageIds", allOf(
- containsInAnyOrder(messageAnswered.getMessageId().serialize()),
+ containsInAnyOrder(messageAnswered.getMessageId().serialize()),
not(containsInAnyOrder(messageNotAnswered.getMessageId().serialize()))));
}
@@ -535,7 +535,7 @@ public abstract class GetMessageListMethodTest {
.statusCode(200)
.body(NAME, equalTo("messageList"))
.body(ARGUMENTS + ".messageIds", allOf(
- containsInAnyOrder(messageNotAnswered.getMessageId().serialize()),
+ containsInAnyOrder(messageNotAnswered.getMessageId().serialize()),
not(containsInAnyOrder(messageAnswered.getMessageId().serialize()))));
}
@@ -612,7 +612,7 @@ public abstract class GetMessageListMethodTest {
.statusCode(200)
.body(NAME, equalTo("messageList"))
.body(ARGUMENTS + ".messageIds", allOf(
- containsInAnyOrder(messageNotSeenFlagged.getMessageId().serialize()),
+ containsInAnyOrder(messageNotSeenFlagged.getMessageId().serialize()),
not(containsInAnyOrder(messageNotSeenNotFlagged.getMessageId().serialize(),
messageSeenNotFlagged.getMessageId().serialize(),
messageSeenFlagged.getMessageId().serialize()))));
@@ -644,7 +644,7 @@ public abstract class GetMessageListMethodTest {
.body(ARGUMENTS + ".messageIds", allOf(
containsInAnyOrder(messageNotSeenFlagged.getMessageId().serialize(),
messageSeenFlagged.getMessageId().serialize(),
- messageNotSeenNotFlagged.getMessageId().serialize()),
+ messageNotSeenNotFlagged.getMessageId().serialize()),
not(containsInAnyOrder(messageSeenNotFlagged.getMessageId().serialize()))));
}
@@ -672,7 +672,7 @@ public abstract class GetMessageListMethodTest {
.statusCode(200)
.body(NAME, equalTo("messageList"))
.body(ARGUMENTS + ".messageIds", allOf(
- containsInAnyOrder(messageSeenNotFlagged.getMessageId().serialize()),
+ containsInAnyOrder(messageSeenNotFlagged.getMessageId().serialize()),
not(containsInAnyOrder(messageNotSeenFlagged.getMessageId().serialize(),
messageSeenFlagged.getMessageId().serialize(),
messageNotSeenNotFlagged.getMessageId().serialize()))));
@@ -706,7 +706,7 @@ public abstract class GetMessageListMethodTest {
.body(NAME, equalTo("messageList"))
.body(ARGUMENTS + ".messageIds", allOf(
containsInAnyOrder(messageSeenFlagged.getMessageId().serialize(),
- messageNotSeenFlagged.getMessageId().serialize()),
+ messageNotSeenFlagged.getMessageId().serialize()),
not(containsInAnyOrder(messageNotSeenNotFlagged.getMessageId().serialize(),
messageSeenNotFlagged.getMessageId().serialize()))));
}
@@ -916,7 +916,7 @@ public abstract class GetMessageListMethodTest {
new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags());
await();
-
+
given()
.header("Authorization", aliceAccessToken.serialize())
.body(String.format("[[\"getMessageList\", {\"filter\":{\"notInMailboxes\":[\"%s\"]}}, \"#0\"]]", mailboxId.serialize()))
@@ -1643,7 +1643,7 @@ public abstract class GetMessageListMethodTest {
.statusCode(200)
.body(NAME, equalTo("messageList"));
}
-
+
@Test
public void getMessageListShouldWorkWhenCollapseThreadIsTrue() {
given()
@@ -1655,7 +1655,7 @@ public abstract class GetMessageListMethodTest {
.statusCode(200)
.body(NAME, equalTo("messageList"));
}
-
+
@Test
public void getMessageListShouldReturnAllMessagesWhenPositionIsNotGiven() throws Exception {
mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, ALICE, "mailbox");
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodReRoutingTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodReRoutingTest.java
new file mode 100644
index 0000000..d60bf21
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodReRoutingTest.java
@@ -0,0 +1,242 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.jmap.methods.integration;
+
+import static io.restassured.RestAssured.given;
+import static io.restassured.config.EncoderConfig.encoderConfig;
+import static io.restassured.config.RestAssuredConfig.newConfig;
+import static org.apache.james.jmap.HttpJmapAuthentication.authenticateJamesUser;
+import static org.apache.james.jmap.JmapCommonRequests.bodyOfMessage;
+import static org.apache.james.jmap.JmapCommonRequests.getLatestMessageId;
+import static org.apache.james.jmap.JmapCommonRequests.getOutboxId;
+import static org.apache.james.jmap.JmapCommonRequests.receiversOfMessage;
+import static org.apache.james.jmap.JmapURIBuilder.baseUri;
+import static org.apache.james.jmap.TestingConstants.ARGUMENTS;
+import static org.apache.james.jmap.TestingConstants.NAME;
+import static org.apache.james.jmap.TestingConstants.calmlyAwait;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.collection.IsMapWithSize.aMapWithSize;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.jmap.api.access.AccessToken;
+import org.apache.james.mailbox.Role;
+import org.apache.james.mailbox.probe.MailboxProbe;
+import org.apache.james.modules.MailboxProbeImpl;
+import org.apache.james.probe.DataProbe;
+import org.apache.james.utils.DataProbeImpl;
+import org.apache.james.utils.JmapGuiceProbe;
+import org.awaitility.Duration;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import io.restassured.RestAssured;
+import io.restassured.builder.RequestSpecBuilder;
+import io.restassured.http.ContentType;
+import io.restassured.parsing.Parser;
+
+public abstract class SetMessagesMethodReRoutingTest {
+ private static final String PASSWORD = "password";
+
+ private static final String DESTINATION_DOMAIN = "domain1.com";
+ private static final String ALIAS_DOMAIN = "domain2.com";
+ private static final String RECEIVER_AT_DESTINATION_DOMAIN = "user@domain1.com";
+ private static final String RECEIVER_AT_ALIAS_DOMAIN = "user@domain2.com";
+ private static final String SENDER_AT_DESTINATION_DOMAIN = "sender@domain1.com";
+
+ private AccessToken receiverAtDestinationDomainToken;
+ private AccessToken senderAtDestinationDomainToken;
+
+ protected abstract GuiceJamesServer createJmapServer() throws IOException;
+
+ protected abstract void await();
+
+ private GuiceJamesServer jmapServer;
+ private MailboxProbe mailboxProbe;
+ private DataProbe dataProbe;
+
+ @Before
+ public void setup() throws Throwable {
+ jmapServer = createJmapServer();
+ jmapServer.start();
+ mailboxProbe = jmapServer.getProbe(MailboxProbeImpl.class);
+ dataProbe = jmapServer.getProbe(DataProbeImpl.class);
+
+ RestAssured.requestSpecification = new RequestSpecBuilder()
+ .setContentType(ContentType.JSON)
+ .setAccept(ContentType.JSON)
+ .setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(StandardCharsets.UTF_8)))
+ .setPort(jmapServer.getProbe(JmapGuiceProbe.class).getJmapPort())
+ .build();
+ RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
+ RestAssured.defaultParser = Parser.JSON;
+
+ dataProbe.addDomain(DESTINATION_DOMAIN);
+ dataProbe.addDomain(ALIAS_DOMAIN);
+ dataProbe.addUser(RECEIVER_AT_DESTINATION_DOMAIN, PASSWORD);
+ dataProbe.addUser(SENDER_AT_DESTINATION_DOMAIN, PASSWORD);
+ receiverAtDestinationDomainToken = authenticateJamesUser(baseUri(jmapServer), RECEIVER_AT_DESTINATION_DOMAIN, PASSWORD);
+ senderAtDestinationDomainToken = authenticateJamesUser(baseUri(jmapServer), SENDER_AT_DESTINATION_DOMAIN, PASSWORD);
+ }
+
+ @After
+ public void teardown() {
+ jmapServer.stop();
+ }
+
+ @Test // MAILET-136
+ public void sendShouldReRouteMailToDestinationAddressWhenDomainAliasMapping() throws Exception {
+ dataProbe.addDomainAliasMapping(ALIAS_DOMAIN, DESTINATION_DOMAIN);
+
+ String messageContent = "content content";
+ String sendMessageBody =
+ "[" +
+ " [" +
+ " \"setMessages\"," +
+ " {" +
+ " \"create\": { \"creationId1337\" : {" +
+ " \"from\": { \"name\": \"Sender\", \"email\": \"" + SENDER_AT_DESTINATION_DOMAIN + "\"}," +
+ " \"to\": [{ \"name\": \"User\", \"email\": \"" + RECEIVER_AT_ALIAS_DOMAIN + "\"}]," +
+ " \"subject\": \"Thank you for joining example.com!\"," +
+ " \"textBody\": \"" + messageContent + "\"," +
+ " \"mailboxIds\": [\"" + getOutboxId(senderAtDestinationDomainToken) + "\"]" +
+ " }}" +
+ " }," +
+ " \"#0\"" +
+ " ]" +
+ "]";
+ given()
+ .header("Authorization", senderAtDestinationDomainToken.serialize())
+ .body(sendMessageBody)
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messagesSet"))
+ .body(ARGUMENTS + ".notCreated", aMapWithSize(0))
+ .body(ARGUMENTS + ".created", aMapWithSize(1));
+
+ calmlyAwait
+ .pollDelay(Duration.FIVE_HUNDRED_MILLISECONDS)
+ .atMost(30, TimeUnit.SECONDS)
+ .untilAsserted(() ->
+ assertThat(getLatestMessageId(receiverAtDestinationDomainToken, Role.INBOX))
+ .isNotNull());
+
+ String inboxMessageId = getLatestMessageId(receiverAtDestinationDomainToken, Role.INBOX);
+ assertThat(bodyOfMessage(receiverAtDestinationDomainToken, inboxMessageId))
+ .isEqualTo(messageContent);
+ }
+
+ @Test // MAILET-136
+ public void sendShouldNotCreateNewUserOrMailboxOfAliasAddressWhenDomainAliasMapping() throws Exception {
+ dataProbe.addDomainAliasMapping(ALIAS_DOMAIN, DESTINATION_DOMAIN);
+
+ String messageContent = "content content";
+ String sendMessageBody =
+ "[" +
+ " [" +
+ " \"setMessages\"," +
+ " {" +
+ " \"create\": { \"creationId1337\" : {" +
+ " \"from\": { \"name\": \"Sender\", \"email\": \"" + SENDER_AT_DESTINATION_DOMAIN + "\"}," +
+ " \"to\": [{ \"name\": \"User\", \"email\": \"" + RECEIVER_AT_ALIAS_DOMAIN + "\"}]," +
+ " \"subject\": \"Thank you for joining example.com!\"," +
+ " \"textBody\": \"" + messageContent + "\"," +
+ " \"mailboxIds\": [\"" + getOutboxId(senderAtDestinationDomainToken) + "\"]" +
+ " }}" +
+ " }," +
+ " \"#0\"" +
+ " ]" +
+ "]";
+ given()
+ .header("Authorization", senderAtDestinationDomainToken.serialize())
+ .body(sendMessageBody)
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messagesSet"))
+ .body(ARGUMENTS + ".notCreated", aMapWithSize(0))
+ .body(ARGUMENTS + ".created", aMapWithSize(1));
+
+ calmlyAwait
+ .pollDelay(Duration.FIVE_HUNDRED_MILLISECONDS)
+ .atMost(30, TimeUnit.SECONDS)
+ .untilAsserted(() ->
+ assertThat(getLatestMessageId(receiverAtDestinationDomainToken, Role.INBOX))
+ .isNotNull());
+
+ assertThat(dataProbe.listUsers())
+ .doesNotContain("user@domain2.com");
+ assertThat(mailboxProbe.listUserMailboxes("user@domain2.com"))
+ .isEmpty();
+ }
+
+
+ @Test // MAILET-136
+ public void sendShouldSaveToAsTheAliasAddressWhenDomainAliasMapping() throws Exception {
+ dataProbe.addDomainAliasMapping(ALIAS_DOMAIN, DESTINATION_DOMAIN);
+
+ String messageContent = "content content";
+ String sendMessageBody =
+ "[" +
+ " [" +
+ " \"setMessages\"," +
+ " {" +
+ " \"create\": { \"creationId1337\" : {" +
+ " \"from\": { \"name\": \"Sender\", \"email\": \"" + SENDER_AT_DESTINATION_DOMAIN + "\"}," +
+ " \"to\": [{ \"name\": \"User\", \"email\": \"" + RECEIVER_AT_ALIAS_DOMAIN + "\"}]," +
+ " \"subject\": \"Thank you for joining example.com!\"," +
+ " \"textBody\": \"" + messageContent + "\"," +
+ " \"mailboxIds\": [\"" + getOutboxId(senderAtDestinationDomainToken) + "\"]" +
+ " }}" +
+ " }," +
+ " \"#0\"" +
+ " ]" +
+ "]";
+ given()
+ .header("Authorization", senderAtDestinationDomainToken.serialize())
+ .body(sendMessageBody)
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .body(NAME, equalTo("messagesSet"))
+ .body(ARGUMENTS + ".notCreated", aMapWithSize(0))
+ .body(ARGUMENTS + ".created", aMapWithSize(1));
+
+ calmlyAwait
+ .pollDelay(Duration.FIVE_HUNDRED_MILLISECONDS)
+ .atMost(30, TimeUnit.SECONDS)
+ .untilAsserted(() ->
+ assertThat(getLatestMessageId(senderAtDestinationDomainToken, Role.SENT))
+ .isNotNull());
+
+ String sentMessageId = getLatestMessageId(senderAtDestinationDomainToken, Role.SENT);
+ assertThat(receiversOfMessage(senderAtDestinationDomainToken, sentMessageId))
+ .containsOnly(RECEIVER_AT_ALIAS_DOMAIN);
+ }
+}
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
index 03ad0b0..a58c3d0 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
@@ -2198,7 +2198,7 @@ public abstract class SetMessagesMethodTest {
" \"#0\"" +
" ]" +
"]";
-
+
given()
.header("Authorization", accessToken.serialize())
.body(copyDraftToOutBox)
@@ -2529,7 +2529,7 @@ public abstract class SetMessagesMethodTest {
String outboxId = getMailboxId(accessToken, Role.OUTBOX);
assertThat(hasNoMessageIn(bobAccessToken, outboxId)).isTrue();
}
-
+
private boolean hasNoMessageIn(AccessToken accessToken, String mailboxId) {
try {
with()
@@ -2544,7 +2544,7 @@ public abstract class SetMessagesMethodTest {
return true;
} catch (AssertionError e) {
return false;
- }
+ }
}
@Test
@@ -4388,7 +4388,7 @@ public abstract class SetMessagesMethodTest {
checkBlobContent(blobId, rawBytes);
}
-
+
@Test
public void setMessagesShouldVerifyHeaderOfMessageInInbox() throws Exception {
String toUsername = "username1@" + DOMAIN;
@@ -4702,7 +4702,7 @@ public abstract class SetMessagesMethodTest {
@Test
public void setMessagesShouldUpdateIsAnsweredWhenInReplyToHeaderSentViaDraft() throws Exception {
OriginalMessage firstMessage = receiveFirstMessage();
-
+
String draftCreationId = "creationId1337";
String createDraft = "[" +
" [" +
@@ -4770,7 +4770,7 @@ public abstract class SetMessagesMethodTest {
@Test
public void setMessagesShouldUpdateIsForwardedWhenXForwardedHeaderSentViaDraft() throws Exception {
OriginalMessage firstMessage = receiveFirstMessage();
-
+
String draftCreationId = "creationId1337";
String createDraft = "[" +
" [" +
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemorySetMessagesMethodReRoutingTest.java b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemorySetMessagesMethodReRoutingTest.java
new file mode 100644
index 0000000..e30e4c7
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemorySetMessagesMethodReRoutingTest.java
@@ -0,0 +1,42 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.jmap.memory;
+
+import java.io.IOException;
+
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.MemoryJmapTestRule;
+import org.apache.james.jmap.methods.integration.SetMessagesMethodReRoutingTest;
+import org.junit.Rule;
+
+public class MemorySetMessagesMethodReRoutingTest extends SetMessagesMethodReRoutingTest {
+
+ @Rule
+ public MemoryJmapTestRule memoryJmap = new MemoryJmapTestRule();
+
+ @Override
+ protected GuiceJamesServer createJmapServer() throws IOException {
+ return memoryJmap.jmapServer();
+ }
+
+ @Override
+ protected void await() {
+ }
+}
diff --git a/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/RabbitMQAwsS3SetMessagesMethodReRoutingTest.java b/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/RabbitMQAwsS3SetMessagesMethodReRoutingTest.java
new file mode 100644
index 0000000..12da9b1
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/RabbitMQAwsS3SetMessagesMethodReRoutingTest.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.jmap.rabbitmq;
+
+import java.io.IOException;
+
+import org.apache.james.CassandraRabbitMQAwsS3JmapTestRule;
+import org.apache.james.DockerCassandraRule;
+import org.apache.james.GuiceJamesServer;
+import org.apache.james.jmap.methods.integration.SetMessagesMethodReRoutingTest;
+import org.junit.Rule;
+
+public class RabbitMQAwsS3SetMessagesMethodReRoutingTest extends SetMessagesMethodReRoutingTest {
+
+ @Rule
+ public DockerCassandraRule cassandra = new DockerCassandraRule();
+
+ @Rule
+ public CassandraRabbitMQAwsS3JmapTestRule rule = CassandraRabbitMQAwsS3JmapTestRule.defaultTestRule();
+
+ @Override
+ protected GuiceJamesServer createJmapServer() throws IOException {
+ return rule.jmapServer(cassandra.getModule());
+ }
+
+ @Override
+ protected void await() {
+ rule.await();
+ }
+}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org