james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [2/6] james-project git commit: JAMES-2195 Allow fine grained right delegation with Cucumber
Date Thu, 26 Oct 2017 22:59:09 GMT
JAMES-2195 Allow fine grained right delegation with Cucumber


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/940b85f3
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/940b85f3
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/940b85f3

Branch: refs/heads/master
Commit: 940b85f37d2dc69bb993440dc8da99f0c175cb72
Parents: f9ab357
Author: benwa <btellier@linagora.com>
Authored: Thu Oct 19 16:07:19 2017 +0700
Committer: Antoine Duprat <aduprat@linagora.com>
Committed: Thu Oct 26 08:44:41 2017 +0200

----------------------------------------------------------------------
 .../org/apache/james/mailbox/model/MailboxACL.java |  2 +-
 .../integration/cucumber/MailboxStepdefs.java      | 17 +++++++++--------
 .../methods/integration/cucumber/UserStepdefs.java |  2 +-
 .../resources/cucumber/DownloadEndpoint.feature    |  2 +-
 .../test/resources/cucumber/DownloadGet.feature    |  8 ++++----
 .../test/resources/cucumber/GetMessages.feature    |  4 ++--
 6 files changed, 18 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/940b85f3/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxACL.java
----------------------------------------------------------------------
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 cf22364..934caa1 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
@@ -198,7 +198,7 @@ public class MailboxACL {
             return new Rfc4314Rights(rightListFromSerializedRfc4314Rights(serializedRfc4314Rights));
         }
 
-        private static List<Right> rightListFromSerializedRfc4314Rights(String serializedRfc4314Rights)
throws UnsupportedRightException {
+        public static List<Right> rightListFromSerializedRfc4314Rights(String serializedRfc4314Rights)
throws UnsupportedRightException {
             return serializedRfc4314Rights.chars()
                 .mapToObj(i -> (char) i)
                 .flatMap(Throwing.function(Rfc4314Rights::convert).sneakyThrow())

http://git-wip-us.apache.org/repos/asf/james-project/blob/940b85f3/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MailboxStepdefs.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MailboxStepdefs.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MailboxStepdefs.java
index 00b3e40..fca2cb9 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MailboxStepdefs.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MailboxStepdefs.java
@@ -24,6 +24,7 @@ import javax.inject.Inject;
 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.modules.ACLProbeImpl;
 
 import cucumber.api.java.en.Given;
 import cucumber.runtime.java.guice.ScenarioScoped;
@@ -43,18 +44,18 @@ public class MailboxStepdefs {
         mainStepdefs.mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username,
mailbox);
     }
 
-    @Given("^\"([^\"]*)\" shares its mailbox \"([^\"]*)\" with \"([^\"]*)\"$")
-    public void shareMailbox(String owner, String mailbox, String shareTo) throws Throwable
{
-        MailboxPath mailboxPath = MailboxPath.forUser(owner, mailbox);
-        MailboxACL.Rfc4314Rights rights = new MailboxACL.Rfc4314Rights(MailboxACL.Right.Lookup,
MailboxACL.Right.Read);
-
-        mainStepdefs.aclProbe.addRights(mailboxPath, shareTo, rights);
-    }
-
     @Given("^\"([^\"]*)\" shares its mailbox \"([^\"]*)\" with rights \"([^\"]*)\" with \"([^\"]*)\"$")
     public void shareMailboxWithRight(String owner, String mailbox, String rights, String
shareTo) throws Throwable {
         MailboxPath mailboxPath = MailboxPath.forUser(owner, mailbox);
 
         mainStepdefs.aclProbe.replaceRights(mailboxPath, shareTo, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights(rights));
     }
+    
+    @Given("^\"([^\"]*)\" shares (?:his|her) mailbox \"([^\"]*)\" with \"([^\"]*)\" with
\"([^\"]*)\" rights$")
+    public void shareMailbox(String owner, String mailbox, String shareTo, String rights)
throws Throwable {
+        mainStepdefs.jmapServer.getProbe(ACLProbeImpl.class)
+            .replaceRights(MailboxPath.forUser(owner, mailbox),
+                shareTo,
+                MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights(rights));
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/940b85f3/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java
index 2ef61e4..fa26e2f 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java
@@ -110,7 +110,7 @@ public class UserStepdefs {
         createUser(username);
         connectUser(username);
     }
-    
+
     @Given("^\"([^\"]*)\" is connected$")
     public void connectUser(String username) throws Throwable {
         AccessToken accessToken = authenticate(username);

http://git-wip-us.apache.org/repos/asf/james-project/blob/940b85f3/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadEndpoint.feature
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadEndpoint.feature
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadEndpoint.feature
index 979907d..ea41c5d 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadEndpoint.feature
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadEndpoint.feature
@@ -86,7 +86,7 @@ Feature: Download endpoint
     Then the user should receive a not found response
 
   Scenario: An authenticated user should have access to a shared attachment
-    Given "usera@domain.tld" shares its mailbox "INBOX" with "userb@domain.tld"
+    Given "usera@domain.tld" shares his mailbox "INBOX" with "userb@domain.tld" with "lr"
rights
     And "userb@domain.tld" is connected
     When "userb@domain.tld" downloads "a1"
     Then the user should be authorized

http://git-wip-us.apache.org/repos/asf/james-project/blob/940b85f3/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature
index 662f3e9..9a69fa7 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/DownloadGet.feature
@@ -83,26 +83,26 @@ Feature: Download GET
 
   Scenario: User can download attachment of another user when shared mailbox
     Given "alice@domain.tld" mailbox "sharedMailbox" contains a message "1" with an attachment
"2"
-    And "alice@domain.tld" shares its mailbox "sharedMailbox" with "bob@domain.tld"
+    And "alice@domain.tld" shares her mailbox "sharedMailbox" with "bob@domain.tld" with
"lr" rights
     When "bob@domain.tld" downloads "2"
     Then he can read that blob
     And the blob size is 3071
 
   Scenario: User can download message blob of another user when shared mailbox
     Given "alice@domain.tld" mailbox "sharedMailbox" contains a message "1" with an attachment
"2"
-    And "alice@domain.tld" shares its mailbox "sharedMailbox" with "bob@domain.tld"
+    And "alice@domain.tld" shares her mailbox "sharedMailbox" with "bob@domain.tld" with
"lr" rights
     When "bob@domain.tld" downloads "1"
     Then he can read that blob
     And the blob size is 4963
 
   Scenario: Attachment read delegation should be user specific
     Given "alice@domain.tld" mailbox "sharedMailbox" contains a message "1" with an attachment
"2"
-    And "alice@domain.tld" shares its mailbox "sharedMailbox" with "bob@domain.tld"
+    And "alice@domain.tld" shares her mailbox "sharedMailbox" with "bob@domain.tld" with
"lr" rights
     When "cedric@domain.tld" downloads "1"
     Then "cedric@domain.tld" should receive a not found response
 
   Scenario: Message download read delegation should be user specific
     Given "alice@domain.tld" mailbox "sharedMailbox" contains a message "1" with an attachment
"2"
-    And "alice@domain.tld" shares its mailbox "sharedMailbox" with "bob@domain.tld"
+    And "alice@domain.tld" shares her mailbox "sharedMailbox" with "bob@domain.tld" with
"lr" rights
     When "cedric@domain.tld" downloads "2"
     Then "cedric@domain.tld" should receive a not found response
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/940b85f3/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature
index 23bc2a9..82d6459 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature
@@ -39,7 +39,7 @@ Feature: GetMessages method
 
   Scenario: Retrieving a message in a mailbox delegated to me
     Given "alice@domain.tld" has a mailbox "shared"
-    And "alice@domain.tld" shares its mailbox "shared" with "bob@domain.tld"
+    And "alice@domain.tld" shares her mailbox "shared" with "bob@domain.tld" with "lr" rights
     And "alice@domain.tld" has a message "m1" in "shared" mailbox with subject "my test subject",
content "testmail"
     When "bob@domain.tld" ask for messages "m1"
     Then no error is returned
@@ -48,7 +48,7 @@ Feature: GetMessages method
 
   Scenario: Retrieving a message in a mailbox delegated to someone else
     Given "alice@domain.tld" has a mailbox "shared"
-    And "alice@domain.tld" shares its mailbox "shared" with "bob@domain.tld"
+    And "alice@domain.tld" shares her mailbox "shared" with "bob@domain.tld" with "lr" rights
     And "alice@domain.tld" has a message "m1" in "shared" mailbox with subject "my test subject",
content "testmail"
     When "cedric@domain.tld" ask for messages "m1"
     Then no error is returned


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message