diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/acl/UnionMailboxACLResolver.java b/mailbox/api/src/main/java/org/apache/james/mailbox/acl/UnionMailboxACLResolver.java index 23119cbbddc..549e16b286b 100644 --- a/mailbox/api/src/main/java/org/apache/james/mailbox/acl/UnionMailboxACLResolver.java +++ b/mailbox/api/src/main/java/org/apache/james/mailbox/acl/UnionMailboxACLResolver.java @@ -129,7 +129,7 @@ public UnionMailboxACLResolver(MailboxACL userGlobalACL, MailboxACL groupGlobalA protected static boolean applies(EntryKey aclKey, EntryKey queryKey, Username resourceOwner) { final String aclKeyName = aclKey.getName(); final NameType aclKeyNameType = aclKey.getNameType(); - if (SpecialName.anybody.name().equals(aclKeyName)) { + if (SpecialName.anyone.name().equals(aclKeyName)) { /* this works also for unauthenticated users */ return true; } else if (queryKey != null) { @@ -208,7 +208,7 @@ protected static boolean applies(EntryKey aclKey, EntryKey queryKey, Username re throw new IllegalStateException("Unexpected " + NameType.class.getName() + "." + queryKey.getNameType()); } } else { - /* non-anybody ACL keys do not match non-authenticated queries */ + /* non-anyone ACL keys do not match non-authenticated queries */ return false; } } @@ -231,7 +231,7 @@ public MailboxACL applyGlobalACL(MailboxACL resourceACL) throws UnsupportedRight *
  • if the given user is the owner of the given mailbox also the "owner" * entry is included
  • *
  • the "authenticated" entry
  • - *
  • the "anybody" entry
  • + *
  • the "anyone" entry
  • * * * (2) if {@code queryKey} is a group key, the rights included come from the @@ -241,7 +241,7 @@ public MailboxACL applyGlobalACL(MailboxACL resourceACL) throws UnsupportedRight *
  • if the given group is the owner of the given mailbox also the "owner" * entry is included
  • *
  • the "authenticated" entry (*)
  • - *
  • the "anybody" entry
  • + *
  • the "anyone" entry
  • * * * (3) if {@code queryKey} is a special key, the rights included come from @@ -250,7 +250,7 @@ public MailboxACL applyGlobalACL(MailboxACL resourceACL) throws UnsupportedRight *
  • the entry literally matching the given special name
  • *
  • the "authenticated" entry if the {@code queryKey} is the "owner" * query key (*)
  • - *
  • the "anybody" entry
  • + *
  • the "anyone" entry
  • * * * (*) This is the most questionable case: should "authenticated" ACL @@ -259,7 +259,7 @@ public MailboxACL applyGlobalACL(MailboxACL resourceACL) throws UnsupportedRight * to be set explicitly for the members of "group1". And secondly the group * rights are actually queried and applied only for authenticated users. To * put it in other words, the hasRight(user, right, ...) call can be - * performed only either with user == null (only "anybody" rights will + * performed only either with user == null (only "anyone" rights will * apply) or with a user name which is there only after the user was * authenticated. */ diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxACL.java b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxACL.java index 55ceabe09f0..bcde6e45b2e 100644 --- a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxACL.java +++ b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxACL.java @@ -86,7 +86,7 @@ public enum NameType { * Special name literals. */ public enum SpecialName { - anybody, authenticated, owner + anyone, authenticated, owner } /** @@ -634,8 +634,8 @@ public final int hashCode() { } } - public static final EntryKey ANYBODY_KEY; - public static final EntryKey ANYBODY_NEGATIVE_KEY; + public static final EntryKey ANYONE_KEY; + public static final EntryKey ANYONE_NEGATIVE_KEY; public static final EntryKey AUTHENTICATED_KEY; public static final EntryKey AUTHENTICATED_NEGATIVE_KEY; public static final MailboxACL EMPTY; @@ -651,8 +651,8 @@ public final int hashCode() { static { try { - ANYBODY_KEY = new EntryKey(SpecialName.anybody.name(), NameType.special, false); - ANYBODY_NEGATIVE_KEY = new EntryKey(SpecialName.anybody.name(), NameType.special, true); + ANYONE_KEY = new EntryKey(SpecialName.anyone.name(), NameType.special, false); + ANYONE_NEGATIVE_KEY = new EntryKey(SpecialName.anyone.name(), NameType.special, true); AUTHENTICATED_KEY = new EntryKey(SpecialName.authenticated.name(), NameType.special, false); AUTHENTICATED_NEGATIVE_KEY = new EntryKey(SpecialName.authenticated.name(), NameType.special, true); EMPTY = new MailboxACL(); diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/acl/UnionMailboxACLResolverTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/acl/UnionMailboxACLResolverTest.java index eeb9478d9a1..56b04809193 100644 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/acl/UnionMailboxACLResolverTest.java +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/acl/UnionMailboxACLResolverTest.java @@ -35,8 +35,8 @@ class UnionMailboxACLResolverTest { private static final Username USER_1 = Username.of("user1"); private static final Username USER_2 = Username.of("user2"); - private MailboxACL anybodyRead; - private MailboxACL anybodyReadNegative; + private MailboxACL anyoneRead; + private MailboxACL anyoneReadNegative; private UnionMailboxACLResolver anyoneReadListGlobal; private MailboxACL authenticatedRead; private UnionMailboxACLResolver authenticatedReadListWriteGlobal; @@ -57,7 +57,7 @@ void setUp() throws Exception { MailboxACL acl = new MailboxACL(new Entry(MailboxACL.AUTHENTICATED_KEY, MailboxACL.FULL_RIGHTS)); authenticatedReadListWriteGlobal = new UnionMailboxACLResolver(acl, acl); - acl = new MailboxACL(new Entry(MailboxACL.ANYBODY_KEY, Rfc4314Rights.fromSerializedRfc4314Rights("rl"))); + acl = new MailboxACL(new Entry(MailboxACL.ANYONE_KEY, Rfc4314Rights.fromSerializedRfc4314Rights("rl"))); anyoneReadListGlobal = new UnionMailboxACLResolver(acl, acl); acl = new MailboxACL(new Entry(MailboxACL.OWNER_KEY, MailboxACL.FULL_RIGHTS)); ownerFullGlobal = new UnionMailboxACLResolver(acl, acl); @@ -66,8 +66,8 @@ void setUp() throws Exception { user1Read = new MailboxACL(new Entry(user1Key, Rfc4314Rights.fromSerializedRfc4314Rights("r"))); user1ReadNegative = new MailboxACL(new Entry(EntryKey.createUserEntryKey(USER_1, true), Rfc4314Rights.fromSerializedRfc4314Rights("r"))); - anybodyRead = new MailboxACL(new Entry(MailboxACL.ANYBODY_KEY, Rfc4314Rights.fromSerializedRfc4314Rights("r"))); - anybodyReadNegative = new MailboxACL(new Entry(MailboxACL.ANYBODY_NEGATIVE_KEY, Rfc4314Rights.fromSerializedRfc4314Rights("r"))); + anyoneRead = new MailboxACL(new Entry(MailboxACL.ANYONE_KEY, Rfc4314Rights.fromSerializedRfc4314Rights("r"))); + anyoneReadNegative = new MailboxACL(new Entry(MailboxACL.ANYONE_NEGATIVE_KEY, Rfc4314Rights.fromSerializedRfc4314Rights("r"))); authenticatedRead = new MailboxACL(new Entry(MailboxACL.AUTHENTICATED_KEY, Rfc4314Rights.fromSerializedRfc4314Rights("r"))); authenticatedReadNegative = new MailboxACL(new Entry(MailboxACL.AUTHENTICATED_NEGATIVE_KEY, Rfc4314Rights.fromSerializedRfc4314Rights("r"))); @@ -82,7 +82,7 @@ void testAppliesNullUser() throws UnsupportedRightException { assertThat(UnionMailboxACLResolver.applies(user1Key, null, USER_1)).isFalse(); assertThat(UnionMailboxACLResolver.applies(user2Key, null, USER_1)).isFalse(); - assertThat(UnionMailboxACLResolver.applies(MailboxACL.ANYBODY_KEY, null, USER_1)).isTrue(); + assertThat(UnionMailboxACLResolver.applies(MailboxACL.ANYONE_KEY, null, USER_1)).isTrue(); assertThat(UnionMailboxACLResolver.applies(MailboxACL.AUTHENTICATED_KEY, null, USER_1)).isFalse(); assertThat(UnionMailboxACLResolver.applies(MailboxACL.OWNER_KEY, null, USER_1)).isFalse(); } @@ -92,21 +92,21 @@ void testAppliesUser() throws UnsupportedRightException { /* requester is the resource owner */ assertThat(UnionMailboxACLResolver.applies(user1Key, user1Key, USER_1)).isTrue(); assertThat(UnionMailboxACLResolver.applies(user2Key, user1Key, USER_1)).isFalse(); - assertThat(UnionMailboxACLResolver.applies(MailboxACL.ANYBODY_KEY, user1Key, USER_1)).isTrue(); + assertThat(UnionMailboxACLResolver.applies(MailboxACL.ANYONE_KEY, user1Key, USER_1)).isTrue(); assertThat(UnionMailboxACLResolver.applies(MailboxACL.AUTHENTICATED_KEY, user1Key, USER_1)).isTrue(); assertThat(UnionMailboxACLResolver.applies(MailboxACL.OWNER_KEY, user1Key, USER_1)).isTrue(); /* requester is not the resource user */ assertThat(UnionMailboxACLResolver.applies(user1Key, user1Key, USER_2)).isTrue(); assertThat(UnionMailboxACLResolver.applies(user2Key, user1Key, USER_2)).isFalse(); - assertThat(UnionMailboxACLResolver.applies(MailboxACL.ANYBODY_KEY, user1Key, USER_2)).isTrue(); + assertThat(UnionMailboxACLResolver.applies(MailboxACL.ANYONE_KEY, user1Key, USER_2)).isTrue(); assertThat(UnionMailboxACLResolver.applies(MailboxACL.AUTHENTICATED_KEY, user1Key, USER_2)).isTrue(); assertThat(UnionMailboxACLResolver.applies(MailboxACL.OWNER_KEY, user1Key, USER_2)).isFalse(); /* owner query */ assertThat(UnionMailboxACLResolver.applies(user1Key, MailboxACL.OWNER_KEY, USER_1)).isFalse(); assertThat(UnionMailboxACLResolver.applies(user2Key, MailboxACL.OWNER_KEY, USER_1)).isFalse(); - assertThat(UnionMailboxACLResolver.applies(MailboxACL.ANYBODY_KEY, MailboxACL.OWNER_KEY, USER_1)).isTrue(); + assertThat(UnionMailboxACLResolver.applies(MailboxACL.ANYONE_KEY, MailboxACL.OWNER_KEY, USER_1)).isTrue(); assertThat(UnionMailboxACLResolver.applies(MailboxACL.AUTHENTICATED_KEY, MailboxACL.OWNER_KEY, USER_1)).isTrue(); assertThat(UnionMailboxACLResolver.applies(MailboxACL.OWNER_KEY, MailboxACL.OWNER_KEY, USER_1)).isTrue(); } @@ -156,38 +156,38 @@ void testResolveRightsNullUser() throws UnsupportedRightException { .isFalse(); assertThat( - anyoneReadListGlobal.resolveRights(null, anybodyRead, USER_1) + anyoneReadListGlobal.resolveRights(null, anyoneRead, USER_1) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( - anyoneReadListGlobal.resolveRights(null, anybodyReadNegative, USER_1) + anyoneReadListGlobal.resolveRights(null, anyoneReadNegative, USER_1) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( - authenticatedReadListWriteGlobal.resolveRights(null, anybodyRead, USER_1) + authenticatedReadListWriteGlobal.resolveRights(null, anyoneRead, USER_1) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( - authenticatedReadListWriteGlobal.resolveRights(null, anybodyReadNegative, USER_1) + authenticatedReadListWriteGlobal.resolveRights(null, anyoneReadNegative, USER_1) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( - ownerFullGlobal.resolveRights(null, anybodyRead, USER_1) + ownerFullGlobal.resolveRights(null, anyoneRead, USER_1) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( - ownerFullGlobal.resolveRights(null, anybodyReadNegative, USER_1) + ownerFullGlobal.resolveRights(null, anyoneReadNegative, USER_1) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( - noGlobals.resolveRights(null, anybodyRead, USER_1) + noGlobals.resolveRights(null, anyoneRead, USER_1) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( - noGlobals.resolveRights(null, anybodyReadNegative, USER_1) + noGlobals.resolveRights(null, anyoneReadNegative, USER_1) .contains(MailboxACL.Right.Read)) .isFalse(); @@ -326,38 +326,38 @@ void testResolveRightsUserSelfOwner() throws UnsupportedRightException { .isFalse(); assertThat( - anyoneReadListGlobal.resolveRights(USER_1, anybodyRead, USER_1) + anyoneReadListGlobal.resolveRights(USER_1, anyoneRead, USER_1) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( - anyoneReadListGlobal.resolveRights(USER_1, anybodyReadNegative, USER_1) + anyoneReadListGlobal.resolveRights(USER_1, anyoneReadNegative, USER_1) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( - authenticatedReadListWriteGlobal.resolveRights(USER_1, anybodyRead, USER_1) + authenticatedReadListWriteGlobal.resolveRights(USER_1, anyoneRead, USER_1) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( - authenticatedReadListWriteGlobal.resolveRights(USER_1, anybodyReadNegative, USER_1) + authenticatedReadListWriteGlobal.resolveRights(USER_1, anyoneReadNegative, USER_1) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( - ownerFullGlobal.resolveRights(USER_1, anybodyRead, USER_1) + ownerFullGlobal.resolveRights(USER_1, anyoneRead, USER_1) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( - ownerFullGlobal.resolveRights(USER_1, anybodyReadNegative, USER_1) + ownerFullGlobal.resolveRights(USER_1, anyoneReadNegative, USER_1) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( - noGlobals.resolveRights(USER_1, anybodyRead, USER_1) + noGlobals.resolveRights(USER_1, anyoneRead, USER_1) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( - noGlobals.resolveRights(USER_1, anybodyReadNegative, USER_1) + noGlobals.resolveRights(USER_1, anyoneReadNegative, USER_1) .contains(MailboxACL.Right.Read)) .isFalse(); @@ -476,38 +476,38 @@ void testResolveRightsUserNotOwner() throws UnsupportedRightException { .isFalse(); assertThat( - anyoneReadListGlobal.resolveRights(USER_1, anybodyRead, USER_2) + anyoneReadListGlobal.resolveRights(USER_1, anyoneRead, USER_2) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( - anyoneReadListGlobal.resolveRights(USER_1, anybodyReadNegative, USER_2) + anyoneReadListGlobal.resolveRights(USER_1, anyoneReadNegative, USER_2) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( - authenticatedReadListWriteGlobal.resolveRights(USER_1, anybodyRead, USER_2) + authenticatedReadListWriteGlobal.resolveRights(USER_1, anyoneRead, USER_2) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( - authenticatedReadListWriteGlobal.resolveRights(USER_1, anybodyReadNegative, USER_2) + authenticatedReadListWriteGlobal.resolveRights(USER_1, anyoneReadNegative, USER_2) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( - ownerFullGlobal.resolveRights(USER_1, anybodyRead, USER_2) + ownerFullGlobal.resolveRights(USER_1, anyoneRead, USER_2) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( - ownerFullGlobal.resolveRights(USER_1, anybodyReadNegative, USER_2) + ownerFullGlobal.resolveRights(USER_1, anyoneReadNegative, USER_2) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( - noGlobals.resolveRights(USER_1, anybodyRead, USER_2) + noGlobals.resolveRights(USER_1, anyoneRead, USER_2) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( - noGlobals.resolveRights(USER_1, anybodyReadNegative, USER_2) + noGlobals.resolveRights(USER_1, anyoneReadNegative, USER_2) .contains(MailboxACL.Right.Read)) .isFalse(); diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxACLEntryKeyTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxACLEntryKeyTest.java index 0e0307b162a..75a46efb9ab 100644 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxACLEntryKeyTest.java +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxACLEntryKeyTest.java @@ -68,15 +68,15 @@ void testNegativeOwner() { } @Test - void testAnybody() { - assertThat(EntryKey.deserialize(SpecialName.anybody.toString())) - .isEqualTo(new EntryKey(SpecialName.anybody.toString(), NameType.special, false)); + void testAnyone() { + assertThat(EntryKey.deserialize(SpecialName.anyone.toString())) + .isEqualTo(new EntryKey(SpecialName.anyone.toString(), NameType.special, false)); } @Test - void testNegativeAnybody() { - assertThat(EntryKey.deserialize(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.anybody.toString())) - .isEqualTo(new EntryKey(SpecialName.anybody.toString(), NameType.special, true)); + void testNegativeAnyone() { + assertThat(EntryKey.deserialize(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.anyone.toString())) + .isEqualTo(new EntryKey(SpecialName.anyone.toString(), NameType.special, true)); } @Test @@ -128,15 +128,15 @@ void testSerializeNegativeOwner() { } @Test - void testSerializeAnybody() { - assertThat(new EntryKey(SpecialName.anybody.toString(), NameType.special, false).serialize()) - .isEqualTo(SpecialName.anybody.toString()); + void testSerializeAnyone() { + assertThat(new EntryKey(SpecialName.anyone.toString(), NameType.special, false).serialize()) + .isEqualTo(SpecialName.anyone.toString()); } @Test - void testSerializeNegativeAnybody() { - assertThat(new EntryKey(SpecialName.anybody.toString(), NameType.special, true).serialize()) - .isEqualTo(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.anybody.toString()); + void testSerializeNegativeAnyone() { + assertThat(new EntryKey(SpecialName.anyone.toString(), NameType.special, true).serialize()) + .isEqualTo(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.anyone.toString()); } @Test diff --git a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Rights.test b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Rights.test index 1af74948007..b9260a38473 100644 --- a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Rights.test +++ b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Rights.test @@ -36,5 +36,41 @@ S: a5 OK DELETEACL completed. C: a6 DELETEACL BAD bob S: a6 NO DELETEACL failed. Mailbox not found. -C: a7 SETACL INBOX bob lr -S: a7 OK SETACL completed. +C: a7 GETACL INBOX +S: \* ACL "INBOX" "owner" "aeiklprstwx" +S: a7 OK GETACL completed. + +C: a8 SETACL INBOX bob l +S: a8 OK SETACL completed. + +C: a9 GETACL INBOX +S: \* ACL "INBOX" "bob" "l" "owner" "aeiklprstwx" +S: a9 OK GETACL completed. + +C: a10 SETACL INBOX anyone r +S: a10 OK SETACL completed. + +C: a11 GETACL INBOX +S: \* ACL "INBOX" "bob" "l" "anyone" "r" "owner" "aeiklprstwx"|\* ACL "INBOX" "anyone" "r" "bob" "l" "owner" "aeiklprstwx" +S: a11 OK GETACL completed. + +C: a12 SETACL INBOX -bob r +S: a12 OK SETACL completed. + +C: a13 GETACL INBOX +S: \* ACL "INBOX" "bob" "l" "anyone" "r" "-bob" "r" "owner" "aeiklprstwx"|\* ACL "INBOX" "-bob" "r" "anyone" "r" "bob" "l" "owner" "aeiklprstwx" +S: a13 OK GETACL completed. + +C: a14 SETACL INBOX -bob -r +S: a14 OK SETACL completed. + +C: a15 GETACL INBOX +S: \* ACL "INBOX" "bob" "l" "anyone" "r" "owner" "aeiklprstwx"|\* ACL "INBOX" "anyone" "r" "bob" "l" "owner" "aeiklprstwx" +S: a15 OK GETACL completed. + +C: a16 SETACL INBOX anyone -r +S: a16 OK SETACL completed. + +C: a17 GETACL INBOX +S: \* ACL "INBOX" "bob" "l" "owner" "aeiklprstwx" +S: a17 OK GETACL completed. \ No newline at end of file diff --git a/mpt/impl/imap-mailbox/jpa/src/test/java/org/apache/james/mpt/imapmailbox/jpa/JpaAuthenticatedStateTest.java b/mpt/impl/imap-mailbox/jpa/src/test/java/org/apache/james/mpt/imapmailbox/jpa/JpaAuthenticatedStateTest.java index 20605954864..25df3f844ee 100644 --- a/mpt/impl/imap-mailbox/jpa/src/test/java/org/apache/james/mpt/imapmailbox/jpa/JpaAuthenticatedStateTest.java +++ b/mpt/impl/imap-mailbox/jpa/src/test/java/org/apache/james/mpt/imapmailbox/jpa/JpaAuthenticatedStateTest.java @@ -22,6 +22,8 @@ import org.apache.james.mpt.api.ImapHostSystem; import org.apache.james.mpt.imapmailbox.jpa.host.JPAHostSystemExtension; import org.apache.james.mpt.imapmailbox.suite.AuthenticatedState; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; public class JpaAuthenticatedStateTest extends AuthenticatedState { @@ -32,4 +34,10 @@ public class JpaAuthenticatedStateTest extends AuthenticatedState { protected ImapHostSystem createImapHostSystem() { return hostSystemExtension.getHostSystem(); } + + @Disabled("Jpa does not implement right storing for mailboxes so this test can be ignored") + @Test + @Override + public void rightsCommandsShouldBeSupported() { + } } diff --git a/server/mailet/integration-testing/src/main/java/org/apache/james/mailets/configuration/Constants.java b/server/mailet/integration-testing/src/main/java/org/apache/james/mailets/configuration/Constants.java index 4429305d28d..c5bdaf4b13c 100644 --- a/server/mailet/integration-testing/src/main/java/org/apache/james/mailets/configuration/Constants.java +++ b/server/mailet/integration-testing/src/main/java/org/apache/james/mailets/configuration/Constants.java @@ -43,6 +43,7 @@ public class Constants { public static final String LOCALHOST_IP = "127.0.0.1"; public static final String PASSWORD = "secret"; public static final String FROM = "user@" + DEFAULT_DOMAIN; + public static final String FROM2 = "user4@" + DEFAULT_DOMAIN; public static final String RECIPIENT = "user2@" + DEFAULT_DOMAIN; public static final String ALIAS = "user2alias@" + DEFAULT_DOMAIN; public static final String RECIPIENT2 = "user3@" + DEFAULT_DOMAIN; diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SubAddressingTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SubAddressingTest.java index 19b3581a282..55f656cc003 100644 --- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SubAddressingTest.java +++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SubAddressingTest.java @@ -23,6 +23,7 @@ import static org.apache.james.mailets.SPFIntegrationTests.POSTMASTER; import static org.apache.james.mailets.configuration.Constants.DEFAULT_DOMAIN; import static org.apache.james.mailets.configuration.Constants.FROM; +import static org.apache.james.mailets.configuration.Constants.FROM2; import static org.apache.james.mailets.configuration.Constants.LOCALHOST_IP; import static org.apache.james.mailets.configuration.Constants.PASSWORD; import static org.apache.james.mailets.configuration.Constants.RECIPIENT; @@ -34,14 +35,10 @@ import java.security.NoSuchAlgorithmException; import java.security.spec.InvalidKeySpecException; -import org.apache.james.core.Username; -import org.apache.james.mailbox.model.MailboxACL; import org.apache.james.mailbox.model.MailboxConstants; -import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailets.configuration.CommonProcessors; import org.apache.james.mailets.configuration.MailetConfiguration; import org.apache.james.mailets.configuration.ProcessorConfiguration; -import org.apache.james.modules.ACLProbeImpl; import org.apache.james.modules.protocols.ImapGuiceProbe; import org.apache.james.modules.protocols.SmtpGuiceProbe; import org.apache.james.probe.DataProbe; @@ -82,6 +79,10 @@ void setup(File temporaryFolder) throws Exception { dataProbe.addDomain(DEFAULT_DOMAIN); dataProbe.addUser(RECIPIENT, PASSWORD); dataProbe.addUser(FROM, PASSWORD); + dataProbe.addUser(FROM2, PASSWORD); + + testIMAPClient.connect(LOCALHOST_IP, jamesServer.getProbe(ImapGuiceProbe.class).getImapPort()) + .login(RECIPIENT, PASSWORD); } @AfterEach @@ -97,43 +98,34 @@ void tearDown() throws IOException { void subAddressedEmailShouldBeDeliveredInINBOXWhenSpecifiedFolderDoesNotExist(@TempDir File temporaryFolder) throws Exception { setup(temporaryFolder); - //do not create mailbox + // do not create mailbox sendSubAddressedMail(); awaitSubAddressedMail(MailboxConstants.INBOX); } @Test - void subAddressedEmailShouldBeDeliveredInINBOXWhenNoRights(@TempDir File temporaryFolder) throws Exception { + void subAddressedEmailShouldBeDeliveredInINBOXWhenNobodyHasRight(@TempDir File temporaryFolder) throws Exception { setup(temporaryFolder); // create mailbox - testIMAPClient.connect(LOCALHOST_IP, jamesServer.getProbe(ImapGuiceProbe.class).getImapPort()) - .login(RECIPIENT, PASSWORD) - .create(TARGETED_MAILBOX); + testIMAPClient.sendCommand("CREATE " + TARGETED_MAILBOX); - //do not give posting rights + // do not give posting rights + testIMAPClient.sendCommand("SETACL " + TARGETED_MAILBOX + " " + "anyone" + " -p"); sendSubAddressedMail(); awaitSubAddressedMail(MailboxConstants.INBOX); } @Test - void subAddressedEmailShouldBeDeliveredInSpecifiedFolderWhenRights(@TempDir File temporaryFolder) throws Exception { + void subAddressedEmailShouldBeDeliveredInSpecifiedFolderWhenAnyoneHasRight(@TempDir File temporaryFolder) throws Exception { setup(temporaryFolder); - // create mailbox - testIMAPClient.connect(LOCALHOST_IP, jamesServer.getProbe(ImapGuiceProbe.class).getImapPort()) - .login(RECIPIENT, PASSWORD) - .create(TARGETED_MAILBOX); - - //give posting rights - jamesServer.getProbe(ACLProbeImpl.class).executeCommand( - MailboxPath.forUser(Username.of(RECIPIENT), TARGETED_MAILBOX), - MailboxACL.command() - .key(MailboxACL.ANYBODY_KEY) - .rights(MailboxACL.Right.Post) - .asAddition()); + testIMAPClient.sendCommand("CREATE " + TARGETED_MAILBOX); + + // give posting rights for anyone + testIMAPClient.sendCommand("SETACL " + TARGETED_MAILBOX + " " + "anyone" + " +p"); sendSubAddressedMail(); awaitSubAddressedMail(TARGETED_MAILBOX); diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/SubAddressingTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/SubAddressingTest.java index 8fe4055cb16..c7b160f4805 100644 --- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/SubAddressingTest.java +++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/SubAddressingTest.java @@ -93,7 +93,7 @@ void shouldNotAddStorageDirectiveWhenTargetMailboxDoesNotExist() throws Exceptio @Test void shouldNotAddStorageDirectiveWhenNobodyHasRight() throws Exception { - removePostRightForKey(MailboxACL.ANYBODY_KEY); + removePostRightForKey(MailboxACL.ANYONE_KEY); Mail mail = mailBuilder(TARGET).sender(SENDER1).build(); testee.service(mail); @@ -105,8 +105,8 @@ void shouldNotAddStorageDirectiveWhenNobodyHasRight() throws Exception { @Test - void shouldAddStorageDirectiveWhenAnybodyHasRight() throws Exception { - givePostRightForKey(MailboxACL.ANYBODY_KEY); + void shouldAddStorageDirectiveWhenAnyoneHasRight() throws Exception { + givePostRightForKey(MailboxACL.ANYONE_KEY); Mail mail = mailBuilder(TARGET).sender(SENDER1).build(); testee.service(mail); @@ -120,7 +120,7 @@ void shouldAddStorageDirectiveWhenAnybodyHasRight() throws Exception { @Test void shouldAddStorageDirectiveWhenSenderIsWhiteListed() throws Exception { // whitelist sender 1 and send from sender 1 - removePostRightForKey(MailboxACL.ANYBODY_KEY); + removePostRightForKey(MailboxACL.ANYONE_KEY); givePostRightForKey(MailboxACL.EntryKey.createUserEntryKey(sender1Username)); Mail mail = mailBuilder(TARGET).sender(SENDER1).build(); @@ -134,7 +134,7 @@ void shouldAddStorageDirectiveWhenSenderIsWhiteListed() throws Exception { @Test void shouldNotAddStorageDirectiveWhenSenderIsNotWhiteListed() throws Exception { // whitelist sender 1 and send from sender 2 - removePostRightForKey(MailboxACL.ANYBODY_KEY); + removePostRightForKey(MailboxACL.ANYONE_KEY); givePostRightForKey(MailboxACL.EntryKey.createUserEntryKey(sender1Username)); Mail mail = mailBuilder(TARGET).sender(SENDER2).build(); @@ -148,7 +148,7 @@ void shouldNotAddStorageDirectiveWhenSenderIsNotWhiteListed() throws Exception { @Test void shouldNotAddStorageDirectiveWhenSenderIsBlackListed() throws Exception { // blacklist sender 1 and send from sender 1 - givePostRightForKey(MailboxACL.ANYBODY_KEY); + givePostRightForKey(MailboxACL.ANYONE_KEY); givePostRightForKey(MailboxACL.EntryKey.createNegativeUserEntryKey(sender1Username)); Mail mail = mailBuilder(TARGET).sender(SENDER1).build(); @@ -162,7 +162,7 @@ void shouldNotAddStorageDirectiveWhenSenderIsBlackListed() throws Exception { @Test void shouldAddStorageDirectiveWhenSenderIsNotBlackListed() throws Exception { // blacklist sender 1 and send from sender 2 - givePostRightForKey(MailboxACL.ANYBODY_KEY); + givePostRightForKey(MailboxACL.ANYONE_KEY); removePostRightForKey(MailboxACL.EntryKey.createUserEntryKey(sender1Username)); Mail mail = mailBuilder(TARGET).sender(SENDER2).build(); @@ -174,8 +174,8 @@ void shouldAddStorageDirectiveWhenSenderIsNotBlackListed() throws Exception { } @Test - void shouldAddStorageDirectiveWhenAnybodyHasRightAndSenderIsUnknown() throws Exception { - givePostRightForKey(MailboxACL.ANYBODY_KEY); + void shouldAddStorageDirectiveWhenAnyoneHasRightAndSenderIsUnknown() throws Exception { + givePostRightForKey(MailboxACL.ANYONE_KEY); Mail mail = mailBuilder(TARGET).build(); testee.service(mail); @@ -187,7 +187,7 @@ void shouldAddStorageDirectiveWhenAnybodyHasRightAndSenderIsUnknown() throws Exc @Test void shouldNotAddStorageDirectiveWhenNobodyHasRightAndSenderIsUnknown() throws Exception { - removePostRightForKey(MailboxACL.ANYBODY_KEY); + removePostRightForKey(MailboxACL.ANYONE_KEY); Mail mail = mailBuilder(TARGET).build(); testee.service(mail);