anchela commented on a change in pull request #43:
URL:
https://github.com/apache/sling-org-apache-sling-feature-cpconverter/pull/43#discussion_r540303991
##########
File path:
src/test/java/org/apache/sling/feature/cpconverter/accesscontrol/AclManagerTest.java
##########
@@ -120,6 +155,37 @@ public void
makeSureAclsAreCreatedOnlyoutsideSytemUsersPaths() throws Exception
assertFalse(operations.isEmpty());
}
+ @Test
+ public void testAddACLforUnknownUser() throws RepoInitParsingException {
+ aclManager.addSystemUser(new
SystemUser("acs-commons-package-replication-status-event-service", new
RepoPath("/home/users/system/foo"), new RepoPath("/home/users/system")));
Review comment:
wouldn't it be easier to omit that an only call 'addAcl' for an unknown
principal? the repo-init statement should then be empty (or nearly empty)
##########
File path:
src/test/java/org/apache/sling/feature/cpconverter/accesscontrol/AclManagerTest.java
##########
@@ -109,7 +101,50 @@ public void
makeSureAclsAreCreatedOnlyoutsideSytemUsersPaths() throws Exception
// "set ACL for
acs-commons-package-replication-status-event-service\n" +
// "allow jcr:read,crx:replicate,jcr:removeNode on
/asd/public\n" +
// "end\n" +
- "set ACL for acs-commons-ensure-oak-index-service" +
System.lineSeparator() +
+ "set ACL for
acs-commons-package-replication-status-event-service" + System.lineSeparator() +
+ "allow jcr:read,rep:write,rep:indexDefinitionManagement on
/asd/not/system/user/path" + System.lineSeparator() +
+ "end" + System.lineSeparator();
+ String actual = repoinitExtension.getText();
+ assertEquals(expected, actual);
+
+ RepoInitParser repoInitParser = new RepoInitParserService();
+ List<Operation> operations = repoInitParser.parse(new
StringReader(actual));
+ assertFalse(operations.isEmpty());
+ }
+
+ @Test
+ public void testRest() throws RepoInitParsingException {
Review comment:
mini typo: there is an 'e' missing for ResEt
##########
File path:
src/test/java/org/apache/sling/feature/cpconverter/accesscontrol/AclManagerTest.java
##########
@@ -109,7 +101,50 @@ public void
makeSureAclsAreCreatedOnlyoutsideSytemUsersPaths() throws Exception
// "set ACL for
acs-commons-package-replication-status-event-service\n" +
// "allow jcr:read,crx:replicate,jcr:removeNode on
/asd/public\n" +
// "end\n" +
- "set ACL for acs-commons-ensure-oak-index-service" +
System.lineSeparator() +
+ "set ACL for
acs-commons-package-replication-status-event-service" + System.lineSeparator() +
+ "allow jcr:read,rep:write,rep:indexDefinitionManagement on
/asd/not/system/user/path" + System.lineSeparator() +
+ "end" + System.lineSeparator();
+ String actual = repoinitExtension.getText();
+ assertEquals(expected, actual);
+
+ RepoInitParser repoInitParser = new RepoInitParserService();
+ List<Operation> operations = repoInitParser.parse(new
StringReader(actual));
+ assertFalse(operations.isEmpty());
+ }
+
+ @Test
+ public void testRest() throws RepoInitParsingException {
+ // We assume this user will not be in the result because of the reset
in the next line
+ aclManager.addSystemUser(new
SystemUser("acs-commons-ensure-oak-index-service", new
RepoPath("/home/users/system/foo"), new RepoPath("/home/users/system")));
+
+ // emulate a second iteration of conversion
+ aclManager.reset();
+
+ aclManager.addSystemUser(new
SystemUser("acs-commons-package-replication-status-event-service", new
RepoPath("/home/users/system/foo"), new RepoPath("/home/users/system")));
+
aclManager.addAcl("acs-commons-package-replication-status-event-service",
newAcl(true, "jcr:read,rep:write,rep:indexDefinitionManagement",
"/asd/not/system/user/path"));
+
+ VaultPackageAssembler assembler = mock(VaultPackageAssembler.class);
+ when(assembler.getEntry(anyString())).thenReturn(new
File(System.getProperty("java.io.tmpdir")));
+ Feature feature = new Feature(new ArtifactId("org.apache.sling",
"org.apache.sling.cp2fm", "0.0.1", null, null));
+
+ FeaturesManager fm = Mockito.spy(new
DefaultFeaturesManager(tempDir.toFile()));
+ when(fm.getTargetFeature()).thenReturn(feature);
+
+ aclManager.addRepoinitExtension(Arrays.asList(assembler), fm);
+
+
+ Extension repoinitExtension =
feature.getExtensions().getByName(Extension.EXTENSION_NAME_REPOINIT);
+ assertNotNull(repoinitExtension);
+
+ // acs-commons-on-deploy-scripts-service will be missed
Review comment:
shouldn't that comment say 'acs-commons-ensure-oak-index-service' will
be missed? because that user was added before the reset
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]