Files
mtusi2026lab2/student-tests/expiry.py
T
2026-11-05 01:43:30 +03:00

15 lines
538 B
Python

"""Run against a separate API with SESSION_TTL_SECONDS=2."""
import sys,time
from pathlib import Path
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'tests'))
from client import Client,run
def main():
c=Client('http://localhost:8081')
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)
print('PASS: a real short-lived session authenticates before expiry and returns 401 after expiry')
if __name__=='__main__': run(main)