You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2021/04/27 15:24:04 UTC

[sling-org-apache-sling-jcr-repoinit] branch master updated: SLING-10333 - test 'disable user' statement and require repoinit language 8.3

This is an automated email from the ASF dual-hosted git repository.

bdelacretaz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-repoinit.git


The following commit(s) were added to refs/heads/master by this push:
     new fcad90a  SLING-10333 - test 'disable user' statement and require repoinit language 8.3
fcad90a is described below

commit fcad90a3a17193a1ffc928b1d6c90d033d94b1a5
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Apr 27 17:21:43 2021 +0200

    SLING-10333 - test 'disable user' statement and require repoinit language 8.3
---
 bnd.bnd                                            |  2 +-
 .../sling/jcr/repoinit/CreateServiceUsersTest.java | 40 ++++++++++++++++++++--
 2 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/bnd.bnd b/bnd.bnd
index f627297..d95093a 100644
--- a/bnd.bnd
+++ b/bnd.bnd
@@ -1,2 +1,2 @@
 Provide-Capability: osgi.implementation;osgi.implementation="org.apache.sling.jcr.repoinit";version:Version="8.1"
-Require-Capability: org.apache.sling.repoinit.language;filter:="(version>=8.2)"
+Require-Capability: org.apache.sling.repoinit.language;filter:="(version>=8.3)"
diff --git a/src/test/java/org/apache/sling/jcr/repoinit/CreateServiceUsersTest.java b/src/test/java/org/apache/sling/jcr/repoinit/CreateServiceUsersTest.java
index 6b32f4c..b3d2a00 100644
--- a/src/test/java/org/apache/sling/jcr/repoinit/CreateServiceUsersTest.java
+++ b/src/test/java/org/apache/sling/jcr/repoinit/CreateServiceUsersTest.java
@@ -23,7 +23,6 @@ import java.util.Random;
 import javax.jcr.RepositoryException;
 
 import org.apache.jackrabbit.api.security.user.AuthorizableTypeException;
-import org.apache.jackrabbit.api.security.user.Group;
 import org.apache.sling.jcr.repoinit.impl.TestUtil;
 import org.apache.sling.jcr.repoinit.impl.UserUtil;
 import org.apache.sling.testing.mock.sling.ResourceResolverType;
@@ -86,6 +85,41 @@ public class CreateServiceUsersTest {
     }
 
     @Test
+    public void disableRegularUserTest() throws Exception {
+        U.assertServiceUser("at start of test", userId, false);
+        U.parseAndExecute("create user " + userId);
+        U.assertEnabledUser("after creating user", userId);
+
+        final String disabledReason = "disabled-" + random.nextInt();
+        U.parseAndExecute("disable user " + userId + " : \"" + disabledReason + "\"");
+        U.assertDisabledUser("after disable user", userId, disabledReason);
+    }
+
+    @Test
+    public void disableDoesntCheckUserTypeOnServiceUserTest() throws Exception {
+        U.assertServiceUser("at start of test", userId, false);
+        U.parseAndExecute("create service user " + userId);
+        U.assertServiceUser("after creating user", userId, true);
+        U.assertEnabledUser("after creating user", userId);
+
+        final String disabledReason = "disabled-" + random.nextInt();
+        U.parseAndExecute("disable user " + userId + " : \"" + disabledReason + "\"");
+        U.assertServiceUser("after creating user", userId, true);
+        U.assertDisabledUser("after disable user", userId, disabledReason);
+    }
+
+    @Test
+    public void disableDoesntCheckUserTypeOnRegularUserTest() throws Exception {
+        U.assertServiceUser("at start of test", userId, false);
+        U.parseAndExecute("create user " + userId);
+        U.assertEnabledUser("after creating user", userId);
+
+        final String disabledReason = "disabled-" + random.nextInt();
+        U.parseAndExecute("disable service user " + userId + " : \"" + disabledReason + "\"");
+        U.assertDisabledUser("after disable user", userId, disabledReason);
+    }
+
+    @Test
     public void deleteNonExistingUserTest() throws Exception {
         U.assertServiceUser("at start of test", userId, false);
         U.parseAndExecute("delete service user " + userId);
@@ -96,7 +130,9 @@ public class CreateServiceUsersTest {
     public void disableNonExistingUserTest() throws Exception {
         U.assertServiceUser("at start of test", userId, false);
         U.parseAndExecute("disable service user " + userId + " : \"Test\"");
-        U.assertServiceUser("after disable user", userId, false);
+        U.assertServiceUser("after disable service user", userId, false);
+        U.parseAndExecute("disable user " + userId + " : \"Test\"");
+        U.assertServiceUser("after disable regular user", userId, false);
     }
     
     private String user(int index) {