This commit is contained in:
pampixz
2026-12-03 19:25:38 +03:00
parent 20afc2c790
commit 38d908afc9
47 changed files with 2065 additions and 24 deletions
+36
View File
@@ -0,0 +1,36 @@
import sys
import subprocess
from pathlib import Path
from uuid import UUID
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "tests"))
from client import Client
c = Client("https://localhost:8443", "secrets/ca.crt")
alice, bob, eve, chat = c.bootstrap()
c.call("GET", "/api/v1/users/me", 200, actor=alice)
print("Before expiry: 200 OK")
user_id = str(UUID(str(alice["id"])))
sql = (
"UPDATE sessions SET expires_at = now() - interval '1 second' "
f"WHERE user_id = '{user_id}';"
)
subprocess.run(
[
"docker", "compose", "exec", "-T", "postgres",
"sh", "-c",
'psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d "$POSTGRES_DB"',
],
input=sql,
text=True,
check=True,
)
c.call("GET", "/api/v1/users/me", 401, actor=alice)
print("After expiry: 401 Unauthorized")
print("PASS: expired session rejected")