You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by an...@apache.org on 2021/05/18 15:37:58 UTC

[sling-org-apache-sling-feature-cpconverter] branch SLING-10386_2 created (now cb2b61b)

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

angela pushed a change to branch SLING-10386_2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-cpconverter.git.


      at cb2b61b  SLING-10386 : Converter needs to issue create path statements for repoinit path without node type (special handling for root and repository path)

This branch includes the following new commits:

     new cb2b61b  SLING-10386 : Converter needs to issue create path statements for repoinit path without node type (special handling for root and repository path)

The 1 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.


[sling-org-apache-sling-feature-cpconverter] 01/01: SLING-10386 : Converter needs to issue create path statements for repoinit path without node type (special handling for root and repository path)

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

angela pushed a commit to branch SLING-10386_2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-cpconverter.git

commit cb2b61b39fe0d1f597c2012af16f5e402a00735e
Author: angela <an...@adobe.com>
AuthorDate: Tue May 18 17:37:42 2021 +0200

    SLING-10386 : Converter needs to issue create path statements for repoinit path without node type (special handling for root and repository path)
---
 .../accesscontrol/DefaultAclManager.java           |  3 +++
 .../cpconverter/accesscontrol/AclManagerTest.java  | 31 ++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/src/main/java/org/apache/sling/feature/cpconverter/accesscontrol/DefaultAclManager.java b/src/main/java/org/apache/sling/feature/cpconverter/accesscontrol/DefaultAclManager.java
index e071f3b..623af48 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/accesscontrol/DefaultAclManager.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/accesscontrol/DefaultAclManager.java
@@ -439,6 +439,9 @@ public class DefaultAclManager implements AclManager, EnforceInfo {
             // user-root 
             log.warn("Failed to extract primary type information for node at path '{}'", path);
             return null;
+        } else if (path.getParent() == null) {
+            log.debug("Omit create path statement for path '{}'", path);
+            return null;
         } else {
             // assume that primary type information is present or can be extracted from default primary type definition 
             // of the the top-level nodes (i.e. their effective node type definition).
diff --git a/src/test/java/org/apache/sling/feature/cpconverter/accesscontrol/AclManagerTest.java b/src/test/java/org/apache/sling/feature/cpconverter/accesscontrol/AclManagerTest.java
index 06fe4f2..05453bf 100644
--- a/src/test/java/org/apache/sling/feature/cpconverter/accesscontrol/AclManagerTest.java
+++ b/src/test/java/org/apache/sling/feature/cpconverter/accesscontrol/AclManagerTest.java
@@ -28,6 +28,7 @@ import org.apache.sling.feature.cpconverter.vltpkg.VaultPackageAssembler;
 import org.apache.sling.repoinit.parser.RepoInitParser;
 import org.apache.sling.repoinit.parser.RepoInitParsingException;
 import org.apache.sling.repoinit.parser.impl.RepoInitParserService;
+import org.apache.sling.repoinit.parser.operations.CreatePath;
 import org.apache.sling.repoinit.parser.operations.Operation;
 import org.junit.After;
 import org.junit.Before;
@@ -47,6 +48,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verifyNoInteractions;
@@ -377,4 +379,33 @@ public class AclManagerTest {
         return new AccessControlEntry(isAllow, Arrays.asList(privileges.split(",")), new RepoPath(PlatformNameFormat.getRepositoryPath(path)));
     }
 
+    @Test
+    public void testGetCreatePathForRootNode() {
+        RepoPath rootPath = new RepoPath("/");
+        DefaultAclManager aclManager = new DefaultAclManager();
+        CreatePath cp = aclManager.getCreatePath(rootPath, Collections.emptyList());
+        assertNull(cp);
+    }
+
+    @Test
+    public void testGetCreatePathForRepositoryPath() {
+        RepoPath repoPath = new RepoPath("");
+        assertTrue(repoPath.isRepositoryPath());
+        
+        DefaultAclManager aclManager = new DefaultAclManager();
+        CreatePath cp = aclManager.getCreatePath(repoPath, Collections.emptyList());
+        assertNull(cp);
+    }
+
+    @Test
+    public void testGetCreatePathForPathBelowUserRoot() {
+        RepoPath userPath = new RepoPath("/home/user/system/feature/usernode");
+        DefaultAclManager aclManager = new DefaultAclManager();
+        aclManager.addSystemUser(new SystemUser("systemUser", userPath, userPath.getParent()));
+        
+        CreatePath cp = aclManager.getCreatePath(new RepoPath("/home/somenode"), Collections.emptyList());
+        assertNull(cp);
+        cp = aclManager.getCreatePath(new RepoPath("/home"), Collections.emptyList());
+        assertNull(cp);
+    }
 }