jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r818433 [2/2] - in /jackrabbit/trunk: jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/user/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/principa...
Date Thu, 24 Sep 2009 10:30:35 GMT
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=818433&r1=818432&r2=818433&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 Sep 24 10:30:34 2009
@@ -32,6 +32,8 @@
 import java.security.Principal;
 import java.util.Iterator;
 import java.util.Set;
+import java.util.Map;
+import java.util.HashMap;
 
 /**
  * <code>UserAdministratorTest</code>...
@@ -43,7 +45,6 @@
 
     // user-admin 'below'
     private String otherUID;
-    private String otherPath;
     private Session otherSession;
 
     // the user-admin group
@@ -64,7 +65,6 @@
         Credentials otherCreds = buildCredentials(p.getName(), pw);
         User other = userMgr.createUser(p.getName(), pw);
         otherUID = other.getID();
-        otherPath = ((UserImpl) other).getNode().getPath();
 
         // make other user a user-administrator:
         Authorizable ua = userMgr.getAuthorizable(UserConstants.USER_ADMIN_GROUP_NAME);
@@ -136,13 +136,43 @@
     public void testCreateUserWithIntermediatePath() throws RepositoryException, NotExecutableException
{
         UserManager umgr = getUserManager(otherSession);
         UserImpl u = null;
+
         // create a new user with intermediate-path
         // -> must succeed and user must be created
-        // -> intermediate path must be ignored.
+        // -> intermediate path must be part of the nodes path
+        Principal p = getTestPrincipal();
+        String usersPath = ((UserManagerImpl) umgr).getUsersPath();
+        Map<String, String> m = new HashMap<String, String>();
+        m.put("/some/intermediate/path", usersPath + "/some/intermediate/path/" + p.getName());
+        m.put("some/intermediate/path", usersPath + "/some/intermediate/path/" + p.getName());
+        m.put("/", usersPath + "/" + p.getName());
+        m.put("", usersPath + "/" + p.getName());
+        m.put(usersPath + "/some/intermediate/path", usersPath + "/some/intermediate/path/"
+ p.getName());
+
+        for (String intermediatePath : m.keySet()) {
+            try {
+                u = (UserImpl) umgr.createUser(p.getName(), buildPassword(p), p, intermediatePath);
+                String expPath = m.get(intermediatePath);
+                assertEquals(expPath, u.getNode().getPath());
+            } finally {
+                if (u != null) {
+                    u.remove();
+                }
+            }
+        }
+    }
+
+    public void testCreateNestedUsers() throws NotExecutableException, RepositoryException
{
+        UserManager umgr = getUserManager(otherSession);
+        UserImpl u = null;
+
+        String invalidIntermediatePath = ((UserImpl) umgr.getAuthorizable(otherUID)).getNode().getPath();
         try {
             Principal p = getTestPrincipal();
-            u = (UserImpl) umgr.createUser(p.getName(), buildPassword(p), p, "/some/intermediate/path");
-            assertEquals(-1, u.getNode().getPath().indexOf("/some/intermediate/path"));
+            u = (UserImpl) umgr.createUser(p.getName(), buildPassword(p), p, invalidIntermediatePath);
+            fail("An attempt to create a user below an existing user must fail.");
+        } catch (RepositoryException e) {
+            // success
         } finally {
             if (u != null) {
                 u.remove();



Mime
View raw message