Skip to content

Commit

Permalink
OAK-6118: XPathConditionVisitor wrongly escapes string values for Imp…
Browse files Browse the repository at this point in the history
…ersonationCondition

Removed the escaping, added test case.


git-svn-id: https://svn.apache.org/repos/asf/jackrabbit/oak/trunk@1792229 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Manfred Baedke committed Apr 21, 2017
1 parent 830e885 commit c187e73
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void visit(Condition.Impersonation condition) {
statement.append('@')
.append(QueryUtil.escapeForQuery(UserConstants.REP_IMPERSONATORS, namePathMapper))
.append("='")
.append(QueryUtil.escapeForQuery(condition.getName()))
.append(condition.getName())
.append('\'');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public void setUp() throws Exception {
addMembers(insects, ant, bee, fly);

User jackrabbit = createUser("jackrabbit", "carrots", 2500, true);
User backslash = createUser("foo\\bar", "characters", 2500, false);
User deer = createUser("deer", "leaves", 120000, true);
User opossum = createUser("opossum", "fruit", 1200, true);
kangaroo = createUser("kangaroo", "grass", 90000, true);
Expand Down Expand Up @@ -160,6 +161,7 @@ public void setUp() throws Exception {
setProperty("continent", vf.createValue("America"), opossum);

elephant.getImpersonation().grantImpersonation(jackrabbit.getPrincipal());
elephant.getImpersonation().grantImpersonation(backslash.getPrincipal());

authorizables.addAll(users);
authorizables.addAll(groups);
Expand Down Expand Up @@ -669,6 +671,20 @@ public <T> void build(QueryBuilder<T> builder) {
assertSameElements(expected, result);
}

@Test
public void testImpersonationWithBackslash() throws RepositoryException {
Iterator<Authorizable> result = userMgr.findAuthorizables(new Query() {
public <T> void build(QueryBuilder<T> builder) {
builder.setCondition(builder.
impersonates("foo\\bar"));
}
});

Iterator<User> expected = Iterators.singletonIterator(elephant);
assertTrue(result.hasNext());
assertSameElements(expected, result);
}

@Test
public void testAdminImpersonation() throws Exception {
final String adminPrincipalName = userMgr.getAuthorizable(superuser.getUserID()).getPrincipal().getName();
Expand Down

0 comments on commit c187e73

Please sign in to comment.