Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix tests as well
  • Loading branch information
sobolevn authored Feb 21, 2025
commit 3af0a8da423515aff899f166bae0ac6309edec2f
15 changes: 7 additions & 8 deletions tests/test_jwt.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import base64
import json
from datetime import datetime, timedelta

try:
from datetime import UTC, datetime, timedelta

utc_now = datetime.now(UTC) # Preferred in Python 3.13+
from datetime import UTC # Preferred in Python 3.13+
except ImportError:
from datetime import datetime, timedelta, timezone

utc_now = datetime.now(timezone.utc) # Preferred in Python 3.12 and below
from datetime import timezone # Preferred in Python 3.12 and below
UTC = timezone.utc


Expand Down Expand Up @@ -514,14 +511,16 @@ def test_unverified_claims_object(self, claims, key):
[
("aud", "aud"),
("ait", "ait"),
("exp", utc_now + timedelta(seconds=3600)),
("nbf", utc_now - timedelta(seconds=5)),
("exp", lambda: datetime.now(UTC) + timedelta(seconds=3600)),
("nbf", lambda: datetime.now(UTC) - timedelta(seconds=5)),
("iss", "iss"),
("sub", "sub"),
("jti", "jti"),
],
)
def test_require(self, claims, key, claim, value):
if callable(value):
value = value()
options = {"require_" + claim: True, "verify_" + claim: False}

token = jwt.encode(claims, key)
Expand Down
Loading