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