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

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


The following commit(s) were added to refs/heads/11.0.x by this push:
     new 8339eb7660 Fix JASPIC tests after updates to address TCK failures.
8339eb7660 is described below

commit 8339eb7660a4ff6afea687783541d97c819a41ac
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 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: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to