feat: Authorize attachment reads and message links (U4)

This commit is contained in:
Самохвалов Андрей Ремович
2026-10-02 14:00:53 +03:00
parent 412b465b85
commit 9347fe35ae
9 changed files with 282 additions and 24 deletions
+25
View File
@@ -0,0 +1,25 @@
Lab4 U4 local verification, 2026-10-02, Colima arm64, APP_PORT=8084.
Synthetic data only; no tokens, passwords, object keys or image bodies recorded.
docker compose -f compose.yaml -f compose.local.yaml --env-file .env up -d --build --wait --scale api=2
Result: postgres/s3/lb and both API replicas healthy; migrate/bootstrap one-shots exited 0.
BASE_URL=http://127.0.0.1:8084 python3 -m unittest discover -s student-tests -p test_attachment_access.py -v
Result: 3 tests OK: message link/replay, ACL and invalid links, bytes served by both replicas.
make test BASE_URL=http://127.0.0.1:8084
Result: PASS lab4 public API scenario.
make test-persistence BASE_URL=http://127.0.0.1:8084 ACTION_SCRIPT=scripts/restart.sh
Result: PASS; hook stopped API, LB, PostgreSQL and S3, then restarted without removing volumes.
Existing token, confirmed message, attachment metadata and original bytes survived.
make test-failover BASE_URL=http://127.0.0.1:8084 ACTION_SCRIPT=scripts/stop-one.sh
Result, run 1: two instances observed; 112 confirmed writes, 1 failed attempt,
first recovery 2.826 seconds; existing token/message/original preserved.
Result, run 2 after restore: two instances observed; 113 confirmed writes,
1 failed attempt, first recovery 3.020 seconds; existing token/message/original preserved.
BASE_URL=http://127.0.0.1:8084 python3 student-tests/test_attachment_failover.py
Result: stopped each of the two distinct replicas after it accepted an upload;
the other replica served byte-identical original; both were restored between runs.