Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EnsureServiceUser config format should strip leading/trailing whitespace for array elements in aces property, for better diff visibility in config files. #1552

Closed
3 tasks done
adamcin opened this issue Nov 9, 2018 · 2 comments

Comments

@adamcin
Copy link
Contributor

adamcin commented Nov 9, 2018

Required Information

  • AEM Version, including Service Packs, Cumulative Fix Packs, etc: any
  • ACS AEM Commons Version: <=3.19
  • Reproducible on Latest? yes

Expected Behavior

Given an EnsureServiceUser sling:OsgiConfig file with multiple values for aces separated by newlines, the whitespace surrounding each element should not be treated as part of the first key or the last value:

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    jcr:primaryType="sling:OsgiConfig"
    operation="add"
    aces="[
         type\=allow;privileges\=jcr:versionManagement\,jcr:read\,crx:replicate\,rep:write\,jcr:lockManagement\,jcr:modifyProperties;path\=/content/dam,
         type\=allow;privileges\=jcr:versionManagement\,jcr:read\,crx:replicate\,rep:write\,jcr:lockManagement\,jcr:modifyProperties;path\=/content,
         type\=allow;privileges\=jcr:versionManagement\,jcr:read\,crx:replicate\,rep:write\,jcr:lockManagement\,jcr:modifyProperties;path\=/content/projects,
         type\=allow;privileges\=jcr:all;path\=/var/workflow,
         type\=allow;privileges\=jcr:all;path\=/etc/workflow
    ]"
    principalName="acme-workflow-service"
    ensure-immediately="{Boolean}true"
/>

Actual Behavior

Given the above file, the current behavior results in an EnsureAuthorizableException thrown because the whitespace before the "type" key is retained, and therefore fails to match the PROP_TYPE constant in the comparison logic.

The bug manifests here:

if (StringUtils.equals(PROP_TYPE, entry.getKey())) {

The symptomatic exception is thrown here:

throw new EnsureAuthorizableException("Ensure Service User requires valid type. [ " + type + " ] type is invalid");

The inconvenient workaround is to eliminate the white space altogether, which forces code reviewers to scroll to the right a ways in order to spot any changes in a pull request.

Steps to Reproduce

Create a new sling:OsgiConfig node at /apps/system/config/com.adobe.acs.commons.users.impl.EnsureServiceUser-acme-workflow-service.xml with the above content, and capture the log output during config installation.

@joerghoh
Copy link
Contributor

joerghoh commented Nov 9, 2018

So trimming the values would be sufficient?

@adamcin
Copy link
Contributor Author

adamcin commented Nov 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants