gnodet-bot commented on code in PR #28689:
URL: https://github.com/apache/camel/pull/28689#discussion_r4412437921


##########
components/camel-oauth/src/test/java/org/apache/camel/oauth/UserProfileTest.java:
##########
@@ -123,12 +176,22 @@ private String signedToken() throws Exception {
     }
 
     private String signedToken(Date notBefore) throws Exception {
+        return signedTokenWithAudience("my-client", notBefore);
+    }
+
+    private String signedTokenWithAudience(String audience) throws Exception {
+        return signedTokenWithAudience(audience, null);
+    }
+
+    private String signedTokenWithAudience(String audience, Date notBefore) 
throws Exception {

Review Comment:
   The test helper always produces a **single-string** `aud` claim via 
`claims.audience(String)`. The production code in `UserProfile.verifyToken` 
also handles a JSON-array `aud` claim (the `JsonArray` branch at line ~211 of 
`UserProfile.java`). That branch is **not exercised** by any new test.
   
   Consider adding one test that passes a multi-value audience (e.g. 
`["my-client", "other-resource"]`) so both parsing paths are covered:
   
   ```java
   @Test
   void accessTokenAcceptedWhenAudienceIsArray() throws Exception {
       // JWT signed with a multi-value aud: ["my-client", "other-resource"]
       JWTClaimsSet claims = new JWTClaimsSet.Builder()
               .subject("user1")
               .issuer("https://idp.example.com";)
               .audience(List.of("my-client", "other-resource"))   // List 
overload → JSON array
               .expirationTime(new Date(System.currentTimeMillis() + 300_000L))
               .issueTime(new Date())
               .build();
       SignedJWT jwt = new SignedJWT(new 
JWSHeader.Builder(JWSAlgorithm.RS256).keyID(rsaKey.getKeyID()).build(), claims);
       jwt.sign(new RSASSASigner(rsaKey));
       String token = jwt.serialize();
   
       JsonObject json = new JsonObject();
       json.addProperty("access_token", token);
       assertNotNull(UserProfile.fromJson(verifyingConfig(), json));
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to