JAMES-2366 Add some recursive forward tests

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

Branch: refs/heads/master
Commit: 9fe1d268de03fe922dbb5ebb8e305e02a9e2cdcf
Parents: ed5b9f8
Author: benwa <btell...@linagora.com>
Authored: Mon Apr 16 15:58:31 2018 +0700
Committer: Matthieu Baechler <matth...@apache.org>
Committed: Tue Apr 24 14:45:26 2018 +0200

----------------------------------------------------------------------
 .../integration/ForwardIntegrationTest.java     | 98 ++++++++++++++++++++
 1 file changed, 98 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/9fe1d268/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/ForwardIntegrationTest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/ForwardIntegrationTest.java
 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/ForwardIntegrationTest.java
index 71d8d3e..e6bdee2 100644
--- 
a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/ForwardIntegrationTest.java
+++ 
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/ForwardIntegrationTest.java
@@ -46,10 +46,12 @@ import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.probe.DataProbe;
 import org.apache.james.utils.DataProbeImpl;
 import org.apache.james.utils.JmapGuiceProbe;
+import org.apache.james.utils.SMTPMessageSender;
 import org.apache.james.utils.WebAdminGuiceProbe;
 import org.apache.james.webadmin.WebAdminUtils;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
 
 import com.jayway.restassured.RestAssured;
@@ -57,6 +59,9 @@ import 
com.jayway.restassured.specification.RequestSpecification;
 
 public abstract class ForwardIntegrationTest {
 
+    @Rule
+    public SMTPMessageSender messageSender = new SMTPMessageSender(DOMAIN);
+
     protected abstract GuiceJamesServer createJmapServer();
 
     private GuiceJamesServer jmapServer;
@@ -192,6 +197,99 @@ public abstract class ForwardIntegrationTest {
     }
 
     @Test
+    public void recursiveForwardShouldWork() {
+        webAdminApi.put(String.format("/address/forwards/%s/targets/%s", 
ALICE, CEDRIC));
+        webAdminApi.put(String.format("/address/forwards/%s/targets/%s", 
CEDRIC, BOB));
+
+        AccessToken cedricAccessToken = 
authenticateJamesUser(baseUri(jmapServer), CEDRIC, CEDRIC_PASSWORD);
+        String messageCreationId = "creationId1337";
+        String requestBody = "[" +
+            "  [" +
+            "    \"setMessages\"," +
+            "    {" +
+            "      \"create\": { \"" + messageCreationId  + "\" : {" +
+            "        \"from\": { \"name\": \"Me\", \"email\": \"" + CEDRIC + 
"\"}," +
+            "        \"to\": [{ \"name\": \"Alice\", \"email\": \"" + ALICE + 
"\"}]," +
+            "        \"subject\": \"subject\"," +
+            "        \"isUnread\": true," +
+            "        \"isFlagged\": true," +
+            "        \"isAnswered\": true," +
+            "        \"isDraft\": true," +
+            "        \"isForwarded\": true," +
+            "        \"mailboxIds\": [\"" + getOutboxId(cedricAccessToken) + 
"\"]" +
+            "      }}" +
+            "    }," +
+            "    \"#0\"" +
+            "  ]" +
+            "]";
+
+        with()
+            .header("Authorization", cedricAccessToken.serialize())
+            .body(requestBody)
+        .post("/jmap");
+
+        AccessToken bobAccessToken = 
authenticateJamesUser(baseUri(jmapServer), BOB, BOB_PASSWORD);
+        calmlyAwait.atMost(30, TimeUnit.SECONDS).until(() -> 
isAnyMessageFoundInRecipientsMailboxes(bobAccessToken));
+        given()
+            .header("Authorization", bobAccessToken.serialize())
+            .body("[[\"getMessageList\", {}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .log().ifValidationFails()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", hasSize(1));
+    }
+
+    @Test
+    public void recursiveWithRecipientCopyForwardShouldWork() {
+        webAdminApi.put(String.format("/address/forwards/%s/targets/%s", 
ALICE, ALICE));
+        webAdminApi.put(String.format("/address/forwards/%s/targets/%s", 
ALICE, BOB));
+        webAdminApi.put(String.format("/address/forwards/%s/targets/%s", BOB, 
CEDRIC));
+
+        AccessToken cedricAccessToken = 
authenticateJamesUser(baseUri(jmapServer), CEDRIC, CEDRIC_PASSWORD);
+        AccessToken aliceAccessToken = 
authenticateJamesUser(baseUri(jmapServer), ALICE, ALICE_PASSWORD);
+        String messageCreationId = "creationId1337";
+        String requestBody = "[" +
+            "  [" +
+            "    \"setMessages\"," +
+            "    {" +
+            "      \"create\": { \"" + messageCreationId  + "\" : {" +
+            "        \"from\": { \"name\": \"Me\", \"email\": \"" + CEDRIC + 
"\"}," +
+            "        \"to\": [{ \"name\": \"Alice\", \"email\": \"" + ALICE + 
"\"}]," +
+            "        \"subject\": \"subject\"," +
+            "        \"isUnread\": true," +
+            "        \"isFlagged\": true," +
+            "        \"isAnswered\": true," +
+            "        \"isDraft\": true," +
+            "        \"isForwarded\": true," +
+            "        \"mailboxIds\": [\"" + getOutboxId(cedricAccessToken) + 
"\"]" +
+            "      }}" +
+            "    }," +
+            "    \"#0\"" +
+            "  ]" +
+            "]";
+
+        with()
+            .header("Authorization", cedricAccessToken.serialize())
+            .body(requestBody)
+        .post("/jmap");
+
+        calmlyAwait.atMost(30, TimeUnit.SECONDS).until(() -> 
isAnyMessageFoundInRecipientsMailboxes(aliceAccessToken));
+        given()
+            .header("Authorization", aliceAccessToken.serialize())
+            .body("[[\"getMessageList\", {}, \"#0\"]]")
+        .when()
+            .post("/jmap")
+        .then()
+            .log().ifValidationFails()
+            .statusCode(200)
+            .body(NAME, equalTo("messageList"))
+            .body(ARGUMENTS + ".messageIds", hasSize(1));
+    }
+
+    @Test
     public void baseRecipientShouldNotReceiveEmailOnDefaultForward() {
         webAdminApi.put(String.format("/address/forwards/%s/targets/%s", 
ALICE, BOB));
 


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to