Skip to content

test: make two tamper assertions deterministic - #83

Merged
ExorTek merged 1 commit into
masterfrom
test/apikey-hashes-match-flake
Oct 24, 2026
Merged

ExorTek merged 1 commit into
masterfrom
test/apikey-hashes-match-flake

Conversation

@ExorTek

@ExorTek ExorTek commented Oct 24, 2026

Copy link
Copy Markdown
Owner

What / why

Master CI went red on packages/apikey/tests/token.test.js — hashesMatch: exact match → true, mismatch → false got true where it expected false. The test "tampered" a hash with hash.replace(/./, 'X'), which is a no-op whenever the hash already starts with X (≈ 1 run in 64). Nothing in the merged change touched apikey.

packages/oauth2/tests/login.test.js had the same pattern (signed.slice(0, -1) + 'X'). Both now swap the first character for one guaranteed to differ (the last base64url character can also carry unused bits, so the first is the safer position).

Which package(s)?

  • @exortek/apikey (tests only)
  • @exortek/oauth2 (tests only)

Type of change

  • 🧹 Chore / refactor / lint / build

Checklist

  • Tests updated
  • Changeset — not needed, no runtime change

The apikey hashesMatch test tampered with a hash via replace(/./, 'X')
and the oauth2 signValue test via slice(0, -1) + 'X'. Whenever the value
already started (or ended) with 'X' the tamper was a no-op, so the test
failed on roughly 1 run in 64 — it turned master CI red. Both now swap
the first character for one that is guaranteed to differ.
Copilot AI balanced review requested due to automatic review settings October 24, 2026 14:10

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@ExorTek
ExorTek merged commit 6066efb into master Oct 24, 2026
3 checks passed
@ExorTek
ExorTek deleted the test/apikey-hashes-match-flake branch October 24, 2026 14:15
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