Terry Chia | 3d7f8d1 | 2015-09-27 21:00:58 +0800 | [diff] [blame^] | 1 | from hypothesis.strategies import binary |
Terry Chia | 42ea0d1 | 2015-09-27 20:26:09 +0800 | [diff] [blame] | 2 | |
Terry Chia | cc2a828 | 2015-03-22 12:06:45 +0800 | [diff] [blame] | 3 | import pytest |
| 4 | |
| 5 | from cryptography.fernet import Fernet |
| 6 | |
Terry Chia | 42ea0d1 | 2015-09-27 20:26:09 +0800 | [diff] [blame] | 7 | |
Terry Chia | cc2a828 | 2015-03-22 12:06:45 +0800 | [diff] [blame] | 8 | hypothesis = pytest.importorskip("hypothesis") |
| 9 | |
| 10 | |
Terry Chia | 42ea0d1 | 2015-09-27 20:26:09 +0800 | [diff] [blame] | 11 | @hypothesis.given(binary()) |
Terry Chia | cc2a828 | 2015-03-22 12:06:45 +0800 | [diff] [blame] | 12 | def test_fernet(data): |
| 13 | f = Fernet(Fernet.generate_key()) |
| 14 | ct = f.encrypt(data) |
| 15 | assert f.decrypt(ct) == data |