[+] Completed lab 2

This commit is contained in:
Антон Архипов
2026-11-16 16:01:24 +03:00
parent 65003b6119
commit f77e500ccf
46 changed files with 4532 additions and 45 deletions
+21
View File
@@ -0,0 +1,21 @@
"""Run against an API with SESSION_TTL_SECONDS=2."""
from pathlib import Path
import sys
from time import sleep
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tests'))
from client import Client, arguments, run
def main():
args = arguments('Student check: two-second session TTL')
client = Client(args.base_url, args.ca_file)
actor = client.user('expiry')
client.call('GET', '/api/v1/users/me', actor=actor, schema='User')
sleep(2.2)
client.call('GET', '/api/v1/users/me', 401, actor=actor)
print('PASS: a valid token became unauthorized after the two-second TTL')
if __name__ == '__main__':
run(main)