jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r644215 [3/3] - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/security/ main/java/org/apache/jackrabbit/core/security/authorization/ main/java/org/apache/jackrabbit/core/security/authorization/acl/ main/java...
Date Thu, 03 Apr 2008 08:15:04 GMT
Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/combined/GlobPatternTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/combined/GlobPatternTest.java?rev=644215&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/combined/GlobPatternTest.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/combined/GlobPatternTest.java
Thu Apr  3 01:15:01 2008
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.core.security.authorization.combined;
+
+import org.apache.jackrabbit.test.JUnitTest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * <code>GlobPatternTest</code>...
+ */
+public class GlobPatternTest extends JUnitTest {
+
+    private static Logger log = LoggerFactory.getLogger(GlobPatternTest.class);
+
+    public void testMatches() {
+        // TODO
+    }
+
+    public void testMatchesItem() {
+       // TODO
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/combined/GlobPatternTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/combined/GlobPatternTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/combined/PolicyEntryImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/combined/PolicyEntryImplTest.java?rev=644215&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/combined/PolicyEntryImplTest.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/combined/PolicyEntryImplTest.java
Thu Apr  3 01:15:01 2008
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.core.security.authorization.combined;
+
+import org.apache.jackrabbit.core.security.authorization.AbstractPolicyEntryTest;
+import org.apache.jackrabbit.core.security.authorization.PolicyEntry;
+import org.apache.jackrabbit.core.security.authorization.PrivilegeRegistry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.RepositoryException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.security.Principal;
+
+/**
+ * <code>PolicyEntryImplTest</code>...
+ */
+public class PolicyEntryImplTest extends AbstractPolicyEntryTest {
+
+    private static Logger log = LoggerFactory.getLogger(PolicyEntryImplTest.class);
+
+    private String nodePath;
+    private String glob;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        nodePath = "/a/b/c/d";
+        glob = "*";
+    }
+
+    protected PolicyEntry createPolicyEntry(Principal principal, int privileges, boolean
isAllow) {
+        return new PolicyEntryImpl(principal, privileges, isAllow, nodePath, glob);
+    }
+
+    public void testPrincipalMustNotBeNull() {
+        try {
+            PolicyEntry pe = new PolicyEntryImpl(null, PrivilegeRegistry.ALL, true, nodePath,
glob);
+            fail("Principal must not be null");
+        } catch (IllegalArgumentException e) {
+            // success
+        }
+    }
+
+    public void testNodePathMustNotBeNull() {
+        try {
+            PolicyEntry pe = new PolicyEntryImpl(testPrincipal, PrivilegeRegistry.ALL, true,
null, glob);
+            fail("NodePath must not be null");
+        } catch (IllegalArgumentException e) {
+            // success
+        }
+    }
+
+    public void testGetNodePath() {
+        PolicyEntryImpl pe = new PolicyEntryImpl(testPrincipal, PrivilegeRegistry.ALL, true,
nodePath, glob);
+        assertEquals(nodePath, pe.getNodePath());
+    }
+
+    public void testGetGlob() {
+        PolicyEntryImpl pe = new PolicyEntryImpl(testPrincipal, PrivilegeRegistry.ALL, true,
nodePath, glob);
+        assertEquals(glob, pe.getGlob());
+
+        pe = new PolicyEntryImpl(testPrincipal, PrivilegeRegistry.ALL, true, nodePath, null);
+        assertNull(pe.getGlob());
+
+        pe = new PolicyEntryImpl(testPrincipal, PrivilegeRegistry.ALL, true, nodePath, "");
+        assertEquals("", pe.getGlob());
+    }
+
+    public void testMatches() throws RepositoryException {
+        PolicyEntryImpl pe = new PolicyEntryImpl(testPrincipal,
+                PrivilegeRegistry.ALL, true, nodePath, glob);
+
+        // TODO: review again
+        List toMatch = new ArrayList();
+        toMatch.add(nodePath + "/any");
+        toMatch.add(nodePath + "/anyother");
+        toMatch.add(nodePath + "/f/g/h");
+        toMatch.add(nodePath);
+        for (Iterator it = toMatch.iterator(); it.hasNext();) {
+            String str = it.next().toString();
+            assertTrue(pe.getNodePath() + pe.getGlob() + " should match " + str, pe.matches(str));
+        }
+
+        List notToMatch = new ArrayList();
+        notToMatch.add(null);
+        notToMatch.add("");
+        notToMatch.add("/");
+        notToMatch.add("/a/b/c/");
+        for (Iterator it = notToMatch.iterator(); it.hasNext();) {
+            Object obj = it.next();
+            String str = (obj == null) ? null : obj.toString();
+            assertFalse(pe.getNodePath() + pe.getGlob() + " shouldn't match " + str, pe.matches(str));
+        }
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/combined/PolicyEntryImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/combined/PolicyEntryImplTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/combined/PolicyTemplateImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/combined/PolicyTemplateImplTest.java?rev=644215&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/combined/PolicyTemplateImplTest.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/combined/PolicyTemplateImplTest.java
Thu Apr  3 01:15:01 2008
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.core.security.authorization.combined;
+
+import org.apache.jackrabbit.core.security.authorization.AbstractPolicyTemplateTest;
+import org.apache.jackrabbit.core.security.authorization.PolicyTemplate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collections;
+
+/**
+ * <code>PolicyTemplateImplTest</code>...
+ */
+public class PolicyTemplateImplTest extends AbstractPolicyTemplateTest {
+
+    private static Logger log = LoggerFactory.getLogger(PolicyTemplateImplTest.class);
+
+    private String testPath = "/rep:accessControl/users/test";
+
+    protected String getTestPath() {
+        return testPath;
+    }
+
+    protected PolicyTemplate createEmptyTemplate(String testPath) {
+        return new PolicyTemplateImpl(Collections.EMPTY_LIST, testPrincipal, testPath);
+    }
+
+    public void testGetPrincipal() {
+        PolicyTemplateImpl pt = (PolicyTemplateImpl) createEmptyTemplate(testPath);
+        assertEquals(testPrincipal, pt.getPrincipal());
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/combined/PolicyTemplateImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/combined/PolicyTemplateImplTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/combined/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/combined/TestAll.java?rev=644215&r1=644214&r2=644215&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/combined/TestAll.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/combined/TestAll.java
Thu Apr  3 01:15:01 2008
@@ -19,8 +19,12 @@
     public static Test suite() {
         TestSuite suite = new TestSuite("security.authorization.combined tests");
 
-        // TODO add tests
+        suite.addTestSuite(PolicyTemplateImplTest.class);
+        suite.addTestSuite(PolicyEntryImplTest.class);
+        suite.addTestSuite(GlobPatternTest.class);
 
+        //todo: add evaluation tests.
+        
         return suite;
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/jsr283/security/AbstractAccessControlTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/jsr283/security/AbstractAccessControlTest.java?rev=644215&r1=644214&r2=644215&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/jsr283/security/AbstractAccessControlTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/jsr283/security/AbstractAccessControlTest.java
Thu Apr  3 01:15:01 2008
@@ -25,6 +25,7 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Repository;
 
 /**
  * <code>AbstractAccessControlTest</code>...
@@ -46,11 +47,8 @@
         if (!(s instanceof SessionImpl)) {
             throw new NotExecutableException();
         }
-        /*
-        if (s.getRepository().getDescriptor(Repository.OPTION_SIMPLE_ACCESS_CONTROL_SUPPORTED)
== null) {
-            throw new NotExecutableException();
-        }
-        */
+        // TODO: uncomment again.
+        // checkSupportedOption(Repository.OPTION_SIMPLE_ACCESS_CONTROL_SUPPORTED);
         try {
             return ((SessionImpl) s).getAccessControlManager();
         } catch (UnsupportedRepositoryOperationException e) {

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/jsr283/security/AccessControlDiscoveryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/jsr283/security/AccessControlDiscoveryTest.java?rev=644215&r1=644214&r2=644215&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/jsr283/security/AccessControlDiscoveryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/jsr283/security/AccessControlDiscoveryTest.java
Thu Apr  3 01:15:01 2008
@@ -32,13 +32,6 @@
  */
 public class AccessControlDiscoveryTest extends AbstractAccessControlTest {
 
-
-    protected void setUp() throws Exception {
-        super.setUp();
-        // TODO: test if options is supporte
-        //checkSupportedOption(superuser, Repository.OPTION_SIMPLE_ACCESS_CONTROL_SUPPORTED
-    }
-
     private Privilege getPrivilege(String name) throws RepositoryException, NotExecutableException
{
         Privilege[] privileges = acMgr.getSupportedPrivileges(testRootNode.getPath());
         for (int i = 0; i < privileges.length; i++) {

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/jsr283/security/AccessControlPolicyIteratorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/jsr283/security/AccessControlPolicyIteratorTest.java?rev=644215&r1=644214&r2=644215&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/jsr283/security/AccessControlPolicyIteratorTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/jsr283/security/AccessControlPolicyIteratorTest.java
Thu Apr  3 01:15:01 2008
@@ -92,9 +92,10 @@
             throw new NotExecutableException();
         }
     }
-    /*
+
     // TODO: uncomment as soon as RangeIterator is adjusted.
-    public void testgetNumberRemaining() {
+    /*
+    public void testgetNumberRemaining() throws NotExecutableException, RepositoryException
{
         checkCanReadAc(path);
         AccessControlPolicyIterator it = acMgr.getApplicablePolicies(path);
 

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/GroupAdministratorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/GroupAdministratorTest.java?rev=644215&r1=644214&r2=644215&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/GroupAdministratorTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/GroupAdministratorTest.java
Thu Apr  3 01:15:01 2008
@@ -342,6 +342,5 @@
             // ok.
         }
         assertFalse(impers.allows(buildSubject(selfPrinc)));
-
     }
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserAdministratorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserAdministratorTest.java?rev=644215&r1=644214&r2=644215&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserAdministratorTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserAdministratorTest.java
Thu Apr  3 01:15:01 2008
@@ -143,6 +143,7 @@
         }
     }
 
+    // TODO: uncomment as soon as group-members are stored as weak references
     /*
     public void testRemoveHimSelf() throws RepositoryException, NotExecutableException {
         UserManager umgr = getUserManager(otherSession);



Mime
View raw message