Skip to content

test: add unit tests for src/secrets.ts - #70

Open
doitrous wants to merge 1 commit into
mrmps:mainfrom
doitrous:test/secrets
Open

doitrous wants to merge 1 commit into
mrmps:mainfrom
doitrous:test/secrets

Conversation

@doitrous

@doitrous doitrous commented Sep 20, 2026 •

Copy link
Copy Markdown

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.

Cover secretEquals (matching, non-matching, empty, unicode, different
lengths), deriveSigningKey (returns usable key, caches same material,
different material produces different keys), and hmacHex (hex format,
determinism, distinct messages).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

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 5c241af and 6a1895c.

📒 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 name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding unit tests for src/secrets.ts.
Docstring Coverage ✅ Passed No 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 ✅ 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 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.

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.

1 participant