|
|
d49da0 |
From bea141d25bd2bc4eea7527e2d6ec1d85b2b3806d Mon Sep 17 00:00:00 2001
|
|
|
d49da0 |
From: Christian Heimes <cheimes@redhat.com>
|
|
|
d49da0 |
Date: Thu, 29 Oct 2020 09:21:06 +0100
|
|
|
d49da0 |
Subject: [PATCH 3] Skip iso8601 test cases
|
|
|
d49da0 |
|
|
|
d49da0 |
---
|
|
|
d49da0 |
tests/test_fernet.py | 15 ++++++++++++++-
|
|
|
d49da0 |
1 file changed, 14 insertions(+), 1 deletion(-)
|
|
|
d49da0 |
|
|
|
d49da0 |
diff --git a/tests/test_fernet.py b/tests/test_fernet.py
|
|
|
d49da0 |
index 38409b03e..343f3e4ec 100644
|
|
|
d49da0 |
--- a/tests/test_fernet.py
|
|
|
d49da0 |
+++ b/tests/test_fernet.py
|
|
|
d49da0 |
@@ -10,7 +10,10 @@ import json
|
|
|
d49da0 |
import os
|
|
|
d49da0 |
import time
|
|
|
d49da0 |
|
|
|
d49da0 |
-import iso8601
|
|
|
d49da0 |
+try:
|
|
|
d49da0 |
+ import iso8601
|
|
|
d49da0 |
+except ImportError:
|
|
|
d49da0 |
+ iso8601 = None
|
|
|
d49da0 |
|
|
|
d49da0 |
import pytest
|
|
|
d49da0 |
|
|
|
d49da0 |
@@ -24,6 +27,12 @@ from cryptography.hazmat.primitives.ciphers import algorithms, modes
|
|
|
d49da0 |
import cryptography_vectors
|
|
|
d49da0 |
|
|
|
d49da0 |
|
|
|
d49da0 |
+skip_iso8601 = pytest.mark.skipif(
|
|
|
d49da0 |
+ iso8601 is None,
|
|
|
d49da0 |
+ reason="is8601 is not available"
|
|
|
d49da0 |
+)
|
|
|
d49da0 |
+
|
|
|
d49da0 |
+
|
|
|
d49da0 |
def json_parametrize(keys, filename):
|
|
|
d49da0 |
vector_file = cryptography_vectors.open_vector_file(
|
|
|
d49da0 |
os.path.join("fernet", filename), "r"
|
|
|
d49da0 |
@@ -49,6 +58,7 @@ def test_default_backend():
|
|
|
d49da0 |
skip_message="Does not support AES CBC",
|
|
|
d49da0 |
)
|
|
|
d49da0 |
class TestFernet(object):
|
|
|
d49da0 |
+ @skip_iso8601
|
|
|
d49da0 |
@json_parametrize(
|
|
|
d49da0 |
("secret", "now", "iv", "src", "token"),
|
|
|
d49da0 |
"generate.json",
|
|
|
d49da0 |
@@ -62,6 +72,7 @@ class TestFernet(object):
|
|
|
d49da0 |
)
|
|
|
d49da0 |
assert actual_token == token.encode("ascii")
|
|
|
d49da0 |
|
|
|
d49da0 |
+ @skip_iso8601
|
|
|
d49da0 |
@json_parametrize(
|
|
|
d49da0 |
("secret", "now", "src", "ttl_sec", "token"),
|
|
|
d49da0 |
"verify.json",
|
|
|
d49da0 |
@@ -81,6 +92,7 @@ class TestFernet(object):
|
|
|
d49da0 |
payload = f.decrypt(token.encode("ascii"), ttl=ttl_sec)
|
|
|
d49da0 |
assert payload == src.encode("ascii")
|
|
|
d49da0 |
|
|
|
d49da0 |
+ @skip_iso8601
|
|
|
d49da0 |
@json_parametrize(("secret", "token", "now", "ttl_sec"), "invalid.json")
|
|
|
d49da0 |
def test_invalid(self, secret, token, now, ttl_sec, backend, monkeypatch):
|
|
|
d49da0 |
f = Fernet(secret.encode("ascii"), backend=backend)
|
|
|
d49da0 |
@@ -117,6 +129,7 @@ class TestFernet(object):
|
|
|
d49da0 |
with pytest.raises(TypeError):
|
|
|
d49da0 |
f.decrypt(u"")
|
|
|
d49da0 |
|
|
|
d49da0 |
+ @skip_iso8601
|
|
|
d49da0 |
def test_timestamp_ignored_no_ttl(self, monkeypatch, backend):
|
|
|
d49da0 |
f = Fernet(base64.urlsafe_b64encode(b"\x00" * 32), backend=backend)
|
|
|
d49da0 |
pt = b"encrypt me"
|
|
|
d49da0 |
--
|
|
|
d49da0 |
2.26.2
|
|
|
d49da0 |
|