Skip to content

Commit d7703cd

Browse files
committed
fix flaky test
1 parent b1ed0d8 commit d7703cd

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

tests/protocol/test_version4.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,15 @@ def test_decrypt_invalid_mac() -> None:
3737
key: bytes = _create_symmetric_key(4, b"0" * 32)
3838

3939
token: bytes = version4.encrypt(message, key)
40+
4041
# tamper with mac
41-
token_with_invalid_mac = token[:40] + b"0" + token[41:]
42+
a_slice = token[40:45]
43+
if a_slice == b"00000":
44+
a_slice = b"11111"
45+
else:
46+
a_slice = b"00000"
47+
token_with_invalid_mac = token[:40] + a_slice + token[45:]
48+
4249
with pytest.raises(InvalidMac):
4350
version4.decrypt(token_with_invalid_mac, key)
4451

0 commit comments

Comments
 (0)