Skip to content

Conversation

@amaydixit11
Copy link
Contributor

@amaydixit11 amaydixit11 commented Jan 21, 2026

This PR adds comprehensive automated API test coverage for the Pre-Authorized Code flow in Inji Certify, covering both positive and negative scenarios end-to-end.

Changes

  • Generate Pre-Authorized Code

    • With valid claims
    • With default expiry
    • With transaction (tx_code)
  • Get Credential Offer

    • Valid offer ID
    • Offer with tx_code
  • Token Exchange

    • Valid pre-authorized code
    • Alphanumeric tx_code
  • Get Credential (Pre-Auth)

    • Successful credential issuance using access token
  • Negative test coverage

    • Invalid credential configuration ID
    • Missing mandatory claims
    • Invalid / non-existent offer IDs
    • Expiry out of allowed range
    • Unsupported grant type
    • Invalid / missing / incorrect tx_code

Summary by CodeRabbit

  • Tests
    • Added comprehensive test coverage for pre-authorization code flow operations, including credential generation, credential offer retrieval, token exchange, and credential issuance.
    • Added negative test scenarios to validate error handling and boundary conditions.
    • Configured test dependencies to ensure proper test execution order.

✏️ Tip: You can customize this high-level summary in your review settings.

jainhitesh9998 and others added 30 commits June 26, 2025 14:47
Signed-off-by: Hitesh C <[email protected]>
… for credential configuration

Signed-off-by: amaydixit11 <[email protected]>
…deService for pre-authorized code flow

Signed-off-by: amaydixit11 <[email protected]>
…h JSON property annotations

Signed-off-by: amaydixit11 <[email protected]>
# Conflicts:
#	certify-service/src/main/java/io/mosip/certify/services/PreAuthorizedCodeService.java
…r and pre-authorized data caching

Signed-off-by: amaydixit11 <[email protected]>
…e names and ignore URLs for credential offer and pre-authorized data

Signed-off-by: amaydixit11 <[email protected]>
…e logic and improved claim validation

Signed-off-by: amaydixit11 <[email protected]>
…ess token utility and clean up code

Signed-off-by: amaydixit11 <[email protected]>
…entialConfigurationServiceImplTest

Signed-off-by: amaydixit11 <[email protected]>
…tions in WellKnownControllerTest

Signed-off-by: amaydixit11 <[email protected]>
@coderabbitai
Copy link

coderabbitai bot commented Jan 21, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (2)
  • develop
  • release-*

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This PR adds test configuration files and templates for the Pre-Authorized Code Flow feature testing, including YAML test definitions, Handlebars templates for request/response payloads, test case interdependency mappings, and TestNG suite configuration to enable automated testing across six distinct test flows with both positive and negative scenarios.

Changes

Cohort / File(s) Summary
Test Interdependency Configuration
config/testCaseInterDependency_preauth.json
Defines test execution dependencies for pre-auth test cases (e.g., TokenExchange depends on GenerateCode) to establish ordering constraints.
GeneratePreAuthCode Tests
PreAuthCodeFlow/GeneratePreAuthCode/GeneratePreAuthCode.yml, GeneratePreAuthCode.hbs, GeneratePreAuthCodeResult.hbs
Test configuration for pre-authorized code generation with three smoke-test scenarios; templates define request payload (credential_configuration_id, claims, expires_in, tx_code) and response (credential_offer_uri).
GetCredentialOffer Tests
PreAuthCodeFlow/GetCredentialOffer/GetCredentialOffer.yml, GetCredentialOffer.hbs, GetCredentialOfferResult.hbs
Test configuration for credential offer retrieval with two scenarios (valid + tx_code variant); templates define response structure (credential_issuer, credential_configuration_ids, grants).
GetCredentialPreAuth Tests
PreAuthCodeFlow/GetCredentialPreAuth/GetCredentialPreAuth.yml, GetCredentialPreAuth.hbs, GetCredentialPreAuthResult.hbs
Test configuration for credential issuance in pre-auth flow; templates define request payload (format, credential_identifier, proof) and response (format, credential).
TokenExchange Tests
PreAuthCodeFlow/TokenExchange/TokenExchange.yml, TokenExchange.hbs, TokenExchangeNegative.yml, TokenExchangeResult.hbs
Test configuration for token exchange (positive + four negative scenarios) and response templates; positive tests expect Bearer token; negative tests cover unsupported grant type, invalid code, missing/wrong tx_code.
PreAuthNegative Tests
PreAuthCodeFlow/PreAuthNegative/PreAuthNegative.hbs, PreAuthNegativeResult.hbs
Templates for negative test scenarios (invalid credential_configuration_id, missing claims, invalid/non-existent offer IDs, expiry range violations); response template maps error field.
TestNG Suite Configuration
testNgXmlFiles/injicertifySuite.xml
Registers six pre-auth test groups (GeneratePreAuthCode, GetCredentialOffer, TokenExchange variants, GetCredential, negative cases) with corresponding YAML files and prerequisite dependencies in TestNG test suite.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Suggested reviewers

  • mohanachandran-s
  • swatigoel

Poem

🐰 Hop, hop! The test suite takes flight,
Pre-auth flows verified—templates done right!
Dependencies mapped, scenarios clear,
Code generation, tokens, and offers all here! 🎫

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately and specifically describes the main change: adding automated API tests for the Pre-Authorized Code flow, which aligns with the comprehensive test additions across multiple test configuration files and templates in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@amaydixit11
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jan 21, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@api-test/src/main/resources/injicertify/PreAuthCodeFlow/GetCredentialPreAuth/GetCredentialPreAuthResult.hbs`:
- Around line 1-4: The template GetCredentialPreAuthResult.hbs incorrectly
quotes the credential value which breaks when format === "ldp_vc" because the
API returns a JSON object; update the template to render the credential unquoted
for ldp_vc (use triple-stash {{{credential}}}) and keep the quoted form for
other formats (e.g., use an if/else on the format variable to choose between
"{{credential}}" and {{{credential}}}); modify the block that outputs
"credential" to conditionally use {{{credential}}} when format equals "ldp_vc".
🧹 Nitpick comments (3)
api-test/src/main/resources/injicertify/PreAuthCodeFlow/TokenExchange/TokenExchange.yml (1)

16-20: Tighten token-exchange assertions to avoid false positives.

The expected outputs only validate token_type (and partially access_token / c_nonce). If the response drops expires_in or c_nonce_expires_in, these tests would still pass. Consider asserting the full response shape to prevent regressions.

Proposed update to expected outputs
       output: '{
           "token_type": "Bearer",
           "access_token": "",
-          "c_nonce": ""
+          "expires_in": 0,
+          "c_nonce": "",
+          "c_nonce_expires_in": 0
       }'
@@
       output: '{
-          "token_type": "Bearer"
+          "token_type": "Bearer",
+          "access_token": "",
+          "expires_in": 0,
+          "c_nonce": "",
+          "c_nonce_expires_in": 0
       }'

Also applies to: 36-38

api-test/src/main/resources/injicertify/PreAuthCodeFlow/PreAuthNegative/PreAuthNegative.yml (1)

72-113: Consider parameterizing expiry bounds to reduce brittleness.

The negative expiry tests use hard-coded values (10, 999999). If server min/max changes, these tests may start failing for the wrong reason. If the framework supports config-driven placeholders, consider referencing those bounds instead of fixed numbers.

api-test/src/main/resources/injicertify/PreAuthCodeFlow/GetCredentialOffer/GetCredentialOffer.yml (1)

18-31: Add credential_configuration_ids assertion for the tx_code case.

The tx_code scenario currently skips validating credential_configuration_ids, so regressions in that field would go unnoticed. Consider asserting it just like the first case.

Proposed output shape alignment
       output: '{
           "credential_issuer": "",
+          "credential_configuration_ids": [],
           "grants": {}
       }'

amaydixit11 and others added 5 commits January 21, 2026 23:08
…dentialPreAuth/GetCredentialPreAuthResult.hbs

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Amay Dixit <[email protected]>
…dentialPreAuth/GetCredentialPreAuthResult.hbs

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Amay Dixit <[email protected]>
…on and token exchange scenarios

Signed-off-by: amaydixit11 <[email protected]>
@sonarqubecloud
Copy link

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.

2 participants