Lab 2: PostgreSQL sessions and recovery experiment

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-11-16 22:33:15 +03:00
co-authored by Copilot
parent 65003b6119
commit c2b9df52df
37 changed files with 2128 additions and 46 deletions
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env python3
"""Check short server-side session expiry on a dedicated local test stack."""
import time
from client import Client, arguments, check, run
def main():
def configure(parser):
parser.add_argument("--ttl", type=int, default=2)
args = arguments("Verify session expiry with SESSION_TTL_SECONDS set to a short value", configure)
check(args.ttl >= 1, "TTL must be positive")
client = Client(args.base_url)
actor = client.user("expiry")
client.call("GET", "/api/v1/users/me", actor=actor, schema="User")
time.sleep(args.ttl + 1)
client.call("GET", "/api/v1/users/me", expected=401, actor=actor)
print("PASS: expired Bearer session rejected after configured TTL")
if __name__ == "__main__":
run(main)