aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_fernet.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2014-10-19 19:11:30 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2014-10-19 22:32:42 -0700
commita1a21f46c0ab36fc49b087b2d70751ed23c94724 (patch)
tree2e76552b6ca2f1be29b8de0c900eb57213037062 /tests/test_fernet.py
parent962f66effa666c161aa93bb55b0f9c4deff67100 (diff)
downloadcryptography-a1a21f46c0ab36fc49b087b2d70751ed23c94724.tar.gz
cryptography-a1a21f46c0ab36fc49b087b2d70751ed23c94724.tar.bz2
cryptography-a1a21f46c0ab36fc49b087b2d70751ed23c94724.zip
Fixed an issue in fernet where the wrong exception would occur on an all-nulls input.
Also switched a few tests to not generate a key
Diffstat (limited to 'tests/test_fernet.py')
-rw-r--r--tests/test_fernet.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/test_fernet.py b/tests/test_fernet.py
index 0683d950..0b4e3e87 100644
--- a/tests/test_fernet.py
+++ b/tests/test_fernet.py
@@ -86,15 +86,20 @@ class TestFernet(object):
f.decrypt(token.encode("ascii"), ttl=ttl_sec)
def test_invalid_start_byte(self, backend):
- f = Fernet(Fernet.generate_key(), backend=backend)
+ f = Fernet(base64.urlsafe_b64encode(b"\x00" * 32), backend=backend)
with pytest.raises(InvalidToken):
f.decrypt(base64.urlsafe_b64encode(b"\x81"))
def test_timestamp_too_short(self, backend):
- f = Fernet(Fernet.generate_key(), backend=backend)
+ f = Fernet(base64.urlsafe_b64encode(b"\x00" * 32), backend=backend)
with pytest.raises(InvalidToken):
f.decrypt(base64.urlsafe_b64encode(b"\x80abc"))
+ def test_non_base64_token(self, backend):
+ f = Fernet(base64.urlsafe_b64encode(b"\x00" * 32), backend=backend)
+ with pytest.raises(InvalidToken):
+ f.decrypt(b"\x00")
+
def test_unicode(self, backend):
f = Fernet(base64.urlsafe_b64encode(b"\x00" * 32), backend=backend)
with pytest.raises(TypeError):