jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1467017 - in /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak: ./ core/ security/authorization/ spi/security/authorization/
Date Thu, 11 Apr 2013 18:05:15 GMT
Author: angela
Date: Thu Apr 11 18:05:15 2013
New Revision: 1467017

URL: http://svn.apache.org/r1467017
Log:
simplify tests

Modified:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/AbstractSecurityTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/ShadowInvisibleContentTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/AbstractAccessControlTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/AbstractSecurityTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/AbstractSecurityTest.java?rev=1467017&r1=1467016&r2=1467017&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/AbstractSecurityTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/AbstractSecurityTest.java
Thu Apr 11 18:05:15 2013
@@ -19,12 +19,16 @@ package org.apache.jackrabbit.oak;
 import javax.annotation.Nullable;
 import javax.jcr.Credentials;
 import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.RepositoryException;
 import javax.jcr.SimpleCredentials;
 import javax.jcr.security.AccessControlManager;
+import javax.jcr.security.Privilege;
 import javax.security.auth.login.Configuration;
 import javax.security.auth.login.LoginException;
 
 import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager;
+import org.apache.jackrabbit.api.security.authorization.PrivilegeManager;
+import org.apache.jackrabbit.api.security.principal.PrincipalManager;
 import org.apache.jackrabbit.api.security.user.UserManager;
 import org.apache.jackrabbit.oak.api.ContentRepository;
 import org.apache.jackrabbit.oak.api.ContentSession;
@@ -50,6 +54,7 @@ public abstract class AbstractSecurityTe
 
     private ContentRepository contentRepository;
     private UserManager userManager;
+    private PrivilegeManager privMgr;
 
     protected NamePathMapper namePathMapper = NamePathMapper.DEFAULT;
     protected SecurityProvider securityProvider;
@@ -99,6 +104,9 @@ public abstract class AbstractSecurityTe
         return new SimpleCredentials(adminId, adminId.toCharArray());
     }
 
+    protected NamePathMapper getNamePathMapper() {
+        return namePathMapper;
+    }
 
     protected UserConfiguration getUserConfiguration() {
         return getSecurityProvider().getUserConfiguration();
@@ -110,6 +118,10 @@ public abstract class AbstractSecurityTe
         }
         return userManager;
     }
+
+    protected PrincipalManager getPrincipalManager() {
+        return getSecurityProvider().getPrincipalConfiguration().getPrincipalManager(root,
getNamePathMapper());
+    }
     
     protected JackrabbitAccessControlManager getAccessControlManager(Root root) {
         AccessControlManager acMgr = securityProvider.getAccessControlConfiguration().getAccessControlManager(root,
NamePathMapper.DEFAULT);
@@ -119,4 +131,19 @@ public abstract class AbstractSecurityTe
             throw new UnsupportedOperationException("Expected JackrabbitAccessControlManager
found " + acMgr.getClass());
         }
     }
+
+    protected Privilege[] privilegesFromNames(String... privilegeNames) throws RepositoryException
{
+        Privilege[] privs = new Privilege[privilegeNames.length];
+        for (int i = 0; i < privilegeNames.length; i++) {
+            privs[i] = getPrivilegeManager().getPrivilege(privilegeNames[i]);
+        }
+        return privs;
+    }
+
+    protected PrivilegeManager getPrivilegeManager() {
+        if (privMgr == null) {
+            privMgr = getSecurityProvider().getPrivilegeConfiguration().getPrivilegeManager(root,
getNamePathMapper());
+        }
+        return privMgr;
+    }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java?rev=1467017&r1=1467016&r2=1467017&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplTest.java
Thu Apr 11 18:05:15 2013
@@ -36,10 +36,8 @@ import org.junit.Test;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 public class RootImplTest extends OakBaseTest {
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/ShadowInvisibleContentTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/ShadowInvisibleContentTest.java?rev=1467017&r1=1467016&r2=1467017&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/ShadowInvisibleContentTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/ShadowInvisibleContentTest.java
Thu Apr 11 18:05:15 2013
@@ -18,14 +18,7 @@
  */
 package org.apache.jackrabbit.oak.security.authorization;
  
-import static org.apache.jackrabbit.JcrConstants.NT_UNSTRUCTURED;
-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 java.security.Principal;
-
 import javax.jcr.NoSuchWorkspaceException;
 import javax.jcr.RepositoryException;
 import javax.jcr.SimpleCredentials;
@@ -46,8 +39,15 @@ import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 
+import static org.apache.jackrabbit.JcrConstants.NT_UNSTRUCTURED;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
 public class ShadowInvisibleContentTest extends AbstractSecurityTest {
-	private static final String USER_ID = "test";
+
+    private static final String USER_ID = "test";
 
 	private Principal userPrincipal;
   
@@ -72,7 +72,7 @@ public class ShadowInvisibleContentTest 
 
         AccessControlManager acMgr = getAccessControlManager(root);
         JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr,
path);
-        acl.addEntry(principal,AccessControlUtils.privilegesFromNames(acMgr, privilegeName)
, isAllow);
+        acl.addEntry(principal, privilegesFromNames(privilegeName) , isAllow);
         acMgr.setPolicy(path, acl);
         root.commit();
     }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/AbstractAccessControlTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/AbstractAccessControlTest.java?rev=1467017&r1=1467016&r2=1467017&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/AbstractAccessControlTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/AbstractAccessControlTest.java
Thu Apr 11 18:05:15 2013
@@ -17,14 +17,10 @@
 package org.apache.jackrabbit.oak.spi.security.authorization;
 
 import javax.jcr.NamespaceRegistry;
-import javax.jcr.security.Privilege;
 
-import org.apache.jackrabbit.api.security.authorization.PrivilegeManager;
-import org.apache.jackrabbit.api.security.principal.PrincipalManager;
 import org.apache.jackrabbit.oak.AbstractSecurityTest;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
-import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.plugins.name.ReadWriteNamespaceRegistry;
 import org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider;
 
@@ -33,7 +29,6 @@ import org.apache.jackrabbit.oak.spi.sec
  */
 public abstract class AbstractAccessControlTest extends AbstractSecurityTest {
 
-    private PrivilegeManager privMgr;
     private RestrictionProvider restrictionProvider;
 
     protected void registerNamespace(String prefix, String uri) throws Exception {
@@ -51,33 +46,10 @@ public abstract class AbstractAccessCont
         nsRegistry.registerNamespace(prefix, uri);
     }
 
-    protected NamePathMapper getNamePathMapper() {
-        return namePathMapper;
-    }
-
-    protected Privilege[] privilegesFromNames(String... privilegeNames) throws Exception
{
-        Privilege[] privs = new Privilege[privilegeNames.length];
-        for (int i = 0; i < privilegeNames.length; i++) {
-            privs[i] = getPrivilegeManager().getPrivilege(privilegeNames[i]);
-        }
-        return privs;
-    }
-
     protected RestrictionProvider getRestrictionProvider() {
         if (restrictionProvider == null) {
             restrictionProvider = getSecurityProvider().getAccessControlConfiguration().getRestrictionProvider(getNamePathMapper());
         }
         return restrictionProvider;
     }
-
-    protected PrincipalManager getPrincipalManager() {
-        return getSecurityProvider().getPrincipalConfiguration().getPrincipalManager(root,
getNamePathMapper());
-    }
-
-    protected PrivilegeManager getPrivilegeManager() {
-        if (privMgr == null) {
-            privMgr = getSecurityProvider().getPrivilegeConfiguration().getPrivilegeManager(root,
getNamePathMapper());
-        }
-        return privMgr;
-    }
 }



Mime
View raw message