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

Method test_decrypt

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

Source from the content-addressed store, hash-verified

173 assert f1.decrypt(f.encrypt(b"abc")) == b"abc"
174
175 def test_decrypt(self, backend):
176 f1 = Fernet(base64.urlsafe_b64encode(b"\x00" * 32), backend=backend)
177 f2 = Fernet(base64.urlsafe_b64encode(b"\x01" * 32), backend=backend)
178 f = MultiFernet([f1, f2])
179
180 # token as bytes
181 assert f.decrypt(f1.encrypt(b"abc")) == b"abc"
182 assert f.decrypt(f2.encrypt(b"abc")) == b"abc"
183
184 # token as str
185 assert f.decrypt(f1.encrypt(b"abc").decode("ascii")) == b"abc"
186 assert f.decrypt(f2.encrypt(b"abc").decode("ascii")) == b"abc"
187
188 with pytest.raises(InvalidToken):
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)

Callers

nothing calls this directly

Calls 4

decryptMethod · 0.95
encryptMethod · 0.95
FernetClass · 0.90
MultiFernetClass · 0.90

Tested by

no test coverage detected