jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1469811 - in /jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization: AbstractEvaluationTest.java NamespaceManagementTest.java NodeTypeDefinitionManagementTest.java PrivilegeManagementTest.java
Date Fri, 19 Apr 2013 13:02:00 GMT
Author: angela
Date: Fri Apr 19 13:02:00 2013
New Revision: 1469811

URL: http://svn.apache.org/r1469811
Log:
OAK-527: permissions (wip, tests)

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/AbstractEvaluationTest.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/NamespaceManagementTest.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/NodeTypeDefinitionManagementTest.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/PrivilegeManagementTest.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/AbstractEvaluationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/AbstractEvaluationTest.java?rev=1469811&r1=1469810&r2=1469811&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/AbstractEvaluationTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/AbstractEvaluationTest.java
Fri Apr 19 13:02:00 2013
@@ -163,15 +163,14 @@ public abstract class AbstractEvaluation
         return getHelper().getRepository().login(creds);
     }
 
-    protected static UserManager getUserManager(Session session) throws
-            NotExecutableException {
+    protected static UserManager getUserManager(Session session) throws NotExecutableException
{
         if (!(session instanceof JackrabbitSession)) {
             throw new NotExecutableException();
         }
         try {
             return ((JackrabbitSession) session).getUserManager();
         } catch (RepositoryException e) {
-            throw new NotExecutableException();
+            throw new NotExecutableException(e.getMessage());
         }
     }
 
@@ -193,14 +192,16 @@ public abstract class AbstractEvaluation
         return Collections.singletonMap("rep:glob", testSession.getValueFactory().createValue(value));
     }
 
-    protected void assertHasPrivilege(@Nullable String path,
-                                      @Nonnull String privName, boolean isAllow) throws Exception
{
+    protected void assertHasRepoPrivilege(@Nonnull String privName, boolean isAllow) throws
Exception {
         Privilege[] privs = privilegesFromName(privName.toString());
-        assertEquals(isAllow, testAcMgr.hasPrivileges(path, privs));
+        assertEquals(isAllow, testAcMgr.hasPrivileges(null, privs));
+    }
+
+    protected void assertHasPrivilege(@Nonnull String path, @Nonnull String privName, boolean
isAllow) throws Exception {
+        assertHasPrivileges(path, privilegesFromName(privName), isAllow);
     }
 
-    protected void assertHasPrivileges(@Nullable String path,
-                                       @Nonnull Privilege[] privileges, boolean isAllow)
throws Exception {
+    protected void assertHasPrivileges(@Nonnull String path, @Nonnull Privilege[] privileges,
boolean isAllow) throws Exception {
         if (testSession.nodeExists(path)) {
             assertEquals(isAllow, testAcMgr.hasPrivileges(path, privileges));
         } else {
@@ -218,8 +219,7 @@ public abstract class AbstractEvaluation
         assertArrayEquals(privilegesFromName(Privilege.JCR_READ), privs);
     }
 
-    protected JackrabbitAccessControlList modify(@Nullable String path,
-                                                 @Nonnull String privilege, boolean isAllow)
throws Exception {
+    protected JackrabbitAccessControlList modify(@Nullable String path, @Nonnull String privilege,
boolean isAllow) throws Exception {
         return modify(path, testUser.getPrincipal(), privilegesFromName(privilege), isAllow,
EMPTY_RESTRICTIONS);
     }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/NamespaceManagementTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/NamespaceManagementTest.java?rev=1469811&r1=1469810&r2=1469811&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/NamespaceManagementTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/NamespaceManagementTest.java
Fri Apr 19 13:02:00 2013
@@ -41,7 +41,7 @@ public class NamespaceManagementTest ext
     protected void setUp() throws Exception {
         super.setUp();
 
-        assertHasPrivilege(null, JCR_NAMESPACE_MANAGEMENT, false);
+        assertHasRepoPrivilege(JCR_NAMESPACE_MANAGEMENT, false);
     }
 
     @Override
@@ -93,10 +93,10 @@ public class NamespaceManagementTest ext
     @Test
     public void testModifyNamespaceWithPrivilege() throws Exception {
         modify(null, JCR_NAMESPACE_MANAGEMENT.toString(), true);
-        assertHasPrivilege(null, JCR_NAMESPACE_MANAGEMENT, true);
+        assertHasRepoPrivilege(JCR_NAMESPACE_MANAGEMENT, true);
 
         modify(null, JCR_NAMESPACE_MANAGEMENT.toString(), false);
-        assertHasPrivilege(null, JCR_NAMESPACE_MANAGEMENT, false);
+        assertHasRepoPrivilege(JCR_NAMESPACE_MANAGEMENT, false);
     }
 
     @Test

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/NodeTypeDefinitionManagementTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/NodeTypeDefinitionManagementTest.java?rev=1469811&r1=1469810&r2=1469811&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/NodeTypeDefinitionManagementTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/NodeTypeDefinitionManagementTest.java
Fri Apr 19 13:02:00 2013
@@ -39,7 +39,7 @@ public class NodeTypeDefinitionManagemen
     protected void setUp() throws Exception {
         super.setUp();
 
-        assertHasPrivilege(null, JCR_NODE_TYPE_DEFINITION_MANAGEMENT, false);
+        assertHasRepoPrivilege(JCR_NODE_TYPE_DEFINITION_MANAGEMENT, false);
     }
 
     @Override
@@ -99,10 +99,10 @@ public class NodeTypeDefinitionManagemen
     @Test
     public void testModifyNodeTypeWithPrivilege() throws Exception {
         modify(null, JCR_NODE_TYPE_DEFINITION_MANAGEMENT.toString(), true);
-        assertHasPrivilege(null, JCR_NODE_TYPE_DEFINITION_MANAGEMENT, true);
+        assertHasRepoPrivilege(JCR_NODE_TYPE_DEFINITION_MANAGEMENT, true);
 
         modify(null, JCR_NODE_TYPE_DEFINITION_MANAGEMENT.toString(), false);
-        assertHasPrivilege(null, JCR_NODE_TYPE_DEFINITION_MANAGEMENT, false);
+        assertHasRepoPrivilege(JCR_NODE_TYPE_DEFINITION_MANAGEMENT, false);
     }
 
     @Test

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/PrivilegeManagementTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/PrivilegeManagementTest.java?rev=1469811&r1=1469810&r2=1469811&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/PrivilegeManagementTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/PrivilegeManagementTest.java
Fri Apr 19 13:02:00 2013
@@ -39,7 +39,7 @@ public class PrivilegeManagementTest ext
         super.setUp();
 
         // test user must not be allowed
-        assertHasPrivilege(null, REP_PRIVILEGE_MANAGEMENT, false);
+        assertHasRepoPrivilege(REP_PRIVILEGE_MANAGEMENT, false);
     }
 
     @Override
@@ -86,10 +86,10 @@ public class PrivilegeManagementTest ext
     @Test
     public void testModifyPrivilegeMgtPrivilege() throws Exception {
         modify(null, REP_PRIVILEGE_MANAGEMENT, true);
-        assertHasPrivilege(null, REP_PRIVILEGE_MANAGEMENT, true);
+        assertHasRepoPrivilege(REP_PRIVILEGE_MANAGEMENT, true);
 
         modify(null, REP_PRIVILEGE_MANAGEMENT, false);
-        assertHasPrivilege(null, REP_PRIVILEGE_MANAGEMENT, false);
+        assertHasRepoPrivilege(REP_PRIVILEGE_MANAGEMENT, false);
     }
 
     @Test



Mime
View raw message