summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2023-03-24 21:41:35 +0800
committerGitHub <noreply@github.com>2023-03-24 13:41:35 +0000
commitffc10f9bb0f71102b743a7b8f2fa4a9a33e86d60 (patch)
treed745b29bdfa48bb8390f92a60a51a563b069b6f4 /tests
parent0794b0e31aae4c550a009550f55f0976ae700083 (diff)
downloadcryptography-ffc10f9bb0f71102b743a7b8f2fa4a9a33e86d60.tar.gz
remove a test dep (#8446)
Diffstat (limited to 'tests')
-rw-r--r--tests/test_fernet.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/tests/test_fernet.py b/tests/test_fernet.py
index d4b1561a0..89908e279 100644
--- a/tests/test_fernet.py
+++ b/tests/test_fernet.py
@@ -4,12 +4,11 @@
import base64
-import calendar
+import datetime
import json
import os
import time
-import iso8601
import pretend
import pytest
@@ -46,7 +45,7 @@ class TestFernet:
f = Fernet(secret.encode("ascii"), backend=backend)
actual_token = f._encrypt_from_parts(
src.encode("ascii"),
- calendar.timegm(iso8601.parse_date(now).utctimetuple()),
+ int(datetime.datetime.fromisoformat(now).timestamp()),
bytes(iv),
)
assert actual_token == token.encode("ascii")
@@ -60,7 +59,7 @@ class TestFernet:
):
# secret & token are both str
f = Fernet(secret.encode("ascii"), backend=backend)
- current_time = calendar.timegm(iso8601.parse_date(now).utctimetuple())
+ current_time = int(datetime.datetime.fromisoformat(now).timestamp())
payload = f.decrypt_at_time(
token, # str
ttl=ttl_sec,
@@ -86,7 +85,7 @@ class TestFernet:
@json_parametrize(("secret", "token", "now", "ttl_sec"), "invalid.json")
def test_invalid(self, secret, token, now, ttl_sec, backend, monkeypatch):
f = Fernet(secret.encode("ascii"), backend=backend)
- current_time = calendar.timegm(iso8601.parse_date(now).utctimetuple())
+ current_time = int(datetime.datetime.fromisoformat(now).timestamp())
with pytest.raises(InvalidToken):
f.decrypt_at_time(
token.encode("ascii"),