This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new 99d478b591 Fix JASPIC tests after updates to address TCK failures.
99d478b591 is described below
commit 99d478b591f5fd45c79baaf39322077061ea9e22
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Sep 19 07:23:51 2024 +0100
Fix JASPIC tests after updates to address TCK failures.
---
.../TestJaspicCallbackHandlerInAuthenticator.java | 28 ++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git
a/test/org/apache/catalina/authenticator/TestJaspicCallbackHandlerInAuthenticator.java
b/test/org/apache/catalina/authenticator/TestJaspicCallbackHandlerInAuthenticator.java
index 57aa8b3fae..1eee99b0a8 100644
---
a/test/org/apache/catalina/authenticator/TestJaspicCallbackHandlerInAuthenticator.java
+++
b/test/org/apache/catalina/authenticator/TestJaspicCallbackHandlerInAuthenticator.java
@@ -67,6 +67,12 @@ public class TestJaspicCallbackHandlerInAuthenticator {
}
+ /*
+ * This shouldn't happen in real usage. In the very unlikely event there
is more than one CallerPrincipalCallback,
+ * it should return the same Principal each time.
+ *
+ * If there are multiple CallerPrincipalCallbacks, Tomcat uses the name
from the most recent.
+ */
@Test
public void testCallerPrincipalCallback() throws Exception {
CallbackHandler callbackHandler = createCallbackHandler(null);
@@ -81,30 +87,44 @@ public class TestJaspicCallbackHandlerInAuthenticator {
});
callbackHandler.handle(new Callback[] { cpc2 });
Set<Object> credentials = clientSubject.getPrivateCredentials();
- Assert.assertTrue(credentials.size() == 2);
- Set<String> names = new HashSet<>(Arrays.asList(new String[] {
"name1", "name2" }));
+ Assert.assertTrue(credentials.size() == 1);
+ Set<String> names = new HashSet<>(Arrays.asList(new String[] { "name2"
}));
for (Object o : credentials) {
names.remove(((GenericPrincipal) o).getName());
}
Assert.assertTrue(names.isEmpty());
}
+
+ /*
+ * This shouldn't happen in real usage. In the very unlikely event there
is more than one GroupPrincipalCallback,
+ * the groups from each should be merged into the final Principal.
+ *
+ * If there are multiple CallerPrincipalCallbacks, Tomcat uses the name
from the most recent.
+ */
@Test
public void testGroupPrincipalCallback() throws Exception {
CallbackHandler callbackHandler = createCallbackHandler(null);
Subject clientSubject = new Subject();
CallerPrincipalCallback cpc = new
CallerPrincipalCallback(clientSubject, "name");
- GroupPrincipalCallback gpc = new GroupPrincipalCallback(clientSubject,
+ GroupPrincipalCallback gpc1 = new GroupPrincipalCallback(clientSubject,
new String[] { "group1", "group2" });
- callbackHandler.handle(new Callback[] { cpc, gpc });
+ callbackHandler.handle(new Callback[] { cpc, gpc1 });
+ GroupPrincipalCallback gpc2 = new GroupPrincipalCallback(clientSubject,
+ new String[] { "group3", "group4" });
+ callbackHandler.handle(new Callback[] { cpc, gpc2 });
Set<Object> credentials = clientSubject.getPrivateCredentials();
Assert.assertTrue(credentials.size() == 1);
GenericPrincipal gp = (GenericPrincipal) credentials.iterator().next();
Assert.assertEquals("name", gp.getName());
+ Assert.assertEquals(4, gp.getRoles().length);
Assert.assertTrue(gp.hasRole("group1"));
Assert.assertTrue(gp.hasRole("group2"));
+ Assert.assertTrue(gp.hasRole("group3"));
+ Assert.assertTrue(gp.hasRole("group4"));
}
+
@Test
public void testPasswordValidationCallback() throws Exception {
CallbackHandler callbackHandler = createCallbackHandler(null);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]