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 ad...@apache.org on 2017/01/26 12:53:05 UTC

[11/13] james-project git commit: JAMES-1869 Integration testing with Cassandra should be error with long mailbox name

JAMES-1869 Integration testing with Cassandra should be error with long mailbox name


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

Branch: refs/heads/master
Commit: 49361c215f74114cb73afb36d3453ec5ad4ca359
Parents: d4fb7f8
Author: Quynh Nguyen <qn...@linagora.com>
Authored: Tue Jan 24 13:44:58 2017 +0700
Committer: Antoine Duprat <ad...@linagora.com>
Committed: Thu Jan 26 13:00:54 2017 +0100

----------------------------------------------------------------------
 .../CassandraSetMailboxesMethodTest.java        |  11 ++
 .../integration/SetMailboxesMethodTest.java     | 193 ++++++++++++-------
 2 files changed, 138 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/49361c21/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMailboxesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMailboxesMethodTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMailboxesMethodTest.java
index 02e5333..7aea5d8 100644
--- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMailboxesMethodTest.java
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraSetMailboxesMethodTest.java
@@ -22,6 +22,7 @@ package org.apache.james.jmap.cassandra;
 import org.apache.james.CassandraJmapTestRule;
 import org.apache.james.JmapJamesServer;
 import org.apache.james.jmap.methods.integration.SetMailboxesMethodTest;
+import org.junit.Ignore;
 import org.junit.Rule;
 
 public class CassandraSetMailboxesMethodTest extends SetMailboxesMethodTest {
@@ -38,4 +39,14 @@ public class CassandraSetMailboxesMethodTest extends SetMailboxesMethodTest {
     protected void await() {
         rule.await();
     }
+
+    @Ignore
+    @Override
+    public void setMailboxesShouldCreateWhenOverLimitName() throws Exception {
+    }
+
+    @Ignore
+    @Override
+    public void setMailboxesShouldUpdateMailboxWhenOverLimitName() throws Exception {
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/49361c21/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java
index 426ce55..dc543f5 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java
@@ -59,6 +59,7 @@ public abstract class SetMailboxesMethodTest {
     private static final String NAME = "[0][0]";
     private static final String ARGUMENTS = "[0][1]";
     private static final String USERS_DOMAIN = "domain.tld";
+    private static int MAILBOX_NAME_LENGTH_64K = 65536;
 
     protected abstract JmapJamesServer createJmapServer();
 
@@ -98,6 +99,132 @@ public abstract class SetMailboxesMethodTest {
     }
 
     @Test
+    public void setMailboxesShouldNotCreateWhenOverLimitName() {
+        String overLimitName = StringUtils.repeat("a", MAILBOX_NAME_LENGTH_64K);
+        String requestBody =
+            "[" +
+                "  [ \"setMailboxes\"," +
+                "    {" +
+                "      \"create\": {" +
+                "        \"create-id01\" : {" +
+                "          \"name\" : \"" + overLimitName + "\"" +
+                "        }" +
+                "      }" +
+                "    }," +
+                "    \"#0\"" +
+                "  ]" +
+                "]";
+
+        given()
+            .header("Authorization", this.accessToken.serialize())
+            .body(requestBody)
+            .when()
+            .post("/jmap")
+            .then()
+            .statusCode(200)
+            .body(NAME, equalTo("mailboxesSet"))
+            .body(ARGUMENTS + ".notCreated", aMapWithSize(1))
+            .body(ARGUMENTS + ".notCreated", hasEntry(equalTo("create-id01"), Matchers.allOf(
+                    hasEntry(equalTo("type"), equalTo("invalidArguments")),
+                    hasEntry(equalTo("description"), equalTo("The mailbox name length is too long")))
+            ));
+    }
+
+    @Test
+    public void setMailboxesShouldNotUpdateMailboxWhenOverLimitName() {
+        String overLimitName = StringUtils.repeat("a", MAILBOX_NAME_LENGTH_64K);
+        jmapServer.serverProbe().createMailbox("#private", username, "myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox");
+        String mailboxId = mailbox.getMailboxId().serialize();
+        String requestBody =
+            "[" +
+                "  [ \"setMailboxes\"," +
+                "    {" +
+                "      \"update\": {" +
+                "        \"" + mailboxId + "\" : {" +
+                "          \"name\" : \"" + overLimitName + "\"" +
+                "        }" +
+                "      }" +
+                "    }," +
+                "    \"#0\"" +
+                "  ]" +
+                "]";
+        given()
+            .header("Authorization", this.accessToken.serialize())
+            .body(requestBody)
+            .when()
+            .post("/jmap")
+            .then()
+            .statusCode(200)
+            .body(NAME, equalTo("mailboxesSet"))
+            .body(ARGUMENTS + ".notUpdated", aMapWithSize(1))
+            .body(ARGUMENTS + ".notUpdated", hasEntry(equalTo(mailboxId), Matchers.allOf(
+                    hasEntry(equalTo("type"), equalTo("invalidArguments")),
+                    hasEntry(equalTo("description"), equalTo("The mailbox name length is too long")))
+            ));
+    }
+
+    @Test
+    public void setMailboxesShouldCreateWhenOverLimitName() throws Exception {
+        String overLimitName = StringUtils.repeat("a", MAILBOX_NAME_LENGTH_64K);
+        String requestBody =
+            "[" +
+                "  [ \"setMailboxes\"," +
+                "    {" +
+                "      \"create\": {" +
+                "        \"create-id01\" : {" +
+                "          \"name\" : \"" + overLimitName + "\"" +
+                "        }" +
+                "      }" +
+                "    }," +
+                "    \"#0\"" +
+                "  ]" +
+                "]";
+
+        given()
+            .header("Authorization", this.accessToken.serialize())
+            .body(requestBody)
+            .when()
+            .post("/jmap")
+            .then()
+            .statusCode(200)
+            .body(NAME, equalTo("mailboxesSet"))
+            .body(ARGUMENTS + ".created", hasKey("create-id01"));
+    }
+
+    @Test
+    public void setMailboxesShouldUpdateMailboxWhenOverLimitName() throws Exception {
+        String overLimitName = StringUtils.repeat("a", MAILBOX_NAME_LENGTH_64K);
+        jmapServer.serverProbe().createMailbox("#private", username, "myBox");
+        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox");
+        String mailboxId = mailbox.getMailboxId().serialize();
+        String requestBody =
+            "[" +
+                "  [ \"setMailboxes\"," +
+                "    {" +
+                "      \"update\": {" +
+                "        \"" + mailboxId + "\" : {" +
+                "          \"name\" : \"" + overLimitName + "\"" +
+                "        }" +
+                "      }" +
+                "    }," +
+                "    \"#0\"" +
+                "  ]" +
+                "]";
+        given()
+            .header("Authorization", this.accessToken.serialize())
+            .body(requestBody)
+            .when()
+            .post("/jmap")
+            .then()
+            .statusCode(200)
+            .body(NAME, equalTo("mailboxesSet"))
+            .body(ARGUMENTS + ".updated", contains(mailboxId));
+
+        assertThat(jmapServer.serverProbe().listSubscriptions(username)).containsOnly(overLimitName);
+    }
+
+    @Test
     public void userShouldBeSubscribedOnCreatedMailboxWhenCreateMailbox() throws Exception{
         String requestBody =
             "[" +
@@ -318,72 +445,6 @@ public abstract class SetMailboxesMethodTest {
     }
 
     @Test
-    public void setMailboxesShouldNotCreateWhenOverLimitName() {
-        String overLimitName = StringUtils.repeat("a", MailboxConstants.DEFAULT_LIMIT_MAILBOX_NAME_LENGTH);
-        String requestBody =
-            "[" +
-                "  [ \"setMailboxes\"," +
-                "    {" +
-                "      \"create\": {" +
-                "        \"create-id01\" : {" +
-                "          \"name\" : \"" + overLimitName + "\"" +
-                "        }" +
-                "      }" +
-                "    }," +
-                "    \"#0\"" +
-                "  ]" +
-                "]";
-
-        given()
-            .header("Authorization", this.accessToken.serialize())
-            .body(requestBody)
-        .when()
-            .post("/jmap")
-        .then()
-            .statusCode(200)
-            .body(NAME, equalTo("mailboxesSet"))
-            .body(ARGUMENTS + ".notCreated", aMapWithSize(1))
-            .body(ARGUMENTS + ".notCreated", hasEntry(equalTo("create-id01"), Matchers.allOf(
-                    hasEntry(equalTo("type"), equalTo("invalidArguments")),
-                    hasEntry(equalTo("description"), equalTo("The mailbox name length '" + overLimitName + "' is over limitation: " + MailboxConstants.DEFAULT_LIMIT_MAILBOX_NAME_LENGTH)))
-            ));
-    }
-
-    @Test
-    public void setMailboxesShouldNotUpdateMailboxWhenOverLimitName() {
-        String overLimitName = StringUtils.repeat("a", MailboxConstants.DEFAULT_LIMIT_MAILBOX_NAME_LENGTH);
-        jmapServer.serverProbe().createMailbox("#private", username, "myBox");
-        Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox");
-        String mailboxId = mailbox.getMailboxId().serialize();
-        String requestBody =
-            "[" +
-                "  [ \"setMailboxes\"," +
-                "    {" +
-                "      \"update\": {" +
-                "        \"" + mailboxId + "\" : {" +
-                "          \"name\" : \"" + overLimitName + "\"" +
-                "        }" +
-                "      }" +
-                "    }," +
-                "    \"#0\"" +
-                "  ]" +
-                "]";
-        given()
-            .header("Authorization", this.accessToken.serialize())
-            .body(requestBody)
-        .when()
-            .post("/jmap")
-        .then()
-            .statusCode(200)
-            .body(NAME, equalTo("mailboxesSet"))
-            .body(ARGUMENTS + ".notUpdated", aMapWithSize(1))
-            .body(ARGUMENTS + ".notUpdated", hasEntry(equalTo(mailboxId), Matchers.allOf(
-                    hasEntry(equalTo("type"), equalTo("invalidArguments")),
-                    hasEntry(equalTo("description"), equalTo("The mailbox name length '" + overLimitName + "' is over limitation: " + MailboxConstants.DEFAULT_LIMIT_MAILBOX_NAME_LENGTH)))
-            ));
-    }
-
-    @Test
     public void setMailboxesShouldErrorNotSupportedWhenRoleGiven() {
         String requestBody =
             "[" +


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