Fix intermittent token service test failures caused by Base64 padding #32
+20
−6
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.
Summary
Two token verification tests were failing intermittently (~4% of runs) because they modified the last character of JWT tokens. Due to Base64 URL-safe encoding with 43-character signatures, the last character only contributes 2 bits to the decoded value. Characters 'U' and 'X' share the same high-order 4 bits (010100 vs 010111), so modifying 'U'→'X' produces an identical decoded signature, correctly passing verification.
Changes:
MIN_TOKEN_LENGTH_FOR_MODIFICATIONandMIN_SIGNATURE_LENGTH_FOR_MODIFICATIONExample of the issue:
Related Issues / Discussions
Issue describes the intermittent test failures with full error logs.
QA Instructions
Run the affected tests multiple times to verify deterministic behavior:
All runs should pass. Previously, approximately 4% would fail.
Merge Plan
N/A - Test-only changes, no production code affected.
Checklist
What's Newcopy (if doing a release after this PR)Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.