17 lines
567 B
Python
17 lines
567 B
Python
from datetime import UTC, datetime
|
|
|
|
from core.security import create_access_token, decode_access_token
|
|
|
|
|
|
def test_create_access_token_uses_twelve_hour_default_window(monkeypatch):
|
|
monkeypatch.setattr("core.security.settings.JWT_EXPIRE_MINUTES", 720)
|
|
|
|
issued_at = datetime.now(UTC)
|
|
token = create_access_token(subject="admin")
|
|
payload = decode_access_token(token)
|
|
expires_at = datetime.fromtimestamp(payload.exp, UTC)
|
|
|
|
lifetime_seconds = (expires_at - issued_at).total_seconds()
|
|
|
|
assert 11.9 * 60 * 60 <= lifetime_seconds <= 12.1 * 60 * 60
|