jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r638834 [11/14] - in /jackrabbit/trunk: jackrabbit-api/src/main/java/org/apache/jackrabbit/api/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/principal/ jack...
Date Wed, 19 Mar 2008 13:57:11 GMT
Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/AuthorizableTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/AuthorizableTest.java?rev=638834&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/AuthorizableTest.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/AuthorizableTest.java Wed Mar 19 06:56:13 2008
@@ -0,0 +1,335 @@
+/*
+ * 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.api.security.user;
+
+import org.apache.jackrabbit.api.security.principal.PrincipalIterator;
+import org.apache.jackrabbit.test.NotExecutableException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import java.security.Principal;
+import java.util.Arrays;
+import java.util.Iterator;
+
+/**
+ * <code>UserTest</code>...
+ */
+public class AuthorizableTest extends AbstractUserTest {
+
+    private static Logger log = LoggerFactory.getLogger(AuthorizableTest.class);
+
+    public void testGetId() throws NotExecutableException, RepositoryException {
+        User user = getTestUser(superuser);
+        assertNotNull(user.getID());
+    }
+
+    public void testGroupGetId() throws NotExecutableException, RepositoryException {
+        Group gr = getTestGroup(superuser);
+        assertNotNull(gr.getID());
+    }
+
+    public void testGetPrincipalNotNull() throws RepositoryException, NotExecutableException {
+        User user = getTestUser(superuser);
+        assertNotNull(user.getPrincipal());
+    }
+
+    public void testGroupGetPrincipalNotNull() throws RepositoryException, NotExecutableException {
+        Group gr = getTestGroup(superuser);
+        assertNotNull(gr.getPrincipal());
+    }
+
+    public void testGetPrincipals() throws NotExecutableException, RepositoryException {
+        User user = getTestUser(superuser);
+        assertNotNull(user.getPrincipals());
+        assertTrue(user.getPrincipals().getSize() > 0);
+    }
+
+    public void testGroupGetPrincipals() throws NotExecutableException, RepositoryException {
+        Group gr = getTestGroup(superuser);
+        assertNotNull(gr.getPrincipals());
+        assertTrue(gr.getPrincipals().getSize() > 0);
+    }
+
+    public void testGetPrincipalsContainsPrincipal() throws RepositoryException, NotExecutableException {
+        Authorizable auth = getTestUser(superuser);
+        Principal p = auth.getPrincipal();
+        PrincipalIterator it = auth.getPrincipals();
+
+        while (it.hasNext()) {
+            if (it.nextPrincipal().equals(p)) {
+                // main principal is indeed present in the iterator.
+                return;
+            }
+        }
+        fail("Main principal (Authorizable.getPrincipal()) must be present in the iterator obtained by Authorizable.getPrincipals()");
+    }
+
+    public void testSetProperty() throws NotExecutableException, RepositoryException {
+        Authorizable auth = getTestUser(superuser);
+
+        // TODO: retrieve propname and value from config
+        String propName = "Fullname";
+        Value v = superuser.getValueFactory().createValue("Super User");
+        try {
+            auth.setProperty(propName, v);
+        } catch (RepositoryException e) {
+            throw new NotExecutableException("Cannot test 'Authorizable.setProperty'.");
+        }
+
+        try {
+            assertTrue(auth.hasProperty(propName));
+            assertTrue(auth.getProperty(propName).length == 1);
+            assertEquals(v, auth.getProperty(propName)[0]);
+            assertTrue(auth.removeProperty(propName));
+        } finally {
+            // try to remove the property again even if previous calls failed.
+            auth.removeProperty(propName);
+        }
+    }
+
+    public void testSetMultiValueProperty() throws NotExecutableException, RepositoryException {
+        Authorizable auth = getTestUser(superuser);
+
+        // TODO: retrieve propname and values from config
+        String propName = "Fullname";
+        Value[] v = new Value[] {superuser.getValueFactory().createValue("Super User")};
+        try {
+            auth.setProperty(propName, v);
+        } catch (RepositoryException e) {
+            throw new NotExecutableException("Cannot test 'Authorizable.setProperty'.");
+        }
+
+        try {
+            assertTrue(auth.hasProperty(propName));
+            assertEquals(Arrays.asList(v), Arrays.asList(auth.getProperty(propName)));
+            assertTrue(auth.removeProperty(propName));
+        } finally {
+            // try to remove the property again even if previous calls failed.
+            auth.removeProperty(propName);
+        }
+    }
+
+    public void testGetNotExistingProperty() throws RepositoryException, NotExecutableException {
+        Authorizable auth = getTestUser(superuser);
+        String hint = "Fullname";
+        String propName = hint;
+        int i = 0;
+        while (auth.hasProperty(propName)) {
+            propName = hint + i;
+            i++;
+        }
+        assertNull(auth.getProperty(propName));
+    }
+
+    public void testRemoveNotExistingProperty() throws RepositoryException, NotExecutableException {
+        Authorizable auth = getTestUser(superuser);
+        String hint = "Fullname";
+        String propName = hint;
+        int i = 0;
+        while (auth.hasProperty(propName)) {
+            propName = hint + i;
+            i++;
+        }
+        assertFalse(auth.removeProperty(propName));
+    }
+
+    public void testMemberOf() throws NotExecutableException, RepositoryException {
+        Authorizable auth = getTestUser(superuser);
+
+        Iterator it = auth.memberOf();
+        while (it.hasNext()) {
+            Object group = it.next();
+            assertTrue(group instanceof Group);
+        }
+    }
+
+    public void testAddReferee() throws NotExecutableException, RepositoryException {
+        Authorizable auth = getTestUser(superuser);
+
+        Principal testPrincipal = getTestPrincipal();
+        try {
+            assertTrue(auth.addReferee(testPrincipal));
+        } catch (AuthorizableExistsException e) {
+            throw new NotExecutableException(e.getMessage());
+        } finally {
+            auth.removeReferee(testPrincipal);
+        }
+    }
+
+    public void testAddRefereeTwice() throws NotExecutableException, RepositoryException {
+        Authorizable auth = getTestUser(superuser);
+
+        Principal testPrincipal = getTestPrincipal();
+        try {
+            auth.addReferee(testPrincipal);
+            // adding same principal again must return false;
+            assertFalse(auth.addReferee(testPrincipal));
+        } finally {
+            auth.removeReferee(testPrincipal);
+        }
+    }
+
+    public void testGetPrincipalsExposeReferees() throws NotExecutableException, RepositoryException {
+        Authorizable auth = getTestUser(superuser);
+
+        Principal testPrincipal = getTestPrincipal();
+        try {
+            if (auth.addReferee(testPrincipal)) {
+                // make sure the referee is part of principals-set
+                boolean found = false;
+                for (PrincipalIterator it = auth.getPrincipals(); it.hasNext() && !found;) {
+                    found = testPrincipal.equals(it.nextPrincipal());
+                }
+                assertTrue("The referee added must be part of the 'getPrincipals()' iterator.", found);
+            } else {
+                throw new NotExecutableException();
+            }
+        } finally {
+            auth.removeReferee(testPrincipal);
+        }
+    }
+
+    public void testRemoveReferee() throws NotExecutableException, RepositoryException {
+        Authorizable auth = getTestUser(superuser);
+
+        Principal testPrincipal = getTestPrincipal();
+        try {
+            auth.addReferee(testPrincipal);
+            assertTrue(auth.removeReferee(testPrincipal));
+        } finally {
+            auth.removeReferee(testPrincipal);
+        }
+    }
+
+    public void testRefereeNotFoundByUserManager() throws NotExecutableException, RepositoryException {
+        Authorizable auth = getTestUser(superuser);
+        Principal testPrincipal = getTestPrincipal();
+
+        try {
+            assertTrue(auth.addReferee(testPrincipal));
+            Authorizable a = userMgr.getAuthorizable(testPrincipal);
+            assertNull(a);
+        } catch (RepositoryException e) {
+            auth.removeReferee(testPrincipal);
+        }
+    }
+
+    public void testAddExistingReferee() throws NotExecutableException, RepositoryException {
+        Authorizable auth = getTestUser(superuser);
+        Authorizable auth2 = getTestGroup(superuser);
+        Principal testPrincipal = getTestPrincipal();
+        try {
+            try {
+                assertTrue(auth.addReferee(testPrincipal));
+            } catch (AuthorizableExistsException e) {
+                throw new NotExecutableException(e.getMessage());
+            }
+
+            // adding same principal to another authorizable must fail
+            try {
+                auth2.addReferee(testPrincipal);
+                fail("Adding an existing referee-principal to another authorizable must fail.");
+            } catch (AuthorizableExistsException e) {
+                // success
+            }
+        } finally {
+            auth.removeReferee(testPrincipal);
+            auth2.removeReferee(testPrincipal);
+        }
+    }
+
+    public void testAddMainPrincipalAsReferee() throws NotExecutableException, RepositoryException {
+        Authorizable auth = getTestUser(superuser);
+        Principal mainPrinc = auth.getPrincipal();
+        try {
+            // adding main principal as referee to another authorizable must
+            // return false
+            assertFalse(auth.addReferee(mainPrinc));
+        } finally {
+            auth.removeReferee(mainPrinc);
+        }
+    }
+
+    public void testAddMainPrincipalAsOthersReferee() throws NotExecutableException, RepositoryException {
+        Authorizable auth = getTestUser(superuser);
+        Authorizable auth2 = getTestGroup(superuser);
+        Principal mainPrinc = auth.getPrincipal();
+        try {
+            // adding main principal as referee to another authorizable must fail
+            try {
+                auth2.addReferee(mainPrinc);
+                fail("Adding an existing main-principal as referee to another authorizable must fail.");
+            } catch (AuthorizableExistsException e) {
+                // success
+            }
+        } finally {
+            auth2.removeReferee(mainPrinc);
+        }
+    }
+
+    public void testRemoveNotExistingReferee() throws NotExecutableException, RepositoryException {
+        Authorizable auth = getTestUser(superuser);
+        Principal testPrincipal = getTestPrincipal();
+
+        if (userMgr.getAuthorizable(testPrincipal) != null) {
+            throw new NotExecutableException("test principal " + testPrincipal.getName() + " already associated with an authorizable.");
+        }
+        for (PrincipalIterator it = auth.getPrincipals(); it.hasNext();) {
+            if (it.nextPrincipal().getName().equals(testPrincipal.getName())) {
+                throw new NotExecutableException("test principal " + testPrincipal.getName() + " already referee.");
+            }
+        }
+        assertFalse(auth.removeReferee(testPrincipal));
+    }
+
+    /**
+     * Removing an authorizable that is still listed as member of a group.
+     */
+    /*
+    public void testRemoveListedAuthorizable() throws RepositoryException, NotExecutableException {
+        String newUserId = null;
+        Group newGroup = null;
+
+        try {
+            Principal uP = getTestPrincipal();
+            User newUser = userMgr.createUser(uP.getName(), buildCredentials(uP), uP);
+            newUserId = newUser.getID();
+
+            newGroup = userMgr.createGroup(getTestPrincipal());
+            newGroup.addMember(newUser);
+
+            // remove the new user that is still listed as member.
+            newUser.remove();
+        } finally {
+            if (newUserId != null) {
+                Authorizable u = userMgr.getAuthorizable(newUserId);
+                if (u != null) {
+                    if (newGroup != null) {
+                        newGroup.removeMember(u);
+                    }
+                    u.remove();
+                }
+            }
+            if (newGroup != null) {
+                newGroup.remove();
+            }
+        }
+    }
+    */
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/AuthorizableTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/AuthorizableTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/GroupTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/GroupTest.java?rev=638834&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/GroupTest.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/GroupTest.java Wed Mar 19 06:56:13 2008
@@ -0,0 +1,202 @@
+/*
+ * 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.api.security.user;
+
+import org.apache.jackrabbit.test.NotExecutableException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.RepositoryException;
+import java.util.Iterator;
+
+/**
+ * <code>GroupTest</code>...
+ */
+public class GroupTest extends AbstractUserTest {
+
+    private static Logger log = LoggerFactory.getLogger(GroupTest.class);
+
+    private static void assertTrueMemberOfContainsGroup(Authorizable auth, Group gr) throws RepositoryException {
+        boolean contained = false;
+        for (Iterator groups = auth.memberOf(); groups.hasNext() && !contained;) {
+            Object next = groups.next();
+            assertTrue(next instanceof Group);
+            contained = ((Group)next).getID().equals(gr.getID());
+        }
+        assertTrue("All members of a group must contain that group upon 'memberOf'.", contained);
+    }
+
+    private static void assertFalseMemberOfContainsGroup(Authorizable auth, Group gr) throws RepositoryException {
+        boolean contained = false;
+        for (Iterator groups = auth.memberOf(); groups.hasNext() && !contained;) {
+            Object next = groups.next();
+            assertTrue(next instanceof Group);
+            contained = ((Group)next).getID().equals(gr.getID());
+        }
+        assertFalse("All members of a group must contain that group upon 'memberOf'.", contained);
+    }
+
+    public void testIsGroup() throws NotExecutableException, RepositoryException {
+        Group gr = getTestGroup(superuser);
+        assertTrue(gr.isGroup());
+    }
+
+    public void testGetMembersNotNull() throws NotExecutableException, RepositoryException {
+        Group gr = getTestGroup(superuser);
+        assertNotNull(gr.getMembers());
+    }
+
+    public void testGetMembersAreAuthorizable() throws NotExecutableException, RepositoryException {
+        Group gr = getTestGroup(superuser);
+        for (Iterator it = gr.getMembers(); it.hasNext();) {
+            assertTrue(it.next() instanceof Authorizable);
+        }
+    }
+
+    public void testGetMembersAgainstIsMember() throws NotExecutableException, RepositoryException {
+        Group gr = getTestGroup(superuser);
+
+        Iterator it = gr.getMembers();
+        while (it.hasNext()) {
+            Authorizable auth = (Authorizable) it.next();
+            assertTrue(gr.isMember(auth));
+        }
+    }
+
+    public void testGetMembersAgainstMemberOf() throws NotExecutableException, RepositoryException {
+        Group gr = getTestGroup(superuser);
+
+        Iterator it = gr.getMembers();
+        while (it.hasNext()) {
+            Authorizable auth = (Authorizable) it.next();
+            assertTrueMemberOfContainsGroup(auth, gr);
+        }
+    }
+
+    public void testAddMember() throws NotExecutableException, RepositoryException {
+        User auth = getTestUser(superuser);
+        Group newGroup = null;
+        try {
+            newGroup = userMgr.createGroup(getTestPrincipal());
+
+            assertFalse(newGroup.isMember(auth));
+            assertFalse(newGroup.removeMember(auth));
+
+            assertTrue(newGroup.addMember(auth));
+            assertTrue(newGroup.isMember(auth));
+            assertTrue(newGroup.isMember(userMgr.getAuthorizable(auth.getID())));
+
+        } finally {
+            if (newGroup != null) {
+                newGroup.removeMember(auth);
+                newGroup.remove();
+            }
+        }
+    }
+
+    public void testAddMemberTwice() throws NotExecutableException, RepositoryException {
+        User auth = getTestUser(superuser);
+        Group newGroup = null;
+        try {
+            newGroup = userMgr.createGroup(getTestPrincipal());
+
+            assertTrue(newGroup.addMember(auth));
+            assertFalse(newGroup.addMember(auth));
+            assertTrue(newGroup.isMember(auth));
+
+        } finally {
+            if (newGroup != null) {
+                newGroup.removeMember(auth);
+                newGroup.remove();
+            }
+        }
+    }
+
+    public void testAddMemberModifiesMemberOf() throws NotExecutableException, RepositoryException {
+        User auth = getTestUser(superuser);
+        Group newGroup = null;
+        try {
+            newGroup = userMgr.createGroup(getTestPrincipal());
+
+            assertFalseMemberOfContainsGroup(auth, newGroup);
+            assertTrue(newGroup.addMember(auth));
+            assertTrueMemberOfContainsGroup(auth, newGroup);
+        } finally {
+            if (newGroup != null) {
+                newGroup.removeMember(auth);
+                newGroup.remove();
+            }
+        }
+    }
+
+    public void testRemoveMemberTwice() throws NotExecutableException, RepositoryException {
+        User auth = getTestUser(superuser);
+        Group newGroup = null;
+        try {
+            newGroup = userMgr.createGroup(getTestPrincipal());
+
+            assertTrue(newGroup.addMember(auth));
+            assertTrue(newGroup.removeMember(userMgr.getAuthorizable(auth.getID())));
+            assertFalse(newGroup.removeMember(auth));
+        } finally {
+            if (newGroup != null) {
+                newGroup.remove();
+            }
+        }
+    }
+
+    public void testAddItselfAsMember() throws RepositoryException {
+        Group newGroup = null;
+        try {
+            newGroup = userMgr.createGroup(getTestPrincipal());
+
+            assertFalse(newGroup.addMember(newGroup));
+            newGroup.removeMember(newGroup);
+        } finally {
+            if (newGroup != null) {
+                newGroup.remove();
+            }
+        }
+    }
+
+    /**
+     * Removing a GroupImpl must be possible even if there are still exiting
+     * members present.
+     *
+     * @throws RepositoryException
+     * @throws NotExecutableException
+     */
+    public void testRemoveGroupIfMemberExist() throws RepositoryException, NotExecutableException {
+        User auth = getTestUser(superuser);
+        String newGroupId = null;
+
+        try {
+            Group newGroup = userMgr.createGroup(getTestPrincipal());
+            newGroupId = newGroup.getID();
+
+            assertTrue(newGroup.addMember(auth));
+            newGroup.remove();
+
+        } finally {
+            Group gr = (Group) userMgr.getAuthorizable(newGroupId);
+            if (gr != null) {
+                gr.removeMember(auth);
+                gr.remove();
+            }
+        }
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/GroupTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/GroupTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/ImpersonationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/ImpersonationTest.java?rev=638834&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/ImpersonationTest.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/ImpersonationTest.java Wed Mar 19 06:56:13 2008
@@ -0,0 +1,194 @@
+/*
+ * 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.api.security.user;
+
+import org.apache.jackrabbit.test.NotExecutableException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.Credentials;
+import javax.jcr.RepositoryException;
+import javax.security.auth.Subject;
+import java.security.Principal;
+import java.util.Collections;
+import java.util.Set;
+
+/**
+ * <code>ImpersonationTest</code>...
+ */
+public class ImpersonationTest extends AbstractUserTest {
+
+    private static Logger log = LoggerFactory.getLogger(ImpersonationTest.class);
+
+    private User newUser;
+    private Impersonation impersonation;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        Principal test = getTestPrincipal();
+        Credentials creds = buildCredentials(test);
+        newUser = userMgr.createUser(test.getName(), creds, test);
+        impersonation = newUser.getImpersonation();
+    }
+
+    protected void tearDown() throws Exception {
+        newUser.remove();
+        super.tearDown();
+    }
+
+    public void testUnknownCannotImpersonate() throws RepositoryException {
+        Principal test = getTestPrincipal();
+        Subject subject = createSubject(test);
+        assertFalse("An unknown principal should not be allowed to impersonate.", impersonation.allows(subject));
+    }
+
+    public void testGrantImpersonationUnknownUser() throws RepositoryException {
+        Principal test = getTestPrincipal();
+        try {
+            assertFalse("Granting impersonation to an unknown principal should not be successful.", impersonation.grantImpersonation(test));
+        }  finally {
+            impersonation.revokeImpersonation(test);
+        }
+    }
+
+    public void testImpersonateGroup() throws RepositoryException, NotExecutableException {
+        Principal group = getTestGroup(helper.getReadOnlySession()).getPrincipal();
+        Subject subject = createSubject(group);
+        assertFalse("An group principal should not be allowed to impersonate.", impersonation.allows(subject));
+    }
+
+    public void testGrantImpersonationToGroupPrincipal() throws RepositoryException, NotExecutableException {
+        Principal group = getTestGroup(helper.getReadOnlySession()).getPrincipal();
+        try {
+            assertFalse("Granting impersonation to a Group should not be successful.", impersonation.grantImpersonation(group));
+        }  finally {
+            impersonation.revokeImpersonation(group);
+        }
+    }
+
+    public void testGrantImpersonation() throws RepositoryException {
+        User u = null;
+        Principal test = getTestPrincipal();
+        try {
+            u = userMgr.createUser(test.getName(), buildCredentials(test), test);
+            assertTrue("Admin should be allowed to edit impersonation and grant to another test-user.", impersonation.grantImpersonation(test));
+        }  finally {
+            impersonation.revokeImpersonation(test);
+            if (u != null) {
+                u.remove();
+            }
+        }
+    }
+
+    public void testGrantImpersonationTwice() throws RepositoryException {
+        Principal test = getTestPrincipal();
+        User u = null;
+        try {
+            u = userMgr.createUser(test.getName(), buildCredentials(test), test);
+            impersonation.grantImpersonation(test);
+            // try again
+            assertFalse("Granting impersonation twice should not succeed.", impersonation.grantImpersonation(test));
+        }  finally {
+            impersonation.revokeImpersonation(test);
+            if (u != null) {
+                u.remove();
+            }
+        }
+    }
+
+    public void testRevokeImpersonation() throws RepositoryException {
+        User u = null;
+        Principal test = getTestPrincipal();
+        try {
+            u = userMgr.createUser(test.getName(), buildCredentials(test), test);
+            impersonation.grantImpersonation(test);
+
+            assertTrue(impersonation.revokeImpersonation(test));
+        }  finally {
+            if (u != null) {
+                u.remove();
+            }
+        }
+    }
+
+    public void testRevokeImpersonationTwice() throws RepositoryException {
+        User u = null;
+        Principal test = getTestPrincipal();
+        try {
+            u = userMgr.createUser(test.getName(), buildCredentials(test), test);
+            impersonation.grantImpersonation(test);
+            impersonation.revokeImpersonation(test);
+            // try again
+            assertFalse("Revoking impersonation twice should not succeed.", impersonation.revokeImpersonation(test));
+        }  finally {
+            if (u != null) {
+                u.remove();
+            }
+        }
+    }
+
+    public void testAdministratorCanImpersonate() throws RepositoryException, NotExecutableException {
+        User admin = getTestUser(superuser);
+        Subject subject = createSubject(admin);
+        assertTrue(impersonation.allows(subject));
+    }
+
+    public void testCannotGrantImpersonationForAdministrator() throws RepositoryException, NotExecutableException {
+        User admin = getTestUser(superuser);
+        try {
+            assertFalse(impersonation.grantImpersonation(admin.getPrincipal()));
+        } finally {
+            impersonation.revokeImpersonation(admin.getPrincipal());
+        }
+    }
+
+    public void testCannotRevokeImpersonationForAdministrator() throws RepositoryException, NotExecutableException {
+        User admin = getTestUser(superuser);
+        assertFalse(impersonation.revokeImpersonation(admin.getPrincipal()));
+    }
+
+    public void testImpersonatingOneself() throws RepositoryException {
+        Subject subject = createSubject(newUser);
+        assertFalse(impersonation.allows(subject));
+    }
+
+    public void testGrantImpersonatingForOneself() throws RepositoryException {
+        Principal main = newUser.getPrincipal();
+        try {
+            assertFalse(impersonation.grantImpersonation(main));
+        } finally {
+            impersonation.revokeImpersonation(main);
+        }
+    }
+
+    public void testRevokeImpersonatingForOneself() throws RepositoryException {
+        Principal main = newUser.getPrincipal();
+        assertFalse(impersonation.revokeImpersonation(main));
+    }
+
+    private Subject createSubject(User u) throws RepositoryException {
+        Principal main = u.getPrincipal();
+        return createSubject(main);
+    }
+
+    private Subject createSubject(Principal p) throws RepositoryException {
+        Set creds = Collections.singleton(buildCredentials(p));
+        Subject subject = new Subject(true, Collections.singleton(p), creds, creds);
+        return subject;
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/ImpersonationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/ImpersonationTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/NestedGroupTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/NestedGroupTest.java?rev=638834&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/NestedGroupTest.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/NestedGroupTest.java Wed Mar 19 06:56:13 2008
@@ -0,0 +1,159 @@
+/*
+ * 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.api.security.user;
+
+import org.apache.jackrabbit.api.JackrabbitSession;
+import org.apache.jackrabbit.api.security.principal.PrincipalIterator;
+import org.apache.jackrabbit.api.security.principal.PrincipalManager;
+import org.apache.jackrabbit.test.NotExecutableException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * <code>NestedGroupTest</code>...
+ */
+public class NestedGroupTest extends AbstractUserTest {
+
+    private static Logger log = LoggerFactory.getLogger(NestedGroupTest.class);
+
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testAddGroupAsMember() throws NotExecutableException, RepositoryException {
+        Group gr1 = null;
+        Group gr2 = null;
+
+        try {
+            gr1 = userMgr.createGroup(getTestPrincipal());
+            gr2 = userMgr.createGroup(getTestPrincipal());
+
+            assertFalse(gr1.isMember(gr2));
+
+            assertTrue(gr1.addMember(gr2));
+            assertTrue(gr1.isMember(gr2));
+
+        } finally {
+            if (gr1 != null) {
+                gr1.removeMember(gr2);
+                gr1.remove();
+            }
+            if (gr2 != null) {
+                gr2.remove();
+            }
+        }
+    }
+
+    public void testAddCircularMembers() throws NotExecutableException, RepositoryException {
+        Group gr1 = null;
+        Group gr2 = null;
+
+        try {
+            gr1 = userMgr.createGroup(getTestPrincipal());
+            gr2 = userMgr.createGroup(getTestPrincipal());
+
+            assertTrue(gr1.addMember(gr2));
+            assertFalse(gr2.addMember(gr1));
+
+        } finally {
+            if (gr1 != null && gr1.isMember(gr2)) {
+                gr1.removeMember(gr2);
+            }
+            if (gr2 != null && gr2.isMember(gr1)) {
+                gr2.removeMember(gr1);
+            }
+            if (gr1 != null) gr1.remove();
+            if (gr2 != null) gr2.remove();
+        }
+    }
+
+    public void testCyclicMembers2() throws RepositoryException {
+        Group gr1 = null;
+        Group gr2 = null;
+        Group gr3 = null;
+        try {
+            gr1 = userMgr.createGroup(getTestPrincipal());
+            gr2 = userMgr.createGroup(getTestPrincipal());
+            gr3 = userMgr.createGroup(getTestPrincipal());
+
+            assertTrue(gr1.addMember(gr2));
+            assertTrue(gr2.addMember(gr3));
+            assertFalse(gr3.addMember(gr1));
+
+        } finally {
+            if (gr1 != null) {
+                gr1.removeMember(gr2);
+            }
+            if (gr2 != null) {
+                gr2.removeMember(gr3);
+                gr2.remove();
+            }
+            if (gr3 != null) {
+                gr3.removeMember(gr1);
+                gr3.remove();
+            }
+            if (gr1 != null) gr1.remove();
+
+        }
+    }
+
+    public void testInheritedMembership() throws NotExecutableException, RepositoryException {
+        Group gr1 = null;
+        Group gr2 = null;
+        Group gr3 = null;
+
+        if (!(superuser instanceof JackrabbitSession)) {
+            throw new NotExecutableException();
+        }
+
+        try {
+            gr1 = userMgr.createGroup(getTestPrincipal());
+            gr2 = userMgr.createGroup(getTestPrincipal());
+            gr3 = userMgr.createGroup(getTestPrincipal());
+
+            assertTrue(gr1.addMember(gr2));
+            assertTrue(gr2.addMember(gr3));
+
+            // NOTE: don't test with Group.isMember for not required to detect
+            // inherited membership -> rather with PrincipalManager.
+            boolean isMember = false;
+            PrincipalManager pmgr = ((JackrabbitSession) superuser).getPrincipalManager();
+            for (PrincipalIterator it = pmgr.getGroupMembership(gr3.getPrincipal());
+                 it.hasNext() && !isMember;) {
+                isMember = it.nextPrincipal().equals(gr1.getPrincipal());
+            }
+            assertTrue(isMember);
+
+        } finally {
+            if (gr1 != null && gr1.isMember(gr2)) {
+                gr1.removeMember(gr2);
+            }
+            if (gr2 != null && gr2.isMember(gr3)) {
+                gr2.removeMember(gr3);
+            }
+            if (gr1 != null) gr1.remove();
+            if (gr2 != null) gr2.remove();
+            if (gr3 != null) gr3.remove();
+        }
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/NestedGroupTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/NestedGroupTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/TestAll.java?rev=638834&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/TestAll.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/TestAll.java Wed Mar 19 06:56:13 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.api.security.user;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class TestAll extends TestCase {
+
+    /**
+     * Returns a <code>Test</code> suite that executes all tests inside this
+     * package.
+     *
+     * @return a <code>Test</code> suite that executes all tests inside this
+     *         package.
+     */
+    public static Test suite() {
+        TestSuite suite = new TestSuite("api.security.user tests");
+
+        suite.addTestSuite(UserManagerTest.class);
+        suite.addTestSuite(UserManagerCreateGroupTest.class);
+        suite.addTestSuite(UserManagerCreateUserTest.class);
+
+        suite.addTestSuite(AuthorizableTest.class);
+        suite.addTestSuite(UserTest.class);
+        suite.addTestSuite(GroupTest.class);
+        suite.addTestSuite(NestedGroupTest.class);
+        suite.addTestSuite(ImpersonationTest.class);
+
+        return suite;
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/TestAll.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/TestAll.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerCreateGroupTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerCreateGroupTest.java?rev=638834&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerCreateGroupTest.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerCreateGroupTest.java Wed Mar 19 06:56:13 2008
@@ -0,0 +1,104 @@
+/*
+ * 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.api.security.user;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.RepositoryException;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * <code>UserManagerCreateGroupTest</code>...
+ */
+public class UserManagerCreateGroupTest extends AbstractUserTest {
+
+    private static Logger log = LoggerFactory.getLogger(UserManagerCreateGroupTest.class);
+
+    private List createdGroups = new ArrayList();
+
+    protected void tearDown() throws Exception {
+        // remove all created groups again
+        for (Iterator it = createdGroups.iterator(); it.hasNext();) {
+            Authorizable gr = (Authorizable) it.next();
+            try {
+                gr.remove();
+            } catch (RepositoryException e) {
+                log.error("Failed to remove Group " + gr.getID() + " during tearDown.");
+            }
+        }
+
+        super.tearDown();
+    }
+
+    public void testCreateGroup() throws RepositoryException {
+        Principal p = getTestPrincipal();
+        Group gr = userMgr.createGroup(p);
+        createdGroups.add(gr);
+
+        assertNotNull(gr.getID());
+        assertEquals(p.getName(), gr.getPrincipal().getName());
+        assertFalse("A new group must not have members.",gr.getMembers().hasNext());
+    }
+
+    public void testCreateGroupWithPath() throws RepositoryException {
+        Principal p = getTestPrincipal();
+        Group gr = userMgr.createGroup(p, "/any/path/to/the/new/group");
+        createdGroups.add(gr);
+
+        assertNotNull(gr.getID());
+        assertEquals(p.getName(), gr.getPrincipal().getName());
+        assertFalse("A new group must not have members.",gr.getMembers().hasNext());
+    }
+
+    public void testCreateGroupWithNullPrincipal() throws RepositoryException {
+        try {
+            Group gr = userMgr.createGroup(null);
+            createdGroups.add(gr);
+
+            fail("A Group cannot be built from 'null' Principal");
+        } catch (Exception e) {
+            // ok
+        }
+
+        try {
+            Group gr = userMgr.createGroup(null, "/any/path/to/the/new/group");
+            createdGroups.add(gr);
+
+            fail("A Group cannot be built from 'null' Principal");
+        } catch (Exception e) {
+            // ok
+        }
+    }
+
+    public void testCreateDuplicateGroup() throws RepositoryException {
+        Principal p = getTestPrincipal();
+        Group gr = userMgr.createGroup(p);
+        createdGroups.add(gr);
+
+        try {
+            Group gr2 = userMgr.createGroup(p);
+            createdGroups.add(gr2);
+            fail("Creating 2 groups with the same Principal should throw AuthorizableExistsException.");
+        } catch (AuthorizableExistsException e) {
+            // success.
+        }
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerCreateGroupTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerCreateGroupTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerCreateUserTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerCreateUserTest.java?rev=638834&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerCreateUserTest.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerCreateUserTest.java Wed Mar 19 06:56:13 2008
@@ -0,0 +1,156 @@
+/*
+ * 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.api.security.user;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.Credentials;
+import javax.jcr.RepositoryException;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * <code>UserManagerCreateGroupTest</code>...
+ */
+public class UserManagerCreateUserTest extends AbstractUserTest {
+
+    private static Logger log = LoggerFactory.getLogger(UserManagerCreateUserTest.class);
+
+    private List createdUsers = new ArrayList();
+
+    protected void tearDown() throws Exception {
+        // remove all created groups again
+        for (Iterator it = createdUsers.iterator(); it.hasNext();) {
+            Authorizable auth = (Authorizable) it.next();
+            try {
+                auth.remove();
+            } catch (RepositoryException e) {
+                log.error("Failed to remove User " + auth.getID() + " during tearDown.");
+            }
+        }
+        super.tearDown();
+    }
+
+    public void testCreateUser() throws RepositoryException {
+        Principal p = getTestPrincipal();
+        String uid = p.getName();
+        User user = userMgr.createUser(uid, buildCredentials(uid, uid), p);
+        createdUsers.add(user);
+
+        assertNotNull(user.getID());
+        assertEquals(p.getName(), user.getPrincipal().getName());
+    }
+
+    public void testCreateUserWithPath() throws RepositoryException {
+        Principal p = getTestPrincipal();
+        String uid = p.getName();
+        User user = userMgr.createUser(uid, buildCredentials(uid, uid), p, "/any/path/to/the/new/user");
+        createdUsers.add(user);
+
+        assertNotNull(user.getID());
+        assertEquals(p.getName(), user.getPrincipal().getName());
+    }
+
+    public void testCreateUserWithNullParamerters() throws RepositoryException {
+        try {
+            User user = userMgr.createUser(null, null, null);
+            createdUsers.add(user);
+
+            fail("A User cannot be built from 'null' parameters");
+        } catch (Exception e) {
+            // ok
+        }
+    }
+
+    public void testCreateUserWithNullUserID() throws RepositoryException {
+        try {
+            Principal p = getTestPrincipal();
+            Credentials creds = buildCredentials(p.getName(), "");
+            User user = userMgr.createUser(null, creds, p);
+            createdUsers.add(user);
+
+            fail("A User cannot be built with 'null' userID");
+        } catch (Exception e) {
+            // ok
+        }
+    }
+
+    public void testCreateUserWithNullPrincipal() throws RepositoryException {
+        try {
+            Principal p = getTestPrincipal();
+            String uid = p.getName();
+            User user = userMgr.createUser(uid, buildCredentials(uid, uid), null);
+            createdUsers.add(user);
+
+            fail("A User cannot be built with 'null' Principal");
+        } catch (Exception e) {
+            // ok
+        }
+    }
+
+    public void testCreateTwiceWithSameUserID() throws RepositoryException {
+        Principal p = getTestPrincipal();
+        String uid = p.getName();
+        Credentials creds = buildCredentials(uid, uid);
+        User user = userMgr.createUser(uid, creds, p);
+        createdUsers.add(user);
+
+        try {
+            p = getTestPrincipal();
+            User user2 = userMgr.createUser(uid, creds, p);
+            createdUsers.add(user2);
+
+            fail("Creating 2 users with the same UserID should throw AuthorizableExistsException.");
+        } catch (AuthorizableExistsException e) {
+            // success.
+        }
+    }
+
+    public void testCreateTwiceWithSamePrincipal() throws RepositoryException {
+        Principal p = getTestPrincipal();
+        String uid = p.getName();
+        Credentials creds = buildCredentials(uid, uid);
+        User user = userMgr.createUser(uid, creds, p);
+        createdUsers.add(user);
+
+        try {
+            uid = getTestPrincipal().getName();
+            creds = buildCredentials(uid, uid);
+
+            User user2 = userMgr.createUser(uid, creds, p);
+            createdUsers.add(user2);
+
+            fail("Creating 2 users with the same Principal should throw AuthorizableExistsException.");
+        } catch (AuthorizableExistsException e) {
+            // success.
+        }
+    }
+
+    public void testGetUserAfterCreation() throws RepositoryException {
+        Principal p = getTestPrincipal();
+        String uid = p.getName();
+
+        User user = userMgr.createUser(uid, buildCredentials(uid, uid), p);
+        createdUsers.add(user);
+
+        assertNotNull(userMgr.getAuthorizable(user.getID()));
+        assertNotNull(userMgr.getAuthorizable(p));
+    }
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerCreateUserTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerCreateUserTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerTest.java?rev=638834&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerTest.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerTest.java Wed Mar 19 06:56:13 2008
@@ -0,0 +1,61 @@
+/*
+ * 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.api.security.user;
+
+import org.apache.jackrabbit.test.NotExecutableException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.RepositoryException;
+import java.security.Principal;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * <code>UserManagerTest</code>...
+ */
+public class UserManagerTest extends AbstractUserTest {
+
+    private static Logger log = LoggerFactory.getLogger(UserManagerTest.class);
+
+    // TODO: add generic tests for UserManager.findAuthorizable
+    // TODO: test creating users/groups if root is locked OR checked-in.
+
+    public void testGetAuthorizableByPrincipal() throws RepositoryException, NotExecutableException {
+        Authorizable auth = null;
+        Set principals = getPrincipalSetFromSession(superuser);
+        for (Iterator it = principals.iterator(); it.hasNext() && auth == null;) {
+            Principal p = (Principal) it.next();
+            auth = userMgr.getAuthorizable(p);
+        }
+        assertNotNull("At least one of the Sessions principal must be a known authorizable to the UserManager", auth);
+    }
+
+    public void testGetAuthorizableById() throws RepositoryException, NotExecutableException {
+        Authorizable auth = null;
+        Set principals = getPrincipalSetFromSession(superuser);
+        for (Iterator it = principals.iterator(); it.hasNext();) {
+            Principal p = (Principal) it.next();
+            auth = userMgr.getAuthorizable(p);
+
+            if (auth != null) {
+                Authorizable authByID = userMgr.getAuthorizable(auth.getID());
+                assertEquals("Equal ID expected", auth.getID(), authByID.getID());
+            }
+        }
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserTest.java?rev=638834&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserTest.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserTest.java Wed Mar 19 06:56:13 2008
@@ -0,0 +1,53 @@
+/*
+ * 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.api.security.user;
+
+import org.apache.jackrabbit.test.NotExecutableException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.RepositoryException;
+import java.util.Iterator;
+
+/**
+ * <code>UserTest</code>...
+ */
+public class UserTest extends AbstractUserTest {
+
+    private static Logger log = LoggerFactory.getLogger(UserTest.class);
+
+    public void testNotIsGroup() throws NotExecutableException, RepositoryException {
+        User user = getTestUser(superuser);
+        assertFalse(user.isGroup());
+    }
+
+    public void testSuperuserIsAdmin() throws NotExecutableException, RepositoryException {
+        User user = getTestUser(superuser);
+        assertTrue(user.isAdmin());
+    }
+
+    public void testReadOnlyIsntAdmin() throws NotExecutableException, RepositoryException {
+        User user = getTestUser(helper.getReadOnlySession());
+        assertFalse(user.isAdmin());
+    }
+
+    public void testUserHasCredentials() throws RepositoryException, NotExecutableException {
+        User user = getTestUser(superuser);
+        Iterator it = user.getCredentials();
+        assertTrue(it.hasNext());
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserTest.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java?rev=638834&r1=638833&r2=638834&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/RepositoryConfigTest.java Wed Mar 19 06:56:13 2008
@@ -18,6 +18,7 @@
 
 import junit.framework.TestCase;
 import org.xml.sax.InputSource;
+import org.apache.jackrabbit.core.security.authorization.WorkspaceAccessManager;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -33,9 +34,8 @@
  */
 public class RepositoryConfigTest extends TestCase {
 
-    private static final String REPOSITORY_XML = "target/test-repository.xml";
-
-    private static final String REPOSITORY_HOME = "target/test-repository";
+    private static final String REPOSITORY_XML = "target/repository_for_test.xml";
+    private static final String REPOSITORY_HOME = "target/repository_for_test";
 
     private static void deleteAll(File file) {
         if (file.exists()) {
@@ -178,10 +178,27 @@
                 new File(REPOSITORY_HOME, "workspaces").getPath(),
                 new File(config.getWorkspacesConfigRootDir()).getPath());
         assertEquals("Jackrabbit", config.getAppName());
+        assertEquals("Jackrabbit", config.getSecurityConfig().getAppName());
+
+        // SecurityManagerConfig
+        SecurityManagerConfig smc = config.getSecurityConfig().getSecurityManagerConfig();
+        assertEquals(
+                "org.apache.jackrabbit.core.security.simple.SimpleSecurityManager",
+                smc.getClassName());
+        assertTrue(smc.getParameters().isEmpty());
+        assertNotNull(smc.getWorkspaceName());
+
+        BeanConfig bc = smc.getWorkspaceAccessConfig();
+        if (bc != null) {
+            WorkspaceAccessManager wac = (WorkspaceAccessManager) smc.getWorkspaceAccessConfig().newInstance();
+            assertEquals("org.apache.jackrabbit.core.security.simple.SimpleWorkspaceAccessManager", wac.getClass().getName());
+        }
 
+        // AccessManagerConfig
         AccessManagerConfig amc = config.getAccessManagerConfig();
+        amc = config.getSecurityConfig().getAccessManagerConfig();
         assertEquals(
-                "org.apache.jackrabbit.core.security.SimpleAccessManager",
+                "org.apache.jackrabbit.core.security.simple.SimpleAccessManager",
                 amc.getClassName());
         assertTrue(amc.getParameters().isEmpty());
 

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/WorkspaceConfigTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/WorkspaceConfigTest.java?rev=638834&r1=638833&r2=638834&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/WorkspaceConfigTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/config/WorkspaceConfigTest.java Wed Mar 19 06:56:13 2008
@@ -22,6 +22,7 @@
 import junit.framework.TestCase;
 
 import org.xml.sax.InputSource;
+import org.apache.jackrabbit.core.security.authorization.AccessControlProvider;
 
 /**
  * Test cases for workspace configuration handling.
@@ -62,10 +63,17 @@
                 "org.apache.jackrabbit.core.query.lucene.SearchIndex",
                 sc.getHandlerClassName());
         assertEquals(4, sc.getParameters().size());
-        assertEquals("true", sc.getParameters().get("useCompoundFile"));
-        assertEquals("1000", sc.getParameters().get("minMergeDocs"));
-        assertEquals("10000", sc.getParameters().get("maxMergeDocs"));
-        assertEquals("10", sc.getParameters().get("mergeFactor"));
+        assertEquals("true", sc.getParameters().getProperty("useCompoundFile"));
+        assertEquals("1000", sc.getParameters().getProperty("minMergeDocs"));
+        assertEquals("10000", sc.getParameters().getProperty("maxMergeDocs"));
+        assertEquals("10", sc.getParameters().getProperty("mergeFactor"));
+
+        WorkspaceSecurityConfig ws = config.getSecurityConfig();
+        if (ws != null) {
+            BeanConfig ppfConfig =  ws.getAccessControlProviderConfig();
+            if (ppfConfig != null) {
+                AccessControlProvider prov = (AccessControlProvider) ppfConfig.newInstance();
+            }
+        }
     }
-
 }

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/AccessManagerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/AccessManagerTest.java?rev=638834&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/AccessManagerTest.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/AccessManagerTest.java Wed Mar 19 06:56:13 2008
@@ -0,0 +1,243 @@
+/*
+ * 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;
+
+import org.apache.jackrabbit.core.ItemId;
+import org.apache.jackrabbit.core.ItemImpl;
+import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.PropertyId;
+import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.security.authorization.Permission;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
+import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
+import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.test.NotExecutableException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * <code>AccessManagerTest</code>...
+ */
+public class AccessManagerTest extends AbstractJCRTest {
+
+    private static Logger log = LoggerFactory.getLogger(AccessManagerTest.class);
+
+    private static AccessManager getAccessManager(Session session) throws NotExecutableException {
+        if (session instanceof SessionImpl) {
+            return ((SessionImpl) session).getAccessManager();
+        } else {
+            throw new NotExecutableException();
+        }
+    }
+
+    private static ItemId getItemId(Item item) throws NotExecutableException {
+        if (item instanceof ItemImpl) {
+            return ((ItemImpl)item).getId();
+        } else {
+            throw new NotExecutableException();
+        }
+    }
+
+    // TODO: add tests for new methods!!!!
+    // TODO: add specific tests for 'AC-read/modify' privileges
+
+    public void testCheckPermissionReadOnlySession() throws RepositoryException, NotExecutableException {
+        Session s = helper.getReadOnlySession();
+        AccessManager acMgr = getAccessManager(s);
+
+        NodeId id = (NodeId) getItemId(s.getItem(testRootNode.getPath()));
+
+        acMgr.checkPermission(id, AccessManager.READ);
+        try {
+            acMgr.checkPermission(id, AccessManager.WRITE);
+            fail();
+        } catch (AccessDeniedException e) {
+            // success
+        }
+
+        try {
+            acMgr.checkPermission(id, AccessManager.WRITE | AccessManager.REMOVE);
+            fail();
+        } catch (AccessDeniedException e) {
+            // success
+        }
+    }
+
+    /**
+     */
+    public void testCheckPermissionWithNoPermissionFlag() throws RepositoryException, NotExecutableException {
+        AccessManager acMgr = getAccessManager(superuser);
+
+        NodeId id = (NodeId) getItemId(superuser.getItem(testRootNode.getPath()));
+        // NOTE: backwards compat. for depr. method: invalid perm-flags will be ignored
+        acMgr.checkPermission(id, AccessManager.READ - 1);
+    }
+
+    public void testCheckPermissionWithInvalidPermission() throws RepositoryException, NotExecutableException {
+        AccessManager acMgr = getAccessManager(superuser);
+
+        NodeId id = (NodeId) getItemId(superuser.getItem(testRootNode.getPath()));
+        // NOTE: backwards compat. for depr. method: invalid perm-flags will be ignored
+        acMgr.checkPermission(id, AccessManager.READ | AccessManager.WRITE | AccessManager.REMOVE  + 1);
+    }
+
+    /*
+    public void testCheckPermissionWithUnknowId() throws RepositoryException, NotExecutableException {
+        Session s = helper.getReadOnlySession();
+        AccessManager acMgr = getAccessManager(s);
+
+        NodeId id = new NodeId(UUID.randomUUID());
+        try {
+            acMgr.checkPermission(id, AccessManager.READ);
+            fail("AccessManager.checkPermission should throw ItemNotFoundException with a random (unknown) item id.");
+        } catch (ItemNotFoundException e) {
+            // ok
+        }
+    }
+    */
+
+    public void testIsGranted() throws RepositoryException, NotExecutableException {
+        Session s = helper.getReadOnlySession();
+        AccessManager acMgr = getAccessManager(s);
+
+        NodeId id = (NodeId) getItemId(s.getItem(testRootNode.getPath()));
+        assertTrue(acMgr.isGranted(id, AccessManager.READ));
+        assertFalse(acMgr.isGranted(id, AccessManager.WRITE));
+        assertFalse(acMgr.isGranted(id, AccessManager.WRITE | AccessManager.REMOVE));
+    }
+
+    public void testIsGrantedOnProperty() throws RepositoryException, NotExecutableException {
+        Session s = helper.getReadOnlySession();
+        AccessManager acMgr = getAccessManager(s);
+
+        PropertyId id = (PropertyId) getItemId(testRootNode.getProperty(jcrPrimaryType));
+
+        assertTrue(acMgr.isGranted(id, AccessManager.READ));
+        assertFalse(acMgr.isGranted(id, AccessManager.WRITE));
+        assertFalse(acMgr.isGranted(id, AccessManager.WRITE | AccessManager.REMOVE));
+    }
+
+    public void testIsGrantedOnNewNode() throws RepositoryException, NotExecutableException {
+        Session s = helper.getReadWriteSession();
+        AccessManager acMgr = getAccessManager(s);
+
+        Node newNode = ((Node) s.getItem(testRoot)).addNode(nodeName2, testNodeType);
+        NodeId id = (NodeId) getItemId(newNode);
+
+        assertTrue(acMgr.isGranted(id, AccessManager.READ));
+        assertTrue(acMgr.isGranted(id, AccessManager.WRITE));
+        assertTrue(acMgr.isGranted(id, AccessManager.WRITE | AccessManager.REMOVE));    }
+
+    public void testCanAccess() throws RepositoryException, NotExecutableException {
+        Session s = helper.getReadOnlySession();
+        String wspName = s.getWorkspace().getName();
+
+        assertTrue(getAccessManager(s).canAccess(wspName));
+    }
+
+    public void testCanAccessAllAvailable() throws RepositoryException, NotExecutableException {
+        Session s = helper.getReadOnlySession();
+        String[] wspNames = s.getWorkspace().getAccessibleWorkspaceNames();
+
+        for (int i = 0; i < wspNames.length; i++) {
+            assertTrue(getAccessManager(s).canAccess(wspNames[i]));
+        }
+    }
+
+    public void testCanAccessDeniedWorkspace() throws RepositoryException, NotExecutableException {
+        Session s = helper.getReadOnlySession();
+
+        Set allAccessibles = new HashSet(Arrays.asList(superuser.getWorkspace().getAccessibleWorkspaceNames()));
+        Set sWorkspaceNames = new HashSet(Arrays.asList(s.getWorkspace().getAccessibleWorkspaceNames()));
+
+        if (!allAccessibles.removeAll(sWorkspaceNames) || allAccessibles.isEmpty()) {
+            throw new NotExecutableException("No workspace name found that exists but is not accessible for ReadOnly session.");
+        }
+
+        String notAccessibleName = allAccessibles.iterator().next().toString();
+        assertFalse(getAccessManager(s).canAccess(notAccessibleName));
+    }
+
+    /*
+    public void testCanAccessNotExistingWorkspace() throws RepositoryException, NotExecutableException {
+        Session s = helper.getReadOnlySession();
+        List all = Arrays.asList(s.getWorkspace().getAccessibleWorkspaceNames());
+        String testName = "anyWorkspace";
+        int i = 0;
+        while (all.contains(testName)) {
+            testName = "anyWorkspace" + i;
+            i++;
+        }
+        assertFalse(getAccessManager(s).canAccess(testName));
+    }
+    */
+
+    public void testIsGrantedWithRelativePath() throws NotExecutableException {
+        AccessManager acMgr = getAccessManager(superuser);
+        Path p = PathFactoryImpl.getInstance().create(NameConstants.JCR_DATA);
+        try {
+            acMgr.isGranted(p, Permission.READ);
+            fail("calling AccessManager.isGranted(Path, int) with relative path must fail.");
+        } catch (RepositoryException e) {
+            // success
+        }
+
+        try {
+            acMgr.isGranted(p, NameConstants.JCR_CREATED, Permission.READ);
+            fail("calling AccessManager.isGranted(Path, int) with relative path must fail.");
+        } catch (RepositoryException e) {
+            // success
+        }
+    }
+
+    public void testIsGrantedPathToNonExistingItem() throws NotExecutableException, RepositoryException {
+        AccessManager acMgr = getAccessManager(superuser);
+        Path p = PathFactoryImpl.getInstance().getRootPath();
+
+        // existing node-path
+        assertTrue(acMgr.isGranted(p, Permission.ALL));
+        // not existing property:
+        assertTrue(acMgr.isGranted(p, NameConstants.JCR_CREATED, Permission.ALL));
+        // existing property
+        assertTrue(acMgr.isGranted(p, NameConstants.JCR_PRIMARYTYPE, Permission.ALL));
+    }
+
+    public void testIsGrantedReadOnlySession() throws NotExecutableException, RepositoryException {
+        AccessManager acMgr = getAccessManager(helper.getReadOnlySession());
+        Path p = PathFactoryImpl.getInstance().getRootPath();
+
+        // existing node-path
+        assertTrue(acMgr.isGranted(p, Permission.READ));
+        // not existing property:
+        assertTrue(acMgr.isGranted(p, NameConstants.JCR_CREATED, Permission.READ));
+
+        // existing node-path
+        assertFalse(acMgr.isGranted(p, Permission.ALL));
+        // not existing property:
+        assertFalse(acMgr.isGranted(p, NameConstants.JCR_CREATED, Permission.ALL));
+    }
+}
\ No newline at end of file

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

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

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/TestAll.java?rev=638834&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/TestAll.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/TestAll.java Wed Mar 19 06:56:13 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;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class TestAll extends TestCase {
+
+    /**
+     * Returns a <code>Test</code> suite that executes all security test.
+     *
+     * @return a <code>Test</code> suite that executes all security test.
+     */
+    public static Test suite() {
+        TestSuite suite = new TestSuite("Security tests");
+
+        suite.addTestSuite(AccessManagerTest.class);
+
+        return suite;
+    }
+}

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

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

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/TestPrincipal.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/TestPrincipal.java?rev=638834&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/TestPrincipal.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/TestPrincipal.java Wed Mar 19 06:56:13 2008
@@ -0,0 +1,55 @@
+/*
+ * 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;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.security.Principal;
+
+/**
+ * <code>TestPrincipal</code>...
+ *
+ * // TODO retrieve principal-Impl and test-name from Configuration
+ */
+public class TestPrincipal implements Principal {
+
+    private static Logger log = LoggerFactory.getLogger(TestPrincipal.class);
+
+    private final String name;
+
+    public TestPrincipal(String name) {
+        this.name = name;
+    }
+    public String getName() {
+        return name;
+    }
+
+    public int hashCode() {
+        return name.hashCode();
+    }
+
+    public boolean equals(Object obj) {
+        if (obj == this) {
+            return true;
+        }
+        if (obj instanceof Principal) {
+            return name.equals(((Principal)obj).getName());
+        }
+        return false;
+    }
+}
\ No newline at end of file

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

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

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/EntryTemplateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/EntryTemplateTest.java?rev=638834&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/EntryTemplateTest.java (added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/EntryTemplateTest.java Wed Mar 19 06:56:13 2008
@@ -0,0 +1,31 @@
+/*
+ * 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;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * <code>EntryTemplateTest</code>...
+ */
+public class EntryTemplateTest extends AbstractJCRTest {
+
+    private static Logger log = LoggerFactory.getLogger(EntryTemplateTest.class);
+
+    // TODO: add tests
+}
\ No newline at end of file

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

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



Mime
View raw message