Skip to content

Add support for iae_post and iae_post.jwt response mode#183

Open
swati-technocratblues wants to merge 1 commit into
inji:developfrom
technocratblues:develop
Open

Add support for iae_post and iae_post.jwt response mode#183
swati-technocratblues wants to merge 1 commit into
inji:developfrom
technocratblues:develop

Conversation

@swati-technocratblues

@swati-technocratblues swati-technocratblues commented Jun 30, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

  • New Features

    • Added support for additional response modes: iae_post and iae_post.jwt.
    • Expanded response mode handling so redirect-based flows accept the new IAE options alongside existing modes.
  • Bug Fixes

    • Improved validation for presentation definitions using mso_mdoc, allowing the newly supported IAE JWT response mode.
    • Updated response mode routing so the correct handler is selected for the new modes.
  • Tests

    • Extended test coverage for the new response modes and validation scenarios.

* Add OpenID4VP response mode handling changes

* Address PR review comments

* Address PR review comments
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Adds two new response modes, IAE_POST ("iae_post") and IAE_POST_JWT ("iae_post.jwt"), to the ResponseMode enum, routes them through ResponseModeBasedHandlerFactory, accepts them in RedirectUriPrefixAuthorizationRequestHandler, and extends mso_mdoc format validation to permit iae_post_jwt. Tests are expanded accordingly.

Changes

IAE_POST/IAE_POST_JWT Response Mode Support

Layer / File(s) Summary
ResponseMode enum and handler factory routing
kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/constants/ResponseMode.kt, kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/responseModeHandler/ResponseModeBasedHandlerFactory.kt
Adds IAE_POST and IAE_POST_JWT enum members, then maps them to DirectPostResponseModeHandler and DirectPostJwtResponseModeHandler in the factory's when block.
RedirectUriPrefix handler and PresentationDefinition validation
kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationRequest/authorizationRequestHandler/types/RedirectUriPrefixAuthorizationRequestHandler.kt, kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationRequest/presentationDefinition/PresentationDefinitionUtil.kt
Imports and adds IAE_POST/IAE_POST_JWT to the supported when cases in validateAndParseRequestFields (logging info instead of error); extends mso_mdoc format check to also allow iae_post_jwt.
Tests
kotlin/openID4VP/src/commonTest/kotlin/io/mosip/openID4VP/authorizationRequest/authorizationRequestHandler/types/RedirectUriPrefixAuthorizationRequestHandlerTest.kt, kotlin/openID4VP/src/commonTest/kotlin/io/mosip/openID4VP/responseModeHandler/ResponseModeBasedHandlerFactoryTest.kt
Renames handler test class, expands JWT iteration sets to include iae_post.jwt, replaces IAR-only tests with parameterized IAR+IAE tests, and adds a factory test for IAE_POST_JWT.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Poem

🐇 Hop, hop, through the modes we go,
iae_post joins the flow!
The factory routes with grace and care,
JWT or plain — both handled there.
New tests confirm each path is right,
This bunny's code works day and night! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding support for iae_post and iae_post.jwt response modes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
kotlin/openID4VP/src/commonTest/kotlin/io/mosip/openID4VP/responseModeHandler/ResponseModeBasedHandlerFactoryTest.kt (1)

44-50: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add the matching IAE_POST factory assertion too.

This PR adds both IAE_POST and IAE_POST_JWT branches in ResponseModeBasedHandlerFactory, but this file only adds coverage for the JWT path. The new non-JWT mapping can still regress unnoticed.

Proposed test addition
+    `@Test`
+    fun `get should return DirectPostResponseModeHandler for iae_post mode`() {
+        val handler = ResponseModeBasedHandlerFactory.get(ResponseMode.IAE_POST.value)
+
+        assertTrue(handler is DirectPostResponseModeHandler)
+        assertNotNull(handler)
+    }
+
     `@Test`
     fun `get should return DirectPostJwtResponseModeHandler for iae_post_jwt mode`() {
         val handler = ResponseModeBasedHandlerFactory.get(ResponseMode.IAE_POST_JWT.value)
🤖 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
`@kotlin/openID4VP/src/commonTest/kotlin/io/mosip/openID4VP/responseModeHandler/ResponseModeBasedHandlerFactoryTest.kt`
around lines 44 - 50, Add test coverage for the new non-JWT response mode
mapping in ResponseModeBasedHandlerFactory by extending
ResponseModeBasedHandlerFactoryTest with an assertion that get returns the
correct handler for ResponseMode.IAE_POST.value, alongside the existing
IAE_POST_JWT test. Use the existing get method and the handler type expected for
the IAE_POST branch so both factory paths are validated and future regressions
are caught.
🤖 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
`@kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationRequest/presentationDefinition/PresentationDefinitionUtil.kt`:
- Around line 155-157: The validation in PresentationDefinitionUtil should use
the actual response mode literal supported by ResponseMode.IAE_POST_JWT.value,
since the current exception text mentions an unsupported `iae_post_jwt` value.
Update the message in the mso_mdoc guard to reference the exact supported
literal used by the enum, alongside the existing `direct_post.jwt` and
`iar-post.jwt` values, so callers see a consistent contract.

---

Nitpick comments:
In
`@kotlin/openID4VP/src/commonTest/kotlin/io/mosip/openID4VP/responseModeHandler/ResponseModeBasedHandlerFactoryTest.kt`:
- Around line 44-50: Add test coverage for the new non-JWT response mode mapping
in ResponseModeBasedHandlerFactory by extending
ResponseModeBasedHandlerFactoryTest with an assertion that get returns the
correct handler for ResponseMode.IAE_POST.value, alongside the existing
IAE_POST_JWT test. Use the existing get method and the handler type expected for
the IAE_POST branch so both factory paths are validated and future regressions
are caught.
🪄 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: 47c52ea5-4e51-4c74-912d-94b4a44461c3

📥 Commits

Reviewing files that changed from the base of the PR and between 0efa798 and 0161e4d.

📒 Files selected for processing (6)
  • kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationRequest/authorizationRequestHandler/types/RedirectUriPrefixAuthorizationRequestHandler.kt
  • kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationRequest/presentationDefinition/PresentationDefinitionUtil.kt
  • kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/constants/ResponseMode.kt
  • kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/responseModeHandler/ResponseModeBasedHandlerFactory.kt
  • kotlin/openID4VP/src/commonTest/kotlin/io/mosip/openID4VP/authorizationRequest/authorizationRequestHandler/types/RedirectUriPrefixAuthorizationRequestHandlerTest.kt
  • kotlin/openID4VP/src/commonTest/kotlin/io/mosip/openID4VP/responseModeHandler/ResponseModeBasedHandlerFactoryTest.kt

Comment on lines +155 to +157
if (hasMsoMdocFormat && (responseMode != ResponseMode.DIRECT_POST_JWT.value && responseMode != ResponseMode.IAR_POST_JWT.value &&
responseMode != ResponseMode.IAE_POST_JWT.value)) {
throw OpenID4VPExceptions.InvalidData("When mso_mdoc format is present in presentation definition, response_mode must be direct_post.jwt or iar-post.jwt or iae_post_jwt", className)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use the actual iae_post.jwt literal in the exception text.

The new guard accepts ResponseMode.IAE_POST_JWT.value, but the message says iae_post_jwt. That points callers to a value the library does not support.

Proposed fix
-        throw OpenID4VPExceptions.InvalidData("When mso_mdoc format is present in presentation definition, response_mode must be direct_post.jwt or iar-post.jwt or iae_post_jwt", className)
+        throw OpenID4VPExceptions.InvalidData(
+            "When mso_mdoc format is present in presentation definition, response_mode must be direct_post.jwt or iar-post.jwt or iae_post.jwt",
+            className
+        )
📝 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.

Suggested change
if (hasMsoMdocFormat && (responseMode != ResponseMode.DIRECT_POST_JWT.value && responseMode != ResponseMode.IAR_POST_JWT.value &&
responseMode != ResponseMode.IAE_POST_JWT.value)) {
throw OpenID4VPExceptions.InvalidData("When mso_mdoc format is present in presentation definition, response_mode must be direct_post.jwt or iar-post.jwt or iae_post_jwt", className)
if (hasMsoMdocFormat && (responseMode != ResponseMode.DIRECT_POST_JWT.value && responseMode != ResponseMode.IAR_POST_JWT.value &&
responseMode != ResponseMode.IAE_POST_JWT.value)) {
throw OpenID4VPExceptions.InvalidData(
"When mso_mdoc format is present in presentation definition, response_mode must be direct_post.jwt or iar-post.jwt or iae_post.jwt",
className
)
🤖 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
`@kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationRequest/presentationDefinition/PresentationDefinitionUtil.kt`
around lines 155 - 157, The validation in PresentationDefinitionUtil should use
the actual response mode literal supported by ResponseMode.IAE_POST_JWT.value,
since the current exception text mentions an unsupported `iae_post_jwt` value.
Update the message in the mso_mdoc guard to reference the exact supported
literal used by the enum, alongside the existing `direct_post.jwt` and
`iar-post.jwt` values, so callers see a consistent contract.

assertNotNull(handler)
}

@Test

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test case for iae_post return DirectPostResponseModeHandler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants