Repository navigation
test: make two tamper assertions deterministic - #83
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What / why
Master CI went red on
packages/apikey/tests/token.test.js—hashesMatch: exact match → true, mismatch → falsegottruewhere it expectedfalse. The test "tampered" a hash withhash.replace(/./, 'X'), which is a no-op whenever the hash already starts withX(≈ 1 run in 64). Nothing in the merged change touched apikey.packages/oauth2/tests/login.test.jshad 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
Checklist