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
Conversation
test this please |
/** | ||
* @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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
|
||
import org.apache.james.mailbox.model.MailboxACL; | ||
|
||
public class ACLChanged { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is not necessary to specify that this class only handles user positive entries?
.and(eq(MAILBOX_ID, bindMarker(MAILBOX_ID)))); | ||
} | ||
|
||
private PreparedStatement prepareSelectUser(Session session) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SelectAllForUser?
.compactionOptions(SchemaBuilder.leveledStrategy()) | ||
.caching(SchemaBuilder.KeyCaching.ALL, | ||
SchemaBuilder.rows(CassandraConstants.DEFAULT_CACHED_ROW_PER_PARTITION)) | ||
.comment("Denormalisation table. Allow to retrieve tnon personnal mailboxId a user has right on"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/tnon/non/
s/mailboxId/mailboxIds
} | ||
|
||
@Test | ||
public void retrieveUserShouldReturnEmptyWhenEmptyData() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/retrieveUser/listRightsForUser/
.map(aclTransformation) | ||
.map(aclWithVersion -> updateStoredACL(cassandraId, aclWithVersion)) | ||
.orElseGet(() -> insertACL(cassandraId, replacement)); | ||
.map(value -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value? aclWithVersion was a better naming, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This value was already used before I refactored. Changed.
@@ -100,6 +101,7 @@ | |||
*/ | |||
public class StoreMailboxManager implements MailboxManager { | |||
private static final Logger LOGGER = LoggerFactory.getLogger(StoreMailboxManager.class); | |||
public static final char SQL_WILDCARD_CHAR = '%'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public before private :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but honestly, I'm wondering if we should not authorize LOGGER to be always the first line, even if private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me I prefer Logger to be in the first line, as it's pretty generic.
} | ||
|
||
@Test | ||
public void IsWildShouldReturnTrueWhenLocalWildcardAtBeginning() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Is/is/ everywhere in this file
} | ||
|
||
@Test | ||
public void getCombinedNameShouldWork() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bad test name, but it's copy / pasted from the refactoring, so I won't ask it to be changed for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that's kind. I got the impression I did the refactoring quota :-)
boolean actual = testee.isExpressionMatch("folder\\123"); | ||
|
||
assertThat(actual).isTrue(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not check each test, I assume it's just a copy paster from previous regexp tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's exactly this ;-)
@@ -176,8 +177,7 @@ public void getPathLikeShouldReturnUserPathLikeWhenNoBaseDefined() throws Except | |||
//Given | |||
MailboxSession session = new MockMailboxSession("user"); | |||
MailboxQuery.Builder testee = MailboxQuery.builder() | |||
.expression("abc") | |||
.mailboxSession(session); | |||
.expression(new PrefixedRegex("", "abc", session.getPathDelimiter())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this empty string? can you name it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No prefix, regex only ;-)
I guess the exact one might be used...
…ible (non personnal) mailboxes
- Allow missing namespace and username in mailboxQuery - Matching logic SHOULD be moved in MailboxQuery
…nymore on MailboxPath for its internal representation
…come after static definitions
…ompulsory to build MailboxQuery
…xternal class hierarchy
…Mailbox search related classes
…ailboxNameExpression
…ace search filtering on the manager layer
} | ||
|
||
private boolean isReadable(MailboxSession session, Mailbox mailbox) throws MailboxException { | ||
return (Objects.equals(mailbox.getUser(), session.getUser().getUserName()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too many conditions here IMO
} | ||
|
||
public Stream<MailboxACL.Entry> addedEntries() { | ||
Map<MailboxACL.EntryKey, MailboxACL.Rfc4314Rights> oldEntries = oldACL.ofPositiveNameType(MailboxACL.NameType.user); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
diff feature should not belong to this class because we will need it really often
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
this.pathDelimiter = Optional.of(pathDelimiter); | ||
public Builder matchesAllMailboxNames() { | ||
this.mailboxNameExpression = Optional.of(new Wildcard()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wildcard should be a Singleton
@@ -349,7 +349,8 @@ public void putShouldReturnOkWhenIssuedTwoTimes() { | |||
@Test | |||
public void putShouldAddAMailbox() { | |||
with() | |||
.put(MAILBOX_NAME); | |||
.put(MAILBOX_NAME) | |||
.prettyPeek(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sysout spotted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for @aduprat changes
private final char pathDelimiter; | ||
|
||
private final Pattern pattern; | ||
public static final char SQL_WILDCARD_CHAR = '%'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have sql logic here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this part of the code was not changed, just moved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did not check the rebase though
@@ -95,7 +96,7 @@ public Builder expression(MailboxNameExpression expression) { | |||
} | |||
|
|||
public Builder matchesAllMailboxNames() { | |||
this.mailboxNameExpression = Optional.of(new Wildcard()); | |||
this.mailboxNameExpression = Optional.of(WILDCARD); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not what I meant, Wildcard whould not have a public constructor as it's always the exact same object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you handle this?
…ly on MailboxNameExpression
…ly on MailboxNameExpression
merged |
This PR includes:
Enjoy.