You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by an...@apache.org on 2015/04/09 21:34:21 UTC

svn commit: r1672469 [2/2] - /jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportFromJackrabbit.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportFromJackrabbit.java?rev=1672469&r1=1672468&r2=1672469&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportFromJackrabbit.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportFromJackrabbit.java Thu Apr  9 19:34:21 2015
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.oak.jcr.se
 
 import javax.jcr.ImportUUIDBehavior;
 import javax.jcr.Node;
+import javax.jcr.Session;
 import javax.jcr.nodetype.ConstraintViolationException;
 
 import org.apache.jackrabbit.api.security.user.Authorizable;
@@ -45,6 +46,16 @@ public class UserImportFromJackrabbit ex
     private String randomNodeName = "f5aj6fp7q9834jof";
     private String intermediatePath = "foo/bar/test";
 
+    private Session importSession;
+
+    @Override
+    public void before() throws Exception {
+        super.before();
+
+        importSession = getImportSession();
+
+    }
+
     @Override
     protected String getTargetPath() {
         return USERPATH;
@@ -71,15 +82,15 @@ public class UserImportFromJackrabbit ex
 
         doImport(getTargetPath(), xml);
 
-        Authorizable newUser = userMgr.getAuthorizable(uid);
+        Authorizable newUser = getUserManager().getAuthorizable(uid);
         assertEquals(uid, newUser.getID());
 
-        Node n = adminSession.getNode(newUser.getPath());
+        Node n = importSession.getNode(newUser.getPath());
         assertTrue(n.hasProperty(UserConstants.REP_AUTHORIZABLE_ID));
         assertEquals(uid, n.getProperty(UserConstants.REP_AUTHORIZABLE_ID).getString());
 
         // saving changes of the import -> must succeed
-        adminSession.save();
+        importSession.save();
     }
 
     /**
@@ -88,9 +99,9 @@ public class UserImportFromJackrabbit ex
     @Test
     public void testUUIDBehaviorReplace() throws Exception {
         // create authorizable
-        User u = userMgr.createUser(uid, null, new PrincipalImpl("t"), getTargetPath() + "/foo/bar/test");
+        User u = getUserManager().createUser(uid, null, new PrincipalImpl("t"), getTargetPath() + "/foo/bar/test");
         String initialPath = u.getPath();
-        adminSession.save();
+        importSession.save();
 
         String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                 "<sv:node sv:name=\""+uid+"\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
@@ -103,18 +114,18 @@ public class UserImportFromJackrabbit ex
 
         doImport(getTargetPath(), xml, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
 
-        Authorizable newUser = userMgr.getAuthorizable(uid);
+        Authorizable newUser = getUserManager().getAuthorizable(uid);
 
         // replace should retain path
         assertEquals(initialPath, newUser.getPath());
         assertFalse(getTargetPath().equals(Text.getRelativeParent(newUser.getPath(), 1)));
 
-        Node n = adminSession.getNode(newUser.getPath());
+        Node n = importSession.getNode(newUser.getPath());
         assertTrue(n.hasProperty(UserConstants.REP_AUTHORIZABLE_ID));
         assertEquals(uid, n.getProperty(UserConstants.REP_AUTHORIZABLE_ID).getString());
 
         // saving changes of the import -> must succeed
-        adminSession.save();
+        importSession.save();
     }
 
     /**
@@ -123,9 +134,9 @@ public class UserImportFromJackrabbit ex
     @Test
     public void testUUIDBehaviorRemove() throws Exception {
         // create authorizable
-        User u = userMgr.createUser(uid, null, new PrincipalImpl(uid), intermediatePath);
+        User u = getUserManager().createUser(uid, null, new PrincipalImpl(uid), intermediatePath);
         String initialPath = u.getPath();
-        adminSession.save();
+        importSession.save();
 
         String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                 "<sv:node sv:name=\"t\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" +
@@ -138,19 +149,19 @@ public class UserImportFromJackrabbit ex
 
         doImport(getTargetPath(), xml, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
 
-        Authorizable newUser = userMgr.getAuthorizable(uid);
+        Authorizable newUser = getUserManager().getAuthorizable(uid);
 
         // IMPORT_UUID_COLLISION_REMOVE_EXISTING should result in the user to
         // be imported a the new path
         assertEquals(getTargetPath(), Text.getRelativeParent(newUser.getPath(), 1));
         assertFalse(initialPath.equals(newUser.getPath()));
 
-        Node n = adminSession.getNode(newUser.getPath());
+        Node n = importSession.getNode(newUser.getPath());
         assertTrue(n.hasProperty(UserConstants.REP_AUTHORIZABLE_ID));
         assertEquals(uid, n.getProperty(UserConstants.REP_AUTHORIZABLE_ID).getString());
 
         // saving changes of the import -> must succeed
-        adminSession.save();
+        importSession.save();
     }
 
     /**
@@ -159,11 +170,11 @@ public class UserImportFromJackrabbit ex
     @Test
     public void testUUIDBehaviorReplaceFromRenamed() throws Exception {
         // create authorizable
-        User u = userMgr.createUser(uid, null, new PrincipalImpl(uid), intermediatePath);
+        User u = getUserManager().createUser(uid, null, new PrincipalImpl(uid), intermediatePath);
         String initialPath = u.getPath();
         String movedPath = Text.getRelativeParent(initialPath, 1) + '/' + randomNodeName;
-        adminSession.move(initialPath, movedPath);
-        adminSession.save();
+        importSession.move(initialPath, movedPath);
+        importSession.save();
 
         // import 'correct' jr2 package which contains the encoded ID in the node name
         String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
@@ -177,18 +188,18 @@ public class UserImportFromJackrabbit ex
 
         doImport(getTargetPath(), xml, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
 
-        Authorizable newUser = userMgr.getAuthorizable(uid);
+        Authorizable newUser = getUserManager().getAuthorizable(uid);
 
         // replace should update the path
         assertEquals("user path", Text.getRelativeParent(initialPath, 1) + '/' + uid, newUser.getPath());
 
-        Node n = adminSession.getNode(newUser.getPath());
+        Node n = importSession.getNode(newUser.getPath());
         assertTrue(n.hasProperty(UserConstants.REP_AUTHORIZABLE_ID));
         assertEquals(UserConstants.REP_AUTHORIZABLE_ID, uid, n.getProperty(UserConstants.REP_AUTHORIZABLE_ID).getString());
         assertEquals(UserConstants.REP_AUTHORIZABLE_ID, uid, newUser.getID());
 
         // saving changes of the import must succeed.
-        adminSession.save();
+        importSession.save();
     }
 
     /**
@@ -197,11 +208,11 @@ public class UserImportFromJackrabbit ex
     @Test
     public void testUUIDBehaviorReplaceFromRenamed2() throws Exception {
         // create authorizable
-        User u = userMgr.createUser(uid, null, new PrincipalImpl(uid), intermediatePath);
+        User u = getUserManager().createUser(uid, null, new PrincipalImpl(uid), intermediatePath);
         String initialPath = u.getPath();
         String movedPath = Text.getRelativeParent(initialPath, 1) + '/' + randomNodeName;
-        adminSession.move(initialPath, movedPath);
-        adminSession.save();
+        importSession.move(initialPath, movedPath);
+        importSession.save();
 
         // we need to include the new node name in the sysview import, so that the importer uses the correct name.
         String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
@@ -215,12 +226,12 @@ public class UserImportFromJackrabbit ex
 
         doImport(getTargetPath(), xml, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
 
-        Authorizable newUser = userMgr.getAuthorizable(uid);
+        Authorizable newUser = getUserManager().getAuthorizable(uid);
 
         // replace should retain path
         assertEquals("user path", movedPath, newUser.getPath());
 
-        Node n = adminSession.getNode(newUser.getPath());
+        Node n = importSession.getNode(newUser.getPath());
         assertTrue(n.hasProperty(UserConstants.REP_AUTHORIZABLE_ID));
         assertEquals(UserConstants.REP_AUTHORIZABLE_ID, randomNodeName, n.getProperty(UserConstants.REP_AUTHORIZABLE_ID).getString());
 
@@ -230,7 +241,7 @@ public class UserImportFromJackrabbit ex
         // correct ID as hashed in the jcr:uuid, the CommitHook will detect
         // the mismatch, which for the diff looks like a modified ID.
         try {
-            adminSession.save();
+            importSession.save();
             fail("Importing an authorizable with mismatch between authorizableId and uuid must fail.");
         } catch (ConstraintViolationException e) {
             // success
@@ -244,9 +255,9 @@ public class UserImportFromJackrabbit ex
     @Test
     public void testUUIDBehaviorReplaceFromRenamed3() throws Exception {
         // create authorizable
-        User u = userMgr.createUser(uid, null, new PrincipalImpl(uid), intermediatePath);
+        User u = getUserManager().createUser(uid, null, new PrincipalImpl(uid), intermediatePath);
         String originalPath = u.getPath();
-        adminSession.save();
+        importSession.save();
 
         // we need to include the new node name in the sysview import, so that the importer uses the correct name.
         String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
@@ -260,13 +271,13 @@ public class UserImportFromJackrabbit ex
 
         doImport(getTargetPath(), xml, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
 
-        Authorizable newUser = userMgr.getAuthorizable(uid);
+        Authorizable newUser = getUserManager().getAuthorizable(uid);
 
         // replace should change the original path
         String expectedPath = Text.getRelativeParent(originalPath, 1) + '/' + randomNodeName;
         assertEquals("user path", expectedPath, newUser.getPath());
 
-        Node n = adminSession.getNode(newUser.getPath());
+        Node n = importSession.getNode(newUser.getPath());
         assertTrue(n.hasProperty(UserConstants.REP_AUTHORIZABLE_ID));
         assertEquals(UserConstants.REP_AUTHORIZABLE_ID, randomNodeName, n.getProperty(UserConstants.REP_AUTHORIZABLE_ID).getString());
 
@@ -275,7 +286,7 @@ public class UserImportFromJackrabbit ex
         // modified node name in combination with the fact that in JR 2.x
         // the node name MUST contain the id as there is no rep:authorizableId.
         try {
-            adminSession.save();
+            importSession.save();
             fail("Importing an authorizable with mismatch between authorizableId and uuid must fail.");
         } catch (ConstraintViolationException e) {
             // success
@@ -289,11 +300,11 @@ public class UserImportFromJackrabbit ex
     @Test
     public void testUUIDBehaviorRemoveFromRenamed() throws Exception {
         // create authorizable
-        User u = userMgr.createUser(uid, null, new PrincipalImpl(uid), intermediatePath);
+        User u = getUserManager().createUser(uid, null, new PrincipalImpl(uid), intermediatePath);
         String initialPath = u.getPath();
         String movedPath = Text.getRelativeParent(initialPath, 1) + '/' + randomNodeName;
-        adminSession.move(initialPath, movedPath);
-        adminSession.save();
+        importSession.move(initialPath, movedPath);
+        importSession.save();
 
         // import 'correct' jr2 package which contains the encoded ID in the node name
         String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
@@ -307,18 +318,18 @@ public class UserImportFromJackrabbit ex
 
         doImport(getTargetPath(), xml, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
 
-        Authorizable newUser = userMgr.getAuthorizable(uid);
+        Authorizable newUser = getUserManager().getAuthorizable(uid);
 
         // IMPORT_UUID_COLLISION_REMOVE_EXISTING should import the user at the new path
         assertEquals("user path", getTargetPath() + '/' + uid, newUser.getPath());
 
-        Node n = adminSession.getNode(newUser.getPath());
+        Node n = importSession.getNode(newUser.getPath());
         assertTrue(n.hasProperty(UserConstants.REP_AUTHORIZABLE_ID));
         assertEquals(UserConstants.REP_AUTHORIZABLE_ID, uid, n.getProperty(UserConstants.REP_AUTHORIZABLE_ID).getString());
         assertEquals(UserConstants.REP_AUTHORIZABLE_ID, uid, newUser.getID());
 
         // saving changes of the import must succeed.
-        adminSession.save();
+        importSession.save();
     }
 
     /**
@@ -327,11 +338,11 @@ public class UserImportFromJackrabbit ex
     @Test
     public void testUUIDBehaviorRemoveFromRenamed2() throws Exception {
         // create authorizable
-        User u = userMgr.createUser(uid, null, new PrincipalImpl(uid), intermediatePath);
+        User u = getUserManager().createUser(uid, null, new PrincipalImpl(uid), intermediatePath);
         String initialPath = u.getPath();
         String movedPath = Text.getRelativeParent(initialPath, 1) + '/' + randomNodeName;
-        adminSession.move(initialPath, movedPath);
-        adminSession.save();
+        importSession.move(initialPath, movedPath);
+        importSession.save();
 
         // we need to include the new node name in the sysview import, so that the importer uses the correct name.
         String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
@@ -345,12 +356,12 @@ public class UserImportFromJackrabbit ex
 
         doImport(getTargetPath(), xml, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
 
-        Authorizable newUser = userMgr.getAuthorizable(uid);
+        Authorizable newUser = getUserManager().getAuthorizable(uid);
 
         // IMPORT_UUID_COLLISION_REMOVE_EXISTING should import the user at the new path
         assertEquals("user path", getTargetPath() + '/' + randomNodeName, newUser.getPath());
 
-        Node n = adminSession.getNode(newUser.getPath());
+        Node n = importSession.getNode(newUser.getPath());
         assertTrue(n.hasProperty(UserConstants.REP_AUTHORIZABLE_ID));
         assertEquals(UserConstants.REP_AUTHORIZABLE_ID, randomNodeName, n.getProperty(UserConstants.REP_AUTHORIZABLE_ID).getString());
 
@@ -358,7 +369,7 @@ public class UserImportFromJackrabbit ex
         // removed and the JR 2.x the node name doesn't contain the correct id,
         // which is detected during save as it looks like the id had been modified.
         try {
-            adminSession.save();
+            importSession.save();
             fail("Importing an authorizable with mismatch between authorizableId and uuid must fail.");
         } catch (ConstraintViolationException e) {
             // success
@@ -372,9 +383,9 @@ public class UserImportFromJackrabbit ex
     @Test
     public void testUUIDBehaviorRemoveFromRenamed3() throws Exception {
         // create authorizable
-        User u = userMgr.createUser(uid, null, new PrincipalImpl(uid), intermediatePath);
+        User u = getUserManager().createUser(uid, null, new PrincipalImpl(uid), intermediatePath);
         String originalPath = u.getPath();
-        adminSession.save();
+        importSession.save();
 
         // we need to include the new node name in the sysview import, so that the importer uses the correct name.
         String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
@@ -388,14 +399,14 @@ public class UserImportFromJackrabbit ex
 
         doImport(getTargetPath(), xml, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
 
-        Authorizable newUser = userMgr.getAuthorizable(uid);
+        Authorizable newUser = getUserManager().getAuthorizable(uid);
 
         // replace should change the original path
         String expectedPath = getTargetPath() + '/' + randomNodeName;
         assertEquals("user path", expectedPath, newUser.getPath());
         assertFalse((Text.getRelativeParent(originalPath,1) + '/' + randomNodeName).equals(newUser.getPath()));
 
-        Node n = adminSession.getNode(newUser.getPath());
+        Node n = importSession.getNode(newUser.getPath());
         assertTrue(n.hasProperty(UserConstants.REP_AUTHORIZABLE_ID));
         assertEquals(UserConstants.REP_AUTHORIZABLE_ID, randomNodeName, n.getProperty(UserConstants.REP_AUTHORIZABLE_ID).getString());
 
@@ -403,7 +414,7 @@ public class UserImportFromJackrabbit ex
         // has been modified (it no longer represents the correct ID due to the
         // fact that in JR 2.x the node name MUST contain the id.
         try {
-            adminSession.save();
+            importSession.save();
             fail("Importing an authorizable with mismatch between authorizableId and uuid must fail.");
         } catch (ConstraintViolationException e) {
             // success

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportIgnoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportIgnoreTest.java?rev=1672469&r1=1672468&r2=1672469&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportIgnoreTest.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportIgnoreTest.java Thu Apr  9 19:34:21 2015
@@ -69,7 +69,7 @@ public class UserImportIgnoreTest extend
                 doImport(getTargetPath(), xml);
                 // no exception during import: no impersonation must be granted
                 // for the invalid principal name
-                Authorizable a = userMgr.getAuthorizable("t");
+                Authorizable a = getUserManager().getAuthorizable("t");
                 if (!a.isGroup()) {
                     Impersonation imp = ((User)a).getImpersonation();
                     Subject s = new Subject();
@@ -82,7 +82,7 @@ public class UserImportIgnoreTest extend
                     fail("Importing 't' didn't create a User.");
                 }
             } finally {
-                adminSession.refresh(false);
+                getImportSession().refresh(false);
             }
         }
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportPwExpiryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportPwExpiryTest.java?rev=1672469&r1=1672468&r2=1672469&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportPwExpiryTest.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportPwExpiryTest.java Thu Apr  9 19:34:21 2015
@@ -20,6 +20,7 @@ import java.util.HashMap;
 import javax.annotation.CheckForNull;
 import javax.jcr.Node;
 import javax.jcr.Property;
+import javax.jcr.Session;
 
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.User;
@@ -87,8 +88,8 @@ public class UserImportPwExpiryTest exte
 
         doImport(USERPATH, xml);
 
-        Authorizable authorizable = userMgr.getAuthorizable("x");
-        Node userNode = adminSession.getNode(authorizable.getPath());
+        Authorizable authorizable = getUserManager().getAuthorizable("x");
+        Node userNode = getImportSession().getNode(authorizable.getPath());
         assertTrue(userNode.hasNode(UserConstants.REP_PWD));
         Node pwdNode = userNode.getNode(UserConstants.REP_PWD);
         assertTrue(pwdNode.getDefinition().isProtected());
@@ -121,8 +122,8 @@ public class UserImportPwExpiryTest exte
         doImport(USERPATH, xml);
 
         // verify that the pwd node has still been created
-        Authorizable authorizable = userMgr.getAuthorizable("x");
-        Node userNode = adminSession.getNode(authorizable.getPath());
+        Authorizable authorizable = getUserManager().getAuthorizable("x");
+        Node userNode = getImportSession().getNode(authorizable.getPath());
         assertTrue(userNode.hasNode(UserConstants.REP_PWD));
         Node pwdNode = userNode.getNode(UserConstants.REP_PWD);
         assertTrue(pwdNode.getDefinition().isProtected());
@@ -165,8 +166,8 @@ public class UserImportPwExpiryTest exte
 
         doImport(USERPATH, xml);
 
-        Authorizable authorizable = userMgr.getAuthorizable("y");
-        Node userNode = adminSession.getNode(authorizable.getPath());
+        Authorizable authorizable = getUserManager().getAuthorizable("y");
+        Node userNode = getImportSession().getNode(authorizable.getPath());
         assertTrue(userNode.hasNode(UserConstants.REP_PWD));
 
         Node pwdNode = userNode.getNode(UserConstants.REP_PWD);
@@ -186,13 +187,14 @@ public class UserImportPwExpiryTest exte
     public void testImportExistingUserWithoutExpiryProperty() throws Exception {
 
         String uid = "existing";
-        User user = userMgr.createUser(uid, uid);
+        User user = getUserManager().createUser(uid, uid);
 
+        Session s = getImportSession();
         // change password to force existence of password last modified property
         user.changePassword(uid);
-        adminSession.save();
+        s.save();
 
-        Node userNode = adminSession.getNode(user.getPath());
+        Node userNode = s.getNode(user.getPath());
         assertTrue(userNode.hasNode(UserConstants.REP_PWD));
         Node pwdNode = userNode.getNode(UserConstants.REP_PWD);
         assertTrue(pwdNode.hasProperty(UserConstants.REP_PASSWORD_LAST_MODIFIED));
@@ -213,8 +215,8 @@ public class UserImportPwExpiryTest exte
 
         doImport(USERPATH, xml);
 
-        Authorizable authorizable = userMgr.getAuthorizable(uid);
-        userNode = adminSession.getNode(authorizable.getPath());
+        Authorizable authorizable = getUserManager().getAuthorizable(uid);
+        userNode = s.getNode(authorizable.getPath());
         assertTrue(userNode.hasNode(UserConstants.REP_PWD));
 
         pwdNode = userNode.getNode(UserConstants.REP_PWD);

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportTest.java?rev=1672469&r1=1672468&r2=1672469&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportTest.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportTest.java Thu Apr  9 19:34:21 2015
@@ -23,6 +23,7 @@ import javax.jcr.ImportUUIDBehavior;
 import javax.jcr.ItemExistsException;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
+import javax.jcr.Session;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.security.auth.Subject;
 
@@ -74,9 +75,9 @@ public class UserImportTest extends Abst
         doImport(getTargetPath(), xml);
 
         assertTrue(target.isModified());
-        assertTrue(adminSession.hasPendingChanges());
+        assertTrue(getImportSession().hasPendingChanges());
 
-        Authorizable newUser = userMgr.getAuthorizable("t");
+        Authorizable newUser = getUserManager().getAuthorizable("t");
         assertNotNull(newUser);
         assertFalse(newUser.isGroup());
         assertEquals("t", newUser.getPrincipal().getName());
@@ -84,7 +85,7 @@ public class UserImportTest extends Abst
         assertTrue(((User) newUser).isDisabled());
         assertEquals("disabledUser", ((User) newUser).getDisabledReason());
 
-        Node n = adminSession.getNode(newUser.getPath());
+        Node n = getImportSession().getNode(newUser.getPath());
         assertTrue(n.isNew());
         assertTrue(n.getParent().isSame(target));
 
@@ -95,7 +96,7 @@ public class UserImportTest extends Abst
 
         // saving changes of the import -> must succeed. add mandatory
         // props should have been created.
-        adminSession.save();
+        getImportSession().save();
     }
 
     /**
@@ -123,16 +124,16 @@ public class UserImportTest extends Abst
         doImport(getTargetPath(), xml);
 
         assertTrue(target.isModified());
-        assertTrue(adminSession.hasPendingChanges());
+        assertTrue(getImportSession().hasPendingChanges());
 
-        Authorizable newGroup = userMgr.getAuthorizable("g");
+        Authorizable newGroup = getUserManager().getAuthorizable("g");
         assertNotNull(newGroup);
         assertTrue(target.hasNode("g"));
         assertTrue(target.hasProperty("g/rep:principalName"));
 
         // saving changes of the import -> must fail
         try {
-            adminSession.save();
+            getImportSession().save();
             fail("Import must be incomplete. Saving changes must fail.");
         } catch (ConstraintViolationException e) {
             // success
@@ -157,7 +158,7 @@ public class UserImportTest extends Abst
         doImport(getTargetPath(), xml);
 
         assertTrue(target.isModified());
-        assertTrue(adminSession.hasPendingChanges());
+        assertTrue(getImportSession().hasPendingChanges());
 
         // node must be present:
         assertTrue(target.hasNode("t"));
@@ -166,17 +167,17 @@ public class UserImportTest extends Abst
 
         // but UserManager.getAuthorizable(String) will not find the
         // authorizable
-        Authorizable newUser = userMgr.getAuthorizable("t");
+        Authorizable newUser = getUserManager().getAuthorizable("t");
         assertNull(newUser);
     }
 
     @Test
     public void testExistingPrincipal() throws Exception {
         Principal existing = null;
-        PrincipalIterator principalIterator = ((JackrabbitSession) adminSession).getPrincipalManager().getPrincipals(PrincipalManager.SEARCH_TYPE_ALL);
+        PrincipalIterator principalIterator = ((JackrabbitSession) getImportSession()).getPrincipalManager().getPrincipals(PrincipalManager.SEARCH_TYPE_ALL);
         while (principalIterator.hasNext()) {
             Principal p = principalIterator.nextPrincipal();
-            if (userMgr.getAuthorizable(p) != null) {
+            if (getUserManager().getAuthorizable(p) != null) {
                 existing = p;
                 break;
             }
@@ -195,7 +196,7 @@ public class UserImportTest extends Abst
 
         try {
             doImport(getTargetPath(), xml);
-            adminSession.save();
+            getImportSession().save();
 
             fail("Import must detect conflicting principals.");
         } catch (RepositoryException e) {
@@ -218,10 +219,10 @@ public class UserImportTest extends Abst
         doImport(getTargetPath(), xml);
 
         assertTrue(target.isModified());
-        assertTrue(adminSession.hasPendingChanges());
+        assertTrue(getImportSession().hasPendingChanges());
 
-        Authorizable newUser = userMgr.getAuthorizable("t");
-        Node n = adminSession.getNode(newUser.getPath());
+        Authorizable newUser = getUserManager().getAuthorizable("t");
+        Node n = getImportSession().getNode(newUser.getPath());
 
         String pwValue = n.getProperty(UserConstants.REP_PASSWORD).getString();
         assertFalse(plainPw.equals(pwValue));
@@ -251,9 +252,9 @@ public class UserImportTest extends Abst
         doImport(getTargetPath(), xml);
 
         assertTrue(target.isModified());
-        assertTrue(adminSession.hasPendingChanges());
+        assertTrue(getImportSession().hasPendingChanges());
 
-        Authorizable newUser = userMgr.getAuthorizable("t");
+        Authorizable newUser = getUserManager().getAuthorizable("t");
         assertNotNull(newUser);
 
         assertTrue(target.hasNode("t"));
@@ -276,22 +277,23 @@ public class UserImportTest extends Abst
                 "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>t</sv:value></sv:property>" +
                 "</sv:node>");
 
+        Session s = getImportSession();
         for (String xml : incompleteXml) {
-            Node target = adminSession.getNode(getTargetPath());
+            Node target = s.getNode(getTargetPath());
             try {
                 doImport(getTargetPath(), xml);
                 // saving changes of the import -> must fail as mandatory prop is missing
                 try {
-                    adminSession.save();
+                    s.save();
                     fail("Import must be incomplete. Saving changes must fail.");
                 } catch (ConstraintViolationException e) {
                     // success
                 }
             } finally {
-                adminSession.refresh(false);
+                s.refresh(false);
                 if (target.hasNode("t")) {
                     target.getNode("t").remove();
-                    adminSession.save();
+                    s.save();
                 }
             }
         }
@@ -311,10 +313,10 @@ public class UserImportTest extends Abst
 
         doImport(getTargetPath(), xml);
 
-        Authorizable user = userMgr.getAuthorizable("t");
+        Authorizable user = getUserManager().getAuthorizable("t");
         assertNotNull(user);
         assertFalse(user.isGroup());
-        assertFalse(adminSession.propertyExists(user.getPath() + "/rep:password"));
+        assertFalse(getImportSession().propertyExists(user.getPath() + "/rep:password"));
     }
 
     @Test
@@ -342,16 +344,17 @@ public class UserImportTest extends Abst
         Node target = getTargetNode();
         doImport(getTargetPath(), xml);
 
+        Session s = getImportSession();
         assertTrue(target.isModified());
-        assertTrue(adminSession.hasPendingChanges());
+        assertTrue(s.hasPendingChanges());
 
-        Authorizable newUser = userMgr.getAuthorizable("t3");
+        Authorizable newUser = getUserManager().getAuthorizable("t3");
         assertNotNull(newUser);
         assertFalse(newUser.isGroup());
         assertEquals("t3", newUser.getPrincipal().getName());
         assertEquals("t3", newUser.getID());
 
-        Node n = adminSession.getNode(newUser.getPath());
+        Node n = s.getNode(newUser.getPath());
         assertTrue(n.isNew());
 
         Node parent = n.getParent();
@@ -383,10 +386,10 @@ public class UserImportTest extends Abst
 
         doImport(getTargetPath(), xml);
 
-        Authorizable newUser = userMgr.getAuthorizable("t");
+        Authorizable newUser = getUserManager().getAuthorizable("t");
         assertNotNull(newUser);
 
-        Authorizable u2 = userMgr.getAuthorizable("g");
+        Authorizable u2 = getUserManager().getAuthorizable("g");
         assertNotNull(u2);
 
         Subject subj = new Subject();
@@ -413,7 +416,7 @@ public class UserImportTest extends Abst
 
         // saving changes of the import -> must succeed. add mandatory
         // props should have been created.
-        adminSession.save();
+        getImportSession().save();
     }
 
     /**
@@ -432,14 +435,16 @@ public class UserImportTest extends Abst
                 "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>t</sv:value></sv:property>" +
                 "</sv:node>";
         doImport(getTargetPath(), xml);
-        adminSession.save();
+
+        Session s = getImportSession();
+        s.save();
 
         // re-import should succeed if UUID-behavior is set accordingly
         doImport(getTargetPath(), xml, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
 
         // saving changes of the import -> must succeed. add mandatory
         // props should have been created.
-        adminSession.save();
+        s.save();
     }
 
     @Test
@@ -478,13 +483,14 @@ public class UserImportTest extends Abst
 
         doImport(getTargetPath(), xml);
 
-        Authorizable newUser = userMgr.getAuthorizable("t");
+        Session s = getImportSession();
+        Authorizable newUser = getUserManager().getAuthorizable("t");
         assertNotNull(newUser);
         assertFalse(newUser.isGroup());
         assertEquals("t", newUser.getID());
-        assertTrue(adminSession.propertyExists(newUser.getPath() + "/rep:authorizableId"));
-        assertEquals("t", adminSession.getProperty(newUser.getPath() + "/rep:authorizableId").getString());
-        adminSession.save();
+        assertTrue(s.propertyExists(newUser.getPath() + "/rep:authorizableId"));
+        assertEquals("t", s.getProperty(newUser.getPath() + "/rep:authorizableId").getString());
+        s.save();
     }
 
     /**
@@ -503,14 +509,15 @@ public class UserImportTest extends Abst
 
         doImport(getTargetPath(), xml);
 
-        Authorizable newUser = userMgr.getAuthorizable("t");
+        Authorizable newUser = getUserManager().getAuthorizable("t");
 
+        Session s = getImportSession();
         assertNotNull(newUser);
         assertFalse(newUser.isGroup());
         assertEquals("t", newUser.getID());
-        assertTrue(adminSession.propertyExists(newUser.getPath() + "/rep:authorizableId"));
-        assertEquals("t", adminSession.getProperty(newUser.getPath() + "/rep:authorizableId").getString());
-        adminSession.save();
+        assertTrue(s.propertyExists(newUser.getPath() + "/rep:authorizableId"));
+        assertEquals("t", s.getProperty(newUser.getPath() + "/rep:authorizableId").getString());
+        s.save();
     }
 
     /**
@@ -531,14 +538,15 @@ public class UserImportTest extends Abst
                 "</sv:node>";
         doImport(getTargetPath(), xml);
 
-        Authorizable newUser = userMgr.getAuthorizable("t");
+        Authorizable newUser = getUserManager().getAuthorizable("t");
 
+        Session s = getImportSession();
         assertNotNull(newUser);
         assertFalse(newUser.isGroup());
         assertEquals("t", newUser.getID());
-        assertTrue(adminSession.propertyExists(newUser.getPath() + "/rep:authorizableId"));
-        assertEquals("t", adminSession.getProperty(newUser.getPath() + "/rep:authorizableId").getString());
-        adminSession.save();
+        assertTrue(s.propertyExists(newUser.getPath() + "/rep:authorizableId"));
+        assertEquals("t", s.getProperty(newUser.getPath() + "/rep:authorizableId").getString());
+        s.save();
     }
 
     /**

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportWithActionsTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportWithActionsTest.java?rev=1672469&r1=1672468&r2=1672469&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportWithActionsTest.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/UserImportWithActionsTest.java Thu Apr  9 19:34:21 2015
@@ -128,11 +128,11 @@ public class UserImportWithActionsTest e
 
         doImport(USERPATH, xml);
 
-        Authorizable a = userMgr.getAuthorizable("t");
+        Authorizable a = getUserManager().getAuthorizable("t");
         assertNotNull(a);
         assertFalse(a.isGroup());
 
-        AccessControlManager acMgr = adminSession.getAccessControlManager();
+        AccessControlManager acMgr = getImportSession().getAccessControlManager();
         AccessControlPolicy[] policies = acMgr.getPolicies(a.getPath());
         assertNotNull(policies);
         assertEquals(1, policies.length);
@@ -159,11 +159,11 @@ public class UserImportWithActionsTest e
 
         doImport(USERPATH, xml);
 
-        Authorizable a = userMgr.getAuthorizable("t");
+        Authorizable a = getUserManager().getAuthorizable("t");
         assertNotNull(a);
         assertFalse(a.isGroup());
 
-        AccessControlManager acMgr = adminSession.getAccessControlManager();
+        AccessControlManager acMgr = getImportSession().getAccessControlManager();
         AccessControlPolicy[] policies = acMgr.getPolicies(a.getPath());
         assertNotNull(policies);
         assertEquals(1, policies.length);
@@ -189,11 +189,11 @@ public class UserImportWithActionsTest e
 
         doImport(GROUPPATH, xml);
 
-        Authorizable a = userMgr.getAuthorizable("g");
+        Authorizable a = getUserManager().getAuthorizable("g");
         assertNotNull(a);
         assertTrue(a.isGroup());
 
-        AccessControlManager acMgr = adminSession.getAccessControlManager();
+        AccessControlManager acMgr = getImportSession().getAccessControlManager();
         AccessControlPolicy[] policies = acMgr.getPolicies(a.getPath());
         assertNotNull(policies);
         assertEquals(1, policies.length);