You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2020/08/25 02:19:55 UTC

[james-project] 04/07: JAMES-3359 add tests for applyRightCommand by MailboxId

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 5f567461bc05bd02cfcfec9fd34e1e87b16b3859
Author: LanKhuat <dl...@linagora.com>
AuthorDate: Wed Aug 19 11:09:06 2020 +0700

    JAMES-3359 add tests for applyRightCommand by MailboxId
---
 .../apache/james/mailbox/MailboxManagerTest.java   | 30 ++++++++++++++++++++++
 .../contract/MailboxSetMethodContract.scala        |  2 --
 2 files changed, 30 insertions(+), 2 deletions(-)

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 04a4a68..95a220a 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
@@ -2854,6 +2854,23 @@ public abstract class MailboxManagerTest<T extends MailboxManager> {
         }
 
         @Test
+        void applyRightsCommandByIdShouldThrowWhenNotOwner() throws Exception {
+            MailboxPath mailboxPath = MailboxPath.forUser(USER_2, "mailbox");
+            MailboxId mailboxId = mailboxManager.createMailbox(mailboxPath, session2).get();
+            mailboxManager.setRights(mailboxPath,  MailboxACL.EMPTY.apply(MailboxACL.command()
+                .key(MailboxACL.EntryKey.createUserEntryKey(USER_1))
+                .rights(new MailboxACL.Rfc4314Rights(MailboxACL.Right.Lookup))
+                .asAddition()), session2);
+
+            assertThatThrownBy(() -> mailboxManager.applyRightsCommand(mailboxId,
+                MailboxACL.command()
+                    .key(MailboxACL.EntryKey.createUserEntryKey(USER_1))
+                    .rights(MailboxACL.FULL_RIGHTS)
+                    .asAddition(), session))
+                .isInstanceOf(InsufficientRightsException.class);
+        }
+
+        @Test
         void setRightsByIdShouldThrowWhenNoRights() throws Exception {
             MailboxPath mailboxPath = MailboxPath.forUser(USER_2, "mailbox");
             MailboxId mailboxId = mailboxManager.createMailbox(mailboxPath, session2).get();
@@ -2891,5 +2908,18 @@ public abstract class MailboxManagerTest<T extends MailboxManager> {
                     .asAddition(), session))
                 .isInstanceOf(MailboxNotFoundException.class);
         }
+
+        @Test
+        void applyRightsCommandByIdShouldThrowWhenNoRights() throws Exception {
+            MailboxPath mailboxPath = MailboxPath.forUser(USER_2, "mailbox");
+            MailboxId mailboxId = mailboxManager.createMailbox(mailboxPath, session2).get();
+
+            assertThatThrownBy(() -> mailboxManager.applyRightsCommand(mailboxId,
+                MailboxACL.command()
+                    .key(MailboxACL.EntryKey.createUserEntryKey(USER_1))
+                    .rights(MailboxACL.FULL_RIGHTS)
+                    .asAddition(), session))
+                .isInstanceOf(MailboxNotFoundException.class);
+        }
     }
 }
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 b624f3b..0398c0e 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
@@ -5168,8 +5168,6 @@ trait MailboxSetMethodContract {
          |}""".stripMargin)
   }
 
-  // TODO write test for rights store manager applyCommandById in MailboxManagerTest
-
   @Test
   def partialRightsUpdateShouldFailWhenInvalidUsername(server: GuiceJamesServer): Unit = {
     val path = MailboxPath.forUser(BOB, "mailbox")


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org