This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
The following commit(s) were added to refs/heads/master by this push:
new 114e3ca588 [FIX] Shared mailbox revocation rights should be visible in
Mailbox/C… (#1495)
114e3ca588 is described below
commit 114e3ca58812f103d5e1a8747b436b9c7ef22575
Author: Rene Cordier <[email protected]>
AuthorDate: Wed Mar 22 14:18:38 2023 +0700
[FIX] Shared mailbox revocation rights should be visible in Mailbox/C…
(#1495)
---
.../james/jmap/api/change/MailboxChange.java | 16 ++-
.../contract/MailboxChangesMethodContract.scala | 139 +++++++++++++++++++++
2 files changed, 154 insertions(+), 1 deletion(-)
diff --git
a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/change/MailboxChange.java
b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/change/MailboxChange.java
index 231dfd98e7..57971dba33 100644
---
a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/change/MailboxChange.java
+++
b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/change/MailboxChange.java
@@ -198,7 +198,21 @@ public class MailboxChange implements JmapChange {
.delegated()
.build());
- return Stream.concat(Stream.of(ownerChange), shareeChanges)
+ Stream<MailboxChange> deletionChanges =
mailboxACLUpdated.getAclDiff()
+ .removedEntries()
+ .filter(entry ->
entry.getKey().getNameType().equals(MailboxACL.NameType.user))
+ .filter(entry -> !entry.getKey().isNegative())
+ .map(entry -> MailboxChange.builder()
+ .accountId(AccountId.fromString(entry.getKey().getName()))
+ .state(stateFactory.generate())
+ .date(now)
+ .isCountChange(false)
+
.updated(ImmutableList.of(mailboxACLUpdated.getMailboxId()))
+ .delegated()
+ .build());
+
+ return Stream.of(Stream.of(ownerChange), shareeChanges,
deletionChanges)
+ .flatMap(e -> e)
.collect(ImmutableList.toImmutableList());
}
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/MailboxChangesMethodContract.scala
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxChangesMethodContract.scala
index bec088808e..6989bff938 100644
---
a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxChangesMethodContract.scala
+++
b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxChangesMethodContract.scala
@@ -1445,6 +1445,145 @@ trait MailboxChangesMethodContract {
}
}
+ @Test
+ def
mailboxChangesShouldReturnUpdatedChangeWhenOwnerRevokingMailboxShareeRights(server:
GuiceJamesServer): Unit = {
+ val accountId: AccountId = AccountId.fromUsername(BOB)
+ val mailboxProbe: MailboxProbeImpl =
server.getProbe(classOf[MailboxProbeImpl])
+ val provisioningState: State = provisionSystemMailboxes(server)
+
+ val path = MailboxPath.forUser(BOB, "mailbox1")
+ val mailboxId: String = mailboxProbe
+ .createMailbox(path)
+ .serialize
+
+ server.getProbe(classOf[ACLProbeImpl])
+ .replaceRights(path, ANDRE.asString, new
MailboxACL.Rfc4314Rights(Right.Lookup, Right.Read))
+
+ waitForNextState(server, accountId, provisioningState)
+ val oldStateAndre: State = waitForNextStateWithDelegation(server,
AccountId.fromUsername(ANDRE), State.INITIAL)
+
+ server.getProbe(classOf[ACLProbeImpl])
+ .replaceRights(path, ANDRE.asString, new MailboxACL.Rfc4314Rights())
+
+ val request =
+ s"""{
+ | "using": ["urn:ietf:params:jmap:core",
"urn:ietf:params:jmap:mail", "urn:apache:james:params:jmap:mail:shares"],
+ | "methodCalls": [[
+ | "Mailbox/changes",
+ | {
+ | "accountId": "$ANDRE_ACCOUNT_ID",
+ | "sinceState": "${oldStateAndre.getValue}"
+ | },
+ | "c1"]]
+ |}""".stripMargin
+
+ awaitAtMostTenSeconds.untilAsserted { () =>
+ val response = `given`(
+ baseRequestSpecBuilder(server)
+ .setAuth(authScheme(UserCredential(ANDRE, ANDRE_PASSWORD)))
+ .addHeader(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+ .setBody(request)
+ .build, new ResponseSpecBuilder().build)
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .contentType(JSON)
+ .extract
+ .body
+ .asString
+
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState")
+ .withOptions(new Options(IGNORING_ARRAY_ORDER))
+ .isEqualTo(
+ s"""{
+ | "sessionState": "${SESSION_STATE.value}",
+ | "methodResponses": [
+ | [ "Mailbox/changes", {
+ | "accountId": "$ANDRE_ACCOUNT_ID",
+ | "oldState": "${oldStateAndre.getValue}",
+ | "hasMoreChanges": false,
+ | "updatedProperties": null,
+ | "created": [],
+ | "updated": ["$mailboxId"],
+ | "destroyed": []
+ | }, "c1"]
+ | ]
+ |}""".stripMargin)
+ }
+ }
+
+ @Test
+ def
mailboxChangesShouldReturnUpdatedChangeWhenOwnerRevokingThenReEnablingMailboxShareeRights(server:
GuiceJamesServer): Unit = {
+ val accountId: AccountId = AccountId.fromUsername(BOB)
+ val mailboxProbe: MailboxProbeImpl =
server.getProbe(classOf[MailboxProbeImpl])
+ val provisioningState: State = provisionSystemMailboxes(server)
+
+ val path = MailboxPath.forUser(BOB, "mailbox1")
+ val mailboxId: String = mailboxProbe
+ .createMailbox(path)
+ .serialize
+
+ server.getProbe(classOf[ACLProbeImpl])
+ .replaceRights(path, ANDRE.asString, new
MailboxACL.Rfc4314Rights(Right.Lookup, Right.Read))
+
+ waitForNextState(server, accountId, provisioningState)
+ val oldStateAndre: State = waitForNextStateWithDelegation(server,
AccountId.fromUsername(ANDRE), State.INITIAL)
+
+ server.getProbe(classOf[ACLProbeImpl])
+ .replaceRights(path, ANDRE.asString, new MailboxACL.Rfc4314Rights())
+
+ server.getProbe(classOf[ACLProbeImpl])
+ .replaceRights(path, ANDRE.asString, new
MailboxACL.Rfc4314Rights(Right.Lookup, Right.Read))
+
+ val request =
+ s"""{
+ | "using": ["urn:ietf:params:jmap:core",
"urn:ietf:params:jmap:mail", "urn:apache:james:params:jmap:mail:shares"],
+ | "methodCalls": [[
+ | "Mailbox/changes",
+ | {
+ | "accountId": "$ANDRE_ACCOUNT_ID",
+ | "sinceState": "${oldStateAndre.getValue}"
+ | },
+ | "c1"]]
+ |}""".stripMargin
+
+ awaitAtMostTenSeconds.untilAsserted { () =>
+ val response = `given`(
+ baseRequestSpecBuilder(server)
+ .setAuth(authScheme(UserCredential(ANDRE, ANDRE_PASSWORD)))
+ .addHeader(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+ .setBody(request)
+ .build, new ResponseSpecBuilder().build)
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .contentType(JSON)
+ .extract
+ .body
+ .asString
+
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState")
+ .withOptions(new Options(IGNORING_ARRAY_ORDER))
+ .isEqualTo(
+ s"""{
+ | "sessionState": "${SESSION_STATE.value}",
+ | "methodResponses": [
+ | [ "Mailbox/changes", {
+ | "accountId": "$ANDRE_ACCOUNT_ID",
+ | "oldState": "${oldStateAndre.getValue}",
+ | "hasMoreChanges": false,
+ | "updatedProperties": null,
+ | "created": [],
+ | "updated": ["$mailboxId"],
+ | "destroyed": []
+ | }, "c1"]
+ | ]
+ |}""".stripMargin)
+ }
+ }
+
@Test
def
returnedIdsShouldNotReturnDuplicatesAccrossCreatedUpdatedOrDestroyed(server:
GuiceJamesServer): Unit = {
val mailboxProbe: MailboxProbeImpl =
server.getProbe(classOf[MailboxProbeImpl])
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]