ЛР5: асинхронная обработка вложений (RabbitMQ + worker), transactional outbox, варианты, трек 5.1

This commit is contained in:
2026-11-20 16:57:31 +03:00
parent 276dbdad8a
commit cbaadb7636
67 changed files with 5603 additions and 20 deletions
+34
View File
@@ -0,0 +1,34 @@
"""Lab3 revocation: logout takes effect immediately on every replica.
Session validity is decided only by PostgreSQL, so a revoked token must be
rejected regardless of which replica answers and regardless of the cache state.
The heavier Valkey-outage reproduction lives in scripts/check-revocation.py.
"""
from __future__ import annotations
import os
def _actor(client, label="revoke"):
suffix = os.urandom(4).hex()
username = f"s_{label}_{suffix}"
password = "T3st-" + os.urandom(8).hex()
assert client.register(username, password).status == 201
token = client.login(username, password).json["token"]
return {"id": client.me(token).json["id"], "token": token}
def test_logout_invalidates_across_replicas(client):
actor = _actor(client)
seen = set()
for _ in range(20):
response = client.me(actor["token"])
assert response.status == 200, response.body
seen.add(response.instance_id)
assert len(seen) >= 2, f"expected the LB to spread requests, saw {sorted(seen)}"
logout = client.logout(actor["token"])
assert logout.status == 204, logout.body
for _ in range(20):
assert client.me(actor["token"]).status == 401