Add integration test to ensure isk claim is present in the ID token#27779
Add integration test to ensure isk claim is present in the ID token#27779HasiniSama wants to merge 1 commit into
Conversation
📝 WalkthroughSummaryThis PR adds integration test coverage to verify that the ChangesThe
Lines changed: +18/-1 Related workThis change complements related updates in the identity-inbound-auth-oauth extension (PR WalkthroughThis pull request enhances a device flow test case for native authentication by integrating JWT token validation into the test execution. The test now configures OIDC to issue JWT-formatted access tokens, requests an OPENID scope during device authorization, and validates that the resulting ID token contains the expected IDP session key claim. The changes add JWT parsing logic using Nimbus libraries and introduce static constants for claim verification. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/applicationNativeAuthentication/ApplicationNativeAuthenticationDeviceFlowTestCase.java`:
- Around line 243-244: The test currently calls toString() directly on
obj.get(OAuth2Constant.ID_TOKEN) which can throw before the Assert.assertNotNull
runs; in ApplicationNativeAuthenticationDeviceFlowTestCase locate the lines
assigning idToken (using obj.get(OAuth2Constant.ID_TOKEN)) and change the flow
to first retrieve the raw Object (e.g., tokenObj), call
Assert.assertNotNull(tokenObj, "ID token is null"), then convert it to String
(tokenObj.toString()) and assign idToken so the assertion fails clearly if the
token is missing.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e7013082-33a2-4640-ad34-71820f98e6da
📒 Files selected for processing (1)
modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/applicationNativeAuthentication/ApplicationNativeAuthenticationDeviceFlowTestCase.java
| String idToken = obj.get(OAuth2Constant.ID_TOKEN).toString(); | ||
| Assert.assertNotNull(idToken, "ID token is null"); |
There was a problem hiding this comment.
Avoid toString() before null assertion for id_token.
At Line 243, toString() can throw before the test reaches the assertion. Cast first, then assert non-null for a clearer failure.
Proposed fix
- String idToken = obj.get(OAuth2Constant.ID_TOKEN).toString();
- Assert.assertNotNull(idToken, "ID token is null");
+ String idToken = (String) obj.get(OAuth2Constant.ID_TOKEN);
+ Assert.assertNotNull(idToken, "ID token is null");📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| String idToken = obj.get(OAuth2Constant.ID_TOKEN).toString(); | |
| Assert.assertNotNull(idToken, "ID token is null"); | |
| String idToken = (String) obj.get(OAuth2Constant.ID_TOKEN); | |
| Assert.assertNotNull(idToken, "ID token is null"); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/applicationNativeAuthentication/ApplicationNativeAuthenticationDeviceFlowTestCase.java`
around lines 243 - 244, The test currently calls toString() directly on
obj.get(OAuth2Constant.ID_TOKEN) which can throw before the Assert.assertNotNull
runs; in ApplicationNativeAuthenticationDeviceFlowTestCase locate the lines
assigning idToken (using obj.get(OAuth2Constant.ID_TOKEN)) and change the flow
to first retrieve the raw Object (e.g., tokenObj), call
Assert.assertNotNull(tokenObj, "ID token is null"), then convert it to String
(tokenObj.toString()) and assign idToken so the assertion fails clearly if the
token is missing.



$subject
Related: wso2-extensions/identity-inbound-auth-oauth#3221
Issue: #27473