Skip to content

Commit 7ed839c

Browse files
fix ci/cd for jwt test
1 parent 17feb94 commit 7ed839c

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

tests/mytests/test_jwt_manager.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,16 @@ def test_decode_token_tampered(self, jwt_manager, test_data):
9999
"""Test decoding a tampered JWT token."""
100100
token = jwt_manager.create_access_token(test_data)
101101

102-
# Tamper with the token by modifying a character
103-
tampered_token = token[:-1] + ("a" if token[-1] != "a" else "b")
102+
# Tamper with the token by modifying the signature (last part)
103+
# Split token into parts and modify the signature more significantly
104+
parts = token.split(".")
105+
# Change multiple characters in the signature to ensure it's invalid
106+
signature = parts[2]
107+
if len(signature) > 5:
108+
tampered_signature = "TAMPERED" + signature[8:]
109+
else:
110+
tampered_signature = "TAMPER"
111+
tampered_token = f"{parts[0]}.{parts[1]}.{tampered_signature}"
104112

105113
with pytest.raises(JWTError):
106114
jwt_manager.decode_token(tampered_token)

0 commit comments

Comments
 (0)