anchela commented on a change in pull request #22:
URL: 
https://github.com/apache/sling-org-apache-sling-jcr-repoinit/pull/22#discussion_r816926678



##########
File path: 
src/test/java/org/apache/sling/jcr/repoinit/PrincipalBasedAclTest.java
##########
@@ -692,28 +693,64 @@ public void testRemoveMatchingEntry() throws Exception {
         }
     }
 
+    @Test
+    public void testRemoveNoExistingPolicy() throws Exception {
+        String setup = "remove principal ACL for " + U.username + "\n"
+                + "allow jcr:read on " + path + "\n"
+                + "end";
+        U.parseAndExecute(setup);
+    }
+
+    @Test
+    public void testRemoveMatchingEntry() throws Exception {
+        Principal principal = getPrincipal(U.username);
+        String setup = "set principal ACL for " + U.username + "\n"
+                + "allow jcr:write on "+path+"\n"
+                + "end";
+        U.parseAndExecute(setup);
+        assertPolicy(principal, U.adminSession, 1);
+
+        // privilege mismatch
+        setup = "remove principal ACL for " + U.username + "\n"
+                + "allow jcr:read,jcr:write on " + path + "\n"
+                + "end";
+        U.parseAndExecute(setup);
+        assertPolicy(principal, U.adminSession, 1);
+
+        // path mismatch
+        setup = "remove principal ACL for " + U.username + "\n"
+                + "allow jcr:write on " + path + "/mismatch\n"
+                + "end";
+        U.parseAndExecute(setup);
+        assertPolicy(principal, U.adminSession, 1);
+
+        // restriction mismatch
+        setup = "remove principal ACL for " + U.username + "\n"
+                + "allow jcr:write on " + path + " restriction(rep:glob, 
/*/jcr:content/*)\n"
+                + "end";
+        U.parseAndExecute(setup);
+        assertPolicy(principal, U.adminSession, 1);
+    }
+
     @Test
     public void testRemoveNoMatchingEntry() throws Exception {
+        Principal principal = getPrincipal(U.username);
         String setup = "set principal ACL for " + U.username + "\n"
                 + "allow jcr:write on "+path+"\n"
                 + "end";
         U.parseAndExecute(setup);
+        assertPolicy(principal, U.adminSession, 1);
 
-        setup = "set principal ACL for " + U.username + "\n"
-                + "remove jcr:read on " + path + "\n"
+        setup = "remove principal ACL for " + U.username + "\n"
+                + "allow jcr:read on " + path + "\n"
                 + "end";
-        try {
-            U.parseAndExecute(setup);
-            fail("Expecting REMOVE to fail");
-        } catch(RuntimeException rex) {
-            assertRegex(REMOVE_NOT_SUPPORTED_REGEX, rex.getMessage());
-        }      
+        assertPolicy(principal, U.adminSession, 1);
     }
 
-    @Test(expected = RuntimeException.class)
+    @Test(expected = RepoInitException.class)
     public void testRemoveNonExistingPrincipal() throws Exception {
-        String setup = "set principal ACL for nonExistingPrincipal\n"

Review comment:
       this one didn't go away.... instead i refactored the tests. i think 1 
test to make sure the unsupported remove-action really throws an exception is 
sufficient.... instead wanted to have extra coverage for the new removal.

##########
File path: 
src/test/java/org/apache/sling/jcr/repoinit/PrincipalBasedAclTest.java
##########
@@ -725,16 +762,16 @@ public void testRemovePrincipalMismatch() throws 
Exception {
                 + "end";
         U.parseAndExecute(setup);
         U.parseAndExecute("create service user otherSystemPrincipal");
+        assertPolicy(getPrincipal(U.username), U.adminSession, 1);
 
-        try {
-            setup = "set principal ACL for otherSystemPrincipal\n"
-            + "remove jcr:write on " + path + "\n"
-            + "end";
-            U.parseAndExecute(setup);
-            fail("Expecting REMOVE to fail");
-        } catch(RuntimeException rex) {
-            assertRegex(REMOVE_NOT_SUPPORTED_REGEX, rex.getMessage());

Review comment:
       see above.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to