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

rombert pushed a commit to annotated tag org.apache.sling.jcr.repoinit-1.0.0
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-repoinit.git

commit a52d167e8820f048d58da12161ab8a6ea0e060ff
Author: Bertrand Delacretaz <bdelacre...@apache.org>
AuthorDate: Wed Dec 23 11:27:28 2015 +0000

    SLING-5355 - cleanup tests
    
    git-svn-id: 
https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/acldef/oak-jcr@1721522
 13f79535-47bb-0310-9956-ffa450edef68
---
 ...otAddChildNodeTest.java => GeneralAclTest.java} | 24 ++++++++++++++++------
 .../sling/acldef/jcr/NonExistentPathTest.java      |  2 +-
 .../java/org/apache/sling/acldef/jcr/TestUtil.java |  5 +++++
 3 files changed, 24 insertions(+), 7 deletions(-)

diff --git 
a/src/test/java/org/apache/sling/acldef/jcr/RootAddChildNodeTest.java 
b/src/test/java/org/apache/sling/acldef/jcr/GeneralAclTest.java
similarity index 84%
rename from src/test/java/org/apache/sling/acldef/jcr/RootAddChildNodeTest.java
rename to src/test/java/org/apache/sling/acldef/jcr/GeneralAclTest.java
index 63d5b3e..c4cfb12 100644
--- a/src/test/java/org/apache/sling/acldef/jcr/RootAddChildNodeTest.java
+++ b/src/test/java/org/apache/sling/acldef/jcr/GeneralAclTest.java
@@ -34,8 +34,8 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
-/** Test root node and node creation privileges */
-public class RootAddChildNodeTest {
+/** Various ACL-related tests */
+public class GeneralAclTest {
 
     @Rule
     public final SlingContext context = new 
SlingContext(ResourceResolverType.JCR_OAK);
@@ -52,17 +52,17 @@ public class RootAddChildNodeTest {
 
     @After
     public void cleanup() throws ParseException, RepositoryException {
-        U.parseAndExecute("delete service user " + U.username);
+        U.cleanupUser();
         s.logout();
     }
     
     @Test(expected=AccessDeniedException.class)
-    public void getRootNodeFails() throws Exception {
+    public void getRootNodeIntiallyFails() throws Exception {
         s.getRootNode();
     }
     
     @Test
-    public void readOnlyThenWrite() throws Exception {
+    public void readOnlyThenWriteThenDeny() throws Exception {
         final Node tmp = U.adminSession.getRootNode().addNode("tmp_" + U.id);
         U.adminSession.save();
         final String path = tmp.getPath();
@@ -84,7 +84,7 @@ public class RootAddChildNodeTest {
         try {
             n.setProperty("U.id", U.id);
             s.save();
-            fail("Expected write access to be denied:" + path);
+            fail("Expected write access to be initially denied:" + path);
         } catch(AccessDeniedException ignore) {
         }
         s.refresh(false);
@@ -97,6 +97,18 @@ public class RootAddChildNodeTest {
         U.parseAndExecute(allowWrite);
         n.setProperty("U.id", U.id);
         s.save();
+        
+        final String deny = 
+                "set ACL for " + U.username + "\n"
+                + "deny jcr:all on " + path + "\n"
+                + "end"
+                ;
+        U.parseAndExecute(deny);
+        try {
+            s.getNode(path);
+            fail("Expected access to be denied again:" + path);
+        } catch(PathNotFoundException ignore) {
+        }
     }
     
     @Test
diff --git a/src/test/java/org/apache/sling/acldef/jcr/NonExistentPathTest.java 
b/src/test/java/org/apache/sling/acldef/jcr/NonExistentPathTest.java
index 184853d..50746cc 100644
--- a/src/test/java/org/apache/sling/acldef/jcr/NonExistentPathTest.java
+++ b/src/test/java/org/apache/sling/acldef/jcr/NonExistentPathTest.java
@@ -48,7 +48,7 @@ public class NonExistentPathTest {
 
     @After
     public void cleanup() throws ParseException, RepositoryException {
-        U.parseAndExecute("delete service user " + U.username);
+        U.cleanupUser();
         s.logout();
     }
     
diff --git a/src/test/java/org/apache/sling/acldef/jcr/TestUtil.java 
b/src/test/java/org/apache/sling/acldef/jcr/TestUtil.java
index 70d5533..ea9c9bb 100644
--- a/src/test/java/org/apache/sling/acldef/jcr/TestUtil.java
+++ b/src/test/java/org/apache/sling/acldef/jcr/TestUtil.java
@@ -77,6 +77,11 @@ class TestUtil {
         adminSession.save();
     }
     
+    void cleanupUser() throws ParseException, RepositoryException {
+        parseAndExecute("delete service user " + username);
+        assertServiceUser("in cleanupUser()", username, false);
+    }
+    
     Session loginService(String serviceUsername) throws RepositoryException {
         final SimpleCredentials cred = new SimpleCredentials(serviceUsername, 
new char[0]);
         return adminSession.impersonate(cred);

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <commits@sling.apache.org>.

Reply via email to