You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2021/04/13 14:23:32 UTC

[tomcat] 09/10: Expand tests to cover escaping of substituted roleBaes values

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit eeb7351219bd8803c0053e1e80444664a7cf5b51
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Apr 13 15:19:31 2021 +0100

    Expand tests to cover escaping of substituted roleBaes values
    
    While the UnboundedID LDAP SDK doesn't appear to have a preference some
    servers (Windows AD, OpenLDAP) do appear to.
---
 java/org/apache/catalina/realm/JNDIRealm.java                |  4 +++-
 test/org/apache/catalina/realm/TestJNDIRealmIntegration.java | 10 +++++-----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/catalina/realm/JNDIRealm.java b/java/org/apache/catalina/realm/JNDIRealm.java
index 43e9ca8..04768e8 100644
--- a/java/org/apache/catalina/realm/JNDIRealm.java
+++ b/java/org/apache/catalina/realm/JNDIRealm.java
@@ -1904,7 +1904,9 @@ public class JNDIRealm extends RealmBase {
             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 {
diff --git a/test/org/apache/catalina/realm/TestJNDIRealmIntegration.java b/test/org/apache/catalina/realm/TestJNDIRealmIntegration.java
index d019fc0..cd69267 100644
--- a/test/org/apache/catalina/realm/TestJNDIRealmIntegration.java
+++ b/test/org/apache/catalina/realm/TestJNDIRealmIntegration.java
@@ -60,7 +60,7 @@ public class TestJNDIRealmIntegration {
             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;
     }
@@ -227,14 +227,14 @@ public class TestJNDIRealmIntegration {
             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",
@@ -245,11 +245,11 @@ public class TestJNDIRealmIntegration {
             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());
         }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org