This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new ba7f750efa Fix JASPIC tests after updates to address TCK failures. ba7f750efa is described below commit ba7f750efae55338bd930ab372795585c803a085 Author: Mark Thomas <ma...@apache.org> 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 0c6c4e4605..03c420403f 100644 --- a/test/org/apache/catalina/authenticator/TestJaspicCallbackHandlerInAuthenticator.java +++ b/test/org/apache/catalina/authenticator/TestJaspicCallbackHandlerInAuthenticator.java @@ -66,6 +66,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); @@ -80,30 +86,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: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org