jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1471025 - in /jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user: CreateGroupTest.java CreateUserTest.java UserManagerTest.java
Date Tue, 23 Apr 2013 16:17:35 GMT
Author: angela
Date: Tue Apr 23 16:17:34 2013
New Revision: 1471025

URL: http://svn.apache.org/r1471025
Log:
OAK-50 : Implement User Management  (tests, resolve TODOs)

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/CreateGroupTest.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/CreateUserTest.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerTest.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/CreateGroupTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/CreateGroupTest.java?rev=1471025&r1=1471024&r2=1471025&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/CreateGroupTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/CreateGroupTest.java
Tue Apr 23 16:17:34 2013
@@ -20,10 +20,12 @@ import java.security.Principal;
 import java.util.ArrayList;
 import java.util.List;
 import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.ConstraintViolationException;
 
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.AuthorizableExistsException;
 import org.apache.jackrabbit.api.security.user.Group;
+import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
 import org.apache.jackrabbit.test.NotExecutableException;
 import org.junit.Test;
 
@@ -70,17 +72,43 @@ public class CreateGroupTest extends Abs
         assertFalse("A new group must not have members.",gr.getMembers().hasNext());
     }
 
-    // TODO: check again.
-//    @Test
-//    public void testCreateGroupWithPath() throws RepositoryException, NotExecutableException
{
-//        Principal p = getTestPrincipal();
-//        Group gr = 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());
-//    }
+    /**
+     * @since OAK 1.0 In contrast to Jackrabbit core the intermediate path may
+     * not be an absolute path in OAK.
+     */
+    @Test
+    public void testCreateGroupWithAbsolutePath() throws RepositoryException, NotExecutableException
{
+        Principal p = getTestPrincipal();
+        try {
+            Group gr = createGroup(p, "/any/path/to/the/new/group");
+            createdGroups.add(gr);
+            fail("ConstraintViolationException expected.");
+        } catch (ConstraintViolationException e) {
+            // success
+        }
+    }
+
+    @Test
+    public void testCreateGroupWithAbsolutePath2() throws RepositoryException, NotExecutableException
{
+        Principal p = getTestPrincipal();
+
+        String groupRoot = UserConstants.DEFAULT_GROUP_PATH;
+        String path = groupRoot + "/any/path/to/the/new/group";
+        Group gr = createGroup(p, path);
+        createdGroups.add(gr);
+
+        assertTrue(gr.getPath().startsWith(path));
+    }
+
+    @Test
+    public void testCreateGroupWithRelativePath() throws RepositoryException, NotExecutableException
{
+        Principal p = getTestPrincipal();
+        Group gr = createGroup(p, "any/path");
+        createdGroups.add(gr);
+
+        assertNotNull(gr.getID());
+        assertTrue(gr.getPath().contains("any/path"));
+    }
 
     @Test
     public void testCreateGroupWithNullPrincipal() throws RepositoryException {

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/CreateUserTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/CreateUserTest.java?rev=1471025&r1=1471024&r2=1471025&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/CreateUserTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/CreateUserTest.java
Tue Apr 23 16:17:34 2013
@@ -20,10 +20,12 @@ import java.security.Principal;
 import java.util.ArrayList;
 import java.util.List;
 import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.ConstraintViolationException;
 
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.AuthorizableExistsException;
 import org.apache.jackrabbit.api.security.user.User;
+import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
 import org.apache.jackrabbit.test.NotExecutableException;
 import org.junit.After;
 import org.junit.Test;
@@ -79,27 +81,46 @@ public class CreateUserTest extends Abst
         assertEquals(p.getName(), user.getPrincipal().getName());
     }
 
-    // TODO: check again.
-//    @Test
-//    public void testCreateUserWithPath() throws RepositoryException, NotExecutableException
{
-//        Principal p = getTestPrincipal();
-//        String uid = p.getName();
-//        User user = createUser(uid, "pw", p, "/any/path/to/the/new/user");
-//        createdUsers.add(user);
-//
-//        assertNotNull(user.getID());
-//        assertEquals(p.getName(), user.getPrincipal().getName());
-//    }
+    /**
+     * @since OAK 1.0 In contrast to Jackrabbit core the intermediate path may
+     * not be an absolute path in OAK.
+     */
+    @Test
+    public void testCreateUserWithAbsolutePath() throws RepositoryException, NotExecutableException
{
+        Principal p = getTestPrincipal();
+        String uid = p.getName();
+
+        try {
+            User user = createUser(uid, "pw", p, "/any/path/to/the/new/user");
+            createdUsers.add(user);
+            fail("ConstraintViolationException expected");
+        } catch (ConstraintViolationException e) {
+            // success
+        }
+    }
 
     @Test
-    public void testCreateUserWithPath2() throws RepositoryException, NotExecutableException
{
+    public void testCreateGroupWithAbsolutePath2() throws RepositoryException, NotExecutableException
{
+        Principal p = getTestPrincipal();
+        String uid = p.getName();
+
+        String userRoot = UserConstants.DEFAULT_USER_PATH;
+        String path = userRoot + "/any/path/to/the/new/user";
+        User user = createUser(uid, "pw", p, path);
+        createdUsers.add(user);
+
+        assertTrue(user.getPath().startsWith(path));
+    }
+
+    @Test
+    public void testCreateUserWithRelativePath() throws RepositoryException, NotExecutableException
{
         Principal p = getTestPrincipal();
         String uid = p.getName();
         User user = createUser(uid, "pw", p, "any/path");
         createdUsers.add(user);
 
         assertNotNull(user.getID());
-        assertEquals(p.getName(), user.getPrincipal().getName());
+        assertTrue(user.getPath().contains("any/path"));
     }
 
     @Test

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerTest.java?rev=1471025&r1=1471024&r2=1471025&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerTest.java
Tue Apr 23 16:17:34 2013
@@ -221,7 +221,7 @@ public class UserManagerTest extends Abs
     }
 
     /**
-     * @since oak
+     * @since OAK 1.0
      */
     @Test
     public void testCreateUserWithoutPassword() throws Exception {



Mime
View raw message