(self, backend)
| 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) |
nothing calls this directly
no test coverage detected