Files
mtusi2026lab4/student-tests/expiry.py
T

16 lines
609 B
Python

"""Run against an API started with SESSION_TTL_SECONDS=2; tokens never printed."""
import sys
import time
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tests'))
from client import Client, arguments
args = arguments('Short-TTL session expiry')
c = Client(args.base_url, args.ca_file)
a = c.user('expiry')
c.call('GET', '/api/v1/users/me', actor=a, schema='User')
time.sleep(3)
c.call('GET', '/api/v1/users/me', 401, actor=a)
c.call('DELETE', '/api/v1/auth/sessions/current', 401, actor=a)
print('PASS: session expires with TTL=2; expired token cannot read or logout')