StoreRightManager implements RightManager { @VisibleForTesting boolean areDomainsDifferent(String user, Username otherUser) { Optional<Domain> domain = Username.of(user).getDomainPart(); Optional<Domain> otherDomain = otherUser.getDomainPart(); return !domain.equals(otherDomain); } @Inject  StoreRightManager(MailboxSessionMapperFactory mailboxSessionMapperFactory,
                             MailboxACLResolver aclResolver,
                             GroupMembershipResolver groupMembershipResolver,
                             EventBus eventBus); @Override boolean hasRight(MailboxPath mailboxPath, Right right, MailboxSession session); @Override boolean hasRight(MailboxId mailboxId, Right right, MailboxSession session); boolean hasRight(Mailbox mailbox, Right right, MailboxSession session); @Override Rfc4314Rights myRights(MailboxPath mailboxPath, MailboxSession session); @Override Mono<Rfc4314Rights> myRights(MailboxId mailboxId, MailboxSession session); @Override Rfc4314Rights myRights(Mailbox mailbox, MailboxSession session); @Override List<Rfc4314Rights> listRights(MailboxPath mailboxPath, EntryKey key, MailboxSession session); @Override MailboxACL listRights(MailboxPath mailboxPath, MailboxSession session); @Override void applyRightsCommand(MailboxPath mailboxPath, ACLCommand mailboxACLCommand, MailboxSession session); @Override void applyRightsCommand(MailboxId mailboxId, ACLCommand mailboxACLCommand, MailboxSession session); boolean isReadWrite(MailboxSession session, Mailbox mailbox, Flags sharedPermanentFlags); @Override void setRights(MailboxId mailboxId, MailboxACL mailboxACL, MailboxSession session); @Override void setRights(MailboxPath mailboxPath, MailboxACL mailboxACL, MailboxSession session); MailboxACL getResolvedMailboxACL(Mailbox mailbox, MailboxSession mailboxSession); static final boolean GROUP_FOLDER; }
@Test void areDomainsDifferentShouldReturnTrueWhenOneHasDomainNotTheOther() { assertThat(storeRightManager.areDomainsDifferent("user@domain.org", Username.of("otherUser"))).isTrue(); }
@Test void areDomainsDifferentShouldReturnTrueWhenOtherHasDomainNotTheOne() { assertThat(storeRightManager.areDomainsDifferent("user", Username.of("otherUser@domain.org"))).isTrue(); }
@Test void areDomainsDifferentShouldReturnFalseWhenNoDomain() { assertThat(storeRightManager.areDomainsDifferent("user", Username.of("otherUser"))).isFalse(); }
@Test void areDomainsDifferentShouldReturnTrueWhenDomainsAreDifferent() { assertThat(storeRightManager.areDomainsDifferent("user@domain.org", Username.of("otherUser@otherdomain.org"))).isTrue(); }
@Test void areDomainsDifferentShouldReturnFalseWhenDomainsAreIdentical() { assertThat(storeRightManager.areDomainsDifferent("user@domain.org", Username.of("otherUser@domain.org"))).isFalse(); }