Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAILBOX-310 MailboxManager::search and delegation #1011

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
434e040
MAILBOX-310 Mailbox query refactoring: Don't expose MailboxQuery cons…
aduprat Sep 28, 2017
929f31d
MAILBOX-310 MailboxACL should present only users ACL
aduprat Sep 29, 2017
3192535
MAILBOX-310 ACLChanged should represent the diff between two ACLs
chibenwa Oct 4, 2017
e55b371
MAILBOX-310 CassandraUserMailboxRightsDAO should store user -> access…
chibenwa Oct 4, 2017
78f208c
MAILBOX-310 Mapper should store the ACL by user/mailbox
chibenwa Oct 4, 2017
42e200d
MAILBOX-310 Refactor mailbox search
chibenwa Oct 3, 2017
04d3388
MAILBOX-310 MailboxManager::search should allow retrieving delegated …
chibenwa Oct 3, 2017
d19f88f
MAILBOX-310 Introduce ACL capability
aduprat Oct 2, 2017
fa04dab
MAILBOX-310 Cassandra modseq and uid test don't need mailbox mapper
chibenwa Oct 3, 2017
8c0edd7
MAILBOX-310 Mailbox query refactoring: MailboxQuery should not rely a…
chibenwa Oct 4, 2017
3986c33
MAILBOX-310 Mailbox query refactoring: Reorder fields. Fields should …
chibenwa Oct 4, 2017
1a7bcf2
MAILBOX-310 Mailbox query refactoring: Slightly improve isExpressionM…
chibenwa Oct 4, 2017
e8b5c8a
MAILBOX-310 Mailbox query refactoring: MailboxSession should not be c…
chibenwa Oct 4, 2017
087bed4
MAILBOX-310 Mailbox query refactoring: Reindent isWild
chibenwa Oct 4, 2017
fa43bc1
MAILBOX-310 Mailbox query refactoring: Use matchesAll more
chibenwa Oct 4, 2017
99dcb1e
MAILBOX-310 Mailbox query refactoring: Remove javadoc for toString
chibenwa Oct 4, 2017
9b38fc3
MAILBOX-310 Mailbox query refactoring: Copy mailboxPath matching in e…
chibenwa Oct 4, 2017
080d04b
MAILBOX-310 Mailbox query refactoring: Create dedicated packages for …
chibenwa Oct 4, 2017
200d8cd
MAILBOX-310 Mailbox query refactoring: Mailbox query should rely on M…
chibenwa Oct 4, 2017
5bff630
MAILBOX-310 Propose a more explicit wording for MailboxMapper::findMa…
chibenwa Oct 4, 2017
7cdc63f
MAILBOX-310 Correct WebAdmin mailbox handling
chibenwa Oct 5, 2017
b70167d
MAILBOX-310 Adding additional tests demonstrating per username/namesp…
chibenwa Oct 5, 2017
50b6c2f
fixup! MAILBOX-310 Refactor mailbox search
aduprat Oct 5, 2017
d50df3b
fixup! MAILBOX-310 Mailbox query refactoring: Mailbox query should re…
aduprat Oct 5, 2017
5227fdb
fixup! MAILBOX-310 Correct WebAdmin mailbox handling
aduprat Oct 5, 2017
9c19ead
fixup! MAILBOX-310 Mailbox query refactoring: Mailbox query should re…
aduprat Oct 5, 2017
6e24197
fixup! MAILBOX-310 Mailbox query refactoring: Mailbox query should re…
aduprat Oct 5, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -878,4 +878,10 @@ public MailboxACL union(EntryKey key, Rfc4314Rights mailboxACLRights) throws Uns
return union(new MailboxACL(new Entry(key, mailboxACLRights)));
}

public Map<EntryKey, Rfc4314Rights> ofPositiveNameType(NameType nameType) {
return this.entries.entrySet().stream()
.filter(entry -> !entry.getKey().isNegative())
.filter(entry -> entry.getKey().getNameType().equals(nameType))
.collect(Guavate.entriesToMap());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,22 @@
import org.apache.james.mailbox.exception.UnsupportedRightException;
import org.apache.james.mailbox.model.MailboxACL.Entry;
import org.apache.james.mailbox.model.MailboxACL.EntryKey;
import org.apache.james.mailbox.model.MailboxACL.NameType;
import org.apache.james.mailbox.model.MailboxACL.Rfc4314Rights;
import org.assertj.core.data.MapEntry;
import org.junit.Before;
import org.junit.Test;

import com.google.common.collect.ImmutableMap;

/**
* @author Peter Palaga
*/
public class MailboxACLTest {

private static final String USER_1 = "user1";
private static final String USER_2 = "user2";
private static final boolean NEGATIVE = true;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NEGATIVE = true this is weird

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're peaky. what I am supposed to do with this?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can let it like that, I just wanted to mention it's a bit weird but I don't see any overkill solution to it


private static final String ae = "ae";
private static final String ik = "ik";
Expand Down Expand Up @@ -224,4 +229,40 @@ public void applyShouldNotThrowWhenRemovingANonExistingEntry() throws Exception{
.isEqualTo(MailboxACL.EMPTY);
}

@Test
public void usersACLShouldReturnEmptyMapWhenEmpty() {
assertThat(MailboxACL.EMPTY.ofPositiveNameType(NameType.user))
.isEmpty();
}

@Test
public void usersACLShouldReturnEmptyMapWhenNoUserEntry() {
MailboxACL mailboxACL = new MailboxACL(
ImmutableMap.of(EntryKey.createGroupEntryKey("group"), MailboxACL.FULL_RIGHTS,
EntryKey.createGroupEntryKey("group2"), MailboxACL.NO_RIGHTS));
assertThat(mailboxACL.ofPositiveNameType(NameType.user))
.isEmpty();
}

@Test
public void usersACLShouldReturnOnlyUsersMapWhenSomeUserEntries() throws Exception {
MailboxACL.Rfc4314Rights rights = MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("aei");
MailboxACL mailboxACL = new MailboxACL(
ImmutableMap.of(EntryKey.createUserEntryKey("user1"), MailboxACL.FULL_RIGHTS,
EntryKey.createGroupEntryKey("group"), MailboxACL.FULL_RIGHTS,
EntryKey.createUserEntryKey("user2"), rights,
EntryKey.createGroupEntryKey("group2"), MailboxACL.NO_RIGHTS));
assertThat(mailboxACL.ofPositiveNameType(NameType.user))
.containsOnly(
MapEntry.entry(EntryKey.createUserEntryKey("user1"), MailboxACL.FULL_RIGHTS),
MapEntry.entry(EntryKey.createUserEntryKey("user2"), rights));
}

@Test
public void ofPositiveNameTypeShouldFilterOutNegativeEntries() throws Exception {
MailboxACL mailboxACL = new MailboxACL(
ImmutableMap.of(EntryKey.createUserEntryKey("user1", NEGATIVE), MailboxACL.FULL_RIGHTS));
assertThat(mailboxACL.ofPositiveNameType(NameType.user))
.isEmpty();
}
}