@Test public void testSuppressAfterExtractViolationIfExpectationSatisfiedAfterScanPackage() throws Exception { final PackageId fooId = PackageId.fromString("some"); final PackageId barEmbedId = PackageId.fromString("other"); final EmbeddedPackageInstallable installable = new EmbeddedPackageInstallable(fooId, "", barEmbedId); ExpectAces.Check check = checkFor(obj() .key(ExpectAces.keys().principal(), "nouser") .key("ignoreNestedPackages", true) .key(ExpectAces.keys().expectedAces(), arr() .val("type=allow;path=/foo1;privileges=jcr:read") .val("type=allow;path=/foo1;privileges=rep:write") ) .key(ExpectAces.keys().notExpectedAces(), arr() .val("type=allow;path=/foo2;privileges=jcr:read") .val("type=allow;path=/foo2;privileges=rep:write") .val("type=allow;path=/foo3;privileges=rep:write") ) .get()); final Principal principal = new PrincipalImpl("nouser"); new OakMachine.Builder().build().adminInitAndInspect(session -> { final JackrabbitAccessControlManager accessControlManager = (JackrabbitAccessControlManager) session.getAccessControlManager(); final PrivilegeManager privilegeManager = ((JackrabbitWorkspace) session.getWorkspace()).getPrivilegeManager(); final Privilege jcrRead = privilegeManager.getPrivilege("jcr:read"); final Node foo1 = session.getRootNode().addNode("foo1", resolver.getJCRName(NameConstants.NT_FOLDER)); foo1.addMixin("rep:AccessControllable"); final Node foo2 = session.getRootNode().addNode("foo2", resolver.getJCRName(NameConstants.NT_FOLDER)); foo2.addMixin("rep:AccessControllable"); session.save(); for (String path : new String[]{"/foo1", "/foo2"}) { for (AccessControlPolicyIterator policyIt = accessControlManager.getApplicablePolicies(path); policyIt.hasNext(); ) { AccessControlPolicy policy = policyIt.nextAccessControlPolicy(); if (policy instanceof JackrabbitAccessControlList) { JackrabbitAccessControlList acl = (JackrabbitAccessControlList) policy; acl.addEntry(principal, new Privilege[]{jcrRead}, true); accessControlManager.setPolicy(path, acl); } } } check.startedScan(); check.identifyPackage(fooId, null); check.afterExtract(fooId, session); check.beforeSlingInstall(fooId, installable, session); check.identifyEmbeddedPackage(barEmbedId, fooId, installable); check.afterExtract(barEmbedId, session); check.afterScanPackage(fooId, session); check.finishedScan(); }); Assert.assertEquals("expected violation count", 1, check.getReportedViolations().stream().filter(viol -> viol.getDescription().startsWith("expected: ")).count()); Assert.assertEquals("expected violated spec ends with rep:write", 1, check.getReportedViolations().stream() .filter(viol -> viol.getDescription().startsWith("expected: ") && viol.getDescription().endsWith("rep:write")).count()); Assert.assertEquals("unexpected violation count", 1, check.getReportedViolations().stream().filter(viol -> viol.getDescription().startsWith("unexpected: ")).count()); Assert.assertEquals("unexpected violated spec ends with jcr:read", 1, check.getReportedViolations().stream() .filter(viol -> viol.getDescription().startsWith("unexpected: ") && viol.getDescription().endsWith("jcr:read")).count()); new OakMachine.Builder().build().adminInitAndInspect(session -> { final JackrabbitAccessControlManager accessControlManager = (JackrabbitAccessControlManager) session.getAccessControlManager(); final PrivilegeManager privilegeManager = ((JackrabbitWorkspace) session.getWorkspace()).getPrivilegeManager(); final Privilege jcrRead = privilegeManager.getPrivilege("jcr:read"); final Node foo1 = session.getRootNode().addNode("foo1", resolver.getJCRName(NameConstants.NT_FOLDER)); foo1.addMixin("rep:AccessControllable"); final Node foo2 = session.getRootNode().addNode("foo2", resolver.getJCRName(NameConstants.NT_FOLDER)); foo2.addMixin("rep:AccessControllable"); session.save(); for (String path : new String[]{"/foo1", "/foo2"}) { for (AccessControlPolicyIterator policyIt = accessControlManager.getApplicablePolicies(path); policyIt.hasNext(); ) { AccessControlPolicy policy = policyIt.nextAccessControlPolicy(); if (policy instanceof JackrabbitAccessControlList) { JackrabbitAccessControlList acl = (JackrabbitAccessControlList) policy; acl.addEntry(principal, new Privilege[]{jcrRead}, true); accessControlManager.setPolicy(path, acl); } } } check.startedScan(); check.identifyPackage(fooId, null); check.afterExtract(fooId, session); check.beforeSlingInstall(fooId, installable, session); check.identifyEmbeddedPackage(barEmbedId, fooId, installable); foo2.remove(); check.afterExtract(barEmbedId, session); check.afterScanPackage(fooId, session); check.finishedScan(); }); Assert.assertEquals("expected violation count", 1, check.getReportedViolations().stream().filter(viol -> viol.getDescription().startsWith("expected: ")).count()); Assert.assertEquals("expected violated spec ends with rep:write", 1, check.getReportedViolations().stream() .filter(viol -> viol.getDescription().startsWith("expected: ") && viol.getDescription().endsWith("rep:write")).count()); Assert.assertEquals("no unexpected violations", 0, check.getReportedViolations().stream() .filter(viol -> viol.getDescription().startsWith("unexpected: ")).count()); }
@NotNull public static JsonKeys keys() { return KEYS; }
ExpectAces implements ProgressCheckFactory { @NotNull public static JsonKeys keys() { return KEYS; } }
ExpectAces implements ProgressCheckFactory { @NotNull public static JsonKeys keys() { return KEYS; }  }
ExpectAces implements ProgressCheckFactory { @NotNull public static JsonKeys keys() { return KEYS; }  @NotNull static JsonKeys keys(); @Override ProgressCheck newInstance(final JsonObject config); }
ExpectAces implements ProgressCheckFactory { @NotNull public static JsonKeys keys() { return KEYS; }  @NotNull static JsonKeys keys(); @Override ProgressCheck newInstance(final JsonObject config); @Deprecated
    static final String CONFIG_PRINCIPAL; @Deprecated
    static final String CONFIG_PRINCIPALS; @Deprecated
    static final String CONFIG_EXPECTED_ACES; @Deprecated
    static final String CONFIG_NOT_EXPECTED_ACES; @Deprecated
    static final String CONFIG_AFTER_PACKAGE_ID_RULES; @Deprecated
    static final String ACE_PARAM_TYPE; @Deprecated
    static final String ACE_PARAM_PRIVILEGES; @Deprecated
    static final String ACE_PARAM_PATH; static final String DELIM_PARAM; static final String DELIM_VALUE; static final String DELIM_LIST; }