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


The following commit(s) were added to refs/heads/master by this push:
     new e08ce98ba6 ISSUE-5290 check that mailboxes on which i have a p right 
are not listed in the ones i can see (#2432)
e08ce98ba6 is described below

commit e08ce98ba6bd69523f079ebea63938d9702c91b9
Author: florentos17 <fazav...@linagora.com>
AuthorDate: Fri Oct 4 09:24:23 2024 +0200

    ISSUE-5290 check that mailboxes on which i have a p right are not listed in 
the ones i can see (#2432)
    
    * ISSUE-5290 new tests in MailboxManagerTest
    
    * ISSUE-5290 changed `mailboxManager.list()` to `mailboxManager.search()`
---
 .../apache/james/mailbox/MailboxManagerTest.java   | 41 ++++++++++++++++++++++
 1 file changed, 41 insertions(+)

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 881fcaaf97..f189c1a3a0 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
@@ -99,6 +99,7 @@ import org.junit.jupiter.api.Nested;
 import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 
+import com.github.fge.lambdas.Throwing;
 import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
@@ -3133,5 +3134,45 @@ public abstract class MailboxManagerTest<T extends 
MailboxManager> {
                     .asAddition(), session))
                 .isInstanceOf(MailboxNotFoundException.class);
         }
+
+        @Test
+        void giveRightToPostToSomeoneShouldNotAllowToSeeMailbox() throws 
Exception {
+            MailboxPath mailboxPath = MailboxPath.forUser(USER_1, "mailbox");
+            mailboxManager.createMailbox(mailboxPath, session);
+
+            MailboxACL.ACLCommand command = MailboxACL.command()
+                    .key(MailboxACL.EntryKey.createUserEntryKey(USER_2))
+                    .rights(MailboxACL.Right.Post)
+                    .asAddition();
+            mailboxManager.applyRightsCommand(mailboxPath, command, session);
+
+            assertThat(mailboxManager.search(
+                    
MailboxQuery.privateMailboxesBuilder(session2).matchesAllMailboxNames().build(),
+                    session2)
+                .toStream().map(MailboxMetaData::getPath)
+                .filter(Throwing.predicate(
+                    path -> mailboxManager.hasRight(path, 
MailboxACL.Right.Lookup, session2))))
+                .doesNotContain(mailboxPath);
+        }
+
+        @Test
+        void giveRightToPostToAnyoneShouldNotAllowToSeeMailbox() throws 
Exception {
+            MailboxPath mailboxPath = MailboxPath.forUser(USER_1, "mailbox");
+            mailboxManager.createMailbox(mailboxPath, session);
+
+            MailboxACL.ACLCommand command = MailboxACL.command()
+                    .key(MailboxACL.ANYONE_KEY)
+                    .rights(MailboxACL.Right.Post)
+                    .asAddition();
+            mailboxManager.applyRightsCommand(mailboxPath, command, session);
+
+            assertThat(mailboxManager.search(
+                    
MailboxQuery.privateMailboxesBuilder(session2).matchesAllMailboxNames().build(),
+                    session2)
+                .toStream().map(MailboxMetaData::getPath)
+                .filter(Throwing.predicate(
+                    path -> mailboxManager.hasRight(path, 
MailboxACL.Right.Lookup, session2))))
+                .doesNotContain(mailboxPath);
+        }
     }
 }


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

Reply via email to