You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2021/09/17 14:30:12 UTC
[sling-org-apache-sling-feature-cpconverter] branch master updated:
SLING-10818 : Add origin information to repoinit
This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-cpconverter.git
The following commit(s) were added to refs/heads/master by this push:
new 92b3662 SLING-10818 : Add origin information to repoinit
92b3662 is described below
commit 92b36622a76c929b0377f8b402313988ce933774
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Sep 17 16:29:30 2021 +0200
SLING-10818 : Add origin information to repoinit
---
.../ContentPackage2FeatureModelConverter.java | 2 +-
.../cpconverter/accesscontrol/AclManager.java | 2 +-
.../cpconverter/accesscontrol/DefaultAclManager.java | 6 +++---
.../cpconverter/features/DefaultFeaturesManager.java | 12 +++++++-----
.../cpconverter/features/FeaturesManager.java | 12 ++++++++++--
.../ContentPackage2FeatureModelConverterTest.java | 2 +-
.../cpconverter/accesscontrol/AclManagerTest.java | 18 +++++++++---------
.../accesscontrol/EnforcePrincipalBasedTest.java | 20 ++++++++++----------
.../cpconverter/features/FeaturesManagerTest.java | 3 ++-
.../handlers/RepPolicyEntryHandlerTest.java | 10 +++++-----
.../handlers/RepPrincipalPolicyEntryHandlerTest.java | 10 +++++-----
.../cpconverter/handlers/UsersEntryHandlerTest.java | 7 ++++---
12 files changed, 58 insertions(+), 46 deletions(-)
diff --git a/src/main/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverter.java b/src/main/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverter.java
index d571d18..5abeed6 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverter.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverter.java
@@ -288,7 +288,7 @@ public class ContentPackage2FeatureModelConverter extends BaseVaultPackageScanne
ArtifactId mvnPackageId = toArtifactId(vaultPackage.getId(), vaultPackage.getFile());
- featuresManager.init(mvnPackageId.getGroupId(), mvnPackageId.getArtifactId(), mvnPackageId.getVersion());
+ featuresManager.init(mvnPackageId);
logger.info("Converting content-package '{}'...", vaultPackage.getId());
diff --git a/src/main/java/org/apache/sling/feature/cpconverter/accesscontrol/AclManager.java b/src/main/java/org/apache/sling/feature/cpconverter/accesscontrol/AclManager.java
index 0879d6a..c27e2f5 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/accesscontrol/AclManager.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/accesscontrol/AclManager.java
@@ -44,7 +44,7 @@ public interface AclManager {
void addRepoinitExtension(@NotNull List<VaultPackageAssembler> packageAssemblers, @NotNull FeaturesManager featureManager)
throws IOException, ConverterException;
- void addRepoinitExtention(@Nullable String repoInitText, @Nullable String runMode, @NotNull FeaturesManager featuresManager)
+ void addRepoinitExtention(@NotNull String source, @Nullable String repoInitText, @Nullable String runMode, @NotNull FeaturesManager featuresManager)
throws IOException, ConverterException;
void addNodetypeRegistration(@NotNull String cndStatements);
diff --git a/src/main/java/org/apache/sling/feature/cpconverter/accesscontrol/DefaultAclManager.java b/src/main/java/org/apache/sling/feature/cpconverter/accesscontrol/DefaultAclManager.java
index 620da26..e4adf46 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/accesscontrol/DefaultAclManager.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/accesscontrol/DefaultAclManager.java
@@ -177,13 +177,13 @@ public class DefaultAclManager implements AclManager, EnforceInfo {
String text = formatter.toString();
if (!text.isEmpty()) {
- featureManager.addOrAppendRepoInitExtension(text, null);
+ featureManager.addOrAppendRepoInitExtension("content-package", text, null);
}
}
}
@Override
- public void addRepoinitExtention(@Nullable String repoInitText, @Nullable String runMode, @NotNull FeaturesManager featuresManager)
+ public void addRepoinitExtention(@NotNull String source, @Nullable String repoInitText, @Nullable String runMode, @NotNull FeaturesManager featuresManager)
throws IOException, ConverterException {
if (repoInitText == null || repoInitText.trim().isEmpty()) {
return;
@@ -215,7 +215,7 @@ public class DefaultAclManager implements AclManager, EnforceInfo {
String text = formatter.toString().trim();
if (!text.isEmpty()) {
- featuresManager.addOrAppendRepoInitExtension(text, runMode);
+ featuresManager.addOrAppendRepoInitExtension(source, text, runMode);
}
} catch (RepoInitParsingException e) {
throw new ConverterException(e.getMessage(), e);
diff --git a/src/main/java/org/apache/sling/feature/cpconverter/features/DefaultFeaturesManager.java b/src/main/java/org/apache/sling/feature/cpconverter/features/DefaultFeaturesManager.java
index 7ce3e40..facba6f 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/features/DefaultFeaturesManager.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/features/DefaultFeaturesManager.java
@@ -157,8 +157,8 @@ public class DefaultFeaturesManager implements FeaturesManager, PackagesEventsEm
}
@Override
- public void init(@NotNull String groupId, @NotNull String artifactId, @NotNull String version) {
- targetFeature = new Feature(new ArtifactId(groupId, artifactId, version, null, SLING_OSGI_FEATURE_TILE_TYPE));
+ public void init(@NotNull ArtifactId packageId) {
+ targetFeature = new Feature(packageId.changeClassifier(null).changeType(SLING_OSGI_FEATURE_TILE_TYPE));
runModes.clear();
}
@@ -271,7 +271,7 @@ public class DefaultFeaturesManager implements FeaturesManager, PackagesEventsEm
}
if (seed.getExtensions().getByName(Extension.EXTENSION_NAME_REPOINIT) != null) {
String repoInitText = seed.getExtensions().getByName(Extension.EXTENSION_NAME_REPOINIT).getText();
- getAclManager().addRepoinitExtention(repoInitText, "seed", this);
+ getAclManager().addRepoinitExtention("seed", repoInitText, "seed", this);
extractNamespaces(repoInitText, namespaceUriByPrefix);
}
@@ -312,7 +312,7 @@ public class DefaultFeaturesManager implements FeaturesManager, PackagesEventsEm
final String[] scripts = Converters.standardConverter().convert(configurationProperties.get("scripts")).to(String[].class);
if (scripts != null && scripts.length > 0) {
for (final String text : scripts) {
- getAclManager().addRepoinitExtention(text, runMode, this);
+ getAclManager().addRepoinitExtention(pid, text, runMode, this);
}
}
checkReferences(configurationProperties, pid);
@@ -526,7 +526,7 @@ public class DefaultFeaturesManager implements FeaturesManager, PackagesEventsEm
}
@Override
- public void addOrAppendRepoInitExtension(@NotNull String text, @Nullable String runMode) {
+ public void addOrAppendRepoInitExtension(@NotNull String source, @NotNull String text, @Nullable String runMode) {
if (runMode == null) {
logger.info("Adding global repo-init");
} else {
@@ -534,6 +534,8 @@ public class DefaultFeaturesManager implements FeaturesManager, PackagesEventsEm
}
Extension repoInitExtension = getRunMode(runMode).getExtensions().getByName(Extension.EXTENSION_NAME_REPOINIT);
+ // prepend source/origin
+ text = "# origin=".concat(String.join("|", this.packageIds)).concat(" source=").concat(source).concat(System.lineSeparator().concat(text));
if (repoInitExtension == null) {
repoInitExtension = new Extension(ExtensionType.TEXT, Extension.EXTENSION_NAME_REPOINIT, ExtensionState.REQUIRED);
getRunMode(runMode).getExtensions().add(repoInitExtension);
diff --git a/src/main/java/org/apache/sling/feature/cpconverter/features/FeaturesManager.java b/src/main/java/org/apache/sling/feature/cpconverter/features/FeaturesManager.java
index 67d6e1a..2d1ac99 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/features/FeaturesManager.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/features/FeaturesManager.java
@@ -28,7 +28,7 @@ import org.jetbrains.annotations.Nullable;
public interface FeaturesManager {
- void init(@NotNull String groupId, @NotNull String artifactId, @NotNull String version);
+ void init(@NotNull ArtifactId packageId);
@Nullable Feature getTargetFeature();
@@ -48,7 +48,15 @@ public interface FeaturesManager {
void serialize() throws IOException;
- void addOrAppendRepoInitExtension(@NotNull String text, @Nullable String runMode)
+ /**
+ * Add repoinit instructions
+ * @param source An identifier for the source, for example the configuration pid
+ * @param text The repoinit instructions
+ * @param runMode Optional runmode
+ * @throws IOException if an error occurs
+ * @throws ConverterException if conversion fails
+ */
+ void addOrAppendRepoInitExtension(@NotNull String source, @NotNull String text, @Nullable String runMode)
throws IOException, ConverterException;
@NotNull
diff --git a/src/test/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverterTest.java b/src/test/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverterTest.java
index 26cc868..6cef58c 100644
--- a/src/test/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverterTest.java
+++ b/src/test/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverterTest.java
@@ -753,7 +753,7 @@ public class ContentPackage2FeatureModelConverterTest extends AbstractConverterT
Extension repoinitExtension = feature.getExtensions().getByName("repoinit");
assertNotNull(repoinitExtension);
- String expected = normalize("register nodetypes\n" +
+ String expected = "# origin=my_packages:test_a:1.0 source=content-package" + System.lineSeparator() + normalize("register nodetypes\n" +
"<<===\n" +
"<< <'sling'='http://sling.apache.org/jcr/sling/1.0'>\n" +
"<< <'nt'='http://www.jcp.org/jcr/nt/1.0'>\n" +
diff --git a/src/test/java/org/apache/sling/feature/cpconverter/accesscontrol/AclManagerTest.java b/src/test/java/org/apache/sling/feature/cpconverter/accesscontrol/AclManagerTest.java
index 0479571..e9d00e2 100644
--- a/src/test/java/org/apache/sling/feature/cpconverter/accesscontrol/AclManagerTest.java
+++ b/src/test/java/org/apache/sling/feature/cpconverter/accesscontrol/AclManagerTest.java
@@ -99,7 +99,7 @@ public class AclManagerTest {
assertNotNull(repoinitExtension);
// acs-commons-on-deploy-scripts-service will be missed
- String expected = Util.normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + Util.normalize(
"create service user acs-commons-package-replication-status-event-service with path system\n" +
"create path /sling:tests/not(nt:unstructured mixin rep:AccessControllable,mix:created)/system/user/path\n" +
"set ACL for acs-commons-package-replication-status-event-service\n" +
@@ -141,7 +141,7 @@ public class AclManagerTest {
assertNotNull(repoinitExtension);
// aacs-commons-ensure-oak-index-service will be missed
- String expected = Util.normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + Util.normalize(
"create service user acs-commons-package-replication-status-event-service with path system\n" +
"create path /sling:tests/not(nt:unstructured mixin rep:AccessControllable,mix:created)/system/user/path\n" +
"set ACL for acs-commons-package-replication-status-event-service\n" +
@@ -191,7 +191,7 @@ public class AclManagerTest {
Extension repoinitExtension = feature.getExtensions().getByName(Extension.EXTENSION_NAME_REPOINIT);
assertNotNull(repoinitExtension);
- String expected = Util.normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + Util.normalize(
"create service user sys-usr with path system\n" +
"create path /content/cq:tags\n"+
"set ACL for sys-usr\n" +
@@ -243,7 +243,7 @@ public class AclManagerTest {
Extension repoinitExtension = feature.getExtensions().getByName(Extension.EXTENSION_NAME_REPOINIT);
assertNotNull(repoinitExtension);
- String expected = Util.normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + Util.normalize(
"create service user sys-usr with path system\n" +
"create path /content/test\n" +
"set ACL for sys-usr\n" +
@@ -303,7 +303,7 @@ public class AclManagerTest {
Extension repoinitExtension = feature.getExtensions().getByName(Extension.EXTENSION_NAME_REPOINIT);
assertNotNull(repoinitExtension);
- String expected = Util.normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + Util.normalize(
"create service user sys-usr with path system\n" +
"create path /content/test\n" +
"set ACL for sys-usr\n" +
@@ -335,7 +335,7 @@ public class AclManagerTest {
// in contrast to testUserHandlingWithMatchingUser in this test /home/users/test2 is not detected
// as user-home-path and thus is processed like a regular path (no 'home(uid)' repo-init statement and no exception).\
// however, no attempt is made to create the path without any available node type information.
- String expected = Util.normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + Util.normalize(
"create service user sys-usr with path system\n" +
"set ACL for sys-usr\n" +
" allow jcr:read on /home/users/notMatching\n" +
@@ -354,14 +354,14 @@ public class AclManagerTest {
@Test(expected = ConverterException.class)
public void testAddRepoinitExtentionInvalidTxt() throws Exception {
DefaultAclManager aclManager = new DefaultAclManager("/home/users/system/cq:services", "system");
- aclManager.addRepoinitExtention("some invalid txt", null, mock(FeaturesManager.class));
+ aclManager.addRepoinitExtention("test", "some invalid txt", null, mock(FeaturesManager.class));
}
@Test
public void testAddRepoinitExtentionEmptyTxt()throws Exception {
FeaturesManager fm = mock(FeaturesManager.class);
DefaultAclManager aclManager = new DefaultAclManager("/home/users/system/cq:services", "system");
- aclManager.addRepoinitExtention("", null, fm);
+ aclManager.addRepoinitExtention("test", "", null, fm);
verifyNoInteractions(fm);
}
@@ -370,7 +370,7 @@ public class AclManagerTest {
public void testAddRepoinitExtentionNullTxt() throws Exception {
FeaturesManager fm = mock(FeaturesManager.class);
DefaultAclManager aclManager = new DefaultAclManager("/home/users/system/cq:services", "system");
- aclManager.addRepoinitExtention(null, null, fm);
+ aclManager.addRepoinitExtention("test", null, null, fm);
verifyNoInteractions(fm);
}
diff --git a/src/test/java/org/apache/sling/feature/cpconverter/accesscontrol/EnforcePrincipalBasedTest.java b/src/test/java/org/apache/sling/feature/cpconverter/accesscontrol/EnforcePrincipalBasedTest.java
index 67be3f2..dcf311b 100644
--- a/src/test/java/org/apache/sling/feature/cpconverter/accesscontrol/EnforcePrincipalBasedTest.java
+++ b/src/test/java/org/apache/sling/feature/cpconverter/accesscontrol/EnforcePrincipalBasedTest.java
@@ -116,7 +116,7 @@ public class EnforcePrincipalBasedTest {
RepoPath accessControlledPath = new RepoPath("/content/feature");
Extension repoinitExtension = getRepoInitExtension(acMgr, accessControlledPath, systemUser, false);
- String expected = normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + normalize(
"create service user user1 with path " + relativeIntermediatePath + "\n" +
"create path /content/feature(sling:Folder)\n" +
"set ACL for user1\n" +
@@ -136,7 +136,7 @@ public class EnforcePrincipalBasedTest {
RepoPath accessControlledPath = new RepoPath("/content/feature");
Extension repoinitExtension = getRepoInitExtension(aclManager, accessControlledPath, systemUser, false);
- String expected = normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + normalize(
"create service user user1 with forced path " + remappedIntermediatePath + "\n" +
"set principal ACL for user1\n" +
" allow jcr:read on /content/feature\n" +
@@ -155,7 +155,7 @@ public class EnforcePrincipalBasedTest {
RepoPath accessControlledPath = new RepoPath("/content/feature");
Extension repoinitExtension = getRepoInitExtension(aclManager, accessControlledPath, systemUser, true);
- String expected = normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + normalize(
"create service user user1 with forced path " + remappedIntermediatePath + "\n" +
"set principal ACL for user1\n" +
" allow jcr:read on /content/feature\n" +
@@ -174,7 +174,7 @@ public class EnforcePrincipalBasedTest {
RepoPath accessControlledPath = systemUser.getPath();
Extension repoinitExtension = getRepoInitExtension(aclManager, accessControlledPath, systemUser, true);
- String expected = normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + normalize(
"create service user user1 with forced path " + remappedIntermediatePath + "\n" +
"set principal ACL for user1\n" +
" allow jcr:read on home(user1)\n" +
@@ -195,7 +195,7 @@ public class EnforcePrincipalBasedTest {
RepoPath accessControlledPath = new RepoPath("/content/feature");
Extension repoinitExtension = getRepoInitExtension(aclManager, accessControlledPath, systemUser, false);
- String expected = normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + normalize(
"create service user user1 with path " +relativeIntermediatePath+ "\n" +
"create path /content/feature\n" +
"set ACL for user1\n" +
@@ -213,7 +213,7 @@ public class EnforcePrincipalBasedTest {
RepoPath accessControlledPath = new RepoPath("/content/feature");
Extension repoinitExtension = getRepoInitExtension(aclManager, accessControlledPath, systemUser, false);
- String expected = normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + normalize(
"create service user user1 with forced path " + remappedIntermediatePath + "\n" +
"set principal ACL for user1\n" +
" allow jcr:read on /content/feature\n" +
@@ -238,7 +238,7 @@ public class EnforcePrincipalBasedTest {
RepoPath accessControlledPath = new RepoPath("/content/feature");
Extension repoinitExtension = getRepoInitExtension(aclManager, accessControlledPath, systemUser, false);
- String expected = normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + normalize(
"create service user user1 with path " + relativeIntermediatePath + "\n" +
"create path /content/feature\n" +
"set ACL for user1\n" +
@@ -264,7 +264,7 @@ public class EnforcePrincipalBasedTest {
RepoPath accessControlledPath = new RepoPath("/content/feature");
Extension repoinitExtension = getRepoInitExtension(aclManager, accessControlledPath, systemUser, false);
- String expected = normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + normalize(
"create service user user1 with forced path " + remappedIntermediatePath + "\n" +
"set principal ACL for user1\n" +
" allow jcr:read on /content/feature\n" +
@@ -285,7 +285,7 @@ public class EnforcePrincipalBasedTest {
props.put("user.mapping", new String[]{"serviceName:subservice=[user1]"," ","serviceName2:subservice2=[user2]"});
seed.getConfigurations().add(foo);
- fm.init("groupId", "artifactId", "version1.0");
+ fm.init(ArtifactId.parse("groupId:artifactId:version1.0"));
fm.addConfiguration("author", foo.getPid(), "/path", props);
// verify that invalid empty mapping has been stripped (without Exception)
@@ -302,7 +302,7 @@ public class EnforcePrincipalBasedTest {
Dictionary<String, Object> props = foo.getProperties();
props.put("user.mapping", new String[]{"serviceName:subservice=[user1]","","serviceName2:subservice2=[user2]"});
- fm.init("groupId", "artifactId", "version1.0");
+ fm.init(ArtifactId.parse("groupId:artifactId:version1.0"));
fm.addConfiguration("author", foo.getPid(), "/path", props);
// verify that invalid empty mapping has been stripped (without Exception)
diff --git a/src/test/java/org/apache/sling/feature/cpconverter/features/FeaturesManagerTest.java b/src/test/java/org/apache/sling/feature/cpconverter/features/FeaturesManagerTest.java
index 6891cd3..7f8fc0c 100644
--- a/src/test/java/org/apache/sling/feature/cpconverter/features/FeaturesManagerTest.java
+++ b/src/test/java/org/apache/sling/feature/cpconverter/features/FeaturesManagerTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.sling.feature.cpconverter.features;
+import org.apache.sling.feature.ArtifactId;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -74,7 +75,7 @@ public class FeaturesManagerTest {
public void testExportsToAPIRegion() throws Exception {
((DefaultFeaturesManager) featuresManager).setExportToAPIRegion("global");
((DefaultFeaturesManager) featuresManager).setAPIRegions(Collections.singletonList("deprecated"));
- featuresManager.init("g", "a", "1");
+ featuresManager.init(ArtifactId.parse("g:a:1"));
featuresManager.addAPIRegionExport(null, "org.foo.a");
featuresManager.addAPIRegionExport(null, "org.foo.b");
featuresManager.addAPIRegionExport("rm1", "x.y");
diff --git a/src/test/java/org/apache/sling/feature/cpconverter/handlers/RepPolicyEntryHandlerTest.java b/src/test/java/org/apache/sling/feature/cpconverter/handlers/RepPolicyEntryHandlerTest.java
index 3f3e5c5..c2597e7 100644
--- a/src/test/java/org/apache/sling/feature/cpconverter/handlers/RepPolicyEntryHandlerTest.java
+++ b/src/test/java/org/apache/sling/feature/cpconverter/handlers/RepPolicyEntryHandlerTest.java
@@ -85,7 +85,7 @@ public final class RepPolicyEntryHandlerTest {
"acs-commons-on-deploy-scripts-service").getRepoinitExtension();
// commented ACLs are due SLING-8561
- String expected = normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + normalize(
"create service user acs-commons-ensure-oak-index-service with path system\n" +
"create service user acs-commons-dispatcher-flush-service with path system\n" +
"create service user acs-commons-package-replication-status-event-service with path system\n" +
@@ -129,7 +129,7 @@ public final class RepPolicyEntryHandlerTest {
"acs-commons-on-deploy-scripts-service");
Extension repoinitExtension = result.getRepoinitExtension();
- String expected = normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + normalize(
"create service user acs-commons-package-replication-status-event-service with path system\n" +
"create service user acs-commons-ensure-service-user-service with path system\n" +
"create service user acs-commons-automatic-package-replicator-service with path system\n" +
@@ -172,7 +172,7 @@ public final class RepPolicyEntryHandlerTest {
ParseResult result = parseAndSetRepoinit(new SystemUser("acs-commons-package-replication-status-event-service",
new RepoPath("/home/users/system/some/other/node"), new RepoPath("/home/users/system/some/other")));
Extension repoinitExtension = result.getRepoinitExtension();
- String expected = normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + normalize(
"create service user acs-commons-package-replication-status-event-service with path system/some/other\n" +
"set ACL for acs-commons-package-replication-status-event-service\n" +
" allow jcr:read,rep:write,jcr:readAccessControl,jcr:modifyAccessControl on /home/users/system/asd\n" +
@@ -215,7 +215,7 @@ public final class RepPolicyEntryHandlerTest {
ParseResult result = parseAndSetRepoinit("/jcr_root/home/groups/g/_rep_policy.xml", aclManager);
Extension repoinitExtension = result.getRepoinitExtension();
- String expected = normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + normalize(
"create service user service1 with path system/services\n" +
"set ACL for service1\n" +
" allow jcr:read,rep:userManagement on /home/groups/g\n" +
@@ -264,7 +264,7 @@ public final class RepPolicyEntryHandlerTest {
String path = "/jcr_root/asd/jr2restrictions/_rep_policy.xml";
Extension repoinitExtension = parseAndSetRepoinit(path, aclManager).getRepoinitExtension();
- String expected = normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + normalize(
"create service user service1 with path system/services\n" +
"create path /asd/jr2restrictions\n" +
"set ACL for service1\n" +
diff --git a/src/test/java/org/apache/sling/feature/cpconverter/handlers/RepPrincipalPolicyEntryHandlerTest.java b/src/test/java/org/apache/sling/feature/cpconverter/handlers/RepPrincipalPolicyEntryHandlerTest.java
index 1c7dbfa..a68db8b 100644
--- a/src/test/java/org/apache/sling/feature/cpconverter/handlers/RepPrincipalPolicyEntryHandlerTest.java
+++ b/src/test/java/org/apache/sling/feature/cpconverter/handlers/RepPrincipalPolicyEntryHandlerTest.java
@@ -69,7 +69,7 @@ public final class RepPrincipalPolicyEntryHandlerTest {
@Test
public void parseSimplePolicy() throws Exception {
Extension repoinitExtension = parseAndSetRepoinit("service1", "random1").getRepoinitExtension();
- String expected = normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + normalize(
"create service user service1 with path system/services\n" +
"set principal ACL for service1\n" +
" allow jcr:read,jcr:readAccessControl on /asd/public\n" +
@@ -86,7 +86,7 @@ public final class RepPrincipalPolicyEntryHandlerTest {
@Test
public void parseMvRestrictions() throws Exception {
Extension repoinitExtension = parseAndSetRepoinit("service2", "random2").getRepoinitExtension();
- String expected = normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + normalize(
"create service user service2 with path system/services\n" +
"set principal ACL for service2\n" +
" allow jcr:read on /asd/public restriction(rep:ntNames,nt:folder,sling:Folder) restriction(sling:customRestriction,customRestrictionValue)\n" +
@@ -110,7 +110,7 @@ public final class RepPrincipalPolicyEntryHandlerTest {
SystemUser systemUser4 = createSystemUser("service4", "random4");
Extension repoinitExtension = parseAndSetRepoinit(getPolicyPath(systemUser4), systemUser4).getRepoinitExtension();
- String expected = normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + normalize(
"create service user service4 with path system/services\n" +
"set principal ACL for service4\n" +
// since service3 is not known to the AclManager it treats the effective path as a regular node.
@@ -131,7 +131,7 @@ public final class RepPrincipalPolicyEntryHandlerTest {
SystemUser systemUser4 = createSystemUser("service4", "random4");
Extension repoinitExtension = parseAndSetRepoinit(getPolicyPath(systemUser4), systemUser4, systemUser3).getRepoinitExtension();
- String expected = normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + normalize(
"create service user service4 with path system/services\n" +
"create service user service3 with path system/services\n" +
"set principal ACL for service4\n" +
@@ -149,7 +149,7 @@ public final class RepPrincipalPolicyEntryHandlerTest {
@Test
public void parsePolicyWithWrongTypeEffectivePath() throws Exception {
Extension repoinitExtension = parseAndSetRepoinit("service4", "random5").getRepoinitExtension();
- String expected = normalize(
+ String expected = "# origin= source=content-package" + System.lineSeparator() + normalize(
"create service user service4 with path system/services\n" +
"set principal ACL for service4\n" +
" allow jcr:read on /effective/path/of/type/string\n" +
diff --git a/src/test/java/org/apache/sling/feature/cpconverter/handlers/UsersEntryHandlerTest.java b/src/test/java/org/apache/sling/feature/cpconverter/handlers/UsersEntryHandlerTest.java
index 96b8fc9..99a5dc0 100644
--- a/src/test/java/org/apache/sling/feature/cpconverter/handlers/UsersEntryHandlerTest.java
+++ b/src/test/java/org/apache/sling/feature/cpconverter/handlers/UsersEntryHandlerTest.java
@@ -45,7 +45,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
public class UsersEntryHandlerTest {
@@ -81,7 +80,8 @@ public class UsersEntryHandlerTest {
assertEquals(ExtensionType.TEXT, repoinitExtension.getType());
assertTrue(repoinitExtension.isRequired());
- String expected = normalize("create service user asd-share-commons-asd-index-definition-reader-service with path system/asd-share-commons\n");
+ String expected = "# origin= source=content-package" + System.lineSeparator() +
+ normalize("create service user asd-share-commons-asd-index-definition-reader-service with path system/asd-share-commons\n");
String actual = repoinitExtension.getText();
assertEquals(expected, actual);
@@ -99,7 +99,8 @@ public class UsersEntryHandlerTest {
assertEquals(ExtensionType.TEXT, repoinitExtension.getType());
assertTrue(repoinitExtension.isRequired());
- String expected = normalize("create service user service1 with path system/services\ndisable service user service1 : \"a reason\"\n");
+ String expected = "# origin= source=content-package" + System.lineSeparator() +
+ normalize("create service user service1 with path system/services\ndisable service user service1 : \"a reason\"\n");
String actual = repoinitExtension.getText();
assertEquals(expected, actual);