Lab2 final implementation and validation
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
2026-10-16 18:31:22 +03:00
parent 5736aa5f89
commit 56cc687b62
6 changed files with 283 additions and 283 deletions
+13
View File
@@ -91,6 +91,18 @@ def main():
assert stale_result["status"] == 200, stale_result
assert stale_result["body"]["username"] == username, stale_result
r.setex(key, 1, json.dumps({
"token": token,
"user_id": str(uuid.uuid4()),
"expires_at": "2100-01-01T00:00:00Z",
"revoked_at": None,
"user": {"id": str(uuid.uuid4()), "username": "ttl-recovery", "display_name": "ttl-recovery", "created_at": "2020-01-01T00:00:00Z"},
}, separators=(",", ":"), ensure_ascii=False))
time.sleep(2)
short_ttl = http_json("GET", "/api/v1/users/me", expected=200, headers={"Authorization": "Bearer " + token})
assert short_ttl["status"] == 200, short_ttl
assert short_ttl["body"]["username"] == username, short_ttl
revoke = http_json("DELETE", "/api/v1/auth/sessions/current", expected=204, headers={"Authorization": "Bearer " + token})
assert revoke["status"] == 204, revoke
assert not r.get(key), "revoked session key should be deleted from cache"
@@ -103,6 +115,7 @@ def main():
print(f"avg_latency_ms={avg:.2f}")
print(f"p95_latency_ms={p95:.2f}")
print("stale_cache_rejected=True")
print("short_ttl_recovers_from_db=True")
print("logout_revokes_cache=True")