private void setRights(MailboxACL mailboxACL, MailboxMapper mapper, Mailbox mailbox, MailboxSession session) throws MailboxException { ACLDiff aclDiff = mapper.setACL(mailbox, mailboxACL); dispatcher.aclUpdated(session, mailbox.generateAssociatedPath(), aclDiff); }
@Test public void eventShouldUpdateNewParentWhenRenameMailboxWhichContainLookupRight() throws Exception { Mailbox childMailbox = mailboxMapper.getMailboxMapper(mailboxSession).findMailboxById(childMailboxId); mailboxMapper.getMailboxMapper(mailboxSession).setACL(childMailbox, new MailboxACL( new Entry(SHARED_USER_KEY, new Rfc4314Rights(Right.Write, Right.Lookup)))); storeMailboxManager.renameMailbox(CHILD_MAILBOX, MailboxPath.forUser(OWNER_USER, "shared1.sub1New"), mailboxSession); MailboxACL actualACL = storeMailboxManager.getMailbox(parentMailboxId1, mailboxSession) .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT) .getACL(); assertThat(actualACL.getEntries()) .contains(lookupEntry); }
@Test public void eventShouldNotUpdateNewParentWhenRenameMailboxWhichDoesContainLookupRight() throws Exception { Mailbox childMailbox = mailboxMapper.getMailboxMapper(mailboxSession).findMailboxById(childMailboxId); mailboxMapper.getMailboxMapper(mailboxSession).setACL(childMailbox, new MailboxACL( new Entry(SHARED_USER_KEY, new Rfc4314Rights(Right.Write)))); storeMailboxManager.renameMailbox(CHILD_MAILBOX, MailboxPath.forUser(OWNER_USER, "shared1.sub1New"), mailboxSession); MailboxACL actualACL = storeMailboxManager.getMailbox(parentMailboxId1, mailboxSession) .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT) .getACL(); assertThat(actualACL.getEntries()) .doesNotContainKeys(SHARED_USER_KEY); }
@Test public void eventShouldUpdateAllNewParentWhenRenameMailboxWhichContainLookupRight() throws Exception { Mailbox grandChildMailbox = mailboxMapper.getMailboxMapper(mailboxSession).findMailboxById(grandChildMailboxId); mailboxMapper.getMailboxMapper(mailboxSession).setACL(grandChildMailbox, new MailboxACL( new Entry(SHARED_USER_KEY, new Rfc4314Rights(Right.Write, Right.Lookup)))); storeMailboxManager.renameMailbox(GRAND_CHILD_MAILBOX, MailboxPath.forUser(OWNER_USER, "shared1.sub1.sub2"), mailboxSession); MailboxACL parentActualACL = storeMailboxManager.getMailbox(parentMailboxId1, mailboxSession) .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT) .getACL(); MailboxACL childActualACL = storeMailboxManager.getMailbox(childMailboxId1, mailboxSession) .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT) .getACL(); assertThat(parentActualACL.getEntries()) .contains(lookupEntry); assertThat(childActualACL.getEntries()) .contains(lookupEntry); }
@Test public void eventShouldDoNothingWhenNewACLIsTheSameAsTheOldOne() throws Exception { Mailbox grandChildMailbox = mailboxMapper.getMailboxMapper(mailboxSession).findMailboxById(grandChildMailboxId); mailboxMapper.getMailboxMapper(mailboxSession).setACL(grandChildMailbox, new MailboxACL( new Entry(SHARED_USER_KEY, new Rfc4314Rights(Right.Lookup)))); storeRightManager.applyRightsCommand( GRAND_CHILD_MAILBOX, MailboxACL.command() .key(SHARED_USER_KEY) .rights(Right.Lookup) .asAddition(), mailboxSession); MailboxACL actualACL = storeMailboxManager.getMailbox(parentMailboxId, mailboxSession) .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT) .getACL(); assertThat(actualACL.getEntries()) .doesNotContainKeys(SHARED_USER_KEY); }
@Test public void eventShouldDoNothingWhenMailboxACLRemoveLookupRight() throws Exception { Mailbox grandChildMailbox = mailboxMapper.getMailboxMapper(mailboxSession).findMailboxById(grandChildMailboxId); mailboxMapper.getMailboxMapper(mailboxSession).setACL(grandChildMailbox, new MailboxACL( new Entry(SHARED_USER_KEY, new Rfc4314Rights(Right.Write, Right.Lookup)))); storeRightManager.applyRightsCommand( GRAND_CHILD_MAILBOX, MailboxACL.command() .key(SHARED_USER_KEY) .rights(Right.Lookup) .asRemoval(), mailboxSession); MailboxACL actualACL = storeMailboxManager.getMailbox(parentMailboxId, mailboxSession) .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT) .getACL(); assertThat(actualACL.getEntries()) .doesNotContainKeys(SHARED_USER_KEY); }
@Test public void eventShouldUpdateParentWhenMailboxACLUpdateLookupRight() throws Exception { Mailbox grandChildMailbox = mailboxMapper.getMailboxMapper(mailboxSession).findMailboxById(grandChildMailboxId); mailboxMapper.getMailboxMapper(mailboxSession).setACL(grandChildMailbox, new MailboxACL( new Entry(SHARED_USER_KEY, new Rfc4314Rights(Right.Write)))); storeRightManager.setRights( GRAND_CHILD_MAILBOX, new MailboxACL( new Entry(SHARED_USER_KEY, new Rfc4314Rights(Right.Lookup))), mailboxSession); MailboxACL actualACL = storeMailboxManager.getMailbox(parentMailboxId, mailboxSession) .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT) .getACL(); assertThat(actualACL.getEntries()) .hasSize(2) .contains(lookupEntry); }
@Test public void eventShouldUpdateAllParentWhenMailboxACLUpdateLookupRight() throws Exception { Mailbox grandChildMailbox = mailboxMapper.getMailboxMapper(mailboxSession).findMailboxById(grandChildMailboxId); mailboxMapper.getMailboxMapper(mailboxSession).setACL(grandChildMailbox, new MailboxACL( new Entry(SHARED_USER_KEY, new Rfc4314Rights(Right.Write)))); storeRightManager.setRights( GRAND_CHILD_MAILBOX, new MailboxACL( new Entry(SHARED_USER_KEY, new Rfc4314Rights(Right.Lookup))), mailboxSession); MailboxACL actualParentACL = storeMailboxManager.getMailbox(parentMailboxId, mailboxSession) .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT) .getACL(); MailboxACL actualChildACL = storeMailboxManager.getMailbox(parentMailboxId, mailboxSession) .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT) .getACL(); assertThat(actualParentACL.getEntries()) .contains(lookupEntry); assertThat(actualChildACL.getEntries()) .contains(lookupEntry); }