#70

test: add unit tests for src/secrets.ts

Opendoitrouswants to merge intofrom

Adds test/secrets.test.ts covering the three exports of src/secrets.ts:

  • secretEquals: matching strings, non-matching, empty, unicode, different lengths
  • deriveSigningKey: returns a usable HMAC key, caches same material, different material → different key
  • hmacHex: 64-char hex output, determinism, distinct messages → distinct digests

12 tests, all pass under bun test.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added coverage for secret comparison, signing-key derivation, and HMAC digest generation.
    • Added checks for matching and non-matching secrets, empty and Unicode inputs, deterministic results, key reuse, and distinct outputs for different inputs.
    • Verified HMAC signatures and hexadecimal digests have the expected formats and lengths.

Activity

2
coderabbitai[bot]1mo ago

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: fdb7d9c6-3600-405a-93f8-4f6382a6ae05

📥 Commits

Reviewing files that changed from the base of the PR and between 5c241afbb44e01f9e60a2d6184b6ce3621c83b36 and 6a1895cfdaa4ada7d7277ee12941621656f6b228.

📒 Files selected for processing (1)
  • test/secrets.test.ts

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The pull request adds test/secrets.test.ts. The tests cover secretEquals, deriveSigningKey, and hmacHex, including comparison cases, key caching, signature differences, and hexadecimal digest output.

Changes

Secrets module tests

Layer / File(s)Summary
Secrets behavior validation
test/secrets.test.ts
Adds tests for matching, non-matching, different-length, empty, and Unicode secrets. Tests verify HMAC key usability, cached promise reuse, distinct outputs for different materials, and deterministic 64-character lowercase hexadecimal digests.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title clearly and concisely describes the main change: adding unit tests for src/secrets.ts.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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.