MCPcopy
hub / github.com/pyca/cryptography / test_invalid

Method test_invalid

tests/test_fernet.py:86–97  ·  view source on GitHub ↗
(self, secret, token, now, ttl_sec, backend, monkeypatch)

Source from the content-addressed store, hash-verified

84
85 @json_parametrize(("secret", "token", "now", "ttl_sec"), "invalid.json")
86 def test_invalid(self, secret, token, now, ttl_sec, backend, monkeypatch):
87 f = Fernet(secret.encode("ascii"), backend=backend)
88 current_time = int(datetime.datetime.fromisoformat(now).timestamp())
89 with pytest.raises(InvalidToken):
90 f.decrypt_at_time(
91 token.encode("ascii"),
92 ttl=ttl_sec,
93 current_time=current_time,
94 )
95 monkeypatch.setattr(time, "time", lambda: current_time)
96 with pytest.raises(InvalidToken):
97 f.decrypt(token.encode("ascii"), ttl=ttl_sec)
98
99 def test_invalid_start_byte(self, backend):
100 f = Fernet(base64.urlsafe_b64encode(b"\x00" * 32), backend=backend)

Callers

nothing calls this directly

Calls 3

decrypt_at_timeMethod · 0.95
decryptMethod · 0.95
FernetClass · 0.90

Tested by

no test coverage detected