diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java index 9c07f86b32e..bbe3df11e69 100644 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java @@ -273,6 +273,7 @@ void hasInboxShouldBeTrueWhenINBOXIsCreated() throws Exception { @Test void shareeShouldBeAbleToCreateMailbox() throws Exception { + assumeTrue(mailboxManager.hasCapability(MailboxCapabilities.ACL)); session = mailboxManager.createSystemSession(USER_1); MailboxPath mailboxPath = MailboxPath.inbox(session); mailboxManager.createMailbox(mailboxPath, session); @@ -294,6 +295,7 @@ void shareeShouldBeAbleToCreateMailbox() throws Exception { @Test void shareeShouldBeAbleToCreateMailboxChildren() throws Exception { + assumeTrue(mailboxManager.hasCapability(MailboxCapabilities.ACL)); session = mailboxManager.createSystemSession(USER_1); MailboxPath mailboxPath = MailboxPath.inbox(session); mailboxManager.createMailbox(mailboxPath, session); @@ -317,6 +319,7 @@ void shareeShouldBeAbleToCreateMailboxChildren() throws Exception { @Test void shareeShouldBeAbleToCreateMailboxChildrenIntermediatePaths() throws Exception { + assumeTrue(mailboxManager.hasCapability(MailboxCapabilities.ACL)); session = mailboxManager.createSystemSession(USER_1); MailboxPath mailboxPath = MailboxPath.inbox(session); mailboxManager.createMailbox(mailboxPath, session); @@ -340,6 +343,7 @@ void shareeShouldBeAbleToCreateMailboxChildrenIntermediatePaths() throws Excepti @Test void shareeShouldBeAbleToDeleteMailbox() throws Exception { + assumeTrue(mailboxManager.hasCapability(MailboxCapabilities.ACL)); session = mailboxManager.createSystemSession(USER_1); MailboxPath mailboxPath = MailboxPath.forUser(USER_1, "child"); mailboxManager.createMailbox(mailboxPath, session); 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 5e9a9c3455d..8c36e10f0ea 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 @@ -2116,7 +2116,7 @@ trait MailboxSetMethodContract { val mailboxId: MailboxId = server.getProbe(classOf[MailboxProbeImpl]).createMailbox(path) server.getProbe(classOf[ACLProbeImpl]) - .replaceRights(path, BOB.asString, new MailboxACL.Rfc4314Rights(Right.Lookup, Right.Read, Right.CreateMailbox)) + .replaceRights(path, BOB.asString, new MailboxACL.Rfc4314Rights(Right.Lookup, Right.Read)) val request = s""" |{ @@ -2173,6 +2173,84 @@ trait MailboxSetMethodContract { |}""".stripMargin) } + @Test + def mailboxSetShouldCreateChildMailboxWhenSharedParentMailboxWithCreateRight(server: GuiceJamesServer): Unit = { + val path = MailboxPath.forUser(ANDRE, "mailbox") + val mailboxId: MailboxId = server.getProbe(classOf[MailboxProbeImpl]).createMailbox(path) + + server.getProbe(classOf[ACLProbeImpl]) + .replaceRights(path, BOB.asString, new MailboxACL.Rfc4314Rights(Right.Lookup, Right.Read, Right.CreateMailbox)) + val request = + s""" + |{ + | "using": [ "urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail" ], + | "methodCalls": [ + | [ + | "Mailbox/set", + | { + | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6", + | "create": { + | "C42": { + | "name": "childMailbox", + | "parentId":"${mailboxId.serialize}" + | } + | } + | }, + | "c1" + | ] + | ] + |} + |""".stripMargin + + val response = `given` + .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER) + .body(request) + .when + .post + .`then` + .log().ifValidationFails() + .statusCode(SC_OK) + .contentType(JSON) + .extract + .body + .asString + + assertThatJson(response) + .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState") + .isEqualTo( + s"""{ + | "sessionState": "${SESSION_STATE.value}", + | "methodResponses": [[ + | "Mailbox/set", + | { + | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6", + | "created":{ + | "C42":{ + | "id":"3", + | "isSubscribed":true, + | "myRights":{ + | "mayAddItems":true, + | "mayCreateChild":true, + | "mayDelete":true, + | "mayReadItems":true, + | "mayRemoveItems":true, + | "mayRename":true, + | "maySetKeywords":true, + | "maySetSeen":true, + | "maySubmit":true + | }, + | "sortOrder":1000, + | "totalEmails":0, + | "totalThreads":0, + | "unreadEmails":0, + | "unreadThreads":0 + | } + | } + | }, + | "c1"]] + |}""".stripMargin) + } + @Test @Tag(CategoryTags.BASIC_FEATURE) def deleteShouldSucceedWhenMailboxExists(server: GuiceJamesServer): Unit = {