Skip to content

Commit af46830

Browse files
immu4989romanlutz
andauthored
FIX use 32-byte test JWT key to silence PyJWT InsecureKeyLengthWarning (microsoft#1804)
Co-authored-by: Roman Lutz <romanlutz13@gmail.com>
1 parent 820f243 commit af46830

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

tests/unit/auth/test_manual_copilot_authenticator.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@
99

1010
from pyrit.auth.manual_copilot_authenticator import ManualCopilotAuthenticator
1111

12+
# HS256 requires a key >= 32 bytes (RFC 7518 §3.2) to avoid PyJWT's
13+
# InsecureKeyLengthWarning. The authenticator decodes tokens with
14+
# verify_signature=False, so the key value is purely formal.
15+
_TEST_JWT_KEY = "a" * 32
16+
1217

1318
def _make_jwt(claims: dict) -> str:
1419
"""Create an unsigned JWT with the given claims for testing."""
15-
return pyjwt.encode(claims, key="secret", algorithm="HS256")
20+
return pyjwt.encode(claims, key=_TEST_JWT_KEY, algorithm="HS256")
1621

1722

1823
VALID_CLAIMS = {"tid": "tenant-id-123", "oid": "object-id-456", "sub": "user"}

0 commit comments

Comments
 (0)