http://git-wip-us.apache.org/repos/asf/james-project/blob/f388ff94/mailbox/api/src/test/java/org/apache/james/mailbox/model/Rfc4314RightsTest.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/Rfc4314RightsTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/Rfc4314RightsTest.java index 45541a4..ee89e35 100644 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/model/Rfc4314RightsTest.java +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/Rfc4314RightsTest.java @@ -20,7 +20,18 @@ package org.apache.james.mailbox.model; +import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.Administer; +import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.CreateMailbox; +import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.DeleteMailbox; +import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.Insert; +import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.Lookup; +import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.PerformExpunge; +import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.Post; +import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.Read; +import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.Write; +import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.WriteSeenFlag; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import org.apache.james.mailbox.exception.UnsupportedRightException; import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights; @@ -84,9 +95,10 @@ public class Rfc4314RightsTest { assertThat(aeik.except(lprs)).isEqualTo(aeik); } - @Test(expected=UnsupportedRightException.class) + @Test public void rfc4314RightsShouldThrowWhenUnknownFlag() throws UnsupportedRightException { - new SimpleMailboxACL.Rfc4314Rights("z"); + assertThatThrownBy(() -> new SimpleMailboxACL.Rfc4314Rights("z")) + .isInstanceOf(UnsupportedRightException.class); } @Test @@ -97,17 +109,17 @@ public class Rfc4314RightsTest { @Test public void fullRightsShouldContainsAllRights() { assertThat(full).containsOnly( - Rfc4314Rights.a_Administer_RIGHT, - Rfc4314Rights.e_PerformExpunge_RIGHT, - Rfc4314Rights.i_Insert_RIGHT, - Rfc4314Rights.k_CreateMailbox_RIGHT, - Rfc4314Rights.l_Lookup_RIGHT, - Rfc4314Rights.p_Post_RIGHT, - Rfc4314Rights.r_Read_RIGHT, - Rfc4314Rights.s_WriteSeenFlag_RIGHT, - Rfc4314Rights.t_DeleteMessages_RIGHT, - Rfc4314Rights.w_Write_RIGHT, - Rfc4314Rights.x_DeleteMailbox_RIGHT); + Administer, + PerformExpunge, + Insert, + CreateMailbox, + Lookup, + Post, + Read, + WriteSeenFlag, + SimpleMailboxACL.Right.DeleteMessages, + SimpleMailboxACL.Right.Write, + SimpleMailboxACL.Right.DeleteMailbox); } @Test @@ -118,47 +130,47 @@ public class Rfc4314RightsTest { @Test public void rightsShouldContainsSpecificRightsWhenAEIK() { assertThat(aeik).containsOnly( - Rfc4314Rights.a_Administer_RIGHT, - Rfc4314Rights.e_PerformExpunge_RIGHT, - Rfc4314Rights.i_Insert_RIGHT, - Rfc4314Rights.k_CreateMailbox_RIGHT); + Administer, + PerformExpunge, + Insert, + CreateMailbox); } @Test public void rightsShouldContainsSpecificRightsWhenLPRS() { assertThat(lprs).containsOnly( - Rfc4314Rights.l_Lookup_RIGHT, - Rfc4314Rights.p_Post_RIGHT, - Rfc4314Rights.r_Read_RIGHT, - Rfc4314Rights.s_WriteSeenFlag_RIGHT); + Lookup, + Post, + Read, + WriteSeenFlag); } @Test public void rightsShouldContainsSpecificRightsWhenTWX() { assertThat(twx).containsOnly( - Rfc4314Rights.t_DeleteMessages_RIGHT, - Rfc4314Rights.w_Write_RIGHT, - Rfc4314Rights.x_DeleteMailbox_RIGHT); + SimpleMailboxACL.Right.DeleteMessages, + SimpleMailboxACL.Right.Write, + SimpleMailboxACL.Right.DeleteMailbox); } @Test public void getValueShouldReturnSigmaWhenAeik() throws UnsupportedRightException { - assertThat(aeik.getValue()).isEqualTo(Rfc4314Rights.a_Administer_MASK | Rfc4314Rights.e_PerformExpunge_MASK | Rfc4314Rights.i_Insert_MASK | Rfc4314Rights.k_CreateMailbox_MASK); + assertThat(aeik).containsExactly(Administer, PerformExpunge, Insert, CreateMailbox); } @Test public void getValueShouldReturnSigmaWhenLprs() throws UnsupportedRightException { - assertThat(lprs.getValue()).isEqualTo(Rfc4314Rights.l_Lookup_MASK | Rfc4314Rights.p_Post_MASK | Rfc4314Rights.s_WriteSeenFlag_MASK | Rfc4314Rights.r_Read_MASK); + assertThat(lprs).containsExactly(Lookup, Post, Read, WriteSeenFlag); } @Test public void getValueShouldReturnSigmaWhenTwx() throws UnsupportedRightException { - assertThat(twx.getValue()).isEqualTo(Rfc4314Rights.t_DeleteMessages_MASK | Rfc4314Rights.w_Write_MASK | Rfc4314Rights.x_DeleteMailbox_MASK); + assertThat(twx).containsExactly(SimpleMailboxACL.Right.DeleteMessages, Write, DeleteMailbox); } @Test public void getValueShouldReturnEmptyWhenNone() throws UnsupportedRightException { - assertThat(new SimpleMailboxACL.Rfc4314Rights("").getValue()).isEqualTo(Rfc4314Rights.EMPTY_MASK); + assertThat(new SimpleMailboxACL.Rfc4314Rights("")).isEmpty(); } @Test @@ -196,8 +208,8 @@ public class Rfc4314RightsTest { assertThat(lprs.union(none)).isEqualTo(lprs); } - @Test(expected=NullPointerException.class) + @Test public void unionShouldThrowWhenAppliedWithNull() throws UnsupportedRightException { - assertThat(lprs.union(null)).isEqualTo(lprs); + assertThatThrownBy(() -> lprs.union(null)).isInstanceOf(NullPointerException.class); } }
http://git-wip-us.apache.org/repos/asf/james-project/blob/f388ff94/mailbox/api/src/test/java/org/apache/james/mailbox/model/SimpleMailboxACLEntryKeyTest.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/SimpleMailboxACLEntryKeyTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/SimpleMailboxACLEntryKeyTest.java index 6bfed79..92d4ce9 100644 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/model/SimpleMailboxACLEntryKeyTest.java +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/SimpleMailboxACLEntryKeyTest.java @@ -20,10 +20,9 @@ package org.apache.james.mailbox.model; -import static org.junit.Assert.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; import org.apache.james.mailbox.exception.UnsupportedRightException; -import org.apache.james.mailbox.model.MailboxACL.MailboxACLEntryKey; import org.apache.james.mailbox.model.MailboxACL.NameType; import org.apache.james.mailbox.model.MailboxACL.SpecialName; import org.apache.james.mailbox.model.SimpleMailboxACL.SimpleMailboxACLEntryKey; @@ -33,111 +32,126 @@ import org.junit.Test; * @author Peter Palaga */ public class SimpleMailboxACLEntryKeyTest { - private static final String GROUP_1 = "group1"; - private static final String USER_1 = "user1"; - + @Test public void testUser() throws UnsupportedRightException { - - MailboxACLEntryKey k = new SimpleMailboxACLEntryKey(USER_1); - assertEquals(k.isNegative(), false); - assertEquals(k.getNameType(), NameType.user); - assertEquals(k.getName(), USER_1); - + assertThat(SimpleMailboxACLEntryKey.deserialize(USER_1)) + .isEqualTo(new SimpleMailboxACLEntryKey(USER_1, NameType.user, false)); } - + @Test public void testNegativeUser() throws UnsupportedRightException { - - MailboxACLEntryKey k = new SimpleMailboxACLEntryKey(MailboxACL.DEFAULT_NEGATIVE_MARKER + USER_1); - assertEquals(k.isNegative(), true); - assertEquals(k.getNameType(), NameType.user); - assertEquals(k.getName(), USER_1); - + assertThat(SimpleMailboxACLEntryKey.deserialize(MailboxACL.DEFAULT_NEGATIVE_MARKER + USER_1)) + .isEqualTo(new SimpleMailboxACLEntryKey(USER_1, NameType.user, true)); } - @Test public void testGroup() throws UnsupportedRightException { - - MailboxACLEntryKey k = new SimpleMailboxACLEntryKey(MailboxACL.DEFAULT_GROUP_MARKER + GROUP_1); - assertEquals(k.isNegative(), false); - assertEquals(k.getNameType(), NameType.group); - assertEquals(k.getName(), GROUP_1); - + assertThat(SimpleMailboxACLEntryKey.deserialize(MailboxACL.DEFAULT_GROUP_MARKER + GROUP_1)) + .isEqualTo(new SimpleMailboxACLEntryKey(GROUP_1, NameType.group, false)); } - + @Test public void testNegativeGroup() throws UnsupportedRightException { - - MailboxACLEntryKey k = new SimpleMailboxACLEntryKey("" + MailboxACL.DEFAULT_NEGATIVE_MARKER + MailboxACL.DEFAULT_GROUP_MARKER + GROUP_1); - assertEquals(k.isNegative(), true); - assertEquals(k.getNameType(), NameType.group); - assertEquals(k.getName(), GROUP_1); - + assertThat(SimpleMailboxACLEntryKey.deserialize(String.valueOf(MailboxACL.DEFAULT_NEGATIVE_MARKER) + MailboxACL.DEFAULT_GROUP_MARKER + GROUP_1)) + .isEqualTo(new SimpleMailboxACLEntryKey(GROUP_1, NameType.group, true)); } - @Test public void testOwner() throws UnsupportedRightException { - - MailboxACLEntryKey k = new SimpleMailboxACLEntryKey(SpecialName.owner.toString()); - assertEquals(k.isNegative(), false); - assertEquals(k.getNameType(), NameType.special); - assertEquals(k.getName(), SpecialName.owner.toString()); - + assertThat(SimpleMailboxACLEntryKey.deserialize(SpecialName.owner.toString())) + .isEqualTo(new SimpleMailboxACLEntryKey(SpecialName.owner.toString(), NameType.special, false)); } - + @Test public void testNegativeOwner() throws UnsupportedRightException { - - MailboxACLEntryKey k = new SimpleMailboxACLEntryKey(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.owner.toString()); - assertEquals(k.isNegative(), true); - assertEquals(k.getNameType(), NameType.special); - assertEquals(k.getName(), SpecialName.owner.toString()); - + assertThat(SimpleMailboxACLEntryKey.deserialize(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.owner.toString())) + .isEqualTo(new SimpleMailboxACLEntryKey(SpecialName.owner.toString(), NameType.special, true)); } @Test public void testAnybody() throws UnsupportedRightException { - - MailboxACLEntryKey k = new SimpleMailboxACLEntryKey(SpecialName.anybody.toString()); - assertEquals(k.isNegative(), false); - assertEquals(k.getNameType(), NameType.special); - assertEquals(k.getName(), SpecialName.anybody.toString()); - + assertThat(SimpleMailboxACLEntryKey.deserialize(SpecialName.anybody.toString())) + .isEqualTo(new SimpleMailboxACLEntryKey(SpecialName.anybody.toString(), NameType.special, false)); } - + @Test public void testNegativeAnybody() throws UnsupportedRightException { - - MailboxACLEntryKey k = new SimpleMailboxACLEntryKey(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.anybody.toString()); - assertEquals(k.isNegative(), true); - assertEquals(k.getNameType(), NameType.special); - assertEquals(k.getName(), SpecialName.anybody.toString()); - + assertThat(SimpleMailboxACLEntryKey.deserialize(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.anybody.toString())) + .isEqualTo(new SimpleMailboxACLEntryKey(SpecialName.anybody.toString(), NameType.special, true)); } - @Test public void testAuthenticated() throws UnsupportedRightException { - - MailboxACLEntryKey k = new SimpleMailboxACLEntryKey(SpecialName.authenticated.toString()); - assertEquals(k.isNegative(), false); - assertEquals(k.getNameType(), NameType.special); - assertEquals(k.getName(), SpecialName.authenticated.toString()); - + assertThat(SimpleMailboxACLEntryKey.deserialize(SpecialName.authenticated.toString())) + .isEqualTo(new SimpleMailboxACLEntryKey(SpecialName.authenticated.toString(), NameType.special, false)); } - + @Test public void testNegativeAuthenticated() throws UnsupportedRightException { - - MailboxACLEntryKey k = new SimpleMailboxACLEntryKey(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.authenticated.toString()); - assertEquals(k.isNegative(), true); - assertEquals(k.getNameType(), NameType.special); - assertEquals(k.getName(), SpecialName.authenticated.toString()); - + assertThat(SimpleMailboxACLEntryKey.deserialize(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.authenticated.toString())) + .isEqualTo(new SimpleMailboxACLEntryKey(SpecialName.authenticated.toString(), NameType.special, true)); + } + @Test + public void testSerializeUser() throws UnsupportedRightException { + assertThat(new SimpleMailboxACLEntryKey(USER_1, NameType.user, false).serialize()) + .isEqualTo(USER_1); + } + + @Test + public void testSerializeNegativeUser() throws UnsupportedRightException { + assertThat(new SimpleMailboxACLEntryKey(USER_1, NameType.user, true).serialize()) + .isEqualTo(MailboxACL.DEFAULT_NEGATIVE_MARKER + USER_1); + } + + @Test + public void testSerializeGroup() throws UnsupportedRightException { + assertThat(new SimpleMailboxACLEntryKey(GROUP_1, NameType.group, false).serialize()) + .isEqualTo(MailboxACL.DEFAULT_GROUP_MARKER + GROUP_1); + } + + @Test + public void testSerializeNegativeGroup() throws UnsupportedRightException { + assertThat(new SimpleMailboxACLEntryKey(GROUP_1, NameType.group, true).serialize()) + .isEqualTo(String.valueOf(MailboxACL.DEFAULT_NEGATIVE_MARKER) + MailboxACL.DEFAULT_GROUP_MARKER + GROUP_1); + } + + @Test + public void testSerializeOwner() throws UnsupportedRightException { + assertThat(new SimpleMailboxACLEntryKey(SpecialName.owner.toString(), NameType.special, false).serialize()) + .isEqualTo(SpecialName.owner.toString()); + } + + @Test + public void testSerializeNegativeOwner() throws UnsupportedRightException { + assertThat(new SimpleMailboxACLEntryKey(SpecialName.owner.toString(), NameType.special, true).serialize()) + .isEqualTo(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.owner.toString()); + } + + @Test + public void testSerializeAnybody() throws UnsupportedRightException { + assertThat(new SimpleMailboxACLEntryKey(SpecialName.anybody.toString(), NameType.special, false).serialize()) + .isEqualTo(SpecialName.anybody.toString()); + } + + @Test + public void testSerializeNegativeAnybody() throws UnsupportedRightException { + assertThat(new SimpleMailboxACLEntryKey(SpecialName.anybody.toString(), NameType.special, true).serialize()) + .isEqualTo(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.anybody.toString()); + } + + + @Test + public void testSerializeAuthenticated() throws UnsupportedRightException { + assertThat(new SimpleMailboxACLEntryKey(SpecialName.authenticated.toString(), NameType.special, false).serialize()) + .isEqualTo(SpecialName.authenticated.toString()); + } + + @Test + public void testSerializeNegativeAuthenticated() throws UnsupportedRightException { + assertThat(new SimpleMailboxACLEntryKey(SpecialName.authenticated.toString(), NameType.special, true).serialize()) + .isEqualTo(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.authenticated.toString()); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/f388ff94/mailbox/api/src/test/java/org/apache/james/mailbox/model/SimpleMailboxACLTest.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/SimpleMailboxACLTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/SimpleMailboxACLTest.java index 9d22e27..ed359c3 100644 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/model/SimpleMailboxACLTest.java +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/SimpleMailboxACLTest.java @@ -20,6 +20,7 @@ package org.apache.james.mailbox.model; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import java.util.HashMap; @@ -30,6 +31,7 @@ import org.apache.james.mailbox.exception.UnsupportedRightException; import org.apache.james.mailbox.model.MailboxACL.MailboxACLEntryKey; import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights; import org.apache.james.mailbox.model.SimpleMailboxACL.Rfc4314Rights; +import org.apache.james.mailbox.model.SimpleMailboxACL.SimpleMailboxACLEntry; import org.apache.james.mailbox.model.SimpleMailboxACL.SimpleMailboxACLEntryKey; import org.junit.Before; import org.junit.Test; @@ -90,16 +92,18 @@ public class SimpleMailboxACLTest { Map<MailboxACLEntryKey, MailboxACLRights> foundEntries = result.getEntries(); - assertEquals(foundEntries, expectedEntries); + assertThat(foundEntries) + .hasSize(expectedEntries.size()) + .containsAllEntriesOf(expectedEntries); } @Test public void testUnionACLExisting() throws UnsupportedRightException { Map<MailboxACLEntryKey, MailboxACLRights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); - expectedEntries.put(new SimpleMailboxACLEntryKey(USER_1), new Rfc4314Rights(aeik + lprs)); + expectedEntries.put(SimpleMailboxACLEntryKey.deserialize(USER_1), new Rfc4314Rights(aeik + lprs)); - MailboxACL toAdd = new SimpleMailboxACL(new SimpleMailboxACL.SimpleMailboxACLEntry[] { new SimpleMailboxACL.SimpleMailboxACLEntry(USER_1, lprs) }); + MailboxACL toAdd = new SimpleMailboxACL(new SimpleMailboxACLEntry(USER_1, lprs)); MailboxACL result = u1u2g1g2ACL.union(toAdd); Map<MailboxACLEntryKey, MailboxACLRights> foundEntries = result.getEntries(); @@ -111,9 +115,9 @@ public class SimpleMailboxACLTest { public void testUnionEntryExisting() throws UnsupportedRightException { Map<MailboxACLEntryKey, MailboxACLRights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); - expectedEntries.put(new SimpleMailboxACLEntryKey(USER_1), new Rfc4314Rights(aeik + lprs)); + expectedEntries.put(SimpleMailboxACLEntryKey.deserialize(USER_1), new Rfc4314Rights(aeik + lprs)); - MailboxACL result = u1u2g1g2ACL.union(new SimpleMailboxACLEntryKey(USER_1), new Rfc4314Rights(lprs)); + MailboxACL result = u1u2g1g2ACL.union(SimpleMailboxACLEntryKey.deserialize(USER_1), new Rfc4314Rights(lprs)); Map<MailboxACLEntryKey, MailboxACLRights> foundEntries = result.getEntries(); @@ -161,54 +165,62 @@ public class SimpleMailboxACLTest { public void testExceptACLExisting() throws UnsupportedRightException { Map<MailboxACLEntryKey, MailboxACLRights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); - expectedEntries.put(new SimpleMailboxACLEntryKey(USER_1), new Rfc4314Rights(ik)); + expectedEntries.put(SimpleMailboxACLEntryKey.deserialize(USER_1), new Rfc4314Rights(ik)); - MailboxACL toRemove = new SimpleMailboxACL(new SimpleMailboxACL.SimpleMailboxACLEntry[] { new SimpleMailboxACL.SimpleMailboxACLEntry(USER_1, ae) }); + MailboxACL toRemove = new SimpleMailboxACL(new SimpleMailboxACLEntry(USER_1, ae)); MailboxACL result = u1u2g1g2ACL.except(toRemove); Map<MailboxACLEntryKey, MailboxACLRights> foundEntries = result.getEntries(); - assertEquals(foundEntries, expectedEntries); + assertThat(foundEntries) + .hasSize(expectedEntries.size()) + .containsAllEntriesOf(expectedEntries); } @Test public void testExceptEntryExisting() throws UnsupportedRightException { Map<MailboxACLEntryKey, MailboxACLRights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); - expectedEntries.put(new SimpleMailboxACLEntryKey(USER_1), new Rfc4314Rights(ik)); + expectedEntries.put(SimpleMailboxACLEntryKey.deserialize(USER_1), new Rfc4314Rights(ik)); - MailboxACL result = u1u2g1g2ACL.except(new SimpleMailboxACLEntryKey(USER_1), new Rfc4314Rights(ae)); + MailboxACL result = u1u2g1g2ACL.except(SimpleMailboxACLEntryKey.deserialize(USER_1), new Rfc4314Rights(ae)); Map<MailboxACLEntryKey, MailboxACLRights> foundEntries = result.getEntries(); - assertEquals(foundEntries, expectedEntries); + assertThat(foundEntries) + .hasSize(expectedEntries.size()) + .containsAllEntriesOf(expectedEntries); } @Test public void testExceptACLFull() throws UnsupportedRightException { Map<MailboxACLEntryKey, MailboxACLRights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); - expectedEntries.remove(new SimpleMailboxACLEntryKey(USER_1)); + expectedEntries.remove(SimpleMailboxACLEntryKey.deserialize(USER_1)); - MailboxACL toRemove = new SimpleMailboxACL(new SimpleMailboxACL.SimpleMailboxACLEntry[] { new SimpleMailboxACL.SimpleMailboxACLEntry(USER_1, SimpleMailboxACL.FULL_RIGHTS.serialize()) }); + MailboxACL toRemove = new SimpleMailboxACL(new SimpleMailboxACLEntry(USER_1, SimpleMailboxACL.FULL_RIGHTS.serialize())); MailboxACL result = u1u2g1g2ACL.except(toRemove); Map<MailboxACLEntryKey, MailboxACLRights> foundEntries = result.getEntries(); - assertEquals(expectedEntries, foundEntries); + assertThat(foundEntries) + .hasSize(expectedEntries.size()) + .containsAllEntriesOf(expectedEntries); } @Test public void testExceptEntryFull() throws UnsupportedRightException { Map<MailboxACLEntryKey, MailboxACLRights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); - expectedEntries.remove(new SimpleMailboxACLEntryKey(USER_1)); + expectedEntries.remove(SimpleMailboxACLEntryKey.deserialize(USER_1)); - MailboxACL result = u1u2g1g2ACL.except(new SimpleMailboxACLEntryKey(USER_1), SimpleMailboxACL.FULL_RIGHTS); + MailboxACL result = u1u2g1g2ACL.except(SimpleMailboxACLEntryKey.deserialize(USER_1), SimpleMailboxACL.FULL_RIGHTS); Map<MailboxACLEntryKey, MailboxACLRights> foundEntries = result.getEntries(); - assertEquals(expectedEntries, foundEntries); + assertThat(foundEntries) + .hasSize(expectedEntries.size()) + .containsAllEntriesOf(expectedEntries); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/f388ff94/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java index 1ac0071..6976f76 100644 --- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java @@ -83,7 +83,7 @@ public class CassandraACLMapperTest { .isEqualTo( SimpleMailboxACL.EMPTY.union( new SimpleMailboxACL.SimpleMailboxACLEntryKey("bob", MailboxACL.NameType.user, false), - new SimpleMailboxACL.Rfc4314Rights(SimpleMailboxACL.Rfc4314Rights.r_Read_RIGHT)) + new SimpleMailboxACL.Rfc4314Rights(SimpleMailboxACL.Right.Read)) ); } @@ -106,7 +106,7 @@ public class CassandraACLMapperTest { @Test public void addACLWhenNoneStoredShouldReturnUpdatedACL() throws Exception { SimpleMailboxACL.SimpleMailboxACLEntryKey key = new SimpleMailboxACL.SimpleMailboxACLEntryKey("bob", MailboxACL.NameType.user, false); - SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(new SimpleMailboxACL.SimpleMailboxACLRight('r')); + SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(SimpleMailboxACL.Right.Read); cassandraACLMapper.updateACL(new SimpleMailboxACL.SimpleMailboxACLCommand(key, MailboxACL.EditMode.ADD, rights)); assertThat(cassandraACLMapper.getACL().join()).isEqualTo(new SimpleMailboxACL().union(key, rights)); } @@ -114,7 +114,7 @@ public class CassandraACLMapperTest { @Test public void modifyACLWhenStoredShouldReturnUpdatedACL() throws MailboxException { SimpleMailboxACL.SimpleMailboxACLEntryKey keyBob = new SimpleMailboxACL.SimpleMailboxACLEntryKey("bob", MailboxACL.NameType.user, false); - SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(new SimpleMailboxACL.SimpleMailboxACLRight('r')); + SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(SimpleMailboxACL.Right.Read); cassandraACLMapper.updateACL(new SimpleMailboxACL.SimpleMailboxACLCommand(keyBob, MailboxACL.EditMode.ADD, rights)); SimpleMailboxACL.SimpleMailboxACLEntryKey keyAlice = new SimpleMailboxACL.SimpleMailboxACLEntryKey("alice", MailboxACL.NameType.user, false); cassandraACLMapper.updateACL(new SimpleMailboxACL.SimpleMailboxACLCommand(keyAlice, MailboxACL.EditMode.ADD, rights)); @@ -124,7 +124,7 @@ public class CassandraACLMapperTest { @Test public void removeWhenStoredShouldReturnUpdatedACL() throws MailboxException { SimpleMailboxACL.SimpleMailboxACLEntryKey key = new SimpleMailboxACL.SimpleMailboxACLEntryKey("bob", MailboxACL.NameType.user, false); - SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(new SimpleMailboxACL.SimpleMailboxACLRight('r')); + SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(SimpleMailboxACL.Right.Read); cassandraACLMapper.updateACL(new SimpleMailboxACL.SimpleMailboxACLCommand(key, MailboxACL.EditMode.ADD, rights)); cassandraACLMapper.updateACL(new SimpleMailboxACL.SimpleMailboxACLCommand(key, MailboxACL.EditMode.REMOVE, rights)); assertThat(cassandraACLMapper.getACL().join()).isEqualTo(SimpleMailboxACL.EMPTY); @@ -133,7 +133,7 @@ public class CassandraACLMapperTest { @Test public void replaceForSingleKeyWithNullRightsWhenSingleKeyStoredShouldReturnEmptyACL() throws MailboxException { SimpleMailboxACL.SimpleMailboxACLEntryKey key = new SimpleMailboxACL.SimpleMailboxACLEntryKey("bob", MailboxACL.NameType.user, false); - SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(new SimpleMailboxACL.SimpleMailboxACLRight('r')); + SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(SimpleMailboxACL.Right.Read); cassandraACLMapper.updateACL(new SimpleMailboxACL.SimpleMailboxACLCommand(key, MailboxACL.EditMode.ADD, rights)); cassandraACLMapper.updateACL(new SimpleMailboxACL.SimpleMailboxACLCommand(key, MailboxACL.EditMode.REPLACE, null)); assertThat(cassandraACLMapper.getACL().join()).isEqualTo(SimpleMailboxACL.EMPTY); @@ -142,7 +142,7 @@ public class CassandraACLMapperTest { @Test public void replaceWhenNotStoredShouldUpdateACLEntry() throws MailboxException { SimpleMailboxACL.SimpleMailboxACLEntryKey key = new SimpleMailboxACL.SimpleMailboxACLEntryKey("bob", MailboxACL.NameType.user, false); - SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(new SimpleMailboxACL.SimpleMailboxACLRight('r')); + SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(SimpleMailboxACL.Right.Read); cassandraACLMapper.updateACL(new SimpleMailboxACL.SimpleMailboxACLCommand(key, MailboxACL.EditMode.REPLACE, rights)); assertThat(cassandraACLMapper.getACL().join()).isEqualTo(new SimpleMailboxACL().union(key, rights)); } @@ -156,7 +156,7 @@ public class CassandraACLMapperTest { .value(CassandraACLTable.VERSION, 1) ); SimpleMailboxACL.SimpleMailboxACLEntryKey key = new SimpleMailboxACL.SimpleMailboxACLEntryKey("bob", MailboxACL.NameType.user, false); - SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(new SimpleMailboxACL.SimpleMailboxACLRight('r')); + SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(SimpleMailboxACL.Right.Read); cassandraACLMapper.updateACL(new SimpleMailboxACL.SimpleMailboxACLCommand(key, MailboxACL.EditMode.ADD, rights)); assertThat(cassandraACLMapper.getACL().join()).isEqualTo(new SimpleMailboxACL().union(key, rights)); } @@ -165,7 +165,7 @@ public class CassandraACLMapperTest { public void twoConcurrentUpdatesWhenNoACEStoredShouldReturnACEWithTwoEntries() throws Exception { CountDownLatch countDownLatch = new CountDownLatch(2); SimpleMailboxACL.SimpleMailboxACLEntryKey keyBob = new SimpleMailboxACL.SimpleMailboxACLEntryKey("bob", MailboxACL.NameType.user, false); - SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(new SimpleMailboxACL.SimpleMailboxACLRight('r')); + SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(SimpleMailboxACL.Right.Read); SimpleMailboxACL.SimpleMailboxACLEntryKey keyAlice = new SimpleMailboxACL.SimpleMailboxACLEntryKey("alice", MailboxACL.NameType.user, false); Future<Boolean> future1 = performACLUpdateInExecutor(executor, keyBob, rights, countDownLatch::countDown); Future<Boolean> future2 = performACLUpdateInExecutor(executor, keyAlice, rights, countDownLatch::countDown); @@ -177,7 +177,7 @@ public class CassandraACLMapperTest { public void twoConcurrentUpdatesWhenStoredShouldReturnACEWithTwoEntries() throws Exception { CountDownLatch countDownLatch = new CountDownLatch(2); SimpleMailboxACL.SimpleMailboxACLEntryKey keyBenwa = new SimpleMailboxACL.SimpleMailboxACLEntryKey("benwa", MailboxACL.NameType.user, false); - SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(new SimpleMailboxACL.SimpleMailboxACLRight('r')); + SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(SimpleMailboxACL.Right.Read); cassandraACLMapper.updateACL(new SimpleMailboxACL.SimpleMailboxACLCommand(keyBenwa, MailboxACL.EditMode.ADD, rights)); SimpleMailboxACL.SimpleMailboxACLEntryKey keyBob = new SimpleMailboxACL.SimpleMailboxACLEntryKey("bob", MailboxACL.NameType.user, false); SimpleMailboxACL.SimpleMailboxACLEntryKey keyAlice = new SimpleMailboxACL.SimpleMailboxACLEntryKey("alice", MailboxACL.NameType.user, false); http://git-wip-us.apache.org/repos/asf/james-project/blob/f388ff94/mailbox/store/src/main/java/org/apache/james/mailbox/store/json/SimpleMailboxACLJsonConverter.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/json/SimpleMailboxACLJsonConverter.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/json/SimpleMailboxACLJsonConverter.java index fbd2c1f..62f9c76 100644 --- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/json/SimpleMailboxACLJsonConverter.java +++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/json/SimpleMailboxACLJsonConverter.java @@ -19,29 +19,29 @@ package org.apache.james.mailbox.store.json; +import java.io.IOException; + +import org.apache.james.mailbox.model.MailboxACL; +import org.apache.james.mailbox.model.SimpleMailboxACL; + import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.KeyDeserializer; import com.fasterxml.jackson.databind.ObjectMapper; - import com.fasterxml.jackson.databind.module.SimpleModule; -import org.apache.james.mailbox.model.MailboxACL; -import org.apache.james.mailbox.model.SimpleMailboxACL; - -import java.io.IOException; public class SimpleMailboxACLJsonConverter { interface Rfc4314RightsMixIn { @JsonValue - int getValue(); + int serializeAsInteger(); } static class ACLKeyDeserializer extends KeyDeserializer { @Override - public Object deserializeKey(String key, DeserializationContext deserializationContext ) throws IOException { - return new SimpleMailboxACL.SimpleMailboxACLEntryKey(key); + public Object deserializeKey(String key, DeserializationContext deserializationContext) throws IOException { + return SimpleMailboxACL.SimpleMailboxACLEntryKey.deserialize(key); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/f388ff94/mailbox/store/src/test/java/org/apache/james/mailbox/store/json/SimpleMailboxACLJsonConverterTest.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/json/SimpleMailboxACLJsonConverterTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/json/SimpleMailboxACLJsonConverterTest.java index 7eb7bea..b1ae6aa 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/json/SimpleMailboxACLJsonConverterTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/json/SimpleMailboxACLJsonConverterTest.java @@ -20,13 +20,23 @@ package org.apache.james.mailbox.store.json; import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson; +import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.CreateMailbox; +import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.DeleteMailbox; +import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.DeleteMessages; +import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.Lookup; +import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.Post; +import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.Read; +import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.Write; +import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.WriteSeenFlag; import static org.assertj.core.api.Assertions.assertThat; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; import org.apache.james.mailbox.model.MailboxACL; import org.apache.james.mailbox.model.SimpleMailboxACL; +import org.apache.james.mailbox.model.SimpleMailboxACL.Rfc4314Rights; import org.junit.Test; import net.javacrumbs.jsonunit.core.Option; @@ -37,25 +47,26 @@ public class SimpleMailboxACLJsonConverterTest { private final Map<SimpleMailboxACL.MailboxACLEntryKey, MailboxACL.MailboxACLRights> map; public ACLMapBuilder() { - map = new HashMap<>(); + map = new LinkedHashMap<>(); } public ACLMapBuilder addSingleUserEntryToMap() { - SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(false, true, true, true, false, true, false, true, true, true, true); + Rfc4314Rights rights = new Rfc4314Rights(CreateMailbox, DeleteMailbox, DeleteMessages, Lookup, Post, Read, WriteSeenFlag, Write); SimpleMailboxACL.MailboxACLEntryKey key = new SimpleMailboxACL.SimpleMailboxACLEntryKey("user", MailboxACL.NameType.user, true); map.put(key, rights); return this; } public ACLMapBuilder addSingleSpecialEntryToMap() { - SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(false, false, true, true, false, true, false, true, false, true, true); + Rfc4314Rights rights = new Rfc4314Rights(DeleteMailbox, DeleteMessages, Lookup, Post, Write, WriteSeenFlag); SimpleMailboxACL.MailboxACLEntryKey key = new SimpleMailboxACL.SimpleMailboxACLEntryKey("special", MailboxACL.NameType.special, true); map.put(key, rights); return this; } public ACLMapBuilder addSingleGroupEntryToMap() { - SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(false, false, true, true, false, true, false, true, true, true, true); + + Rfc4314Rights rights = new Rfc4314Rights(DeleteMailbox, DeleteMessages, Lookup, Post, Read, Write, WriteSeenFlag); SimpleMailboxACL.MailboxACLEntryKey key = new SimpleMailboxACL.SimpleMailboxACLEntryKey("group", MailboxACL.NameType.group, true); map.put(key, rights); return this; @@ -109,19 +120,19 @@ public class SimpleMailboxACLJsonConverterTest { @Test public void singleUserEntryACLShouldBeWellDeSerialized() throws Exception { - assertThat(SimpleMailboxACLJsonConverter.toACL("{\"entries\":{\"-user\":2040}}")) + assertThatJson(SimpleMailboxACLJsonConverter.toACL("{\"entries\":{\"-user\":2040}}")) .isEqualTo(new ACLMapBuilder().addSingleUserEntryToMap().buildAsACL()); } @Test public void singleGroupEntryACLShouldBeWellDeSerialized() throws Exception { - assertThat(SimpleMailboxACLJsonConverter.toACL("{\"entries\":{\"-$group\":2032}}")) + assertThatJson(SimpleMailboxACLJsonConverter.toACL("{\"entries\":{\"-$group\":2032}}")) .isEqualTo(new ACLMapBuilder().addSingleGroupEntryToMap().buildAsACL()); } @Test public void multipleEntriesACLShouldBeWellDeSerialized() throws Exception { - assertThat(SimpleMailboxACLJsonConverter.toACL("{\"entries\":{\"-user\":2040,\"-$group\":2032}}")) + assertThatJson(SimpleMailboxACLJsonConverter.toACL("{\"entries\":{\"-user\":2040,\"-$group\":2032}}")) .isEqualTo(new ACLMapBuilder().addSingleUserEntryToMap().addSingleGroupEntryToMap().buildAsACL()); } http://git-wip-us.apache.org/repos/asf/james-project/blob/f388ff94/protocols/imap/src/main/java/org/apache/james/imap/processor/DeleteACLProcessor.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/DeleteACLProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/DeleteACLProcessor.java index f3b5ede..253d48c 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/processor/DeleteACLProcessor.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/DeleteACLProcessor.java @@ -41,7 +41,6 @@ import org.apache.james.mailbox.model.MailboxACL.EditMode; import org.apache.james.mailbox.model.MailboxACL.MailboxACLEntryKey; import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.model.SimpleMailboxACL; -import org.apache.james.mailbox.model.SimpleMailboxACL.Rfc4314Rights; import org.apache.james.mailbox.model.SimpleMailboxACL.SimpleMailboxACLEntryKey; import org.apache.james.metrics.api.MetricFactory; import org.apache.james.util.MDCBuilder; @@ -87,13 +86,13 @@ public class DeleteACLProcessor extends AbstractMailboxProcessor<DeleteACLReques * would be used if the mailbox did not exist, thus revealing no * existence information, much less the mailboxâs ACL. */ - if (!mailboxManager.hasRight(mailboxPath, Rfc4314Rights.l_Lookup_RIGHT, mailboxSession)) { + if (!mailboxManager.hasRight(mailboxPath, SimpleMailboxACL.Right.Lookup, mailboxSession)) { no(command, tag, responder, HumanReadableText.MAILBOX_NOT_FOUND); } /* RFC 4314 section 4. */ - else if (!mailboxManager.hasRight(mailboxPath, Rfc4314Rights.a_Administer_RIGHT, mailboxSession)) { + else if (!mailboxManager.hasRight(mailboxPath, SimpleMailboxACL.Right.Administer, mailboxSession)) { Object[] params = new Object[] { - Rfc4314Rights.a_Administer_RIGHT.toString(), + SimpleMailboxACL.Right.Administer.toString(), command.getName(), mailboxName }; @@ -102,7 +101,7 @@ public class DeleteACLProcessor extends AbstractMailboxProcessor<DeleteACLReques } else { - MailboxACLEntryKey key = new SimpleMailboxACLEntryKey(identifier); + MailboxACLEntryKey key = SimpleMailboxACLEntryKey.deserialize(identifier); // FIXME check if identifier is a valid user or group // FIXME Servers, when processing a command that has an identifier as a http://git-wip-us.apache.org/repos/asf/james-project/blob/f388ff94/protocols/imap/src/main/java/org/apache/james/imap/processor/GetACLProcessor.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/GetACLProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/GetACLProcessor.java index f2a0a3b..25d3ea0 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/processor/GetACLProcessor.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/GetACLProcessor.java @@ -40,7 +40,7 @@ import org.apache.james.mailbox.MessageManager.MetaData.FetchGroup; import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.exception.MailboxNotFoundException; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.SimpleMailboxACL.Rfc4314Rights; +import org.apache.james.mailbox.model.SimpleMailboxACL; import org.apache.james.metrics.api.MetricFactory; import org.apache.james.util.MDCBuilder; import org.slf4j.Logger; @@ -83,13 +83,13 @@ public class GetACLProcessor extends AbstractMailboxProcessor<GetACLRequest> imp * would be used if the mailbox did not exist, thus revealing no * existence information, much less the mailboxâs ACL. */ - if (!mailboxManager.hasRight(mailboxPath, Rfc4314Rights.l_Lookup_RIGHT, mailboxSession)) { + if (!mailboxManager.hasRight(mailboxPath, SimpleMailboxACL.Right.Lookup, mailboxSession)) { no(command, tag, responder, HumanReadableText.MAILBOX_NOT_FOUND); } /* RFC 4314 section 4. */ - else if (!mailboxManager.hasRight(mailboxPath, Rfc4314Rights.a_Administer_RIGHT, mailboxSession)) { + else if (!mailboxManager.hasRight(mailboxPath, SimpleMailboxACL.Right.Administer, mailboxSession)) { Object[] params = new Object[] { - Rfc4314Rights.a_Administer_RIGHT.toString(), + SimpleMailboxACL.Right.Administer.toString(), command.getName(), mailboxName }; http://git-wip-us.apache.org/repos/asf/james-project/blob/f388ff94/protocols/imap/src/main/java/org/apache/james/imap/processor/GetQuotaProcessor.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/GetQuotaProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/GetQuotaProcessor.java index 00c1d6b..ab3861e 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/processor/GetQuotaProcessor.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/GetQuotaProcessor.java @@ -84,7 +84,7 @@ public class GetQuotaProcessor extends AbstractMailboxProcessor<GetQuotaRequest> okComplete(command, tag, responder); } else { Object[] params = new Object[]{ - SimpleMailboxACL.Rfc4314Rights.r_Read_RIGHT.toString(), + SimpleMailboxACL.Right.Read.toString(), command.getName(), "Any mailbox of this user USER" }; @@ -101,7 +101,7 @@ public class GetQuotaProcessor extends AbstractMailboxProcessor<GetQuotaRequest> final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session); List<MailboxPath> mailboxList = quotaRootResolver.retrieveAssociatedMailboxes(quotaRootResolver.createQuotaRoot(quotaRoot), mailboxSession); for(MailboxPath mailboxPath : mailboxList) { - if(getMailboxManager().hasRight(mailboxPath, SimpleMailboxACL.Rfc4314Rights.r_Read_RIGHT, mailboxSession)) { + if(getMailboxManager().hasRight(mailboxPath, SimpleMailboxACL.Right.Read, mailboxSession)) { return true; } } http://git-wip-us.apache.org/repos/asf/james-project/blob/f388ff94/protocols/imap/src/main/java/org/apache/james/imap/processor/GetQuotaRootProcessor.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/GetQuotaRootProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/GetQuotaRootProcessor.java index fd45b64..6504e52 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/processor/GetQuotaRootProcessor.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/GetQuotaRootProcessor.java @@ -76,7 +76,7 @@ public class GetQuotaRootProcessor extends AbstractMailboxProcessor<GetQuotaRoot // First check mailbox exists try { - if (mailboxManager.hasRight(mailboxPath, SimpleMailboxACL.Rfc4314Rights.r_Read_RIGHT, mailboxSession)) { + if (mailboxManager.hasRight(mailboxPath, SimpleMailboxACL.Right.Read, mailboxSession)) { QuotaRoot quotaRoot = quotaRootResolver.getQuotaRoot(mailboxPath); Quota messageQuota = quotaManager.getMessageQuota(quotaRoot); // See RFC 2087 : response for STORAGE should be in KB. For more accuracy, we stores B, so conversion should be made @@ -87,7 +87,7 @@ public class GetQuotaRootProcessor extends AbstractMailboxProcessor<GetQuotaRoot okComplete(command, tag, responder); } else { Object[] params = new Object[]{ - SimpleMailboxACL.Rfc4314Rights.r_Read_RIGHT.toString(), + SimpleMailboxACL.Right.Read.toString(), command.getName(), message.getMailboxName() }; http://git-wip-us.apache.org/repos/asf/james-project/blob/f388ff94/protocols/imap/src/main/java/org/apache/james/imap/processor/ListRightsProcessor.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/ListRightsProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/ListRightsProcessor.java index da4d75c..fea89fe 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/processor/ListRightsProcessor.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/ListRightsProcessor.java @@ -39,7 +39,7 @@ import org.apache.james.mailbox.exception.MailboxNotFoundException; import org.apache.james.mailbox.model.MailboxACL.MailboxACLEntryKey; import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.SimpleMailboxACL.Rfc4314Rights; +import org.apache.james.mailbox.model.SimpleMailboxACL; import org.apache.james.mailbox.model.SimpleMailboxACL.SimpleMailboxACLEntryKey; import org.apache.james.metrics.api.MetricFactory; import org.apache.james.util.MDCBuilder; @@ -86,13 +86,13 @@ public class ListRightsProcessor extends AbstractMailboxProcessor<ListRightsRequ * would be used if the mailbox did not exist, thus revealing no * existence information, much less the mailboxâs ACL. */ - if (!mailboxManager.hasRight(mailboxPath, Rfc4314Rights.l_Lookup_RIGHT, mailboxSession)) { + if (!mailboxManager.hasRight(mailboxPath, SimpleMailboxACL.Right.Lookup, mailboxSession)) { no(command, tag, responder, HumanReadableText.MAILBOX_NOT_FOUND); } /* RFC 4314 section 4. */ - else if (!mailboxManager.hasRight(mailboxPath, Rfc4314Rights.a_Administer_RIGHT, mailboxSession)) { + else if (!mailboxManager.hasRight(mailboxPath, SimpleMailboxACL.Right.Administer, mailboxSession)) { Object[] params = new Object[] { - Rfc4314Rights.a_Administer_RIGHT.toString(), + SimpleMailboxACL.Right.Administer.toString(), command.getName(), mailboxName }; @@ -101,7 +101,7 @@ public class ListRightsProcessor extends AbstractMailboxProcessor<ListRightsRequ } else { - MailboxACLEntryKey key = new SimpleMailboxACLEntryKey(identifier); + MailboxACLEntryKey key = SimpleMailboxACLEntryKey.deserialize(identifier); // FIXME check if identifier is a valid user or group // FIXME Servers, when processing a command that has an identifier as a http://git-wip-us.apache.org/repos/asf/james-project/blob/f388ff94/protocols/imap/src/main/java/org/apache/james/imap/processor/MyRightsProcessor.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/MyRightsProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/MyRightsProcessor.java index 92d2430..1c2312e 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/processor/MyRightsProcessor.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/MyRightsProcessor.java @@ -39,7 +39,7 @@ import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.exception.MailboxNotFoundException; import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.SimpleMailboxACL.Rfc4314Rights; +import org.apache.james.mailbox.model.SimpleMailboxACL; import org.apache.james.metrics.api.MetricFactory; import org.apache.james.util.MDCBuilder; import org.slf4j.Logger; @@ -86,12 +86,12 @@ public class MyRightsProcessor extends AbstractMailboxProcessor<MyRightsRequest> * RFC 4314 section 4. * MYRIGHTS - any of the following rights is * required to perform the operation: "l", "r", "i", "k", "x", "a". */ - if (!myRights.contains(Rfc4314Rights.l_Lookup_RIGHT) - && !myRights.contains(Rfc4314Rights.r_Read_RIGHT) - && !myRights.contains(Rfc4314Rights.i_Insert_RIGHT) - && !myRights.contains(Rfc4314Rights.k_CreateMailbox_RIGHT) - && !myRights.contains(Rfc4314Rights.x_DeleteMailbox_RIGHT) - && !myRights.contains(Rfc4314Rights.a_Administer_RIGHT)) { + if (!myRights.contains(SimpleMailboxACL.Right.Lookup) + && !myRights.contains(SimpleMailboxACL.Right.Read) + && !myRights.contains(SimpleMailboxACL.Right.Insert) + && !myRights.contains(SimpleMailboxACL.Right.CreateMailbox) + && !myRights.contains(SimpleMailboxACL.Right.DeleteMailbox) + && !myRights.contains(SimpleMailboxACL.Right.Administer)) { no(command, tag, responder, HumanReadableText.MAILBOX_NOT_FOUND); } else { MyRightsResponse myRightsResponse = new MyRightsResponse(mailboxName, myRights); http://git-wip-us.apache.org/repos/asf/james-project/blob/f388ff94/protocols/imap/src/main/java/org/apache/james/imap/processor/SetACLProcessor.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/SetACLProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/SetACLProcessor.java index 0e136ab..455a439 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/processor/SetACLProcessor.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/SetACLProcessor.java @@ -105,13 +105,13 @@ public class SetACLProcessor extends AbstractMailboxProcessor<SetACLRequest> imp * would be used if the mailbox did not exist, thus revealing no * existence information, much less the mailboxâs ACL. */ - if (!mailboxManager.hasRight(mailboxPath, Rfc4314Rights.l_Lookup_RIGHT, mailboxSession)) { + if (!mailboxManager.hasRight(mailboxPath, SimpleMailboxACL.Right.Lookup, mailboxSession)) { no(command, tag, responder, HumanReadableText.MAILBOX_NOT_FOUND); } /* RFC 4314 section 4. */ - else if (!mailboxManager.hasRight(mailboxPath, Rfc4314Rights.a_Administer_RIGHT, mailboxSession)) { + else if (!mailboxManager.hasRight(mailboxPath, SimpleMailboxACL.Right.Administer, mailboxSession)) { Object[] params = new Object[] { - Rfc4314Rights.a_Administer_RIGHT.toString(), + SimpleMailboxACL.Right.Administer.toString(), command.getName(), mailboxName }; @@ -120,7 +120,7 @@ public class SetACLProcessor extends AbstractMailboxProcessor<SetACLRequest> imp } else { - MailboxACLEntryKey key = new SimpleMailboxACLEntryKey(identifier); + MailboxACLEntryKey key = SimpleMailboxACLEntryKey.deserialize(identifier); // FIXME check if identifier is a valid user or group // FIXME Servers, when processing a command that has an identifier as a http://git-wip-us.apache.org/repos/asf/james-project/blob/f388ff94/protocols/imap/src/test/java/org/apache/james/imap/processor/DeleteACLProcessorTest.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/DeleteACLProcessorTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/DeleteACLProcessorTest.java index 5a7519d..48bae00 100644 --- a/protocols/imap/src/test/java/org/apache/james/imap/processor/DeleteACLProcessorTest.java +++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/DeleteACLProcessorTest.java @@ -42,7 +42,6 @@ import org.apache.james.mailbox.model.MailboxACL.EditMode; import org.apache.james.mailbox.model.MailboxACL.MailboxACLEntryKey; import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.model.SimpleMailboxACL; -import org.apache.james.mailbox.model.SimpleMailboxACL.Rfc4314Rights; import org.apache.james.mailbox.model.SimpleMailboxACL.SimpleMailboxACLEntryKey; import org.apache.james.metrics.api.NoopMetricFactory; import org.jmock.Expectations; @@ -114,7 +113,7 @@ public class DeleteACLProcessorTest { deleteACLRequest = new DeleteACLRequest("TAG", ImapCommand.anyStateCommand("Name"), MAILBOX_NAME, USER_1); - user1Key = new SimpleMailboxACLEntryKey(USER_1); + user1Key = SimpleMailboxACLEntryKey.deserialize(USER_1); } @Test @@ -122,7 +121,7 @@ public class DeleteACLProcessorTest { Expectations expectations = prepareRightsExpectations(); - expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub))); + expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Lookup)), expectations.with(Expectations.same(mailboxSessionStub))); expectations.will(Expectations.returnValue(false)); expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class))); @@ -145,10 +144,10 @@ public class DeleteACLProcessorTest { public void testNoAdminRight() throws Exception { Expectations expectations = prepareRightsExpectations(); - expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub))); + expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Lookup)), expectations.with(Expectations.same(mailboxSessionStub))); expectations.will(Expectations.returnValue(true)); - expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub))); + expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Administer)), expectations.with(Expectations.same(mailboxSessionStub))); expectations.will(Expectations.returnValue(false)); expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class))); @@ -196,10 +195,10 @@ public class DeleteACLProcessorTest { expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class))); expectations.will(Expectations.returnValue(messageManagerStub)); - expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub))); + expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Lookup)), expectations.with(Expectations.same(mailboxSessionStub))); expectations.will(Expectations.returnValue(true)); - expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub))); + expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Administer)), expectations.with(Expectations.same(mailboxSessionStub))); expectations.will(Expectations.returnValue(true)); expectations.allowing(mailboxManagerStub).setRights(expectations.with(path), expectations.with(new SimpleMailboxACL.SimpleMailboxACLCommand(user1Key, EditMode.REPLACE, null)), expectations.with(mailboxSessionStub)); http://git-wip-us.apache.org/repos/asf/james-project/blob/f388ff94/protocols/imap/src/test/java/org/apache/james/imap/processor/GetACLProcessorTest.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/GetACLProcessorTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/GetACLProcessorTest.java index ad9417d..8a9391f 100644 --- a/protocols/imap/src/test/java/org/apache/james/imap/processor/GetACLProcessorTest.java +++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/GetACLProcessorTest.java @@ -41,7 +41,6 @@ import org.apache.james.mailbox.exception.MailboxNotFoundException; import org.apache.james.mailbox.model.MailboxACL; import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.model.SimpleMailboxACL; -import org.apache.james.mailbox.model.SimpleMailboxACL.Rfc4314Rights; import org.apache.james.metrics.api.NoopMetricFactory; import org.jmock.Expectations; import org.jmock.Mockery; @@ -116,7 +115,7 @@ public class GetACLProcessorTest { public void testNoListRight() throws Exception { Expectations expectations = prepareRightsExpectations(); - expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub))); + expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Lookup)), expectations.with(Expectations.same(mailboxSessionStub))); expectations.will(Expectations.returnValue(false)); expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class))); @@ -139,10 +138,10 @@ public class GetACLProcessorTest { public void testNoAdminRight() throws Exception { Expectations expectations = prepareRightsExpectations(); - expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub))); + expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Lookup)), expectations.with(Expectations.same(mailboxSessionStub))); expectations.will(Expectations.returnValue(true)); - expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub))); + expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Administer)), expectations.with(Expectations.same(mailboxSessionStub))); expectations.will(Expectations.returnValue(false)); expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class))); @@ -190,10 +189,10 @@ public class GetACLProcessorTest { expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class))); expectations.will(Expectations.returnValue(messageManagerStub)); - expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub))); + expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Lookup)), expectations.with(Expectations.same(mailboxSessionStub))); expectations.will(Expectations.returnValue(true)); - expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub))); + expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Administer)), expectations.with(Expectations.same(mailboxSessionStub))); expectations.will(Expectations.returnValue(true)); http://git-wip-us.apache.org/repos/asf/james-project/blob/f388ff94/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaProcessorTest.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaProcessorTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaProcessorTest.java index f96e9a9..8b23543 100644 --- a/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaProcessorTest.java +++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaProcessorTest.java @@ -93,7 +93,7 @@ public class GetQuotaProcessorTest { .thenReturn(QUOTA_ROOT); when(mockedQuotaRootResolver.retrieveAssociatedMailboxes(QUOTA_ROOT, mailboxSession)) .thenReturn(ImmutableList.of(MAILBOX_PATH)); - when(mockedMailboxManager.hasRight(MAILBOX_PATH, SimpleMailboxACL.Rfc4314Rights.r_Read_RIGHT, mailboxSession)) + when(mockedMailboxManager.hasRight(MAILBOX_PATH, SimpleMailboxACL.Right.Read, mailboxSession)) .thenReturn(true); when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(MESSAGE_QUOTA); when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenReturn(STORAGE_QUOTA); @@ -125,7 +125,7 @@ public class GetQuotaProcessorTest { .thenReturn(QUOTA_ROOT); when(mockedQuotaRootResolver.retrieveAssociatedMailboxes(QUOTA_ROOT, mailboxSession)) .thenReturn(ImmutableList.of(MAILBOX_PATH)); - when(mockedMailboxManager.hasRight(MAILBOX_PATH, SimpleMailboxACL.Rfc4314Rights.r_Read_RIGHT, mailboxSession)) + when(mockedMailboxManager.hasRight(MAILBOX_PATH, SimpleMailboxACL.Right.Read, mailboxSession)) .thenReturn(true); when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenThrow(new MailboxException()); when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenReturn(STORAGE_QUOTA); @@ -152,7 +152,7 @@ public class GetQuotaProcessorTest { .thenReturn(QUOTA_ROOT); when(mockedQuotaRootResolver.retrieveAssociatedMailboxes(QUOTA_ROOT, mailboxSession)) .thenReturn(ImmutableList.of(MAILBOX_PATH)); - when(mockedMailboxManager.hasRight(MAILBOX_PATH, SimpleMailboxACL.Rfc4314Rights.r_Read_RIGHT, mailboxSession)) + when(mockedMailboxManager.hasRight(MAILBOX_PATH, SimpleMailboxACL.Right.Read, mailboxSession)) .thenReturn(false); testee.doProcess(getQuotaRequest, mockedResponder, mockedImapSession); http://git-wip-us.apache.org/repos/asf/james-project/blob/f388ff94/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaRootProcessorTest.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaRootProcessorTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaRootProcessorTest.java index f0eb740..ddac3dc 100644 --- a/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaRootProcessorTest.java +++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/GetQuotaRootProcessorTest.java @@ -33,6 +33,7 @@ import org.apache.james.mailbox.MailboxManager; import org.apache.james.mailbox.MailboxSession; import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.mock.MockMailboxSession; +import org.apache.james.mailbox.model.MailboxACL; import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.model.Quota; import org.apache.james.mailbox.model.QuotaRoot; @@ -93,7 +94,7 @@ public class GetQuotaRootProcessorTest { expectations.will(Expectations.returnValue(QUOTA_ROOT)); expectations.allowing(mockedMailboxManager).hasRight(expectations.with(MAILBOX_PATH), - expectations.with(SimpleMailboxACL.Rfc4314Rights.r_Read_RIGHT), expectations.with(mailboxSession)); + expectations.with((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Read), expectations.with(mailboxSession)); expectations.will(Expectations.returnValue(true)); expectations.allowing(mockedQuotaManager).getMessageQuota(expectations.with(QUOTA_ROOT)); @@ -136,7 +137,7 @@ public class GetQuotaRootProcessorTest { expectations.will(Expectations.returnValue(mailboxSession)); expectations.allowing(mockedMailboxManager).hasRight(expectations.with(MAILBOX_PATH), - expectations.with(SimpleMailboxACL.Rfc4314Rights.r_Read_RIGHT), expectations.with(mailboxSession)); + expectations.with((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Read), expectations.with(mailboxSession)); expectations.will(Expectations.throwException(new MailboxException())); expectations.allowing(mockedMailboxManager).startProcessingRequest(expectations.with(mailboxSession)); @@ -167,7 +168,7 @@ public class GetQuotaRootProcessorTest { expectations.will(Expectations.returnValue(mailboxSession)); expectations.allowing(mockedMailboxManager).hasRight(expectations.with(MAILBOX_PATH), - expectations.with(SimpleMailboxACL.Rfc4314Rights.r_Read_RIGHT), expectations.with(mailboxSession)); + expectations.with((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Read), expectations.with(mailboxSession)); expectations.will(Expectations.returnValue(false)); expectations.allowing(mockedMailboxManager).startProcessingRequest(expectations.with(mailboxSession)); http://git-wip-us.apache.org/repos/asf/james-project/blob/f388ff94/protocols/imap/src/test/java/org/apache/james/imap/processor/ListRightsProcessorTest.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/ListRightsProcessorTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/ListRightsProcessorTest.java index cf8e8de..6b72545 100644 --- a/protocols/imap/src/test/java/org/apache/james/imap/processor/ListRightsProcessorTest.java +++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/ListRightsProcessorTest.java @@ -116,7 +116,7 @@ public class ListRightsProcessorTest { listRightsRequest = new ListRightsRequest("TAG", ImapCommand.anyStateCommand("Name"), MAILBOX_NAME, USER_1); - user1Key = new SimpleMailboxACLEntryKey(USER_1); + user1Key = SimpleMailboxACLEntryKey.deserialize(USER_1); listRights = new MailboxACLRights[] {new Rfc4314Rights("ae"), new Rfc4314Rights("i"), new Rfc4314Rights("k")}; } @@ -124,7 +124,7 @@ public class ListRightsProcessorTest { public void testNoListRight() throws Exception { Expectations expectations = prepareRightsExpectations(); - expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub))); + expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Lookup)), expectations.with(Expectations.same(mailboxSessionStub))); expectations.will(Expectations.returnValue(false)); expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class))); @@ -147,10 +147,10 @@ public class ListRightsProcessorTest { public void testNoAdminRight() throws Exception { Expectations expectations = prepareRightsExpectations(); - expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub))); + expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Lookup)), expectations.with(Expectations.same(mailboxSessionStub))); expectations.will(Expectations.returnValue(true)); - expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub))); + expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Administer)), expectations.with(Expectations.same(mailboxSessionStub))); expectations.will(Expectations.returnValue(false)); expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class))); @@ -198,10 +198,10 @@ public class ListRightsProcessorTest { expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class))); expectations.will(Expectations.returnValue(messageManagerStub)); - expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub))); + expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Lookup)), expectations.with(Expectations.same(mailboxSessionStub))); expectations.will(Expectations.returnValue(true)); - expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub))); + expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Administer)), expectations.with(Expectations.same(mailboxSessionStub))); expectations.will(Expectations.returnValue(true)); expectations.allowing(mailboxManagerStub).listRigths(expectations.with(path), expectations.with(Expectations.equal(user1Key)), expectations.with(Expectations.same(mailboxSessionStub))); http://git-wip-us.apache.org/repos/asf/james-project/blob/f388ff94/protocols/imap/src/test/java/org/apache/james/imap/processor/SetACLProcessorTest.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/SetACLProcessorTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/SetACLProcessorTest.java index 1f687f8..0c18456 100644 --- a/protocols/imap/src/test/java/org/apache/james/imap/processor/SetACLProcessorTest.java +++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/SetACLProcessorTest.java @@ -118,7 +118,7 @@ public class SetACLProcessorTest { replaceACLRequest = new SetACLRequest("TAG", ImapCommand.anyStateCommand("Name"), MAILBOX_NAME, USER_1, SET_RIGHTS); - user1Key = new SimpleMailboxACLEntryKey(USER_1); + user1Key = SimpleMailboxACLEntryKey.deserialize(USER_1); setRights = new Rfc4314Rights(SET_RIGHTS); } @@ -126,7 +126,7 @@ public class SetACLProcessorTest { public void testUnsupportedRight() throws Exception { Expectations expectations = prepareRightsExpectations(); - expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub))); + expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Lookup)), expectations.with(Expectations.same(mailboxSessionStub))); expectations.will(Expectations.returnValue(false)); expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class))); @@ -149,7 +149,7 @@ public class SetACLProcessorTest { public void testNoListRight() throws Exception { Expectations expectations = prepareRightsExpectations(); - expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub))); + expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Lookup)), expectations.with(Expectations.same(mailboxSessionStub))); expectations.will(Expectations.returnValue(false)); expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class))); @@ -172,10 +172,10 @@ public class SetACLProcessorTest { public void testNoAdminRight() throws Exception { Expectations expectations = prepareRightsExpectations(); - expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub))); + expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Lookup)), expectations.with(Expectations.same(mailboxSessionStub))); expectations.will(Expectations.returnValue(true)); - expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub))); + expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Administer)), expectations.with(Expectations.same(mailboxSessionStub))); expectations.will(Expectations.returnValue(false)); expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class))); @@ -226,10 +226,10 @@ public class SetACLProcessorTest { expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class))); expectations.will(Expectations.returnValue(messageManagerStub)); - expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub))); + expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Lookup)), expectations.with(Expectations.same(mailboxSessionStub))); expectations.will(Expectations.returnValue(true)); - expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub))); + expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal((MailboxACL.MailboxACLRight) SimpleMailboxACL.Right.Administer)), expectations.with(Expectations.same(mailboxSessionStub))); expectations.will(Expectations.returnValue(true)); expectations.allowing(mailboxManagerStub).setRights(expectations.with(path), expectations.with(Expectations.equal(new SimpleMailboxACL.SimpleMailboxACLCommand(user1Key, editMode, setRights))), expectations.with(mailboxSessionStub)); --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org