Expand tests to cover escaping of substituted roleBaes values · apache/tomcat@eeb7351 · GitHub
Skip to content

Commit

Permalink
Expand tests to cover escaping of substituted roleBaes values
Browse files Browse the repository at this point in the history
While the UnboundedID LDAP SDK doesn't appear to have a preference some
servers (Windows AD, OpenLDAP) do appear to.
  • Loading branch information
markt-asf committed Apr 13, 2021
1 parent 81f16b0 commit eeb7351
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion java/org/apache/catalina/realm/JNDIRealm.java
Original file line number Diff line number Diff line change
Expand Up @@ -1904,7 +1904,9 @@ protected List<String> getRoles(JNDIConnection connection, User user) throws Nam
Name name = np.parse(dn);
String nameParts[] = new String[name.size()];
for (int i = 0; i < name.size(); i++) {
nameParts[i] = name.get(i);
// May have been returned with \<char> escaping rather than
// \<hex><hex>. Make sure it is \<hex><hex>.
nameParts[i] = convertToHexEscape(name.get(i));
}
base = connection.roleBaseFormat.format(nameParts);
} else {
Expand Down
10 changes: 5 additions & 5 deletions test/org/apache/catalina/realm/TestJNDIRealmIntegration.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static Collection<Object[]> parameters() {
addUsers(USER_PATTERN, null, null, roleSearch, ROLE_BASE, parameterSets);
addUsers(null, USER_SEARCH, USER_BASE, roleSearch, ROLE_BASE, parameterSets);
}
parameterSets.add(new Object[] { "cn={0},ou=sub,ou=people,dc=example,dc=com", null, null, ROLE_SEARCH_A,
parameterSets.add(new Object[] { "cn={0},ou=s\\;ub,ou=people,dc=example,dc=com", null, null, ROLE_SEARCH_A,
"{3},ou=people,dc=example,dc=com", "testsub", "test", new String[] {"TestGroup4"} });
return parameterSets;
}
Expand Down Expand Up @@ -227,14 +227,14 @@ public static void createLDAP() throws Exception {
Assert.assertEquals(ResultCode.SUCCESS, result.getResultCode());

AddRequest addPeopleSub = new AddRequest(
"dn: ou=sub,ou=people,dc=example,dc=com",
"dn: ou=s\\;ub,ou=people,dc=example,dc=com",
"objectClass: top",
"objectClass: organizationalUnit");
result = conn.processOperation(addPeopleSub);
Assert.assertEquals(ResultCode.SUCCESS, result.getResultCode());

AddRequest addUserTestSub = new AddRequest(
"dn: cn=testsub,ou=sub,ou=people,dc=example,dc=com",
"dn: cn=testsub,ou=s\\;ub,ou=people,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
Expand All @@ -245,11 +245,11 @@ public static void createLDAP() throws Exception {
Assert.assertEquals(ResultCode.SUCCESS, result.getResultCode());

AddRequest addGroupTest4 = new AddRequest(
"dn: cn=TestGroup4,ou=sub,ou=people,dc=example,dc=com",
"dn: cn=TestGroup4,ou=s\\;ub,ou=people,dc=example,dc=com",
"objectClass: top",
"objectClass: groupOfNames",
"cn: TestGroup4",
"member: cn=testsub,ou=sub,ou=people,dc=example,dc=com");
"member: cn=testsub,ou=s\\;ub,ou=people,dc=example,dc=com");
result = conn.processOperation(addGroupTest4);
Assert.assertEquals(ResultCode.SUCCESS, result.getResultCode());
}
Expand Down

0 comments on commit eeb7351

Please sign in to comment.