ЛР 2: PostgreSQL, сессии и Bearer-аутентификация (оценка 3)
Skeleton contracts / contracts (pull_request) Canceled after 0s
Skeleton contracts / contracts (pull_request) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
=== 1. Start from a clean clone ===
|
||||
$ cp .env.example .env # local synthetic credentials only; .env is gitignored
|
||||
$ docker compose --env-file .env config --quiet
|
||||
config --quiet: OK
|
||||
$ docker compose --env-file .env up -d --build
|
||||
Image postgres:16-alpine Pulled
|
||||
Image mtusi2026lab2-api Built
|
||||
Volume mtusi2026lab2_pgdata Created
|
||||
Container mtusi2026lab2-db-1 Healthy
|
||||
Container mtusi2026lab2-api-1 Started
|
||||
|
||||
=== 2. Readiness ===
|
||||
$ curl.exe -s -i http://localhost:8080/health/ready
|
||||
HTTP/1.1 200 OK
|
||||
content-type: application/json
|
||||
x-request-id: d59c51aa-1532-4c02-a24c-6a1091942bc2
|
||||
x-instance-id: e37ad21ced60
|
||||
{"status":"ok"}
|
||||
|
||||
=== 3. State BEFORE restart ===
|
||||
$ docker compose --env-file .env ps
|
||||
NAME IMAGE SERVICE STATUS
|
||||
mtusi2026lab2-api-1 mtusi2026lab2-api api Up (health: starting)
|
||||
mtusi2026lab2-db-1 postgres:16-alpine db Up (healthy)
|
||||
|
||||
$ docker compose --env-file .env exec -T db psql -U messenger -d messenger -c \
|
||||
'SELECT (SELECT count(*) FROM users) users, (SELECT count(*) FROM sessions) sessions,
|
||||
(SELECT count(*) FROM chats) chats, (SELECT count(*) FROM messages) messages;'
|
||||
users | sessions | chats | messages
|
||||
-------+----------+-------+----------
|
||||
15 | 14 | 4 | 6
|
||||
|
||||
$ docker compose --env-file .env exec -T db psql -U messenger -d messenger -c \
|
||||
'SELECT name FROM schema_migrations ORDER BY name;'
|
||||
name
|
||||
--------------
|
||||
001_init.sql
|
||||
|
||||
=== 4. Public smoke ===
|
||||
$ python tests/smoke.py --base-url http://localhost:8080
|
||||
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
|
||||
|
||||
=== 5. Explicit restart hook (API + PostgreSQL, volumes preserved) ===
|
||||
$ scripts/restart.sh # Linux/macOS
|
||||
$ scripts\restart.cmd # Windows local run
|
||||
cd <repo>; docker compose --env-file .env restart db api
|
||||
# no down -v, no flush, no re-seed
|
||||
|
||||
=== 6. State AFTER restart ===
|
||||
$ docker compose --env-file .env ps
|
||||
NAME IMAGE SERVICE STATUS
|
||||
mtusi2026lab2-api-1 mtusi2026lab2-api api Up (health: starting)
|
||||
mtusi2026lab2-db-1 postgres:16-alpine db Up (health: starting)
|
||||
# Both containers were actually restarted; mtusi2026lab2_pgdata volume was kept.
|
||||
|
||||
$ docker compose --env-file .env exec -T db psql -U messenger -d messenger -c \
|
||||
'SELECT (SELECT count(*) FROM users) users, ... ;'
|
||||
users | sessions | chats | messages
|
||||
-------+----------+-------+----------
|
||||
18 | 16 | 5 | 8
|
||||
# Counts grew because smoke and the persistence test create new synthetic users each run.
|
||||
# Earlier rows were not deleted; the migration list is unchanged (001_init.sql only),
|
||||
# which confirms migrations were not re-applied.
|
||||
|
||||
=== 7. Persistence test with the SAME Bearer token after restart ===
|
||||
$ python tests/resilience.py --mode persistence --action-script scripts/restart.cmd --base-url http://localhost:8080
|
||||
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
|
||||
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
|
||||
=== 8. Own unit tests ===
|
||||
$ python -m unittest discover -s student-tests -p 'test_*.py' -v
|
||||
Ran 9 tests ... OK
|
||||
# covers: scrypt KDF/salts, UTF-8 password with colon, Basic/Bearer parsing,
|
||||
# opaque token hashing, keyset cursor round-trip and tamper rejection.
|
||||
|
||||
=== 9. Offline checks ===
|
||||
$ python scripts/check_contract.py
|
||||
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
||||
Reference in New Issue
Block a user