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/11/30 12:12:28 UTC

[james-project] 02/07: JAMES-3458 Skip ACL verifications for owner

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 e5e6cd4c0e2ca4caddb8b3fecf91dc8a91baa73f
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Fri Nov 27 10:09:31 2020 +0700

    JAMES-3458 Skip ACL verifications for owner
---
 .../java/org/apache/james/mailbox/store/StoreRightManager.java     | 7 +++++++
 .../java/org/apache/james/mailbox/store/StoreRightManagerTest.java | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
index 2845ed8..3c15ace 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
@@ -95,6 +95,13 @@ public class StoreRightManager implements RightManager {
 
     @Override
     public Rfc4314Rights myRights(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
+        if (mailboxPath.belongsTo(session)) {
+            if (mailboxSessionMapperFactory.getMailboxMapper(session).pathExists(mailboxPath).block()) {
+                return MailboxACL.FULL_RIGHTS;
+            } else {
+                throw new MailboxNotFoundException(mailboxPath);
+            }
+        }
         MailboxMapper mapper = mailboxSessionMapperFactory.getMailboxMapper(session);
         Mailbox mailbox = blockOptional(mapper.findMailboxByPath(mailboxPath))
             .orElseThrow(() -> new MailboxNotFoundException(mailboxPath));
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreRightManagerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreRightManagerTest.java
index 465da65..a315927 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreRightManagerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreRightManagerTest.java
@@ -86,8 +86,8 @@ class StoreRightManagerTest {
     @Test
     void hasRightShouldThrowMailboxNotFoundExceptionWhenMailboxDoesNotExist() {
         MailboxPath mailboxPath = MailboxPath.forUser(MailboxFixture.ALICE, "unexisting mailbox");
-        when(mockedMailboxMapper.findMailboxByPath(mailboxPath))
-            .thenReturn(Mono.error(new MailboxNotFoundException("")));
+        when(mockedMailboxMapper.pathExists(mailboxPath))
+            .thenReturn(Mono.just(false));
 
         assertThatThrownBy(() ->
             storeRightManager.hasRight(mailboxPath, Right.Read, aliceSession))


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