Skip to content

Conversation

@ixunio
Copy link
Owner

@ixunio ixunio commented Jan 3, 2026

It is now possible to spoof time for any JWTBaseModel model. Closes #46

from datetime import datetime, UTC
from superjwt import JWTClaims
from superjwt.exceptions import TokenExpiredError

claims = JWTClaims().with_expiration(minutes=30)

isnotnow: datetime = datetime(2042, 1, 1, 20, 42, 59, tzinfo=UTC)
claims.spoof_time(isnotnow)

try:
    claims.revalidate()  # fails
except TokenExpiredError:
    print("expired!!!")

claims.now_ = None
claims.revalidate()  # passes

@codecov
Copy link

codecov bot commented Jan 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.06%. Comparing base (eb5a252) to head (c07ef8a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #51      +/-   ##
==========================================
+ Coverage   95.53%   96.06%   +0.52%     
==========================================
  Files          14       14              
  Lines        1299     1397      +98     
  Branches       85       87       +2     
==========================================
+ Hits         1241     1342     +101     
+ Misses         41       39       -2     
+ Partials       17       16       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ixunio ixunio force-pushed the nowisnotnow branch 3 times, most recently from e9ce0f0 to 2162d8f Compare January 4, 2026 18:27
@ixunio ixunio merged commit c07ef8a into main Jan 4, 2026
10 checks passed
@ixunio ixunio deleted the nowisnotnow branch January 4, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the possibility to override the present time

2 participants