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

Method test_decrypt_at_time

tests/test_fernet.py:191–204  ·  view source on GitHub ↗
(self, backend)

Source from the content-addressed store, hash-verified

189 f.decrypt(b"\x00" * 16)
190
191 def test_decrypt_at_time(self, backend):
192 f1 = Fernet(base64.urlsafe_b64encode(b"\x00" * 32), backend=backend)
193 f = MultiFernet([f1])
194 pt = b"encrypt me"
195 token = f.encrypt_at_time(pt, current_time=100)
196 assert f.decrypt_at_time(token, ttl=1, current_time=100) == pt
197 with pytest.raises(InvalidToken):
198 f.decrypt_at_time(token, ttl=1, current_time=102)
199 with pytest.raises(ValueError):
200 f.decrypt_at_time(
201 token,
202 ttl=None, # type: ignore[arg-type]
203 current_time=100,
204 )
205
206 def test_no_fernets(self, backend):
207 with pytest.raises(ValueError):

Callers

nothing calls this directly

Calls 4

encrypt_at_timeMethod · 0.95
decrypt_at_timeMethod · 0.95
FernetClass · 0.90
MultiFernetClass · 0.90

Tested by

no test coverage detected