You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by GitBox <gi...@apache.org> on 2022/10/13 09:05:11 UTC
[GitHub] [james-project] quantranhong1999 commented on a diff in pull request #1246: JAMES-3830 UserQuotaRootResolver support method list all QuotaRoot of delegated mailboxes
quantranhong1999 commented on code in PR #1246:
URL: https://github.com/apache/james-project/pull/1246#discussion_r994366241
##########
server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/QuotaGetMethodContract.scala:
##########
@@ -903,4 +904,297 @@ trait QuotaGetMethodContract {
|}
|""".stripMargin)
}
+
+ @Test
+ def quotaGetShouldNotReturnQuotaRootOfDelegatedMailboxWhenNotExtension(server: GuiceJamesServer): Unit = {
+ val quotaProbe = server.getProbe(classOf[QuotaProbesImpl])
+ val bobQuotaRoot = quotaProbe.getQuotaRoot(MailboxPath.inbox(BOB))
+ quotaProbe.setMaxMessageCount(bobQuotaRoot, QuotaCountLimit.count(100L))
+
+ // setup delegated Mailbox
+ val andreMailbox = MailboxPath.forUser(ANDRE, "mailbox")
+ val mailboxId = server.getProbe(classOf[MailboxProbeImpl]).createMailbox(andreMailbox)
+ server.getProbe(classOf[ACLProbeImpl])
+ .replaceRights(andreMailbox, BOB.asString, new MailboxACL.Rfc4314Rights(Read))
+
+ quotaProbe.setMaxMessageCount(quotaProbe.getQuotaRoot(andreMailbox), QuotaCountLimit.count(88L))
+
+
+ val response = `given`
+ .body(
+ s"""{
+ | "using": [
+ | "urn:ietf:params:jmap:core",
+ | "urn:ietf:params:jmap:quota"],
+ | "methodCalls": [[
+ | "Quota/get",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "ids": null
+ | },
+ | "c1"]]
+ |}""".stripMargin)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .contentType(JSON)
+ .extract
+ .body
+ .asString
+
+ assertThatJson(response).isEqualTo(
+ s"""{
+ | "sessionState": "${SESSION_STATE.value}",
+ | "methodResponses": [
+ | [
+ | "Quota/get",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "notFound": [],
+ | "state": "${INSTANCE.value}",
+ | "list": [
+ | {
+ | "used": 0,
+ | "name": "#private&bob@domain.tld@domain.tld:account:count:Mail",
+ | "id": "08417be420b6dd6fa77d48fb2438e0d19108cd29424844bb109b52d356fab528",
+ | "dataTypes": [
+ | "Mail"
+ | ],
+ | "limit": 100,
+ | "warnLimit": 90,
+ | "resourceType": "count",
+ | "scope": "account"
+ | }
+ | ]
+ | },
+ | "c1"
+ | ]
+ | ]
+ |}
+ |""".stripMargin)
+ }
+
+ @Test
+ def quotaGetShouldReturnQuotaRootOfDelegatedMailboxWhenExtension(server: GuiceJamesServer): Unit = {
+ val quotaProbe = server.getProbe(classOf[QuotaProbesImpl])
+ val bobQuotaRoot = quotaProbe.getQuotaRoot(MailboxPath.inbox(BOB))
+ quotaProbe.setMaxMessageCount(bobQuotaRoot, QuotaCountLimit.count(100L))
+
+ // setup delegated Mailbox
+ val andreMailbox = MailboxPath.forUser(ANDRE, "mailbox")
+ val mailboxId = server.getProbe(classOf[MailboxProbeImpl]).createMailbox(andreMailbox)
+ server.getProbe(classOf[ACLProbeImpl])
+ .replaceRights(andreMailbox, BOB.asString, new MailboxACL.Rfc4314Rights(Read))
+
+ quotaProbe.setMaxMessageCount(quotaProbe.getQuotaRoot(andreMailbox), QuotaCountLimit.count(88L))
+
+ val response = `given`
+ .body(
+ s"""{
+ | "using": [
+ | "urn:ietf:params:jmap:core",
+ | "urn:ietf:params:jmap:quota",
+ | "urn:apache:james:params:jmap:mail:shares" ],
+ | "methodCalls": [[
+ | "Quota/get",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "ids": null
+ | },
+ | "c1"]]
+ |}""".stripMargin)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .contentType(JSON)
+ .extract
+ .body
+ .asString
+
+ assertThatJson(response).isEqualTo(
+ s"""{
+ | "sessionState": "${SESSION_STATE.value}",
+ | "methodResponses": [
+ | [
+ | "Quota/get",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "notFound": [],
+ | "state": "${INSTANCE.value}",
+ | "list": [
+ | {
+ | "used": 0,
+ | "name": "#private&bob@domain.tld@domain.tld:account:count:Mail",
+ | "id": "08417be420b6dd6fa77d48fb2438e0d19108cd29424844bb109b52d356fab528",
+ | "dataTypes": [
+ | "Mail"
+ | ],
+ | "limit": 100,
+ | "warnLimit": 90,
+ | "resourceType": "count",
+ | "scope": "account"
+ | },
+ | {
+ | "used": 0,
+ | "name": "#private&andre@domain.tld@domain.tld:account:count:Mail",
Review Comment:
Q: How does the client know which (delegated) mailbox this quota applies to? Should we need some kind of associated mailbox id or client just parse this quota name to get the mailbox name?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org