diff --git a/evidence/00-clean-start.txt b/evidence/00-clean-start.txt new file mode 100644 index 00000000..4ecedb35 --- /dev/null +++ b/evidence/00-clean-start.txt @@ -0,0 +1,337 @@ +# 00 чистый старт (2026-11-12T18:04:45Z) +$ docker compose down -v + Volume mtusi2026lab2_pgdata Removing + Volume mtusi2026lab2_pgdata Removed +$ sh scripts/setup-secrets.sh +secrets: ok (значения не печатаются) +$ docker compose up -d --build + postgres Pulling + 500aaa681781 Pulling fs layer + 6886cb0fa181 Pulling fs layer + 09852ea151b6 Pulling fs layer + 3c23ffc3610d Pulling fs layer + da9db072f522 Pulling fs layer + 7c35d0b2112f Pulling fs layer + 754dcd3183db Pulling fs layer + 5b2b0e42c692 Pulling fs layer + d68e4f14dc32 Pulling fs layer + b6fcda863f21 Pulling fs layer + 4f90fd4705e0 Pulling fs layer + 6886cb0fa181 Download complete + 500aaa681781 Download complete + 754dcd3183db Downloading [==================================================>] 5.416kB/5.416kB + b6fcda863f21 Download complete + 7c35d0b2112f Download complete + 5b2b0e42c692 Download complete + 09852ea151b6 Download complete + 4f90fd4705e0 Download complete + 754dcd3183db Download complete + 3c23ffc3610d Download complete + d68e4f14dc32 Downloading [> ] 1.049MB/94.39MB + da9db072f522 Downloading [==============> ] 1.049MB/3.624MB + d68e4f14dc32 Downloading [> ] 1.049MB/94.39MB + da9db072f522 Downloading [==============> ] 1.049MB/3.624MB + d68e4f14dc32 Downloading [> ] 1.049MB/94.39MB + da9db072f522 Downloading [==============> ] 1.049MB/3.624MB + d68e4f14dc32 Downloading [=> ] 2.097MB/94.39MB + d68e4f14dc32 Downloading [=> ] 2.097MB/94.39MB + da9db072f522 Downloading [==============> ] 1.049MB/3.624MB + d68e4f14dc32 Downloading [=> ] 3.146MB/94.39MB + da9db072f522 Downloading [============================> ] 2.097MB/3.624MB + d68e4f14dc32 Downloading [=> ] 3.146MB/94.39MB + da9db072f522 Downloading [===========================================> ] 3.146MB/3.624MB + d68e4f14dc32 Downloading [==> ] 4.194MB/94.39MB + da9db072f522 Download complete + da9db072f522 Extracting 1 s + d68e4f14dc32 Downloading [==> ] 4.194MB/94.39MB + da9db072f522 Extracting 1 s + d68e4f14dc32 Downloading [==> ] 4.194MB/94.39MB + da9db072f522 Pull complete + d68e4f14dc32 Downloading [==> ] 5.243MB/94.39MB + 7c35d0b2112f Extracting 1 s + d68e4f14dc32 Downloading [===> ] 6.291MB/94.39MB + 7c35d0b2112f Pull complete + 3c23ffc3610d Pull complete + d68e4f14dc32 Downloading [===> ] 6.291MB/94.39MB + 6886cb0fa181 Pull complete + 4f90fd4705e0 Pull complete + d68e4f14dc32 Downloading [===> ] 7.34MB/94.39MB + d68e4f14dc32 Downloading [====> ] 8.389MB/94.39MB + d68e4f14dc32 Downloading [====> ] 8.389MB/94.39MB + d68e4f14dc32 Downloading [====> ] 9.437MB/94.39MB + d68e4f14dc32 Downloading [=====> ] 10.49MB/94.39MB + d68e4f14dc32 Downloading [=====> ] 10.49MB/94.39MB + d68e4f14dc32 Downloading [=====> ] 10.49MB/94.39MB + d68e4f14dc32 Downloading [======> ] 11.53MB/94.39MB + d68e4f14dc32 Downloading [======> ] 12.58MB/94.39MB + d68e4f14dc32 Downloading [======> ] 12.58MB/94.39MB + d68e4f14dc32 Downloading [=======> ] 13.63MB/94.39MB + d68e4f14dc32 Downloading [=======> ] 14.02MB/94.39MB + d68e4f14dc32 Downloading [=======> ] 14.68MB/94.39MB + d68e4f14dc32 Downloading [========> ] 15.27MB/94.39MB + d68e4f14dc32 Downloading [========> ] 16.36MB/94.39MB + d68e4f14dc32 Downloading [========> ] 16.78MB/94.39MB + d68e4f14dc32 Downloading [=========> ] 17.83MB/94.39MB + d68e4f14dc32 Downloading [=========> ] 17.83MB/94.39MB + d68e4f14dc32 Downloading [=========> ] 17.83MB/94.39MB + d68e4f14dc32 Downloading [=========> ] 18.87MB/94.39MB + d68e4f14dc32 Downloading [==========> ] 19.92MB/94.39MB + d68e4f14dc32 Downloading [===========> ] 20.97MB/94.39MB + d68e4f14dc32 Downloading [===========> ] 22.02MB/94.39MB + d68e4f14dc32 Downloading [===========> ] 22.02MB/94.39MB + d68e4f14dc32 Downloading [============> ] 23.07MB/94.39MB + d68e4f14dc32 Downloading [============> ] 24.12MB/94.39MB + d68e4f14dc32 Downloading [=============> ] 25.17MB/94.39MB + d68e4f14dc32 Downloading [=============> ] 26.21MB/94.39MB + d68e4f14dc32 Downloading [=============> ] 26.21MB/94.39MB + d68e4f14dc32 Downloading [==============> ] 27.26MB/94.39MB + d68e4f14dc32 Downloading [===============> ] 29.36MB/94.39MB + d68e4f14dc32 Downloading [===============> ] 29.36MB/94.39MB + d68e4f14dc32 Downloading [================> ] 30.41MB/94.39MB + d68e4f14dc32 Downloading [================> ] 31.46MB/94.39MB + d68e4f14dc32 Downloading [=================> ] 32.51MB/94.39MB + d68e4f14dc32 Downloading [=================> ] 33.55MB/94.39MB + d68e4f14dc32 Downloading [=================> ] 33.55MB/94.39MB + d68e4f14dc32 Downloading [==================> ] 34.6MB/94.39MB + d68e4f14dc32 Downloading [==================> ] 35.65MB/94.39MB + d68e4f14dc32 Downloading [===================> ] 37.75MB/94.39MB + d68e4f14dc32 Downloading [====================> ] 38.8MB/94.39MB + d68e4f14dc32 Downloading [=====================> ] 39.85MB/94.39MB + d68e4f14dc32 Downloading [=====================> ] 39.85MB/94.39MB + d68e4f14dc32 Downloading [======================> ] 41.94MB/94.39MB + d68e4f14dc32 Downloading [======================> ] 42.99MB/94.39MB + d68e4f14dc32 Downloading [======================> ] 42.99MB/94.39MB + d68e4f14dc32 Downloading [=======================> ] 45.09MB/94.39MB + d68e4f14dc32 Downloading [=======================> ] 45.09MB/94.39MB + d68e4f14dc32 Downloading [========================> ] 45.65MB/94.39MB + d68e4f14dc32 Downloading [========================> ] 47.19MB/94.39MB + d68e4f14dc32 Downloading [==========================> ] 49.28MB/94.39MB + d68e4f14dc32 Downloading [==========================> ] 50.33MB/94.39MB + d68e4f14dc32 Downloading [==========================> ] 50.33MB/94.39MB + d68e4f14dc32 Downloading [===========================> ] 52.43MB/94.39MB + d68e4f14dc32 Downloading [============================> ] 53.48MB/94.39MB + d68e4f14dc32 Downloading [============================> ] 54.53MB/94.39MB + d68e4f14dc32 Downloading [=============================> ] 55.57MB/94.39MB + d68e4f14dc32 Downloading [=============================> ] 56.62MB/94.39MB + d68e4f14dc32 Downloading [=============================> ] 56.62MB/94.39MB + d68e4f14dc32 Downloading [==============================> ] 57.67MB/94.39MB + d68e4f14dc32 Downloading [===============================> ] 59.77MB/94.39MB + d68e4f14dc32 Downloading [================================> ] 60.82MB/94.39MB + d68e4f14dc32 Downloading [================================> ] 61.87MB/94.39MB + d68e4f14dc32 Downloading [=================================> ] 62.91MB/94.39MB + d68e4f14dc32 Downloading [=================================> ] 63.96MB/94.39MB + d68e4f14dc32 Downloading [==================================> ] 65.01MB/94.39MB + d68e4f14dc32 Downloading [==================================> ] 66.06MB/94.39MB + d68e4f14dc32 Downloading [==================================> ] 66.06MB/94.39MB + d68e4f14dc32 Downloading [===================================> ] 67.11MB/94.39MB + d68e4f14dc32 Downloading [====================================> ] 68.16MB/94.39MB + d68e4f14dc32 Downloading [====================================> ] 69.21MB/94.39MB + d68e4f14dc32 Downloading [=====================================> ] 71.27MB/94.39MB + d68e4f14dc32 Downloading [======================================> ] 72.35MB/94.39MB + d68e4f14dc32 Downloading [======================================> ] 73.4MB/94.39MB + d68e4f14dc32 Downloading [=======================================> ] 74.45MB/94.39MB + d68e4f14dc32 Downloading [=======================================> ] 75.5MB/94.39MB + d68e4f14dc32 Downloading [=======================================> ] 75.5MB/94.39MB + d68e4f14dc32 Downloading [========================================> ] 76.55MB/94.39MB + d68e4f14dc32 Downloading [=========================================> ] 77.59MB/94.39MB + d68e4f14dc32 Downloading [==========================================> ] 79.69MB/94.39MB + d68e4f14dc32 Downloading [==========================================> ] 80.74MB/94.39MB + d68e4f14dc32 Downloading [===========================================> ] 81.79MB/94.39MB + d68e4f14dc32 Downloading [===========================================> ] 82.84MB/94.39MB + d68e4f14dc32 Downloading [============================================> ] 83.54MB/94.39MB + d68e4f14dc32 Downloading [============================================> ] 84.93MB/94.39MB + d68e4f14dc32 Downloading [============================================> ] 84.93MB/94.39MB + d68e4f14dc32 Downloading [=============================================> ] 85.98MB/94.39MB + d68e4f14dc32 Downloading [=============================================> ] 85.98MB/94.39MB + d68e4f14dc32 Downloading [=============================================> ] 85.98MB/94.39MB + d68e4f14dc32 Downloading [==============================================> ] 88.08MB/94.39MB + d68e4f14dc32 Downloading [==============================================> ] 88.08MB/94.39MB + d68e4f14dc32 Downloading [===============================================> ] 89.13MB/94.39MB + d68e4f14dc32 Downloading [================================================> ] 91.23MB/94.39MB + d68e4f14dc32 Downloading [================================================> ] 91.23MB/94.39MB + d68e4f14dc32 Downloading [================================================> ] 92.27MB/94.39MB + d68e4f14dc32 Downloading [================================================> ] 92.27MB/94.39MB + d68e4f14dc32 Downloading [================================================> ] 92.27MB/94.39MB + d68e4f14dc32 Downloading [==================================================>] 94.39MB/94.39MB + d68e4f14dc32 Downloading [==================================================>] 94.39MB/94.39MB + d68e4f14dc32 Downloading [==================================================>] 94.39MB/94.39MB + d68e4f14dc32 Download complete + d68e4f14dc32 Extracting 1 s + d68e4f14dc32 Extracting 1 s + d68e4f14dc32 Extracting 1 s + d68e4f14dc32 Extracting 1 s + d68e4f14dc32 Extracting 1 s + d68e4f14dc32 Extracting 1 s + d68e4f14dc32 Extracting 1 s + d68e4f14dc32 Extracting 1 s + d68e4f14dc32 Extracting 1 s + d68e4f14dc32 Extracting 1 s + d68e4f14dc32 Extracting 2 s + d68e4f14dc32 Extracting 2 s + d68e4f14dc32 Extracting 2 s + d68e4f14dc32 Extracting 2 s + d68e4f14dc32 Extracting 2 s + d68e4f14dc32 Extracting 2 s + d68e4f14dc32 Extracting 2 s + d68e4f14dc32 Extracting 2 s + d68e4f14dc32 Extracting 2 s + d68e4f14dc32 Extracting 2 s + d68e4f14dc32 Extracting 3 s + d68e4f14dc32 Extracting 3 s + d68e4f14dc32 Extracting 3 s + d68e4f14dc32 Extracting 3 s + d68e4f14dc32 Extracting 3 s + d68e4f14dc32 Extracting 3 s + d68e4f14dc32 Extracting 3 s + d68e4f14dc32 Extracting 3 s + d68e4f14dc32 Extracting 3 s + d68e4f14dc32 Extracting 3 s + d68e4f14dc32 Extracting 4 s + d68e4f14dc32 Extracting 4 s + d68e4f14dc32 Extracting 4 s + d68e4f14dc32 Extracting 4 s + d68e4f14dc32 Extracting 4 s + d68e4f14dc32 Extracting 4 s + d68e4f14dc32 Extracting 4 s + d68e4f14dc32 Extracting 4 s + d68e4f14dc32 Extracting 4 s + d68e4f14dc32 Extracting 4 s + d68e4f14dc32 Extracting 5 s + d68e4f14dc32 Extracting 5 s + d68e4f14dc32 Extracting 5 s + d68e4f14dc32 Extracting 5 s + d68e4f14dc32 Extracting 5 s + d68e4f14dc32 Extracting 5 s + d68e4f14dc32 Extracting 5 s + d68e4f14dc32 Extracting 5 s + b6fcda863f21 Pull complete + 5b2b0e42c692 Pull complete + d68e4f14dc32 Pull complete + 500aaa681781 Pull complete + 09852ea151b6 Pull complete + 754dcd3183db Pull complete + postgres Pulled +Compose can now delegate builds to bake for better performance. + To do so, set COMPOSE_BAKE=true. +#0 building with "desktop-linux" instance using docker driver + +#1 [api internal] load build definition from Dockerfile +#1 transferring dockerfile: 500B 0.0s done +#1 DONE 0.1s + +#2 [api internal] load metadata for docker.io/library/python:3.12.7-slim-bookworm +#2 DONE 3.0s + +#3 [api internal] load .dockerignore +#3 transferring context: 216B done +#3 DONE 0.0s + +#4 [api internal] load build context +#4 DONE 0.0s + +#5 [api 1/6] FROM docker.io/library/python:3.12.7-slim-bookworm@sha256:60d9996b6a8a3689d36db740b49f4327be3be09a21122bd02fb8895abb38b50d +#5 resolve docker.io/library/python:3.12.7-slim-bookworm@sha256:60d9996b6a8a3689d36db740b49f4327be3be09a21122bd02fb8895abb38b50d 0.0s done +#5 DONE 0.0s + +#5 [api 1/6] FROM docker.io/library/python:3.12.7-slim-bookworm@sha256:60d9996b6a8a3689d36db740b49f4327be3be09a21122bd02fb8895abb38b50d +#5 CACHED + +#4 [api internal] load build context +#4 transferring context: 18.27kB 0.0s done +#4 DONE 0.1s + +#6 [api 2/6] WORKDIR /app +#6 DONE 0.3s + +#7 [api 3/6] COPY src/requirements.txt . +#7 DONE 0.0s + +#8 [api 4/6] RUN pip install --no-cache-dir -r requirements.txt +#8 3.470 Collecting starlette==0.41.3 (from -r requirements.txt (line 1)) +#8 4.000 Downloading starlette-0.41.3-py3-none-any.whl.metadata (6.0 kB) +#8 4.333 Collecting uvicorn==0.32.1 (from -r requirements.txt (line 2)) +#8 4.440 Downloading uvicorn-0.32.1-py3-none-any.whl.metadata (6.6 kB) +#8 4.634 Collecting psycopg==3.2.3 (from psycopg[binary,pool]==3.2.3->-r requirements.txt (line 3)) +#8 4.740 Downloading psycopg-3.2.3-py3-none-any.whl.metadata (4.3 kB) +#8 5.137 Collecting argon2-cffi==23.1.0 (from -r requirements.txt (line 4)) +#8 5.244 Downloading argon2_cffi-23.1.0-py3-none-any.whl.metadata (5.2 kB) +#8 5.540 Collecting anyio<5,>=3.4.0 (from starlette==0.41.3->-r requirements.txt (line 1)) +#8 5.647 Downloading anyio-4.16.0-py3-none-any.whl.metadata (4.7 kB) +#8 5.977 Collecting click>=7.0 (from uvicorn==0.32.1->-r requirements.txt (line 2)) +#8 6.083 Downloading click-8.5.1-py3-none-any.whl.metadata (2.6 kB) +#8 6.575 Collecting h11>=0.8 (from uvicorn==0.32.1->-r requirements.txt (line 2)) +#8 6.682 Downloading h11-0.16.0-py3-none-any.whl.metadata (8.3 kB) +#8 7.089 Collecting typing-extensions>=4.6 (from psycopg==3.2.3->psycopg[binary,pool]==3.2.3->-r requirements.txt (line 3)) +#8 7.197 Downloading typing_extensions-4.16.0-py3-none-any.whl.metadata (3.3 kB) +#8 7.436 Collecting argon2-cffi-bindings (from argon2-cffi==23.1.0->-r requirements.txt (line 4)) +#8 7.542 Downloading argon2_cffi_bindings-26.1.0-cp310-abi3-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.metadata (7.5 kB) +#8 12.83 Collecting psycopg-binary==3.2.3 (from psycopg[binary,pool]==3.2.3->-r requirements.txt (line 3)) +#8 12.94 Downloading psycopg_binary-3.2.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (2.8 kB) +#8 13.22 Collecting psycopg-pool (from psycopg[binary,pool]==3.2.3->-r requirements.txt (line 3)) +#8 13.33 Downloading psycopg_pool-3.3.3-py3-none-any.whl.metadata (2.8 kB) +#8 13.63 Collecting idna>=2.8 (from anyio<5,>=3.4.0->starlette==0.41.3->-r requirements.txt (line 1)) +#8 13.73 Downloading idna-3.20-py3-none-any.whl.metadata (7.2 kB) +#8 17.93 Collecting cffi>=1.0.1 (from argon2-cffi-bindings->argon2-cffi==23.1.0->-r requirements.txt (line 4)) +#8 18.50 Downloading cffi-2.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.metadata (2.5 kB) +#8 18.65 Collecting pycparser (from cffi>=1.0.1->argon2-cffi-bindings->argon2-cffi==23.1.0->-r requirements.txt (line 4)) +#8 18.76 Downloading pycparser-3.12-py3-none-any.whl.metadata (9.7 kB) +#8 18.95 Downloading starlette-0.41.3-py3-none-any.whl (73 kB) +#8 19.71 Downloading uvicorn-0.32.1-py3-none-any.whl (63 kB) +#8 20.39 Downloading psycopg-3.2.3-py3-none-any.whl (197 kB) +#8 24.93 Downloading argon2_cffi-23.1.0-py3-none-any.whl (15 kB) +#8 25.35 Downloading psycopg_binary-3.2.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.2 MB) +#8 114.8 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.2/4.2 MB 48.1 kB/s eta 0:00:00 +#8 114.9 Downloading anyio-4.16.0-py3-none-any.whl (134 kB) +#8 116.6 Downloading click-8.5.1-py3-none-any.whl (126 kB) +#8 118.1 Downloading h11-0.16.0-py3-none-any.whl (37 kB) +#8 118.5 Downloading typing_extensions-4.16.0-py3-none-any.whl (45 kB) +#8 119.0 Downloading argon2_cffi_bindings-26.1.0-cp310-abi3-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl (26 kB) +#8 119.3 Downloading psycopg_pool-3.3.3-py3-none-any.whl (40 kB) +#8 119.9 Downloading cffi-2.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (221 kB) +#8 123.5 Downloading idna-3.20-py3-none-any.whl (69 kB) +#8 124.3 Downloading pycparser-3.12-py3-none-any.whl (62 kB) +#8 125.4 Installing collected packages: typing-extensions, pycparser, psycopg-binary, idna, h11, click, uvicorn, psycopg-pool, psycopg, cffi, anyio, starlette, argon2-cffi-bindings, argon2-cffi +#8 126.4 Successfully installed anyio-4.16.0 argon2-cffi-23.1.0 argon2-cffi-bindings-26.1.0 cffi-2.1.1 click-8.5.1 h11-0.16.0 idna-3.20 psycopg-3.2.3 psycopg-binary-3.2.3 psycopg-pool-3.3.3 pycparser-3.12 starlette-0.41.3 typing-extensions-4.16.0 uvicorn-0.32.1 +#8 126.4 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable.It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning. +#8 126.9 +#8 126.9 [notice] A new release of pip is available: 24.2 -> 26.3 +#8 126.9 [notice] To update, run: pip install --upgrade pip +#8 DONE 127.2s + +#9 [api 5/6] COPY src/ . +#9 DONE 0.1s + +#10 [api 6/6] RUN useradd -r -u 10001 appuser +#10 0.477 useradd warning: appuser's uid 10001 is greater than SYS_UID_MAX 999 +#10 DONE 0.5s + +#11 [api] exporting to image +#11 exporting layers +#11 exporting layers 0.9s done +#11 exporting manifest sha256:2e1cc496adb1045607f08bb61ac4f573f784e82fdf62ec3d61e7baaa95bffcc9 0.0s done +#11 exporting config sha256:23ae9e77c4d2fee678bf455531777f07f6d77a0c928ab9092130325030805f1c 0.0s done +#11 exporting attestation manifest sha256:f9af64a0e5f7d2e5fbe8d182bb92bcac260b5cd1b64ddb99ea6be12c6d80a3fb 0.0s done +#11 exporting manifest list sha256:bf04714d16cb9b11addf8ab71caa4754875e7b55ffb419aff89f2e77a63b4248 0.0s done +#11 naming to docker.io/library/mtusi2026lab2-api:latest done +#11 unpacking to docker.io/library/mtusi2026lab2-api:latest +#11 unpacking to docker.io/library/mtusi2026lab2-api:latest 0.4s done +#11 DONE 1.4s + +#12 [api] resolving provenance for metadata file +#12 DONE 0.0s + api Built + Network mtusi2026lab2_default Creating + Network mtusi2026lab2_default Created + Volume "mtusi2026lab2_pgdata" Creating + Volume "mtusi2026lab2_pgdata" Created + Container mtusi2026lab2-postgres-1 Creating + Container mtusi2026lab2-postgres-1 Created + Container mtusi2026lab2-api-1 Creating + Container mtusi2026lab2-api-1 Created + Container mtusi2026lab2-postgres-1 Starting + Container mtusi2026lab2-postgres-1 Started + Container mtusi2026lab2-postgres-1 Waiting + Container mtusi2026lab2-postgres-1 Healthy + Container mtusi2026lab2-api-1 Starting + Container mtusi2026lab2-api-1 Started +ready через 164 с после запуска up diff --git a/evidence/01-env.txt b/evidence/01-env.txt new file mode 100644 index 00000000..90bf72e6 --- /dev/null +++ b/evidence/01-env.txt @@ -0,0 +1,37 @@ +# 01 окружение (2026-11-12T18:52:34Z) +commit: ac54d4cfde5fa2876fdfedf55fd7d5840c33cdac +git status: +?? evidence/00-clean-start.txt +?? evidence/01-env.txt +?? evidence/02-smoke.txt +?? evidence/03-student-checks.txt +?? evidence/04-persistence.txt +?? evidence/05-db-schema.txt +?? evidence/06-migrations.txt +?? evidence/07-ttl.txt +?? evidence/08-db-down.txt +?? evidence/09-git-hygiene.txt +?? evidence/summary.txt +$ docker version +client=28.0.4 server=28.0.4 os=linux/amd64 +$ docker compose version +Docker Compose version v2.34.0-desktop.1 +python: Python 3.11.5 +$ docker compose config --quiet +compose config: OK +$ docker compose images +CONTAINER REPOSITORY TAG IMAGE ID SIZE +mtusi2026lab2-api-1 mtusi2026lab2-api latest bf04714d16cb 52.1MB +mtusi2026lab2-postgres-1 postgres 16.4-alpine 5660c2cbfea5 99.2MB +$ docker compose ps +NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS +mtusi2026lab2-api-1 mtusi2026lab2-api "uvicorn app.main:ap…" api 44 minutes ago Up 44 minutes (healthy) 127.0.0.1:8080->8080/tcp +mtusi2026lab2-postgres-1 postgres:16.4-alpine "docker-entrypoint.s…" postgres 45 minutes ago Up 44 minutes (healthy) 5432/tcp +$ docker volume ls (pgdata) +local mtusi2026lab2_pgdata +$ docker stats --no-stream +NAME CPU % MEM USAGE / LIMIT +mtusi2026lab2-api-1 0.16% 35.07MiB / 7.694GiB +mtusi2026lab2-postgres-1 0.00% 22.8MiB / 7.694GiB +$ docker info (лимиты хоста) +CPUs=16 Mem=8261029888 diff --git a/evidence/02-smoke.txt b/evidence/02-smoke.txt new file mode 100644 index 00000000..76c0fbaa --- /dev/null +++ b/evidence/02-smoke.txt @@ -0,0 +1,7 @@ +# 02 публичные проверки (2026-11-12T18:52:39Z) +$ python scripts/check_contract.py +PASS: offline skeleton structure, local refs and Python syntax; application NOT tested. +exit code: 0 +$ python tests/smoke.py --base-url http://localhost:8080 +PASS: lab2 public API scenario; infrastructure and grading evidence remain separate. +exit code: 0 diff --git a/evidence/03-student-checks.txt b/evidence/03-student-checks.txt new file mode 100644 index 00000000..7f830827 --- /dev/null +++ b/evidence/03-student-checks.txt @@ -0,0 +1,44 @@ +# 03 собственные проверки (2026-11-12T18:52:41Z) +$ python student-tests/lab2_checks.py --base-url http://localhost:8080 +PASS: повторный username -> 409 +PASS: пароль короче 12 -> 400 +PASS: лишнее поле -> 400 +PASS: User не содержит пароль/hash/токен +PASS: гонка одинакового username: ровно один 201, остальные 409 +PASS: неверный пароль и неизвестный пользователь неразличимы (401, тот же code/message/заголовок) +PASS: вход JSON-телом без Basic -> 401 +PASS: Bearer на POST /auth/sessions -> 401 +PASS: токен >=256 бит, token_type Bearer +PASS: Basic на бизнес-endpoint -> 401 + WWW-Authenticate: Bearer +PASS: один X-User-Id доступа не даёт +PASS: X-User-Id игнорируется: владелец определяется токеном +PASS: неизвестный токен -> 401 +PASS: X-Request-Id совпадает с request_id в теле ошибки +PASS: чат с неизвестным участником -> 400 +PASS: после отказа новый чат не появился (нет частичной записи) +PASS: чат создан с обоими участниками +PASS: создатель обязан быть среди member_ids -> 400 +PASS: посторонний: GET /chat -> 404 +PASS: посторонний: GET /messages -> 404 +PASS: посторонний не может писать -> 404 +PASS: неверный UUID /chats/not-a-uuid -> 400 +PASS: неверный UUID /chats/not-a-uuid/messages -> 400 +PASS: sender_id в запросе не принимается -> 400 +PASS: пробельный текст -> 400 +PASS: отправитель берётся из токена +PASS: пагинация limit=2: без повторов, все 6 сообщений +PASS: cursor от другого чата -> 400 +PASS: ?limit=0 -> 400 +PASS: ?limit=101 -> 400 +PASS: ?limit=abc -> 400 +PASS: ?limit=%2B5 -> 400 +PASS: ?limit=2&limit=3 -> 400 +PASS: тело >1 MiB -> 413 +PASS: не JSON Content-Type -> 415 +PASS: битый JSON -> 400 +PASS: logout -> 204 +PASS: повторный logout с отозванным токеном -> 401 +PASS: отозванный токен -> 401 + WWW-Authenticate: Bearer +PASS: logout одного пользователя не затрагивает чужие сессии +PASS: все проверки режима 'main' +exit code: 0 diff --git a/evidence/04-persistence.txt b/evidence/04-persistence.txt new file mode 100644 index 00000000..331e57f3 --- /dev/null +++ b/evidence/04-persistence.txt @@ -0,0 +1,29 @@ +# 04 сохранность при рестарте API и PostgreSQL (2026-11-12T18:52:43Z) +--- до +/mtusi2026lab2-api-1 StartedAt=2026-11-12T18:08:09.637929997Z RestartCount=0 +/mtusi2026lab2-postgres-1 StartedAt=2026-11-12T18:08:14.311138792Z RestartCount=0 +NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS +mtusi2026lab2-api-1 mtusi2026lab2-api "uvicorn app.main:ap…" api 44 minutes ago Up 44 minutes (healthy) 127.0.0.1:8080->8080/tcp +mtusi2026lab2-postgres-1 postgres:16.4-alpine "docker-entrypoint.s…" postgres 45 minutes ago Up 44 minutes (healthy) 5432/tcp +$ python tests/resilience.py --mode persistence --action-script scripts/restart.cmd +Executing explicit persistence hook; hook output suppressed to avoid leaking secrets. +PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence. +exit code: 0 +--- после (StartedAt должен измениться у обоих контейнеров) +/mtusi2026lab2-api-1 StartedAt=2026-11-12T18:52:47.887609866Z RestartCount=0 +/mtusi2026lab2-postgres-1 StartedAt=2026-11-12T18:52:46.134830386Z RestartCount=0 +NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS +mtusi2026lab2-api-1 mtusi2026lab2-api "uvicorn app.main:ap…" api 44 minutes ago Up 2 seconds (health: starting) 127.0.0.1:8080->8080/tcp +mtusi2026lab2-postgres-1 postgres:16.4-alpine "docker-entrypoint.s…" postgres 45 minutes ago Up 3 seconds (healthy) 5432/tcp +--- время восстановления одного рестарта (hook + ожидание /health/ready) + Container mtusi2026lab2-postgres-1 Restarting + Container mtusi2026lab2-postgres-1 Started + Container mtusi2026lab2-api-1 Restarting + Container mtusi2026lab2-api-1 Started +готов через 4 с +--- проверка сохранности данных в БД после рестарта + users | chats | messages | sessions +-------+-------+----------+---------- + 21 | 8 | 18 | 22 +(1 row) + diff --git a/evidence/05-db-schema.txt b/evidence/05-db-schema.txt new file mode 100644 index 00000000..1bd6de00 --- /dev/null +++ b/evidence/05-db-schema.txt @@ -0,0 +1,109 @@ +# 05 схема БД (2026-11-12T18:52:54Z) + version | applied_at +--------------+------------------------------ + 001_init.sql | 2026-11-12 18:07:29.27036+00 +(1 row) + + List of relations + Schema | Name | Type | Owner +--------+-------------------+-------+------- + public | chat_members | table | msg + public | chats | table | msg + public | messages | table | msg + public | schema_migrations | table | msg + public | sessions | table | msg + public | users | table | msg +(6 rows) + + Table "public.users" + Column | Type | Collation | Nullable | Default +---------------+--------------------------+-----------+----------+--------- + id | uuid | | not null | + username | text | | not null | + display_name | text | | not null | + password_hash | text | | not null | + created_at | timestamp with time zone | | not null | now() +Indexes: + "users_pkey" PRIMARY KEY, btree (id) + "users_username_key" UNIQUE CONSTRAINT, btree (username) +Check constraints: + "users_display_name_check" CHECK (char_length(display_name) >= 1 AND char_length(display_name) <= 100) + "users_username_check" CHECK (username ~ '^[a-z0-9_]{3,32}$'::text) +Referenced by: + TABLE "chat_members" CONSTRAINT "chat_members_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) + TABLE "messages" CONSTRAINT "messages_sender_id_fkey" FOREIGN KEY (sender_id) REFERENCES users(id) + TABLE "sessions" CONSTRAINT "sessions_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) + + Table "public.chats" + Column | Type | Collation | Nullable | Default +------------+--------------------------+-----------+----------+------------------- + id | uuid | | not null | + title | text | | not null | + created_at | timestamp with time zone | | not null | clock_timestamp() +Indexes: + "chats_pkey" PRIMARY KEY, btree (id) + "chats_created_idx" btree (created_at, id) +Check constraints: + "chats_title_check" CHECK (char_length(title) >= 1 AND char_length(title) <= 100) +Referenced by: + TABLE "chat_members" CONSTRAINT "chat_members_chat_id_fkey" FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE + TABLE "messages" CONSTRAINT "messages_chat_id_fkey" FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE + + Table "public.chat_members" + Column | Type | Collation | Nullable | Default +---------+------+-----------+----------+--------- + chat_id | uuid | | not null | + user_id | uuid | | not null | +Indexes: + "chat_members_pkey" PRIMARY KEY, btree (chat_id, user_id) + "chat_members_user_idx" btree (user_id, chat_id) +Foreign-key constraints: + "chat_members_chat_id_fkey" FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE + "chat_members_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) + + Table "public.messages" + Column | Type | Collation | Nullable | Default +------------+--------------------------+-----------+----------+------------------- + id | uuid | | not null | + chat_id | uuid | | not null | + sender_id | uuid | | not null | + text | text | | not null | + created_at | timestamp with time zone | | not null | clock_timestamp() +Indexes: + "messages_pkey" PRIMARY KEY, btree (id) + "messages_history_idx" btree (chat_id, created_at, id) +Check constraints: + "messages_text_check" CHECK (char_length(text) >= 1 AND char_length(text) <= 4000) +Foreign-key constraints: + "messages_chat_id_fkey" FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE + "messages_sender_id_fkey" FOREIGN KEY (sender_id) REFERENCES users(id) + + Table "public.sessions" + Column | Type | Collation | Nullable | Default +------------+--------------------------+-----------+----------+--------- + token_hash | bytea | | not null | + user_id | uuid | | not null | + expires_at | timestamp with time zone | | not null | + revoked_at | timestamp with time zone | | | +Indexes: + "sessions_pkey" PRIMARY KEY, btree (token_hash) + "sessions_expires_idx" btree (expires_at) +Foreign-key constraints: + "sessions_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) + +--- пароли хранятся как Argon2id + hash_prefix | count +-------------+------- + $argon2id$ | 21 +(1 row) + +--- в sessions только sha256 токена (32 байта), не сам токен + token_hash_bytes | count +------------------+------- + 32 | 22 +(1 row) + +--- volume с данными PostgreSQL +volume mtusi2026lab2_pgdata -> /var/lib/postgresql/data +bind -> /run/secrets/pg_password + diff --git a/evidence/06-migrations.txt b/evidence/06-migrations.txt new file mode 100644 index 00000000..abbbdb82 --- /dev/null +++ b/evidence/06-migrations.txt @@ -0,0 +1,30 @@ +# 06 повторный запуск миграций (2026-11-12T18:52:58Z) +--- до + version +-------------- + 001_init.sql +(1 row) + + users | messages +-------+---------- + 21 | 18 +(1 row) + +--- рестарт API (миграции выполняются при старте) + Container mtusi2026lab2-api-1 Restarting + Container mtusi2026lab2-api-1 Started +ready +--- ещё два явных запуска migrate.run внутри контейнера api +migrate.run ok +migrate.run ok +--- после + version +-------------- + 001_init.sql +(1 row) + + users | messages +-------+---------- + 21 | 18 +(1 row) + diff --git a/evidence/07-ttl.txt b/evidence/07-ttl.txt new file mode 100644 index 00000000..4ed9c1ba --- /dev/null +++ b/evidence/07-ttl.txt @@ -0,0 +1,23 @@ +# 07 истечение сессии при SESSION_TTL_SECONDS=2 (2026-11-12T18:53:04Z) +$ SESSION_TTL_SECONDS=2 docker compose up -d api + Container mtusi2026lab2-postgres-1 Running + Container mtusi2026lab2-api-1 Recreate + Container mtusi2026lab2-api-1 Recreated + Container mtusi2026lab2-postgres-1 Waiting + Container mtusi2026lab2-postgres-1 Healthy + Container mtusi2026lab2-api-1 Starting + Container mtusi2026lab2-api-1 Started +ready (TTL=2) +PASS: TTL: сразу после входа токен действует (200) +PASS: TTL: через 3.5 с при SESSION_TTL_SECONDS=2 токен истёк (401) +PASS: все проверки режима 'ttl' +exit code: 0 +--- возврат к TTL по умолчанию + Container mtusi2026lab2-postgres-1 Running + Container mtusi2026lab2-api-1 Recreate + Container mtusi2026lab2-api-1 Recreated + Container mtusi2026lab2-postgres-1 Waiting + Container mtusi2026lab2-postgres-1 Healthy + Container mtusi2026lab2-api-1 Starting + Container mtusi2026lab2-api-1 Started +ready (TTL по умолчанию) diff --git a/evidence/08-db-down.txt b/evidence/08-db-down.txt new file mode 100644 index 00000000..b732a2a8 --- /dev/null +++ b/evidence/08-db-down.txt @@ -0,0 +1,14 @@ +# 08 недоступность PostgreSQL (2026-11-12T18:53:15Z) +$ docker compose stop postgres + Container mtusi2026lab2-postgres-1 Stopping + Container mtusi2026lab2-postgres-1 Stopped +GET /health/live -> 200 +GET /health/ready -> {"error":{"code":"unavailable","message":"Сервис временно недоступен","request_id":"9c380c3a7b7b4c8fa3033cdbf0e35f5b"}} 503 +GET /api/v1/users/me (анонимный токен) -> {"error":{"code":"unavailable","message":"Сервис временно недоступен","request_id":"ac5c64206e424174a5e3c2d1c1e41eae"}} 503 +$ docker compose start postgres + Container mtusi2026lab2-postgres-1 Starting + Container mtusi2026lab2-postgres-1 Started +ready снова через 2 с (без рестарта API) +NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS +mtusi2026lab2-api-1 mtusi2026lab2-api "uvicorn app.main:ap…" api 8 seconds ago Up 6 seconds (healthy) 127.0.0.1:8080->8080/tcp +mtusi2026lab2-postgres-1 postgres:16.4-alpine "docker-entrypoint.s…" postgres 45 minutes ago Up 1 second (health: starting) 5432/tcp diff --git a/evidence/09-git-hygiene.txt b/evidence/09-git-hygiene.txt new file mode 100644 index 00000000..96c5133b --- /dev/null +++ b/evidence/09-git-hygiene.txt @@ -0,0 +1,7 @@ +# 09 секреты и volumes вне Git (2026-11-12T18:53:20Z) +$ git check-ignore -v secrets/pg_password secrets/database_url .env +.gitignore:35:secrets/ secrets/pg_password +.gitignore:35:secrets/ secrets/database_url +.gitignore:36:.env .env +$ отслеживаемые файлы, похожие на секреты: +нет diff --git a/evidence/summary.txt b/evidence/summary.txt new file mode 100644 index 00000000..2c2d0c6c --- /dev/null +++ b/evidence/summary.txt @@ -0,0 +1,669 @@ +# Сводка сбора доказательств (2026-11-12T18:53:20Z) + +01 окружение -> evidence/01-env.txt +02 smoke -> evidence/02-smoke.txt: 1 PASS-строк smoke +03 собственные -> evidence/03-student-checks.txt: PASS: все проверки режима 'main' +04 persistence -> evidence/04-persistence.txt: PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence. +05 схема БД -> evidence/05-db-schema.txt +06 миграции повторно -> evidence/06-migrations.txt +07 TTL -> evidence/07-ttl.txt: PASS: все проверки режима 'ttl' +08 БД недоступна -> evidence/08-db-down.txt +09 git hygiene -> evidence/09-git-hygiene.txt + + +=================== evidence/00-clean-start.txt +# 00 чистый старт (2026-11-12T18:04:45Z) +$ docker compose down -v + Volume mtusi2026lab2_pgdata Removing + Volume mtusi2026lab2_pgdata Removed +$ sh scripts/setup-secrets.sh +secrets: ok (значения не печатаются) +$ docker compose up -d --build + postgres Pulling + 500aaa681781 Pulling fs layer + 6886cb0fa181 Pulling fs layer + 09852ea151b6 Pulling fs layer + 3c23ffc3610d Pulling fs layer + da9db072f522 Pulling fs layer + 7c35d0b2112f Pulling fs layer + 754dcd3183db Pulling fs layer + 5b2b0e42c692 Pulling fs layer + d68e4f14dc32 Pulling fs layer + b6fcda863f21 Pulling fs layer + 4f90fd4705e0 Pulling fs layer + 6886cb0fa181 Download complete + 500aaa681781 Download complete + 754dcd3183db Downloading [==================================================>] 5.416kB/5.416kB + b6fcda863f21 Download complete + 7c35d0b2112f Download complete + 5b2b0e42c692 Download complete + 09852ea151b6 Download complete + 4f90fd4705e0 Download complete + 754dcd3183db Download complete + 3c23ffc3610d Download complete + d68e4f14dc32 Downloading [> ] 1.049MB/94.39MB + da9db072f522 Downloading [==============> ] 1.049MB/3.624MB + d68e4f14dc32 Downloading [> ] 1.049MB/94.39MB + da9db072f522 Downloading [==============> ] 1.049MB/3.624MB + d68e4f14dc32 Downloading [> ] 1.049MB/94.39MB + da9db072f522 Downloading [==============> ] 1.049MB/3.624MB + d68e4f14dc32 Downloading [=> ] 2.097MB/94.39MB + d68e4f14dc32 Downloading [=> ] 2.097MB/94.39MB + da9db072f522 Downloading [==============> ] 1.049MB/3.624MB + d68e4f14dc32 Downloading [=> ] 3.146MB/94.39MB + da9db072f522 Downloading [============================> ] 2.097MB/3.624MB + d68e4f14dc32 Downloading [=> ] 3.146MB/94.39MB + da9db072f522 Downloading [===========================================> ] 3.146MB/3.624MB + d68e4f14dc32 Downloading [==> ] 4.194MB/94.39MB + da9db072f522 Download complete + da9db072f522 Extracting 1 s + d68e4f14dc32 Downloading [==> ] 4.194MB/94.39MB + da9db072f522 Extracting 1 s + d68e4f14dc32 Downloading [==> ] 4.194MB/94.39MB + da9db072f522 Pull complete + d68e4f14dc32 Downloading [==> ] 5.243MB/94.39MB + 7c35d0b2112f Extracting 1 s + d68e4f14dc32 Downloading [===> ] 6.291MB/94.39MB + 7c35d0b2112f Pull complete + 3c23ffc3610d Pull complete + d68e4f14dc32 Downloading [===> ] 6.291MB/94.39MB + 6886cb0fa181 Pull complete + 4f90fd4705e0 Pull complete + d68e4f14dc32 Downloading [===> ] 7.34MB/94.39MB + d68e4f14dc32 Downloading [====> ] 8.389MB/94.39MB + d68e4f14dc32 Downloading [====> ] 8.389MB/94.39MB + d68e4f14dc32 Downloading [====> ] 9.437MB/94.39MB + d68e4f14dc32 Downloading [=====> ] 10.49MB/94.39MB + d68e4f14dc32 Downloading [=====> ] 10.49MB/94.39MB + d68e4f14dc32 Downloading [=====> ] 10.49MB/94.39MB + d68e4f14dc32 Downloading [======> ] 11.53MB/94.39MB + d68e4f14dc32 Downloading [======> ] 12.58MB/94.39MB + d68e4f14dc32 Downloading [======> ] 12.58MB/94.39MB + d68e4f14dc32 Downloading [=======> ] 13.63MB/94.39MB + d68e4f14dc32 Downloading [=======> ] 14.02MB/94.39MB + d68e4f14dc32 Downloading [=======> ] 14.68MB/94.39MB + d68e4f14dc32 Downloading [========> ] 15.27MB/94.39MB + d68e4f14dc32 Downloading [========> ] 16.36MB/94.39MB + d68e4f14dc32 Downloading [========> ] 16.78MB/94.39MB + d68e4f14dc32 Downloading [=========> ] 17.83MB/94.39MB + d68e4f14dc32 Downloading [=========> ] 17.83MB/94.39MB + d68e4f14dc32 Downloading [=========> ] 17.83MB/94.39MB + d68e4f14dc32 Downloading [=========> ] 18.87MB/94.39MB + d68e4f14dc32 Downloading [==========> ] 19.92MB/94.39MB + d68e4f14dc32 Downloading [===========> ] 20.97MB/94.39MB + d68e4f14dc32 Downloading [===========> ] 22.02MB/94.39MB + d68e4f14dc32 Downloading [===========> ] 22.02MB/94.39MB + d68e4f14dc32 Downloading [============> ] 23.07MB/94.39MB + d68e4f14dc32 Downloading [============> ] 24.12MB/94.39MB + d68e4f14dc32 Downloading [=============> ] 25.17MB/94.39MB + d68e4f14dc32 Downloading [=============> ] 26.21MB/94.39MB + d68e4f14dc32 Downloading [=============> ] 26.21MB/94.39MB + d68e4f14dc32 Downloading [==============> ] 27.26MB/94.39MB + d68e4f14dc32 Downloading [===============> ] 29.36MB/94.39MB + d68e4f14dc32 Downloading [===============> ] 29.36MB/94.39MB + d68e4f14dc32 Downloading [================> ] 30.41MB/94.39MB + d68e4f14dc32 Downloading [================> ] 31.46MB/94.39MB + d68e4f14dc32 Downloading [=================> ] 32.51MB/94.39MB + d68e4f14dc32 Downloading [=================> ] 33.55MB/94.39MB + d68e4f14dc32 Downloading [=================> ] 33.55MB/94.39MB + d68e4f14dc32 Downloading [==================> ] 34.6MB/94.39MB + d68e4f14dc32 Downloading [==================> ] 35.65MB/94.39MB + d68e4f14dc32 Downloading [===================> ] 37.75MB/94.39MB + d68e4f14dc32 Downloading [====================> ] 38.8MB/94.39MB + d68e4f14dc32 Downloading [=====================> ] 39.85MB/94.39MB + d68e4f14dc32 Downloading [=====================> ] 39.85MB/94.39MB + d68e4f14dc32 Downloading [======================> ] 41.94MB/94.39MB + d68e4f14dc32 Downloading [======================> ] 42.99MB/94.39MB + d68e4f14dc32 Downloading [======================> ] 42.99MB/94.39MB + d68e4f14dc32 Downloading [=======================> ] 45.09MB/94.39MB + d68e4f14dc32 Downloading [=======================> ] 45.09MB/94.39MB + d68e4f14dc32 Downloading [========================> ] 45.65MB/94.39MB + d68e4f14dc32 Downloading [========================> ] 47.19MB/94.39MB + d68e4f14dc32 Downloading [==========================> ] 49.28MB/94.39MB + d68e4f14dc32 Downloading [==========================> ] 50.33MB/94.39MB + d68e4f14dc32 Downloading [==========================> ] 50.33MB/94.39MB + d68e4f14dc32 Downloading [===========================> ] 52.43MB/94.39MB + d68e4f14dc32 Downloading [============================> ] 53.48MB/94.39MB + d68e4f14dc32 Downloading [============================> ] 54.53MB/94.39MB + d68e4f14dc32 Downloading [=============================> ] 55.57MB/94.39MB + d68e4f14dc32 Downloading [=============================> ] 56.62MB/94.39MB + d68e4f14dc32 Downloading [=============================> ] 56.62MB/94.39MB + d68e4f14dc32 Downloading [==============================> ] 57.67MB/94.39MB + d68e4f14dc32 Downloading [===============================> ] 59.77MB/94.39MB + d68e4f14dc32 Downloading [================================> ] 60.82MB/94.39MB + d68e4f14dc32 Downloading [================================> ] 61.87MB/94.39MB + d68e4f14dc32 Downloading [=================================> ] 62.91MB/94.39MB + d68e4f14dc32 Downloading [=================================> ] 63.96MB/94.39MB + d68e4f14dc32 Downloading [==================================> ] 65.01MB/94.39MB + d68e4f14dc32 Downloading [==================================> ] 66.06MB/94.39MB + d68e4f14dc32 Downloading [==================================> ] 66.06MB/94.39MB + d68e4f14dc32 Downloading [===================================> ] 67.11MB/94.39MB + d68e4f14dc32 Downloading [====================================> ] 68.16MB/94.39MB + d68e4f14dc32 Downloading [====================================> ] 69.21MB/94.39MB + d68e4f14dc32 Downloading [=====================================> ] 71.27MB/94.39MB + d68e4f14dc32 Downloading [======================================> ] 72.35MB/94.39MB + d68e4f14dc32 Downloading [======================================> ] 73.4MB/94.39MB + d68e4f14dc32 Downloading [=======================================> ] 74.45MB/94.39MB + d68e4f14dc32 Downloading [=======================================> ] 75.5MB/94.39MB + d68e4f14dc32 Downloading [=======================================> ] 75.5MB/94.39MB + d68e4f14dc32 Downloading [========================================> ] 76.55MB/94.39MB + d68e4f14dc32 Downloading [=========================================> ] 77.59MB/94.39MB + d68e4f14dc32 Downloading [==========================================> ] 79.69MB/94.39MB + d68e4f14dc32 Downloading [==========================================> ] 80.74MB/94.39MB + d68e4f14dc32 Downloading [===========================================> ] 81.79MB/94.39MB + d68e4f14dc32 Downloading [===========================================> ] 82.84MB/94.39MB + d68e4f14dc32 Downloading [============================================> ] 83.54MB/94.39MB + d68e4f14dc32 Downloading [============================================> ] 84.93MB/94.39MB + d68e4f14dc32 Downloading [============================================> ] 84.93MB/94.39MB + d68e4f14dc32 Downloading [=============================================> ] 85.98MB/94.39MB + d68e4f14dc32 Downloading [=============================================> ] 85.98MB/94.39MB + d68e4f14dc32 Downloading [=============================================> ] 85.98MB/94.39MB + d68e4f14dc32 Downloading [==============================================> ] 88.08MB/94.39MB + d68e4f14dc32 Downloading [==============================================> ] 88.08MB/94.39MB + d68e4f14dc32 Downloading [===============================================> ] 89.13MB/94.39MB + d68e4f14dc32 Downloading [================================================> ] 91.23MB/94.39MB + d68e4f14dc32 Downloading [================================================> ] 91.23MB/94.39MB + d68e4f14dc32 Downloading [================================================> ] 92.27MB/94.39MB + d68e4f14dc32 Downloading [================================================> ] 92.27MB/94.39MB + d68e4f14dc32 Downloading [================================================> ] 92.27MB/94.39MB + d68e4f14dc32 Downloading [==================================================>] 94.39MB/94.39MB + d68e4f14dc32 Downloading [==================================================>] 94.39MB/94.39MB + d68e4f14dc32 Downloading [==================================================>] 94.39MB/94.39MB + d68e4f14dc32 Download complete + d68e4f14dc32 Extracting 1 s + d68e4f14dc32 Extracting 1 s + d68e4f14dc32 Extracting 1 s + d68e4f14dc32 Extracting 1 s + d68e4f14dc32 Extracting 1 s + d68e4f14dc32 Extracting 1 s + d68e4f14dc32 Extracting 1 s + d68e4f14dc32 Extracting 1 s + d68e4f14dc32 Extracting 1 s + d68e4f14dc32 Extracting 1 s + d68e4f14dc32 Extracting 2 s + d68e4f14dc32 Extracting 2 s + d68e4f14dc32 Extracting 2 s + d68e4f14dc32 Extracting 2 s + d68e4f14dc32 Extracting 2 s + d68e4f14dc32 Extracting 2 s + d68e4f14dc32 Extracting 2 s + d68e4f14dc32 Extracting 2 s + d68e4f14dc32 Extracting 2 s + d68e4f14dc32 Extracting 2 s + d68e4f14dc32 Extracting 3 s + d68e4f14dc32 Extracting 3 s + d68e4f14dc32 Extracting 3 s + d68e4f14dc32 Extracting 3 s + d68e4f14dc32 Extracting 3 s + d68e4f14dc32 Extracting 3 s + d68e4f14dc32 Extracting 3 s + d68e4f14dc32 Extracting 3 s + d68e4f14dc32 Extracting 3 s + d68e4f14dc32 Extracting 3 s + d68e4f14dc32 Extracting 4 s + d68e4f14dc32 Extracting 4 s + d68e4f14dc32 Extracting 4 s + d68e4f14dc32 Extracting 4 s + d68e4f14dc32 Extracting 4 s + d68e4f14dc32 Extracting 4 s + d68e4f14dc32 Extracting 4 s + d68e4f14dc32 Extracting 4 s + d68e4f14dc32 Extracting 4 s + d68e4f14dc32 Extracting 4 s + d68e4f14dc32 Extracting 5 s + d68e4f14dc32 Extracting 5 s + d68e4f14dc32 Extracting 5 s + d68e4f14dc32 Extracting 5 s + d68e4f14dc32 Extracting 5 s + d68e4f14dc32 Extracting 5 s + d68e4f14dc32 Extracting 5 s + d68e4f14dc32 Extracting 5 s + b6fcda863f21 Pull complete + 5b2b0e42c692 Pull complete + d68e4f14dc32 Pull complete + 500aaa681781 Pull complete + 09852ea151b6 Pull complete + 754dcd3183db Pull complete + postgres Pulled +Compose can now delegate builds to bake for better performance. + To do so, set COMPOSE_BAKE=true. +#0 building with "desktop-linux" instance using docker driver + +#1 [api internal] load build definition from Dockerfile +#1 transferring dockerfile: 500B 0.0s done +#1 DONE 0.1s + +#2 [api internal] load metadata for docker.io/library/python:3.12.7-slim-bookworm +#2 DONE 3.0s + +#3 [api internal] load .dockerignore +#3 transferring context: 216B done +#3 DONE 0.0s + +#4 [api internal] load build context +#4 DONE 0.0s + +#5 [api 1/6] FROM docker.io/library/python:3.12.7-slim-bookworm@sha256:60d9996b6a8a3689d36db740b49f4327be3be09a21122bd02fb8895abb38b50d +#5 resolve docker.io/library/python:3.12.7-slim-bookworm@sha256:60d9996b6a8a3689d36db740b49f4327be3be09a21122bd02fb8895abb38b50d 0.0s done +#5 DONE 0.0s + +#5 [api 1/6] FROM docker.io/library/python:3.12.7-slim-bookworm@sha256:60d9996b6a8a3689d36db740b49f4327be3be09a21122bd02fb8895abb38b50d +#5 CACHED + +#4 [api internal] load build context +#4 transferring context: 18.27kB 0.0s done +#4 DONE 0.1s + +#6 [api 2/6] WORKDIR /app +#6 DONE 0.3s + +#7 [api 3/6] COPY src/requirements.txt . +#7 DONE 0.0s + +#8 [api 4/6] RUN pip install --no-cache-dir -r requirements.txt +#8 3.470 Collecting starlette==0.41.3 (from -r requirements.txt (line 1)) +#8 4.000 Downloading starlette-0.41.3-py3-none-any.whl.metadata (6.0 kB) +#8 4.333 Collecting uvicorn==0.32.1 (from -r requirements.txt (line 2)) +#8 4.440 Downloading uvicorn-0.32.1-py3-none-any.whl.metadata (6.6 kB) +#8 4.634 Collecting psycopg==3.2.3 (from psycopg[binary,pool]==3.2.3->-r requirements.txt (line 3)) +#8 4.740 Downloading psycopg-3.2.3-py3-none-any.whl.metadata (4.3 kB) +#8 5.137 Collecting argon2-cffi==23.1.0 (from -r requirements.txt (line 4)) +#8 5.244 Downloading argon2_cffi-23.1.0-py3-none-any.whl.metadata (5.2 kB) +#8 5.540 Collecting anyio<5,>=3.4.0 (from starlette==0.41.3->-r requirements.txt (line 1)) +#8 5.647 Downloading anyio-4.16.0-py3-none-any.whl.metadata (4.7 kB) +#8 5.977 Collecting click>=7.0 (from uvicorn==0.32.1->-r requirements.txt (line 2)) +#8 6.083 Downloading click-8.5.1-py3-none-any.whl.metadata (2.6 kB) +#8 6.575 Collecting h11>=0.8 (from uvicorn==0.32.1->-r requirements.txt (line 2)) +#8 6.682 Downloading h11-0.16.0-py3-none-any.whl.metadata (8.3 kB) +#8 7.089 Collecting typing-extensions>=4.6 (from psycopg==3.2.3->psycopg[binary,pool]==3.2.3->-r requirements.txt (line 3)) +#8 7.197 Downloading typing_extensions-4.16.0-py3-none-any.whl.metadata (3.3 kB) +#8 7.436 Collecting argon2-cffi-bindings (from argon2-cffi==23.1.0->-r requirements.txt (line 4)) +#8 7.542 Downloading argon2_cffi_bindings-26.1.0-cp310-abi3-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.metadata (7.5 kB) +#8 12.83 Collecting psycopg-binary==3.2.3 (from psycopg[binary,pool]==3.2.3->-r requirements.txt (line 3)) +#8 12.94 Downloading psycopg_binary-3.2.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (2.8 kB) +#8 13.22 Collecting psycopg-pool (from psycopg[binary,pool]==3.2.3->-r requirements.txt (line 3)) +#8 13.33 Downloading psycopg_pool-3.3.3-py3-none-any.whl.metadata (2.8 kB) +#8 13.63 Collecting idna>=2.8 (from anyio<5,>=3.4.0->starlette==0.41.3->-r requirements.txt (line 1)) +#8 13.73 Downloading idna-3.20-py3-none-any.whl.metadata (7.2 kB) +#8 17.93 Collecting cffi>=1.0.1 (from argon2-cffi-bindings->argon2-cffi==23.1.0->-r requirements.txt (line 4)) +#8 18.50 Downloading cffi-2.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.metadata (2.5 kB) +#8 18.65 Collecting pycparser (from cffi>=1.0.1->argon2-cffi-bindings->argon2-cffi==23.1.0->-r requirements.txt (line 4)) +#8 18.76 Downloading pycparser-3.12-py3-none-any.whl.metadata (9.7 kB) +#8 18.95 Downloading starlette-0.41.3-py3-none-any.whl (73 kB) +#8 19.71 Downloading uvicorn-0.32.1-py3-none-any.whl (63 kB) +#8 20.39 Downloading psycopg-3.2.3-py3-none-any.whl (197 kB) +#8 24.93 Downloading argon2_cffi-23.1.0-py3-none-any.whl (15 kB) +#8 25.35 Downloading psycopg_binary-3.2.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.2 MB) +#8 114.8 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.2/4.2 MB 48.1 kB/s eta 0:00:00 +#8 114.9 Downloading anyio-4.16.0-py3-none-any.whl (134 kB) +#8 116.6 Downloading click-8.5.1-py3-none-any.whl (126 kB) +#8 118.1 Downloading h11-0.16.0-py3-none-any.whl (37 kB) +#8 118.5 Downloading typing_extensions-4.16.0-py3-none-any.whl (45 kB) +#8 119.0 Downloading argon2_cffi_bindings-26.1.0-cp310-abi3-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl (26 kB) +#8 119.3 Downloading psycopg_pool-3.3.3-py3-none-any.whl (40 kB) +#8 119.9 Downloading cffi-2.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (221 kB) +#8 123.5 Downloading idna-3.20-py3-none-any.whl (69 kB) +#8 124.3 Downloading pycparser-3.12-py3-none-any.whl (62 kB) +#8 125.4 Installing collected packages: typing-extensions, pycparser, psycopg-binary, idna, h11, click, uvicorn, psycopg-pool, psycopg, cffi, anyio, starlette, argon2-cffi-bindings, argon2-cffi +#8 126.4 Successfully installed anyio-4.16.0 argon2-cffi-23.1.0 argon2-cffi-bindings-26.1.0 cffi-2.1.1 click-8.5.1 h11-0.16.0 idna-3.20 psycopg-3.2.3 psycopg-binary-3.2.3 psycopg-pool-3.3.3 pycparser-3.12 starlette-0.41.3 typing-extensions-4.16.0 uvicorn-0.32.1 +#8 126.4 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable.It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning. +#8 126.9 +#8 126.9 [notice] A new release of pip is available: 24.2 -> 26.3 +#8 126.9 [notice] To update, run: pip install --upgrade pip +#8 DONE 127.2s + +#9 [api 5/6] COPY src/ . +#9 DONE 0.1s + +#10 [api 6/6] RUN useradd -r -u 10001 appuser +#10 0.477 useradd warning: appuser's uid 10001 is greater than SYS_UID_MAX 999 +#10 DONE 0.5s + +#11 [api] exporting to image +#11 exporting layers +#11 exporting layers 0.9s done +#11 exporting manifest sha256:2e1cc496adb1045607f08bb61ac4f573f784e82fdf62ec3d61e7baaa95bffcc9 0.0s done +#11 exporting config sha256:23ae9e77c4d2fee678bf455531777f07f6d77a0c928ab9092130325030805f1c 0.0s done +#11 exporting attestation manifest sha256:f9af64a0e5f7d2e5fbe8d182bb92bcac260b5cd1b64ddb99ea6be12c6d80a3fb 0.0s done +#11 exporting manifest list sha256:bf04714d16cb9b11addf8ab71caa4754875e7b55ffb419aff89f2e77a63b4248 0.0s done +#11 naming to docker.io/library/mtusi2026lab2-api:latest done +#11 unpacking to docker.io/library/mtusi2026lab2-api:latest +#11 unpacking to docker.io/library/mtusi2026lab2-api:latest 0.4s done +#11 DONE 1.4s + +#12 [api] resolving provenance for metadata file +#12 DONE 0.0s + api Built + Network mtusi2026lab2_default Creating + Network mtusi2026lab2_default Created + Volume "mtusi2026lab2_pgdata" Creating + Volume "mtusi2026lab2_pgdata" Created + Container mtusi2026lab2-postgres-1 Creating + Container mtusi2026lab2-postgres-1 Created + Container mtusi2026lab2-api-1 Creating + Container mtusi2026lab2-api-1 Created + Container mtusi2026lab2-postgres-1 Starting + Container mtusi2026lab2-postgres-1 Started + Container mtusi2026lab2-postgres-1 Waiting + Container mtusi2026lab2-postgres-1 Healthy + Container mtusi2026lab2-api-1 Starting + Container mtusi2026lab2-api-1 Started +ready через 164 с после запуска up + +=================== evidence/01-env.txt +# 01 окружение (2026-11-12T18:52:34Z) +commit: ac54d4cfde5fa2876fdfedf55fd7d5840c33cdac +git status: +?? evidence/00-clean-start.txt +?? evidence/01-env.txt +?? evidence/02-smoke.txt +?? evidence/03-student-checks.txt +?? evidence/04-persistence.txt +?? evidence/05-db-schema.txt +?? evidence/06-migrations.txt +?? evidence/07-ttl.txt +?? evidence/08-db-down.txt +?? evidence/09-git-hygiene.txt +?? evidence/summary.txt +$ docker version +client=28.0.4 server=28.0.4 os=linux/amd64 +$ docker compose version +Docker Compose version v2.34.0-desktop.1 +python: Python 3.11.5 +$ docker compose config --quiet +compose config: OK +$ docker compose images +CONTAINER REPOSITORY TAG IMAGE ID SIZE +mtusi2026lab2-api-1 mtusi2026lab2-api latest bf04714d16cb 52.1MB +mtusi2026lab2-postgres-1 postgres 16.4-alpine 5660c2cbfea5 99.2MB +$ docker compose ps +NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS +mtusi2026lab2-api-1 mtusi2026lab2-api "uvicorn app.main:ap…" api 44 minutes ago Up 44 minutes (healthy) 127.0.0.1:8080->8080/tcp +mtusi2026lab2-postgres-1 postgres:16.4-alpine "docker-entrypoint.s…" postgres 45 minutes ago Up 44 minutes (healthy) 5432/tcp +$ docker volume ls (pgdata) +local mtusi2026lab2_pgdata +$ docker stats --no-stream +NAME CPU % MEM USAGE / LIMIT +mtusi2026lab2-api-1 0.16% 35.07MiB / 7.694GiB +mtusi2026lab2-postgres-1 0.00% 22.8MiB / 7.694GiB +$ docker info (лимиты хоста) +CPUs=16 Mem=8261029888 + +=================== evidence/02-smoke.txt +# 02 публичные проверки (2026-11-12T18:52:39Z) +$ python scripts/check_contract.py +PASS: offline skeleton structure, local refs and Python syntax; application NOT tested. +exit code: 0 +$ python tests/smoke.py --base-url http://localhost:8080 +PASS: lab2 public API scenario; infrastructure and grading evidence remain separate. +exit code: 0 + +=================== evidence/03-student-checks.txt +# 03 собственные проверки (2026-11-12T18:52:41Z) +$ python student-tests/lab2_checks.py --base-url http://localhost:8080 +PASS: повторный username -> 409 +PASS: пароль короче 12 -> 400 +PASS: лишнее поле -> 400 +PASS: User не содержит пароль/hash/токен +PASS: гонка одинакового username: ровно один 201, остальные 409 +PASS: неверный пароль и неизвестный пользователь неразличимы (401, тот же code/message/заголовок) +PASS: вход JSON-телом без Basic -> 401 +PASS: Bearer на POST /auth/sessions -> 401 +PASS: токен >=256 бит, token_type Bearer +PASS: Basic на бизнес-endpoint -> 401 + WWW-Authenticate: Bearer +PASS: один X-User-Id доступа не даёт +PASS: X-User-Id игнорируется: владелец определяется токеном +PASS: неизвестный токен -> 401 +PASS: X-Request-Id совпадает с request_id в теле ошибки +PASS: чат с неизвестным участником -> 400 +PASS: после отказа новый чат не появился (нет частичной записи) +PASS: чат создан с обоими участниками +PASS: создатель обязан быть среди member_ids -> 400 +PASS: посторонний: GET /chat -> 404 +PASS: посторонний: GET /messages -> 404 +PASS: посторонний не может писать -> 404 +PASS: неверный UUID /chats/not-a-uuid -> 400 +PASS: неверный UUID /chats/not-a-uuid/messages -> 400 +PASS: sender_id в запросе не принимается -> 400 +PASS: пробельный текст -> 400 +PASS: отправитель берётся из токена +PASS: пагинация limit=2: без повторов, все 6 сообщений +PASS: cursor от другого чата -> 400 +PASS: ?limit=0 -> 400 +PASS: ?limit=101 -> 400 +PASS: ?limit=abc -> 400 +PASS: ?limit=%2B5 -> 400 +PASS: ?limit=2&limit=3 -> 400 +PASS: тело >1 MiB -> 413 +PASS: не JSON Content-Type -> 415 +PASS: битый JSON -> 400 +PASS: logout -> 204 +PASS: повторный logout с отозванным токеном -> 401 +PASS: отозванный токен -> 401 + WWW-Authenticate: Bearer +PASS: logout одного пользователя не затрагивает чужие сессии +PASS: все проверки режима 'main' +exit code: 0 + +=================== evidence/04-persistence.txt +# 04 сохранность при рестарте API и PostgreSQL (2026-11-12T18:52:43Z) +--- до +/mtusi2026lab2-api-1 StartedAt=2026-11-12T18:08:09.637929997Z RestartCount=0 +/mtusi2026lab2-postgres-1 StartedAt=2026-11-12T18:08:14.311138792Z RestartCount=0 +NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS +mtusi2026lab2-api-1 mtusi2026lab2-api "uvicorn app.main:ap…" api 44 minutes ago Up 44 minutes (healthy) 127.0.0.1:8080->8080/tcp +mtusi2026lab2-postgres-1 postgres:16.4-alpine "docker-entrypoint.s…" postgres 45 minutes ago Up 44 minutes (healthy) 5432/tcp +$ python tests/resilience.py --mode persistence --action-script scripts/restart.cmd +Executing explicit persistence hook; hook output suppressed to avoid leaking secrets. +PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence. +exit code: 0 +--- после (StartedAt должен измениться у обоих контейнеров) +/mtusi2026lab2-api-1 StartedAt=2026-11-12T18:52:47.887609866Z RestartCount=0 +/mtusi2026lab2-postgres-1 StartedAt=2026-11-12T18:52:46.134830386Z RestartCount=0 +NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS +mtusi2026lab2-api-1 mtusi2026lab2-api "uvicorn app.main:ap…" api 44 minutes ago Up 2 seconds (health: starting) 127.0.0.1:8080->8080/tcp +mtusi2026lab2-postgres-1 postgres:16.4-alpine "docker-entrypoint.s…" postgres 45 minutes ago Up 3 seconds (healthy) 5432/tcp +--- время восстановления одного рестарта (hook + ожидание /health/ready) + Container mtusi2026lab2-postgres-1 Restarting + Container mtusi2026lab2-postgres-1 Started + Container mtusi2026lab2-api-1 Restarting + Container mtusi2026lab2-api-1 Started +готов через 4 с +--- проверка сохранности данных в БД после рестарта + users | chats | messages | sessions +-------+-------+----------+---------- + 21 | 8 | 18 | 22 +(1 row) + + +=================== evidence/05-db-schema.txt +# 05 схема БД (2026-11-12T18:52:54Z) + version | applied_at +--------------+------------------------------ + 001_init.sql | 2026-11-12 18:07:29.27036+00 +(1 row) + + List of relations + Schema | Name | Type | Owner +--------+-------------------+-------+------- + public | chat_members | table | msg + public | chats | table | msg + public | messages | table | msg + public | schema_migrations | table | msg + public | sessions | table | msg + public | users | table | msg +(6 rows) + + Table "public.users" + Column | Type | Collation | Nullable | Default +---------------+--------------------------+-----------+----------+--------- + id | uuid | | not null | + username | text | | not null | + display_name | text | | not null | + password_hash | text | | not null | + created_at | timestamp with time zone | | not null | now() +Indexes: + "users_pkey" PRIMARY KEY, btree (id) + "users_username_key" UNIQUE CONSTRAINT, btree (username) +Check constraints: + "users_display_name_check" CHECK (char_length(display_name) >= 1 AND char_length(display_name) <= 100) + "users_username_check" CHECK (username ~ '^[a-z0-9_]{3,32}$'::text) +Referenced by: + TABLE "chat_members" CONSTRAINT "chat_members_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) + TABLE "messages" CONSTRAINT "messages_sender_id_fkey" FOREIGN KEY (sender_id) REFERENCES users(id) + TABLE "sessions" CONSTRAINT "sessions_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) + + Table "public.chats" + Column | Type | Collation | Nullable | Default +------------+--------------------------+-----------+----------+------------------- + id | uuid | | not null | + title | text | | not null | + created_at | timestamp with time zone | | not null | clock_timestamp() +Indexes: + "chats_pkey" PRIMARY KEY, btree (id) + "chats_created_idx" btree (created_at, id) +Check constraints: + "chats_title_check" CHECK (char_length(title) >= 1 AND char_length(title) <= 100) +Referenced by: + TABLE "chat_members" CONSTRAINT "chat_members_chat_id_fkey" FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE + TABLE "messages" CONSTRAINT "messages_chat_id_fkey" FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE + + Table "public.chat_members" + Column | Type | Collation | Nullable | Default +---------+------+-----------+----------+--------- + chat_id | uuid | | not null | + user_id | uuid | | not null | +Indexes: + "chat_members_pkey" PRIMARY KEY, btree (chat_id, user_id) + "chat_members_user_idx" btree (user_id, chat_id) +Foreign-key constraints: + "chat_members_chat_id_fkey" FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE + "chat_members_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) + + Table "public.messages" + Column | Type | Collation | Nullable | Default +------------+--------------------------+-----------+----------+------------------- + id | uuid | | not null | + chat_id | uuid | | not null | + sender_id | uuid | | not null | + text | text | | not null | + created_at | timestamp with time zone | | not null | clock_timestamp() +Indexes: + "messages_pkey" PRIMARY KEY, btree (id) + "messages_history_idx" btree (chat_id, created_at, id) +Check constraints: + "messages_text_check" CHECK (char_length(text) >= 1 AND char_length(text) <= 4000) +Foreign-key constraints: + "messages_chat_id_fkey" FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE + "messages_sender_id_fkey" FOREIGN KEY (sender_id) REFERENCES users(id) + + Table "public.sessions" + Column | Type | Collation | Nullable | Default +------------+--------------------------+-----------+----------+--------- + token_hash | bytea | | not null | + user_id | uuid | | not null | + expires_at | timestamp with time zone | | not null | + revoked_at | timestamp with time zone | | | +Indexes: + "sessions_pkey" PRIMARY KEY, btree (token_hash) + "sessions_expires_idx" btree (expires_at) +Foreign-key constraints: + "sessions_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) + +--- пароли хранятся как Argon2id + hash_prefix | count +-------------+------- + $argon2id$ | 21 +(1 row) + +--- в sessions только sha256 токена (32 байта), не сам токен + token_hash_bytes | count +------------------+------- + 32 | 22 +(1 row) + +--- volume с данными PostgreSQL +volume mtusi2026lab2_pgdata -> /var/lib/postgresql/data +bind -> /run/secrets/pg_password + + +=================== evidence/06-migrations.txt +# 06 повторный запуск миграций (2026-11-12T18:52:58Z) +--- до + version +-------------- + 001_init.sql +(1 row) + + users | messages +-------+---------- + 21 | 18 +(1 row) + +--- рестарт API (миграции выполняются при старте) + Container mtusi2026lab2-api-1 Restarting + Container mtusi2026lab2-api-1 Started +ready +--- ещё два явных запуска migrate.run внутри контейнера api +migrate.run ok +migrate.run ok +--- после + version +-------------- + 001_init.sql +(1 row) + + users | messages +-------+---------- + 21 | 18 +(1 row) + + +=================== evidence/07-ttl.txt +# 07 истечение сессии при SESSION_TTL_SECONDS=2 (2026-11-12T18:53:04Z) +$ SESSION_TTL_SECONDS=2 docker compose up -d api + Container mtusi2026lab2-postgres-1 Running + Container mtusi2026lab2-api-1 Recreate + Container mtusi2026lab2-api-1 Recreated + Container mtusi2026lab2-postgres-1 Waiting + Container mtusi2026lab2-postgres-1 Healthy + Container mtusi2026lab2-api-1 Starting + Container mtusi2026lab2-api-1 Started +ready (TTL=2) +PASS: TTL: сразу после входа токен действует (200) +PASS: TTL: через 3.5 с при SESSION_TTL_SECONDS=2 токен истёк (401) +PASS: все проверки режима 'ttl' +exit code: 0 +--- возврат к TTL по умолчанию + Container mtusi2026lab2-postgres-1 Running + Container mtusi2026lab2-api-1 Recreate + Container mtusi2026lab2-api-1 Recreated + Container mtusi2026lab2-postgres-1 Waiting + Container mtusi2026lab2-postgres-1 Healthy + Container mtusi2026lab2-api-1 Starting + Container mtusi2026lab2-api-1 Started +ready (TTL по умолчанию) + +=================== evidence/08-db-down.txt +# 08 недоступность PostgreSQL (2026-11-12T18:53:15Z) +$ docker compose stop postgres + Container mtusi2026lab2-postgres-1 Stopping + Container mtusi2026lab2-postgres-1 Stopped +GET /health/live -> 200 +GET /health/ready -> {"error":{"code":"unavailable","message":"Сервис временно недоступен","request_id":"9c380c3a7b7b4c8fa3033cdbf0e35f5b"}} 503 +GET /api/v1/users/me (анонимный токен) -> {"error":{"code":"unavailable","message":"Сервис временно недоступен","request_id":"ac5c64206e424174a5e3c2d1c1e41eae"}} 503 +$ docker compose start postgres + Container mtusi2026lab2-postgres-1 Starting + Container mtusi2026lab2-postgres-1 Started +ready снова через 2 с (без рестарта API) +NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS +mtusi2026lab2-api-1 mtusi2026lab2-api "uvicorn app.main:ap…" api 8 seconds ago Up 6 seconds (healthy) 127.0.0.1:8080->8080/tcp +mtusi2026lab2-postgres-1 postgres:16.4-alpine "docker-entrypoint.s…" postgres 45 minutes ago Up 1 second (health: starting) 5432/tcp + +=================== evidence/09-git-hygiene.txt +# 09 секреты и volumes вне Git (2026-11-12T18:53:20Z) +$ git check-ignore -v secrets/pg_password secrets/database_url .env +.gitignore:35:secrets/ secrets/pg_password +.gitignore:35:secrets/ secrets/database_url +.gitignore:36:.env .env +$ отслеживаемые файлы, похожие на секреты: +нет