lab2
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
2026-11-13 20:42:10 +03:00
parent 17377031cc
commit 3ed1c4e5b6
29 changed files with 2141 additions and 244 deletions
+26
View File
@@ -0,0 +1,26 @@
"""Истечение сессии: API перезапускается с SESSION_TTL_SECONDS=2, затем возвращается обычный TTL."""
import time
from common import *
TTL = 2
def main():
compose("up", "-d", "api", env={"SESSION_TTL_SECONDS": str(TTL)})
wait_ready()
try:
alice = new_user("exp")
session = login(alice)
token = session["token"]
check(call("GET", "/api/v1/users/me", headers=bearer(token))[0] == 200, "fresh token works (and is cached)")
time.sleep(TTL + 1.5)
st, _, h, _ = call("GET", "/api/v1/users/me", headers=bearer(token))
check(st == 401 and h.get("WWW-Authenticate", "").startswith("Bearer"), f"expired token must be 401, got {st}")
print(f"ok: TTL={TTL}s, after {TTL + 1.5}s the same token -> 401 (cache does not extend the session)")
finally:
compose("up", "-d", "api") # обычный TTL из .env
wait_ready()
print("PASS: test_expiry")
run(main)