You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2020/08/27 02:24:37 UTC
[james-project] 05/14: JAMES-3359 Mailbox/set updates parentId:
test delegation behaviour
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 6c75d5249e320f56c240b7392853d80ec4d5c16b
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Thu Aug 20 14:21:55 2020 +0700
JAMES-3359 Mailbox/set updates parentId: test delegation behaviour
---
.../contract/MailboxSetMethodContract.scala | 189 ++++++++++++++++++++-
1 file changed, 187 insertions(+), 2 deletions(-)
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 25760d5..e388765 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
@@ -6616,8 +6616,6 @@ trait MailboxSetMethodContract {
.body
.asString
- println(response)
-
assertThatJson(response).isEqualTo(
s"""{
| "sessionState": "75128aab4b1b",
@@ -6636,4 +6634,191 @@ trait MailboxSetMethodContract {
| ]
|}""".stripMargin)
}
+
+ @Test
+ def updateShouldFailWhenRenamingParentIdWithinADelegatedAccount(server: GuiceJamesServer): Unit = {
+ val mailboxProbe = server.getProbe(classOf[MailboxProbeImpl])
+ val path = MailboxPath.forUser(ANDRE, "mailbox")
+ val mailboxId: MailboxId = mailboxProbe.createMailbox(path)
+ val parentPath = MailboxPath.forUser(ANDRE, "parent")
+ val parentId = mailboxProbe.createMailbox(parentPath)
+
+ val aCLProbeImpl = server.getProbe(classOf[ACLProbeImpl])
+ aCLProbeImpl.replaceRights(path, BOB.asString, MailboxACL.FULL_RIGHTS)
+ aCLProbeImpl.replaceRights(parentPath, BOB.asString, MailboxACL.FULL_RIGHTS)
+
+ val request = s"""
+ |{
+ | "using": [ "urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail" ],
+ | "methodCalls": [
+ | [
+ | "Mailbox/set",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "update": {
+ | "${mailboxId.serialize()}": {
+ | "/parentId": "${parentId.serialize()}"
+ | }
+ | }
+ | },
+ | "c2"
+ | ]
+ | ]
+ |}
+ |""".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).isEqualTo(
+ s"""{
+ | "sessionState": "75128aab4b1b",
+ | "methodResponses": [
+ | ["Mailbox/set", {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "newState": "000001",
+ | "notUpdated": {
+ | "${mailboxId.serialize()}": {
+ | "type": "notFound",
+ | "description": "#private:andre@domain.tld:parent.mailbox"
+ | }
+ | }
+ | }, "c2"]
+ | ]
+ |}""".stripMargin)
+ }
+
+ @Test
+ def updateShouldFailWhenRenamingParentIdFromADelegatedAccount(server: GuiceJamesServer): Unit = {
+ val mailboxProbe = server.getProbe(classOf[MailboxProbeImpl])
+ val path = MailboxPath.forUser(ANDRE, "mailbox")
+ val mailboxId: MailboxId = mailboxProbe.createMailbox(path)
+ val parentPath = MailboxPath.forUser(BOB, "parent")
+ val parentId = mailboxProbe.createMailbox(parentPath)
+
+ val aCLProbeImpl = server.getProbe(classOf[ACLProbeImpl])
+ aCLProbeImpl.replaceRights(path, BOB.asString, MailboxACL.FULL_RIGHTS)
+
+ val request = s"""
+ |{
+ | "using": [ "urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail" ],
+ | "methodCalls": [
+ | [
+ | "Mailbox/set",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "update": {
+ | "${mailboxId.serialize()}": {
+ | "/parentId": "${parentId.serialize()}"
+ | }
+ | }
+ | },
+ | "c2"
+ | ]
+ | ]
+ |}
+ |""".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).isEqualTo(
+ s"""{
+ | "sessionState": "75128aab4b1b",
+ | "methodResponses": [
+ | ["Mailbox/set", {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "newState": "000001",
+ | "notUpdated": {
+ | "${mailboxId.serialize()}": {
+ | "type": "notFound",
+ | "description": "#private:andre@domain.tld:mailbox"
+ | }
+ | }
+ | }, "c2"]
+ | ]
+ |}""".stripMargin)
+ }
+
+ @Test
+ def updateShouldFailWhenRenamingParentIdToADelegatedAccount(server: GuiceJamesServer): Unit = {
+ val mailboxProbe = server.getProbe(classOf[MailboxProbeImpl])
+ val path = MailboxPath.forUser(BOB, "mailbox")
+ val mailboxId: MailboxId = mailboxProbe.createMailbox(path)
+ val parentPath = MailboxPath.forUser(ANDRE, "parent")
+ val parentId = mailboxProbe.createMailbox(parentPath)
+
+ val aCLProbeImpl = server.getProbe(classOf[ACLProbeImpl])
+ aCLProbeImpl.replaceRights(parentPath, BOB.asString, MailboxACL.FULL_RIGHTS)
+
+ val request = s"""
+ |{
+ | "using": [ "urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail" ],
+ | "methodCalls": [
+ | [
+ | "Mailbox/set",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "update": {
+ | "${mailboxId.serialize()}": {
+ | "/parentId": "${parentId.serialize()}"
+ | }
+ | }
+ | },
+ | "c2"
+ | ]
+ | ]
+ |}
+ |""".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).isEqualTo(
+ s"""{
+ | "sessionState": "75128aab4b1b",
+ | "methodResponses": [
+ | ["Mailbox/set", {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "newState": "000001",
+ | "notUpdated": {
+ | "${mailboxId.serialize()}": {
+ | "type": "notFound",
+ | "description": "#private:andre@domain.tld:parent.mailbox"
+ | }
+ | }
+ | }, "c2"]
+ | ]
+ |}""".stripMargin)
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org