@Test public void applyShouldNotThrowWhenRemovingANonExistingEntry() throws Exception { assertThat(MailboxACL.EMPTY .apply(MailboxACL.command().forUser("bob").noRights().asReplacement())) .isEqualTo(MailboxACL.EMPTY); }
@Test public void removedEntriesShouldReturnEmptyWhenAddedEntry() throws Exception { PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff( MailboxACL.EMPTY, MailboxACL.EMPTY.apply( MailboxACL.command() .key(USER_ENTRY_KEY) .rights(RIGHTS) .asAddition())); assertThat(positiveUserAclDiff.removedEntries()) .isEmpty(); }
@Test public void changedEntriesShouldReturnEmptyWhenAddedEntry() throws Exception { ACLDiff aclDiff = ACLDiff.computeDiff( MailboxACL.EMPTY, MailboxACL.EMPTY.apply( MailboxACL.command() .key(ENTRY_KEY) .rights(RIGHTS) .asAddition())); assertThat(aclDiff.changedEntries()) .isEmpty(); }
@Test public void addedEntriesShouldFilterNegativeUserEntryKey() throws Exception { PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff( MailboxACL.EMPTY, MailboxACL.EMPTY.apply( MailboxACL.command() .key(NEGATIVE_USER_ENTRY_KEY) .rights(RIGHTS) .asAddition())); assertThat(positiveUserAclDiff.addedEntries()) .isEmpty(); }
@Test public void changedEntriesShouldReturnEmptyWhenSameNonEmptyACL() throws UnsupportedRightException { MailboxACL mailboxACL = MailboxACL.EMPTY.apply( MailboxACL.command() .key(ENTRY_KEY) .rights(RIGHTS) .asAddition()); ACLDiff acldiff = ACLDiff.computeDiff(mailboxACL, mailboxACL); assertThat(acldiff.changedEntries()).isEmpty(); }
@Test public void addedEntriesShouldReturnEmptyWhenRemovedEntry() throws Exception { ACLDiff aclDiff = ACLDiff.computeDiff( MailboxACL.EMPTY.apply( MailboxACL.command() .key(ENTRY_KEY) .rights(RIGHTS) .asAddition()), MailboxACL.EMPTY); assertThat(aclDiff.addedEntries()) .isEmpty(); }
@Test public void changedEntriesShouldReturnEmptyWhenRemovedEntry() throws Exception { ACLDiff aclDiff = ACLDiff.computeDiff( MailboxACL.EMPTY.apply( MailboxACL.command() .key(ENTRY_KEY) .rights(RIGHTS) .asAddition()), MailboxACL.EMPTY); assertThat(aclDiff.changedEntries()) .isEmpty(); }
@Test public void changedEntriesShouldReturnEmptyWhenSameNonEmptyACL() throws UnsupportedRightException { MailboxACL mailboxACL = MailboxACL.EMPTY.apply( MailboxACL.command() .key(USER_ENTRY_KEY) .rights(RIGHTS) .asAddition()); PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(mailboxACL, mailboxACL); assertThat(positiveUserAclDiff.changedEntries()).isEmpty(); }
@Test public void addedEntriesShouldReturnEmptyWhenRemovedEntry() throws Exception { PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff( MailboxACL.EMPTY.apply( MailboxACL.command() .key(USER_ENTRY_KEY) .rights(RIGHTS) .asAddition()), MailboxACL.EMPTY); assertThat(positiveUserAclDiff.addedEntries()) .isEmpty(); }
@Test public void changedEntriesShouldReturnEmptyWhenRemovedEntry() throws Exception { PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff( MailboxACL.EMPTY.apply( MailboxACL.command() .key(USER_ENTRY_KEY) .rights(RIGHTS) .asAddition()), MailboxACL.EMPTY); assertThat(positiveUserAclDiff.changedEntries()) .isEmpty(); }
@Test public void removedEntriesShouldReturnEmptyWhenSameNonEmptyACL() throws UnsupportedRightException { MailboxACL mailboxACL = MailboxACL.EMPTY.apply( MailboxACL.command() .key(ENTRY_KEY) .rights(RIGHTS) .asAddition()); ACLDiff aclDiff = ACLDiff.computeDiff(mailboxACL, mailboxACL); assertThat(aclDiff.removedEntries()).isEmpty(); }
@Test public void removedEntriesShouldReturnEmptyWhenAddedEntry() throws Exception { ACLDiff aclDiff = ACLDiff.computeDiff( MailboxACL.EMPTY, MailboxACL.EMPTY.apply( MailboxACL.command() .key(ENTRY_KEY) .rights(RIGHTS) .asAddition())); assertThat(aclDiff.removedEntries()) .isEmpty(); }
@Test public void changedEntriesShouldReturnEmptyWhenAddedEntry() throws Exception { PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff( MailboxACL.EMPTY, MailboxACL.EMPTY.apply( MailboxACL.command() .key(USER_ENTRY_KEY) .rights(RIGHTS) .asAddition())); assertThat(positiveUserAclDiff.changedEntries()) .isEmpty(); }
@Test public void addedEntriesShouldReturnEmptyWhenSameNonEmptyACL() throws UnsupportedRightException { MailboxACL mailboxACL = MailboxACL.EMPTY.apply( MailboxACL.command() .key(ENTRY_KEY) .rights(RIGHTS) .asAddition()); ACLDiff aclDiff = ACLDiff.computeDiff(mailboxACL, mailboxACL); assertThat(aclDiff.addedEntries()).isEmpty(); }
@Test void replaceWhenNotStoredShouldUpdateACLEntry() throws MailboxException { MailboxACL.EntryKey key = new MailboxACL.EntryKey("bob", MailboxACL.NameType.user, false); MailboxACL.Rfc4314Rights rights = new MailboxACL.Rfc4314Rights(MailboxACL.Right.Read); cassandraACLMapper.updateACL(MAILBOX_ID, MailboxACL.command().key(key).rights(rights).asReplacement()); assertThat(cassandraACLMapper.getACL(MAILBOX_ID).join()).isEqualTo(new MailboxACL().union(key, rights)); }
@Test void updateInvalidACLShouldBeBasedOnEmptyACL(CassandraCluster cassandra) throws Exception { cassandra.getConf().execute( insertInto(CassandraACLTable.TABLE_NAME) .value(CassandraACLTable.ID, MAILBOX_ID.asUuid()) .value(CassandraACLTable.ACL, "{\"entries\":{\"bob\":invalid}}") .value(CassandraACLTable.VERSION, 1)); MailboxACL.EntryKey key = new MailboxACL.EntryKey("bob", MailboxACL.NameType.user, false); MailboxACL.Rfc4314Rights rights = new MailboxACL.Rfc4314Rights(MailboxACL.Right.Read); cassandraACLMapper.updateACL(MAILBOX_ID, MailboxACL.command().key(key).rights(rights).asAddition()); assertThat(cassandraACLMapper.getACL(MAILBOX_ID).join()).isEqualTo(new MailboxACL().union(key, rights)); }
@Test public void addedEntriesShouldReturnNewEntryWhenAddedEntry() throws Exception { PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff( MailboxACL.EMPTY, MailboxACL.EMPTY.apply( MailboxACL.command() .key(USER_ENTRY_KEY) .rights(RIGHTS) .asAddition())); assertThat(positiveUserAclDiff.addedEntries()) .containsOnly(new Entry(USER_ENTRY_KEY, RIGHTS)); }
@Test public void removedEntriesShouldReturnEntryWhenRemovedEntry() throws Exception { ACLDiff aclDiff = ACLDiff.computeDiff( MailboxACL.EMPTY.apply( MailboxACL.command() .key(ENTRY_KEY) .rights(RIGHTS) .asAddition()), MailboxACL.EMPTY); assertThat(aclDiff.removedEntries()) .containsOnly(new MailboxACL.Entry(ENTRY_KEY, RIGHTS)); }
@Test public void removedEntriesShouldReturnEntryWhenRemovedEntry() throws Exception { PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff( MailboxACL.EMPTY.apply( MailboxACL.command() .key(USER_ENTRY_KEY) .rights(RIGHTS) .asAddition()), MailboxACL.EMPTY); assertThat(positiveUserAclDiff.removedEntries()) .containsOnly(new Entry(USER_ENTRY_KEY, RIGHTS)); }
@Test public void addedEntriesShouldReturnNewEntryWhenAddedEntry() throws Exception { ACLDiff aclDiff = ACLDiff.computeDiff( MailboxACL.EMPTY, MailboxACL.EMPTY.apply( MailboxACL.command() .key(ENTRY_KEY) .rights(RIGHTS) .asAddition())); assertThat(aclDiff.addedEntries()) .containsOnly(new MailboxACL.Entry(ENTRY_KEY, RIGHTS)); }