You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2020/02/20 11:12:47 UTC

[sling-org-apache-sling-jcr-repoinit] branch master updated (49e30a7 -> 9800e4f)

This is an automated email from the ASF dual-hosted git repository.

bdelacretaz pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-repoinit.git.


    from 49e30a7  SLING-9085 - setup https Maven repository
     new 9b8a8da  Remove unused imports
     new 9800e4f  SLING-8757 - add integration tests for the home() functions syntax

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 pom.xml                                             |  2 +-
 .../sling/jcr/repoinit/PrincipalBasedAclTest.java   |  5 -----
 .../sling/jcr/repoinit/it/RepoInitTestSupport.java  |  2 +-
 .../sling/jcr/repoinit/it/RepoInitTextIT.java       | 21 ++++++++++++++++++++-
 .../java/org/apache/sling/jcr/repoinit/it/U.java    | 13 +++++++++++++
 src/test/resources/repoinit.txt                     |  9 +++++++++
 6 files changed, 44 insertions(+), 8 deletions(-)


[sling-org-apache-sling-jcr-repoinit] 02/02: SLING-8757 - add integration tests for the home() functions syntax

Posted by bd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-repoinit.git

commit 9800e4f7a7aadee212c3acfdcfb34fb40634cede
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Thu Feb 20 12:12:36 2020 +0100

    SLING-8757 - add integration tests for the home() functions syntax
---
 pom.xml                                             |  2 +-
 .../sling/jcr/repoinit/it/RepoInitTestSupport.java  |  2 +-
 .../sling/jcr/repoinit/it/RepoInitTextIT.java       | 21 ++++++++++++++++++++-
 .../java/org/apache/sling/jcr/repoinit/it/U.java    | 13 +++++++++++++
 src/test/resources/repoinit.txt                     |  9 +++++++++
 5 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/pom.xml b/pom.xml
index 840f1c7..b580379 100644
--- a/pom.xml
+++ b/pom.xml
@@ -219,7 +219,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.repoinit.parser</artifactId>
-            <version>1.4.0</version>
+            <version>1.4.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
diff --git a/src/test/java/org/apache/sling/jcr/repoinit/it/RepoInitTestSupport.java b/src/test/java/org/apache/sling/jcr/repoinit/it/RepoInitTestSupport.java
index 8c13b07..4019d65 100644
--- a/src/test/java/org/apache/sling/jcr/repoinit/it/RepoInitTestSupport.java
+++ b/src/test/java/org/apache/sling/jcr/repoinit/it/RepoInitTestSupport.java
@@ -63,6 +63,7 @@ public abstract class RepoInitTestSupport extends TestSupport {
     @Configuration
     public Option[] configuration() {
         SlingOptions.versionResolver.setVersionFromProject("org.apache.jackrabbit", "jackrabbit-api");
+        SlingOptions.versionResolver.setVersionFromProject("org.apache.sling", "org.apache.sling.repoinit.parser");
         final String localRepo = System.getProperty("maven.repo.local", "");
         final Option[] options = 
         remove(new Option[] {
@@ -75,7 +76,6 @@ public abstract class RepoInitTestSupport extends TestSupport {
             when(localRepo.length() > 0).useOptions(
                 systemProperty("org.ops4j.pax.url.mvn.localRepository").value(localRepo)
             ),
-            mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.repoinit.parser").versionAsInProject(),
             junitBundles(),
             newConfiguration("org.apache.sling.jcr.base.internal.LoginAdminWhitelist")
                 .put("whitelist.bundles.regexp", "^PAXEXAM.*$")
diff --git a/src/test/java/org/apache/sling/jcr/repoinit/it/RepoInitTextIT.java b/src/test/java/org/apache/sling/jcr/repoinit/it/RepoInitTextIT.java
index 4903b7d..10b363f 100644
--- a/src/test/java/org/apache/sling/jcr/repoinit/it/RepoInitTextIT.java
+++ b/src/test/java/org/apache/sling/jcr/repoinit/it/RepoInitTextIT.java
@@ -44,6 +44,8 @@ public class RepoInitTextIT extends RepoInitTestSupport {
 
     private static final String FRED_WILMA = "fredWilmaService";
     private static final String ANOTHER = "anotherService";
+    private static final String ALICE = "alice";
+    private static final String BOB = "bob";
 
     public static final String REPO_INIT_FILE = "/repoinit.txt";
 
@@ -72,11 +74,13 @@ public class RepoInitTextIT extends RepoInitTestSupport {
     }
 
     @Test
-    public void serviceUserCreated() throws Exception {
+    public void serviceUserCreatedWithHomePath() throws Exception {
         new Retry() {
             @Override
             public Void call() throws Exception {
                 assertTrue("Expecting user " + FRED_WILMA, U.userExists(session, FRED_WILMA));
+                final String path = U.getHomePath(session, FRED_WILMA);
+                assertTrue("Expecting path " + path, session.itemExists(path));
                 return null;
             }
         };
@@ -112,4 +116,19 @@ public class RepoInitTextIT extends RepoInitTestSupport {
         session.getRootNode().addNode(nodeName, "slingtest:unstructured");
         session.save();
     }
+
+    @Test
+    public void fredWilmaHomeAcl() throws Exception {
+        new Retry() {
+            @Override
+            public Void call() throws Exception {
+                assertTrue("Expecting user " + FRED_WILMA, U.userExists(session, FRED_WILMA));
+                final String path = U.getHomePath(session, FRED_WILMA);
+                assertTrue("Expecting path " + path, session.itemExists(path));
+                assertTrue("Expecting write access for alice", U.canWrite(session, ALICE, path));
+                assertFalse("Expecting no access for bob", U.canRead(session, BOB, path));
+                return null;
+            }
+        };
+    }
 }
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/jcr/repoinit/it/U.java b/src/test/java/org/apache/sling/jcr/repoinit/it/U.java
index cf834a3..499e94f 100644
--- a/src/test/java/org/apache/sling/jcr/repoinit/it/U.java
+++ b/src/test/java/org/apache/sling/jcr/repoinit/it/U.java
@@ -25,6 +25,7 @@ import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
+import javax.jcr.UnsupportedRepositoryOperationException;
 
 import org.apache.jackrabbit.api.JackrabbitSession;
 import org.apache.jackrabbit.api.security.user.Authorizable;
@@ -66,6 +67,9 @@ public class U {
             serviceSession.save();
         } catch(AccessDeniedException ade) {
             return false;
+        } catch(PathNotFoundException pnf) {
+            // Thrown when access is denied to a user's home node
+            return false;
         } finally {
             serviceSession.logout();
         }
@@ -84,9 +88,18 @@ public class U {
             serviceSession.getItem(path);
         } catch(AccessDeniedException ade) {
             return false;
+        } catch(PathNotFoundException pnf) {
+            // Thrown when access is denied to a user's home node
+            return false;
         } finally {
             serviceSession.logout();
         }
         return true;
     }
+
+    public static String getHomePath(Session session, String userId)
+    throws UnsupportedRepositoryOperationException, RepositoryException {
+        final Authorizable a = ((JackrabbitSession)session).getUserManager().getAuthorizable(userId);
+        return a.getPath();
+    }
 }
\ No newline at end of file
diff --git a/src/test/resources/repoinit.txt b/src/test/resources/repoinit.txt
index 17d892d..897f262 100644
--- a/src/test/resources/repoinit.txt
+++ b/src/test/resources/repoinit.txt
@@ -47,3 +47,12 @@ register nodetypes
 << <slingtest='http://sling.apache.org/ns/test/repoinit-it/v1.0'>
 << [slingtest:unstructured] > nt:unstructured
 ===>>
+
+# SLING-8757 home() functions
+create user alice
+create user bob
+
+set ACL on home(fredWilmaService)
+  allow jcr:all for alice
+  deny jcr:all for bob
+end
\ No newline at end of file


[sling-org-apache-sling-jcr-repoinit] 01/02: Remove unused imports

Posted by bd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-repoinit.git

commit 9b8a8daf523bd6f803bf88baf97e183526fe1f67
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Thu Feb 20 11:21:37 2020 +0100

    Remove unused imports
---
 .../java/org/apache/sling/jcr/repoinit/PrincipalBasedAclTest.java    | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/src/test/java/org/apache/sling/jcr/repoinit/PrincipalBasedAclTest.java b/src/test/java/org/apache/sling/jcr/repoinit/PrincipalBasedAclTest.java
index 67f51d5..aeb33b4 100644
--- a/src/test/java/org/apache/sling/jcr/repoinit/PrincipalBasedAclTest.java
+++ b/src/test/java/org/apache/sling/jcr/repoinit/PrincipalBasedAclTest.java
@@ -20,9 +20,6 @@ import org.apache.jackrabbit.api.JackrabbitRepository;
 import org.apache.jackrabbit.api.JackrabbitSession;
 import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager;
 import org.apache.jackrabbit.api.security.authorization.PrincipalAccessControlList;
-import org.apache.jackrabbit.api.JackrabbitSession;
-import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager;
-import org.apache.jackrabbit.api.security.authorization.PrincipalAccessControlList;
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.UserManager;
 import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils;
@@ -65,8 +62,6 @@ import javax.security.auth.Subject;
 import java.security.Principal;
 import java.security.PrivilegedExceptionAction;
 import java.util.Collections;
-import java.util.List;
-import java.util.Set;
 
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;