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 409f94c76b2e7f41cb9e66d702ff85a7e24f52dc
Author: RĂ©mi Kowalski <[email protected]>
AuthorDate: Wed Sep 23 11:12:17 2020 +0200

    JAMES-3386 add test to ensure blank mailbox paths are not allowed in jmap 
draft
---
 .../integration/SetMailboxesMethodTest.java        | 61 ++++++++++++++++++++++
 .../contract/MailboxSetMethodContract.scala        |  8 +--
 2 files changed, 65 insertions(+), 4 deletions(-)

diff --git 
a/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/src/test/java/org/apache/james/jmap/draft/methods/integration/SetMailboxesMethodTest.java
 
b/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/src/test/java/org/apache/james/jmap/draft/methods/integration/SetMailboxesMethodTest.java
index b2d0de0..ca325a9 100644
--- 
a/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/src/test/java/org/apache/james/jmap/draft/methods/integration/SetMailboxesMethodTest.java
+++ 
b/server/protocols/jmap-draft-integration-testing/jmap-draft-integration-testing-common/src/test/java/org/apache/james/jmap/draft/methods/integration/SetMailboxesMethodTest.java
@@ -215,6 +215,36 @@ public abstract class SetMailboxesMethodTest {
     }
 
     @Test
+    public void setMailboxesCreateShouldFailWhenBlankName() {
+        String creationId = "create-id01";
+        String requestBody =
+            "[" +
+                "  [ \"setMailboxes\"," +
+                "    {" +
+                "      \"create\": {" +
+                "        \"" + creationId + "\" : {" +
+                "          \"name\" : \"        \"" +
+                "        }" +
+                "      }" +
+                "    }," +
+                "    \"#0\"" +
+                "  ]" +
+                "]";
+
+        given()
+            .header("Authorization", accessToken.asString())
+            .body(requestBody)
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("mailboxesSet"))
+            .body(ARGUMENTS + ".notCreated", hasKey(creationId))
+            .body(ARGUMENTS + ".notCreated." + creationId + ".type", 
is("invalidArguments"))
+            .body(ARGUMENTS + ".notCreated." + creationId + ".description", 
is("'#private:[email protected]:        ' has an empty part within its 
mailbox name considering . as a delimiter"));
+    }
+
+    @Test
     public void setMailboxesUpdateShouldFailWhenOverLimitName() throws 
Exception {
         String overLimitName = StringUtils.repeat("a", 
MailboxManager.MAX_MAILBOX_NAME_LENGTH + 1);
         MailboxId mailboxId = 
mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, 
username.asString(), "myBox");
@@ -246,6 +276,37 @@ public abstract class SetMailboxesMethodTest {
         
assertThat(mailboxProbe.listSubscriptions(username.asString())).doesNotContain(overLimitName);
     }
 
+    @Test
+    public void setMailboxesUpdateShouldFailWhenBlankName() throws Exception {
+        MailboxId mailboxId = 
mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, 
username.asString(), "myBox");
+        String requestBody =
+            "[" +
+                "  [ \"setMailboxes\"," +
+                "    {" +
+                "      \"update\": {" +
+                "        \"" + mailboxId.serialize() + "\" : {" +
+                "          \"name\" : \"    \"" +
+                "        }" +
+                "      }" +
+                "    }," +
+                "    \"#0\"" +
+                "  ]" +
+                "]";
+        given()
+            .header("Authorization", accessToken.asString())
+            .body(requestBody)
+        .when()
+            .post("/jmap")
+        .then()
+            .statusCode(200)
+            .body(NAME, equalTo("mailboxesSet"))
+            .body(ARGUMENTS + ".notUpdated", hasKey(mailboxId.serialize()))
+            .body(ARGUMENTS + ".notUpdated." + mailboxId.serialize() + 
".type", is("invalidArguments"))
+            .body(ARGUMENTS + ".notUpdated." + mailboxId.serialize() + 
".description", is("'#private:[email protected]:    ' has an empty part 
within its mailbox name considering . as a delimiter"));
+
+        
assertThat(mailboxProbe.listSubscriptions(username.asString())).doesNotContain("
    ");
+    }
+
     @Category(BasicFeature.class)
     @Test
     public void userShouldBeSubscribedOnCreatedMailboxWhenCreateMailbox() 
throws Exception {
diff --git 
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala
 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala
index dca59bd..4434d3f 100644
--- 
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala
+++ 
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala
@@ -738,9 +738,9 @@ trait MailboxSetMethodContract {
       `given`
         .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
         .body(request)
-        .when
+      .when
         .post
-        .`then`
+      .`then`
         .log().ifValidationFails()
         .statusCode(SC_OK)
         .contentType(JSON)
@@ -794,9 +794,9 @@ trait MailboxSetMethodContract {
       `given`
         .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
         .body(request)
-        .when
+      .when
         .post
-        .`then`
+      .`then`
         .log().ifValidationFails()
         .statusCode(SC_OK)
         .contentType(JSON)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to