jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r772171 - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/security/ jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/ jackrabbit-co...
Date Wed, 06 May 2009 12:22:52 GMT
Author: reschke
Date: Wed May  6 12:22:35 2009
New Revision: 772171

URL: http://svn.apache.org/viewvc?rev=772171&view=rev
Log:
JCR-2085: move security tests to jackrabbit-jcr-tests; extend RepositoryStub so that it can
provide instances of Principal.

Added:
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/
      - copied from r772109, jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/security/
Removed:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/jsr283/security/
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SkipDeniedNodesTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractACLTemplateTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractEntryTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractEvaluationTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/JackrabbitAccessControlListTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/JCRTestSuite.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/JNDIRepositoryStub.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryHelper.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryStub.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AbstractAccessControlTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlDiscoveryTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlListTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlPolicyIteratorTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlPolicyTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlDiscoveryTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlPolicyTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlTest.java
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/TestAll.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/test/java/org/apache/jackrabbit/spi2dav/RepositoryStubImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java?rev=772171&r1=772170&r2=772171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/JackrabbitRepositoryStub.java
Wed May  6 12:22:35 2009
@@ -22,6 +22,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.security.Principal;
+import java.security.acl.Group;
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.HashSet;
@@ -43,6 +45,7 @@
 import org.apache.jackrabbit.api.JackrabbitWorkspace;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
 import org.apache.jackrabbit.core.retention.RetentionPolicyImpl;
+import org.apache.jackrabbit.test.NotExecutableException;
 import org.apache.jackrabbit.test.RepositoryStub;
 import org.apache.jackrabbit.test.RepositoryStubException;
 
@@ -360,4 +363,36 @@
         resource.setProperty("jcr:lastModified", Calendar.getInstance());
     }
 
+    @Override
+    public Principal getKnownPrincipal(Session session) throws RepositoryException {
+        
+        Principal knownPrincipal = null;
+        
+        if (session instanceof SessionImpl) {
+            for (Principal p : ((SessionImpl)session).getSubject().getPrincipals()) {
+                if (! (p instanceof Group)) {
+                    knownPrincipal = p;
+                }
+            }
+        }
+        
+        if (knownPrincipal != null) {
+            return knownPrincipal;
+        }
+        else {
+            throw new RepositoryException("no applicable principal found");
+        }
+    }
+
+    private static Principal UNKNOWN_PRINCIPAL = new Principal() {
+        public String getName() {
+            return "an_unknown_user";
+        }
+    };
+    
+    @Override
+    public Principal getUnknownPrincipal(Session session) throws RepositoryException, NotExecutableException
{
+        return UNKNOWN_PRINCIPAL;
+    }
+
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SkipDeniedNodesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SkipDeniedNodesTest.java?rev=772171&r1=772170&r2=772171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SkipDeniedNodesTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SkipDeniedNodesTest.java
Wed May  6 12:22:35 2009
@@ -30,11 +30,11 @@
 import javax.jcr.security.Privilege;
 
 import org.apache.jackrabbit.api.JackrabbitSession;
-import org.apache.jackrabbit.api.jsr283.security.AbstractAccessControlTest;
 import org.apache.jackrabbit.api.security.user.User;
 import org.apache.jackrabbit.api.security.user.UserManager;
 import org.apache.jackrabbit.core.security.authorization.JackrabbitAccessControlList;
 import org.apache.jackrabbit.test.NotExecutableException;
+import org.apache.jackrabbit.test.api.security.AbstractAccessControlTest;
 
 /**
  * <code>SkipDeniedNodesTest</code> checks if nodes are correctly skipped

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractACLTemplateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractACLTemplateTest.java?rev=772171&r1=772170&r2=772171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractACLTemplateTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractACLTemplateTest.java
Wed May  6 12:22:35 2009
@@ -26,11 +26,11 @@
 import javax.jcr.security.Privilege;
 
 import org.apache.jackrabbit.api.JackrabbitSession;
-import org.apache.jackrabbit.api.jsr283.security.AbstractAccessControlTest;
 import org.apache.jackrabbit.api.security.principal.PrincipalIterator;
 import org.apache.jackrabbit.api.security.principal.PrincipalManager;
 import org.apache.jackrabbit.core.security.TestPrincipal;
 import org.apache.jackrabbit.test.NotExecutableException;
+import org.apache.jackrabbit.test.api.security.AbstractAccessControlTest;
 
 /**
  * <code>AbstractACLTemplateTest</code>...

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractEntryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractEntryTest.java?rev=772171&r1=772170&r2=772171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractEntryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractEntryTest.java
Wed May  6 12:22:35 2009
@@ -27,8 +27,8 @@
 import javax.jcr.security.AccessControlException;
 import javax.jcr.security.Privilege;
 
-import org.apache.jackrabbit.api.jsr283.security.AbstractAccessControlTest;
 import org.apache.jackrabbit.test.NotExecutableException;
+import org.apache.jackrabbit.test.api.security.AbstractAccessControlTest;
 
 /**
  * <code>AbstractEntryTest</code>...

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractEvaluationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractEvaluationTest.java?rev=772171&r1=772170&r2=772171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractEvaluationTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractEvaluationTest.java
Wed May  6 12:22:35 2009
@@ -22,12 +22,12 @@
 import javax.jcr.security.AccessControlManager;
 import javax.jcr.security.Privilege;
 
-import org.apache.jackrabbit.api.jsr283.security.AbstractAccessControlTest;
 import org.apache.jackrabbit.api.security.user.User;
 import org.apache.jackrabbit.api.security.user.UserManager;
 import org.apache.jackrabbit.api.JackrabbitSession;
 import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.test.NotExecutableException;
+import org.apache.jackrabbit.test.api.security.AbstractAccessControlTest;
 import org.apache.jackrabbit.core.SessionImpl;
 
 import javax.jcr.Session;

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/JackrabbitAccessControlListTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/JackrabbitAccessControlListTest.java?rev=772171&r1=772170&r2=772171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/JackrabbitAccessControlListTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/JackrabbitAccessControlListTest.java
Wed May  6 12:22:35 2009
@@ -30,10 +30,10 @@
 import javax.jcr.security.Privilege;
 
 import org.apache.jackrabbit.api.JackrabbitSession;
-import org.apache.jackrabbit.api.jsr283.security.AbstractAccessControlTest;
 import org.apache.jackrabbit.api.security.principal.PrincipalIterator;
 import org.apache.jackrabbit.api.security.principal.PrincipalManager;
 import org.apache.jackrabbit.test.NotExecutableException;
+import org.apache.jackrabbit.test.api.security.AbstractAccessControlTest;
 
 /**
  * <code>JackrabbitAccessControlListTest</code>...

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/JCRTestSuite.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/JCRTestSuite.java?rev=772171&r1=772170&r2=772171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/JCRTestSuite.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/JCRTestSuite.java
Wed May  6 12:22:35 2009
@@ -35,6 +35,7 @@
         addTest(org.apache.jackrabbit.test.api.version.simple.TestAll.suite());
         addTest(org.apache.jackrabbit.test.api.observation.TestAll.suite());
         addTest(org.apache.jackrabbit.test.api.retention.TestAll.suite());
+        addTest(org.apache.jackrabbit.test.api.security.TestAll.suite());
     }
 
 }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/JNDIRepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/JNDIRepositoryStub.java?rev=772171&r1=772170&r2=772171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/JNDIRepositoryStub.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/JNDIRepositoryStub.java
Wed May  6 12:22:35 2009
@@ -16,9 +16,12 @@
  */
 package org.apache.jackrabbit.test;
 
+import java.security.Principal;
 import java.util.Properties;
 
 import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import javax.rmi.PortableRemoteObject;
@@ -63,4 +66,14 @@
         }
         return repository;
     }
+
+    public Principal getKnownPrincipal(Session session) throws RepositoryException {
+        // TODO Auto-generated method stub
+        throw new RepositoryException("TDB");
+    }
+
+    public Principal getUnknownPrincipal(Session session) throws RepositoryException, NotExecutableException
{
+        // TODO Auto-generated method stub
+        throw new RepositoryException("TDB");
+    }
 }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryHelper.java?rev=772171&r1=772170&r2=772171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryHelper.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryHelper.java
Wed May  6 12:22:35 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.test;
 
+import java.security.Principal;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -187,4 +188,20 @@
     public Credentials getSuperuserCredentials() {
         return repoStub.getSuperuserCredentials();
     }
+    
+    /**
+     * Returns a {@link Principal} identifiying a known user.
+     * @param session
+     */
+    public Principal getKnownPrincipal(Session session) throws RepositoryException {
+        return repoStub.getKnownPrincipal(session);
+    }
+    
+    /**
+     * Returns a {@link Principal} identifiying an unknown user.
+     * @param session
+     */
+    public Principal getUnknownPrincipal(Session session) throws NotExecutableException,
RepositoryException {
+        return repoStub.getUnknownPrincipal(session);
+    }
 }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryStub.java?rev=772171&r1=772170&r2=772171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryStub.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/RepositoryStub.java
Wed May  6 12:22:35 2009
@@ -16,21 +16,21 @@
  */
 package org.apache.jackrabbit.test;
 
-import javax.jcr.Credentials;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
-import javax.jcr.retention.RetentionPolicy;
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
-import java.util.Properties;
+import java.security.Principal;
 import java.util.Map;
+import java.util.Properties;
+
+import javax.jcr.Credentials;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
 
 /**
  * The <code>RepositoryStub</code> is the entry point to the JCR Repository
@@ -301,4 +301,18 @@
     public String getProperty(String name) {
         return environment.getProperty(name);
     }
+    
+    /**
+     * Returns a {@link Principal} identifiying a known user (not group)
+     * @param session
+     */
+    public abstract Principal getKnownPrincipal(Session session) throws RepositoryException;
+
+    /**
+     * Returns a {@link Principal} identifiying an unknown user.
+     * @param session
+     * @throws NotExecutableException if the implementation can not provide an
+     * instance of Principal for unkwnown users
+     */
+    public abstract Principal getUnknownPrincipal(Session session) throws RepositoryException,
NotExecutableException;
 }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AbstractAccessControlTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AbstractAccessControlTest.java?rev=772171&r1=772109&r2=772171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AbstractAccessControlTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AbstractAccessControlTest.java
Wed May  6 12:22:35 2009
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.api.jsr283.security;
+package org.apache.jackrabbit.test.api.security;
 
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlDiscoveryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlDiscoveryTest.java?rev=772171&r1=772109&r2=772171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlDiscoveryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlDiscoveryTest.java
Wed May  6 12:22:35 2009
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.api.jsr283.security;
+package org.apache.jackrabbit.test.api.security;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -30,7 +30,6 @@
 import javax.jcr.security.AccessControlException;
 import javax.jcr.security.Privilege;
 
-import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.test.NotExecutableException;
 
 /**
@@ -151,7 +150,7 @@
         Privilege allPriv = acMgr.privilegeFromName(Privilege.JCR_ALL);
         try {
             String remappedPrefix = "_jcr";
-            superuser.setNamespacePrefix(remappedPrefix, Name.NS_JCR_URI);
+            superuser.setNamespacePrefix(remappedPrefix, "http://www.jcp.org/jcr/1.0");
 
             List l = new ArrayList();
             l.add(acMgr.privilegeFromName(Privilege.JCR_ALL));
@@ -171,7 +170,7 @@
                 // success
             }
         } finally {
-            superuser.setNamespacePrefix(Name.NS_JCR_PREFIX, Name.NS_JCR_URI);
+            superuser.setNamespacePrefix("jcr", "http://www.jcp.org/jcr/1.0");
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlListTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlListTest.java?rev=772171&r1=772109&r2=772171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlListTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlListTest.java
Wed May  6 12:22:35 2009
@@ -14,14 +14,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.api.jsr283.security;
+package org.apache.jackrabbit.test.api.security;
 
 import java.security.Principal;
-import java.security.acl.Group;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
@@ -37,8 +35,6 @@
 import javax.jcr.security.AccessControlPolicyIterator;
 import javax.jcr.security.Privilege;
 
-import org.apache.jackrabbit.core.SessionImpl;
-import org.apache.jackrabbit.core.security.TestPrincipal;
 import org.apache.jackrabbit.test.NotExecutableException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -62,8 +58,6 @@
         super.setUp();
 
         // TODO: make sure, entries to ADD are not present yet.
-        // TODO: retrieve principal name from tck-Configuration
-        // TODO: get rid of SessionImpl dependency
         try {
             // TODO: retrieve targetPath from configuration
             Node n = testRootNode.addNode(nodeName1, testNodeType);
@@ -76,20 +70,8 @@
                 throw new NotExecutableException("No supported privileges at absPath " +
path);
             }
 
-            if (superuser instanceof SessionImpl) {
-                for (Iterator it = ((SessionImpl) superuser).getSubject().getPrincipals().iterator();
it.hasNext();) {
-                    Principal p = (Principal) it.next();
-                    if (!(p instanceof Group)) {
-                        testPrincipal = p;
-                    }
-                }
-                if (testPrincipal == null) {
-                    throw new NotExecutableException("Test principal missing.");
-                }
-            } else {
-                throw new NotExecutableException("SessionImpl expected");
-            }
-
+            testPrincipal = helper.getKnownPrincipal(superuser);
+            
             // remember existing entries for test-principal -> later restore.
             privilegesToRestore = currentPrivileges(getList(acMgr, path), testPrincipal);
         } catch (Exception e) {
@@ -335,8 +317,7 @@
     public void testAddAccessControlEntryInvalidPrincipal() throws NotExecutableException,
RepositoryException {
         checkCanModifyAc(path);
         try {
-            // TODO: retrieve unknown principal name from config
-            Principal invalidPrincipal = new TestPrincipal("an_unknown_principal");
+            Principal invalidPrincipal = helper.getUnknownPrincipal(superuser);
             AccessControlList acl = getList(acMgr, path);
             acl.addAccessControlEntry(invalidPrincipal, privs);
             fail("Adding an entry with an unknown principal must throw AccessControlException.");

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlPolicyIteratorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlPolicyIteratorTest.java?rev=772171&r1=772109&r2=772171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlPolicyIteratorTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlPolicyIteratorTest.java
Wed May  6 12:22:35 2009
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.api.jsr283.security;
+package org.apache.jackrabbit.test.api.security;
 
 import java.util.NoSuchElementException;
 
@@ -24,16 +24,12 @@
 import javax.jcr.security.AccessControlPolicyIterator;
 
 import org.apache.jackrabbit.test.NotExecutableException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * <code>AccessControlPolicyIteratorTest</code>...
  */
 public class AccessControlPolicyIteratorTest extends AbstractAccessControlTest {
 
-    private static Logger log = LoggerFactory.getLogger(AccessControlPolicyIteratorTest.class);
-
     private String path;
 
     protected void setUp() throws Exception {

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlPolicyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlPolicyTest.java?rev=772171&r1=772109&r2=772171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlPolicyTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlPolicyTest.java
Wed May  6 12:22:35 2009
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.api.jsr283.security;
+package org.apache.jackrabbit.test.api.security;
 
 import java.util.Arrays;
 import java.util.HashMap;
@@ -53,7 +53,7 @@
     protected void setUp() throws Exception {
         super.setUp();
 
-        // policy-option is cover the by the 'OPTION_ACCESS_CONTROL_SUPPORTED' -> see
super-class
+        // policy-option is covered the by the 'OPTION_ACCESS_CONTROL_SUPPORTED' -> see
super-class
 
         Node n = testRootNode.addNode(nodeName1, testNodeType);
         superuser.save();
@@ -79,7 +79,7 @@
         checkCanReadAc(path);
         // call must succeed without exception
         AccessControlPolicy[] policies = acMgr.getEffectivePolicies(path);
-        if (policies == null && policies.length == 0) {
+        if (policies == null || policies.length == 0) {
             fail("To every existing node at least a single effective policy applies.");
         }
     }

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlDiscoveryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlDiscoveryTest.java?rev=772171&r1=772109&r2=772171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlDiscoveryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlDiscoveryTest.java
Wed May  6 12:22:35 2009
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.api.jsr283.security;
+package org.apache.jackrabbit.test.api.security;
 
 import java.util.Arrays;
 import java.util.List;

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlPolicyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlPolicyTest.java?rev=772171&r1=772109&r2=772171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlPolicyTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlPolicyTest.java
Wed May  6 12:22:35 2009
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.api.jsr283.security;
+package org.apache.jackrabbit.test.api.security;
 
 import javax.jcr.AccessDeniedException;
 import javax.jcr.Node;
@@ -26,16 +26,12 @@
 import javax.jcr.security.AccessControlPolicyIterator;
 
 import org.apache.jackrabbit.test.NotExecutableException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * <code>AccessControlPolicyTest</code>...
  */
 public class RSessionAccessControlPolicyTest extends AbstractAccessControlTest {
 
-    private static Logger log = LoggerFactory.getLogger(RSessionAccessControlPolicyTest.class);
-
     private String path;
     private Session readOnlySession;
     private AccessControlManager testAcMgr;

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlTest.java?rev=772171&r1=772109&r2=772171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/RSessionAccessControlTest.java
Wed May  6 12:22:35 2009
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.api.jsr283.security;
+package org.apache.jackrabbit.test.api.security;
 
 import javax.jcr.AccessDeniedException;
 import javax.jcr.Node;

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/TestAll.java?rev=772171&r1=772109&r2=772171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/TestAll.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/TestAll.java
Wed May  6 12:22:35 2009
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.api.jsr283.security;
+package org.apache.jackrabbit.test.api.security;
 
 import junit.framework.Test;
 import junit.framework.TestCase;

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/test/java/org/apache/jackrabbit/spi2dav/RepositoryStubImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/test/java/org/apache/jackrabbit/spi2dav/RepositoryStubImpl.java?rev=772171&r1=772170&r2=772171&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/test/java/org/apache/jackrabbit/spi2dav/RepositoryStubImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/test/java/org/apache/jackrabbit/spi2dav/RepositoryStubImpl.java
Wed May  6 12:22:35 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.spi2dav;
 
+import org.apache.jackrabbit.test.NotExecutableException;
 import org.apache.jackrabbit.test.RepositoryStub;
 import org.apache.jackrabbit.test.RepositoryStubException;
 import org.apache.jackrabbit.spi.RepositoryService;
@@ -32,6 +33,9 @@
 
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import java.security.Principal;
 import java.util.Properties;
 
 /**
@@ -80,4 +84,14 @@
         QValueFactory vFactory = QValueFactoryImpl.getInstance();
         return new RepositoryServiceImpl(uri, idFactory, nFactory, pFactory, vFactory);
     }
+
+    public Principal getKnownPrincipal(Session session) throws RepositoryException {
+        // TODO Auto-generated method stub
+        throw new RepositoryException("TBD");
+    }
+
+    public Principal getUnknownPrincipal(Session session) throws RepositoryException, NotExecutableException
{
+        // TODO Auto-generated method stub
+        throw new RepositoryException("TBD");
+    }
 }
\ No newline at end of file



Mime
View raw message