Skip to content

test: add unit tests for VCProcessor SD-JWT reconstruction#2408

Open
dhruv1955 wants to merge 2 commits into
inji:masterfrom
dhruv1955:test/vcprocessor-sd-jwt-reconstruction
Open

test: add unit tests for VCProcessor SD-JWT reconstruction#2408
dhruv1955 wants to merge 2 commits into
inji:masterfrom
dhruv1955:test/vcprocessor-sd-jwt-reconstruction

Conversation

@dhruv1955
Copy link
Copy Markdown

@dhruv1955 dhruv1955 commented Apr 25, 2026

What and Why

VCProcessor.ts is the core SD-JWT parsing layer but had zero test coverage. This PR adds 8 unit tests covering the full reconstruction and rendering pipeline.

Changes

  • components/VC/common/VCProcessor.test.ts - new test file
  • .talismanrc - added checksum ignore for JWT claim names (iss, iat) that were flagged as false positives

Tests Added

reconstructSdJwtFromCompact()

  • Simple top-level claim disclosure (given_name)
  • Nested claim disclosure (address.city)
  • Array claim disclosure (nationalities)
  • Undisclosed claim - resolved payload excludes it, no crash
  • Malformed input - throws gracefully

processForRendering()

  • vc+sd-jwt format - populates fullResolvedPayload correctly
  • dc+sd-jwt format - same behaviour as vc+sd-jwt
  • ldp_vc format - does not go through SD-JWT path

Summary by CodeRabbit

  • Tests
    • Added comprehensive unit tests for credential processing and claim resolution, validating disclosed and undisclosed claims across various disclosure scenarios and multiple credential formats.

ckm007 and others added 2 commits March 16, 2026 20:56
Signed-off-by: Chandra Keshav Mishra <chandrakeshavmishra@gmail.com>
Signed-off-by: dhruv1955 <dhruvyadav042905@gmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 25, 2026

Walkthrough

A new test file for VCProcessor is added with comprehensive unit tests covering reconstructSdJwtFromCompact and processForRendering methods across multiple VC formats (vc_sd_jwt, dc_sd_jwt, ldp_vc). The test file is registered in the Talisman ignore configuration.

Changes

Cohort / File(s) Summary
Configuration
.talismanrc
Added VCProcessor test file to Talisman's fileignoreconfig with checksum to exclude from change detection.
Test Suite
components/VC/common/VCProcessor.test.ts
New test file with 254 lines covering reconstructSdJwtFromCompact (claimed resolution at multiple depths, undisclosed digests, malformed inputs) and processForRendering validation across vc_sd_jwt, dc_sd_jwt, and ldp_vc formats including field population and mock verification.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly Related PRs

Suggested Reviewers

  • KiruthikaJeyashankar
  • swatigoel
  • abhip2565

Poem

🐰 A test file hops in today,

Validating claims in every way,

SD-JWTs and formats galore,

VCProcessor tested to the core! 🥕✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description provides clear context on what was tested and why, but is missing required template sections: issue ticket number/link and screenshots. Add the missing required sections: 'Issue ticket number and link' and 'Screenshots' (if applicable) to match the repository template.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately describes the main change: adding unit tests for VCProcessor SD-JWT reconstruction, which matches the primary focus of the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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

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

Copy link
Copy Markdown

@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.

🧹 Nitpick comments (2)
components/VC/common/VCProcessor.test.ts (2)

32-32: Nit: createDisclosure is a thin alias.

createDisclosure just forwards to encodeBase64Url without adding behavior. Either inline the call sites or have it perform the SD-JWT-specific tuple shape check ([salt, key, value] vs [salt, value]) so the helper carries semantic value.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/VC/common/VCProcessor.test.ts` at line 32, createDisclosure is
just a thin alias to encodeBase64Url; either inline encodeBase64Url at the test
call sites or enhance createDisclosure to validate and normalize SD-JWT
disclosure tuples before encoding. Specifically, update the helper
createDisclosure to accept a value: unknown[], assert it matches SD-JWT
disclosure shapes (length 2 or 3), verify the first element is a salt string and
the optional second element (for 3-tuple) is a key string, then construct the
canonical tuple ([salt, key, value] or [salt, value]) and pass that to
encodeBase64Url; alternatively remove createDisclosure and replace its usages
with direct calls to encodeBase64Url with properly-formed tuples.

172-253: Consider adding mso_mdoc coverage.

The RNPixelpassModule.decodeBase64UrlEncodedCBORData mock is set up at lines 10-12 but never asserted against. VCProcessor.processForRendering has two mso_mdoc branches (returning vcData.processedCredential early, and decoding via RNPixelpassModule) that are currently uncovered. Adding two small tests there would close the remaining gap in this method.

Want me to draft those two mso_mdoc test cases?

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/VC/common/VCProcessor.test.ts` around lines 172 - 253, Add two
unit tests to cover VCProcessor.processForRendering's VCFormat.mso_mdoc
branches: 1) a test where vcData contains processedCredential and calling
VCProcessor.processForRendering with VCFormat.mso_mdoc returns
vcData.processedCredential directly (assert no call to
RNPixelpassModule.decodeBase64UrlEncodedCBORData and that the returned value
equals processedCredential); 2) a test where vcData contains a base64url CBOR
payload and stub RNPixelpassModule.decodeBase64UrlEncodedCBORData to return a
decoded object, then call VCProcessor.processForRendering with VCFormat.mso_mdoc
and assert RNPixelpassModule.decodeBase64UrlEncodedCBORData was called with the
encoded payload and that the returned value matches the decoded object;
reference VCProcessor.processForRendering, VCFormat.mso_mdoc,
vcData.processedCredential and RNPixelpassModule.decodeBase64UrlEncodedCBORData
to locate the logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@components/VC/common/VCProcessor.test.ts`:
- Line 32: createDisclosure is just a thin alias to encodeBase64Url; either
inline encodeBase64Url at the test call sites or enhance createDisclosure to
validate and normalize SD-JWT disclosure tuples before encoding. Specifically,
update the helper createDisclosure to accept a value: unknown[], assert it
matches SD-JWT disclosure shapes (length 2 or 3), verify the first element is a
salt string and the optional second element (for 3-tuple) is a key string, then
construct the canonical tuple ([salt, key, value] or [salt, value]) and pass
that to encodeBase64Url; alternatively remove createDisclosure and replace its
usages with direct calls to encodeBase64Url with properly-formed tuples.
- Around line 172-253: Add two unit tests to cover
VCProcessor.processForRendering's VCFormat.mso_mdoc branches: 1) a test where
vcData contains processedCredential and calling VCProcessor.processForRendering
with VCFormat.mso_mdoc returns vcData.processedCredential directly (assert no
call to RNPixelpassModule.decodeBase64UrlEncodedCBORData and that the returned
value equals processedCredential); 2) a test where vcData contains a base64url
CBOR payload and stub RNPixelpassModule.decodeBase64UrlEncodedCBORData to return
a decoded object, then call VCProcessor.processForRendering with
VCFormat.mso_mdoc and assert RNPixelpassModule.decodeBase64UrlEncodedCBORData
was called with the encoded payload and that the returned value matches the
decoded object; reference VCProcessor.processForRendering, VCFormat.mso_mdoc,
vcData.processedCredential and RNPixelpassModule.decodeBase64UrlEncodedCBORData
to locate the logic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f012732d-cb34-4009-9865-ba49f7486a34

📥 Commits

Reviewing files that changed from the base of the PR and between 21743f7 and 501c613.

📒 Files selected for processing (2)
  • .talismanrc
  • components/VC/common/VCProcessor.test.ts

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