FIX use 32-byte test JWT key to silence PyJWT InsecureKeyLengthWarning#1804
Merged
Conversation
tests/unit/auth/test_manual_copilot_authenticator.py used a 6-byte key ("secret") to sign test JWTs with HS256. PyJWT emits InsecureKeyLengthWarning because HMAC-SHA256 requires a key >=32 bytes per RFC 7518 section 3.2. The full unit suite emits 12 of these warnings per run.
ManualCopilotAuthenticator decodes tokens with verify_signature=False (pyrit/auth/copilot_authenticator.py:259), so the test key value is purely formal -- any well-formed key works. Switch to a module-level 32-byte constant with a brief explanatory comment.
No functional change; warnings drop from 12 to 0 for this test module.
romanlutz
approved these changes
May 26, 2026
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.
Fixes #1803.
tests/unit/auth/test_manual_copilot_authenticator.pysigns test JWTs withkey="secret"(6 bytes), which trips PyJWT'sInsecureKeyLengthWarningbecause HMAC-SHA256 requires a key of at least 32 bytes per RFC 7518 §3.2. The unit suite emits 12 of these warnings per run.Fix
Move the test key to a module-level constant set to a 32-byte string, with a brief comment noting (a) the RFC requirement and (b) that
ManualCopilotAuthenticatordecodes withverify_signature=False(pyrit/auth/copilot_authenticator.py:259), so the key value is purely formal.No functional change.
Verification