ЛР4 на 4: MinIO-вложения поверх LB, идемпотентности и failover.

PNG/JPEG через API, student-tests, REPORT и DEFENSE.
This commit is contained in:
2026-12-01 22:01:52 +03:00
parent ec540a1a72
commit 0b4a21a83f
44 changed files with 9152 additions and 37 deletions
+419
View File
@@ -0,0 +1,419 @@
DATABASE_URL="${DATABASE_URL:-postgres://messenger:messenger@127.0.0.1:5434/messenger?sslmode=disable}" \
REDIS_URL="${REDIS_URL:-redis://127.0.0.1:6381/0}" \
S3_ENDPOINT="${S3_ENDPOINT:-http://127.0.0.1:9003}" \
S3_ACCESS_KEY="${S3_ACCESS_KEY:-messenger-api}" \
S3_SECRET_KEY="${S3_SECRET_KEY:-messenger-api-secret-change-me}" \
S3_BUCKET="${S3_BUCKET:-messenger}" \
go test ./student-tests/ -v -count=1 -timeout 300s
=== RUN TestMalformedJSONAndValidation
api_test.go:96: → битый JSON, хвост после объекта, лишнее поле, пустой текст, чужой чат
2026/12/01 21:58:20 method=POST path=/api/v1/users status=400 request_id=01afd54c-3d79-44a4-b0ee-372be57ebc6f duration_ms=0
api_test.go:99: status=400 body={"error":{"code":"invalid_request","message":"malformed json","request_id":"01afd54c-3d79-44a4-b0ee-372be57ebc6f"}}
2026/12/01 21:58:20 method=POST path=/api/v1/users status=400 request_id=3762a883-eec9-4e8b-bd40-5b1d13e0dbe5 duration_ms=0
api_test.go:106: status=400 body={"error":{"code":"invalid_request","message":"malformed json","request_id":"3762a883-eec9-4e8b-bd40-5b1d13e0dbe5"}}
2026/12/01 21:58:20 method=POST path=/api/v1/users status=201 request_id=94c38c2f-5e6f-47a7-8e1a-cbc6adf8719b duration_ms=65
api_test.go:111: создан ok_user_67a97ae5 id=326efb60-10c6-480a-b6cb-f0f4a0a50e41
2026/12/01 21:58:20 method=POST path=/api/v1/auth/sessions status=201 request_id=04ff26a0-e778-4f21-9711-466bf7da5ead duration_ms=51
api_test.go:112: сессия выпущена, длина токена=64 (значение не печатаем)
2026/12/01 21:58:20 method=POST path=/api/v1/chats status=201 request_id=71b4f183-b13c-4533-b9c0-ae87e70b1a04 duration_ms=10
2026/12/01 21:58:20 method=POST path=/api/v1/chats/239a7816-a704-4d6c-9029-89df22bd194c/messages status=400 request_id=3925d0b1-52ea-4285-bede-afed2a0fe206 duration_ms=1
api_test.go:119: status=400 body={"error":{"code":"invalid_request","message":"malformed json","request_id":"3925d0b1-52ea-4285-bede-afed2a0fe206"}}
2026/12/01 21:58:20 method=POST path=/api/v1/chats/239a7816-a704-4d6c-9029-89df22bd194c/messages status=400 request_id=b10068a5-769e-42d3-add1-cbd41d028402 duration_ms=1
api_test.go:119: status=400 body={"error":{"code":"invalid_request","message":"malformed json","request_id":"b10068a5-769e-42d3-add1-cbd41d028402"}}
2026/12/01 21:58:20 method=POST path=/api/v1/chats/239a7816-a704-4d6c-9029-89df22bd194c/messages status=400 request_id=a5efa1ee-cff1-4566-975e-0b0c73a00796 duration_ms=1
api_test.go:126: status=400 body={"error":{"code":"invalid_request","message":"invalid text","request_id":"a5efa1ee-cff1-4566-975e-0b0c73a00796"}}
2026/12/01 21:58:20 method=POST path=/api/v1/users status=201 request_id=f4708ea7-86c9-43d2-9ac4-dfe61767beee duration_ms=38
api_test.go:131: создан outsider_37688b02 id=aa88cb70-1a95-48f2-ab09-3ab86bca5291
2026/12/01 21:58:20 method=POST path=/api/v1/auth/sessions status=201 request_id=b5f53907-1b8f-4827-bfee-7de0405c1909 duration_ms=53
api_test.go:132: сессия выпущена, длина токена=64 (значение не печатаем)
2026/12/01 21:58:20 method=POST path=/api/v1/chats/239a7816-a704-4d6c-9029-89df22bd194c/messages status=404 request_id=911eadc5-7016-4a7d-b42a-940f020b8b7f duration_ms=13
api_test.go:134: status=404 body={"error":{"code":"not_found","message":"object not found","request_id":"911eadc5-7016-4a7d-b42a-940f020b8b7f"}}
api_test.go:138: ✓ валидация JSON, хвоста, пустого текста и чужого чата
--- PASS: TestMalformedJSONAndValidation (0.25s)
=== RUN TestMessageTextPreservedAndLengthOnOriginal
api_test.go:144: → пробелы по краям сохраняются; длина считается по исходному тексту
2026/12/01 21:58:20 method=POST path=/api/v1/users status=201 request_id=261ab52e-3db2-443a-b98c-ba51f794705f duration_ms=67
api_test.go:145: создан text_user_9eb6cc3d id=6b83b904-828c-4332-b2c5-4c64db22c9bb
2026/12/01 21:58:20 method=POST path=/api/v1/auth/sessions status=201 request_id=0080807c-8e34-4c2f-815d-6b4ba46ce245 duration_ms=46
api_test.go:146: сессия выпущена, длина токена=64 (значение не печатаем)
2026/12/01 21:58:20 method=POST path=/api/v1/chats status=201 request_id=4e3f73c9-1f7d-4d28-b0c3-dda4aeb963ee duration_ms=6
2026/12/01 21:58:20 method=POST path=/api/v1/chats/a770fe64-a4b9-49cd-9e3b-e03aa057b60a/messages status=201 request_id=7432aef4-4ea3-43fe-92e0-d2e3250be14c duration_ms=8
api_test.go:153: status=201 body={"attachment_ids":[],"chat_id":"a770fe64-a4b9-49cd-9e3b-e03aa057b60a","created_at":"2026-12-01T18:58:20.688Z","id":"ed09cba4-8870-40a1-9025-66da3ee0fd58","sender_id":"6b83b904-828c-4332-b2c5-4c64db22c9bb","text":" строка\nс пробелами "}
2026/12/01 21:58:20 method=POST path=/api/v1/chats/a770fe64-a4b9-49cd-9e3b-e03aa057b60a/messages status=400 request_id=488be3a5-4456-4088-b211-893977910ae8 duration_ms=0
api_test.go:165: status=400 body={"error":{"code":"invalid_request","message":"invalid text","request_id":"488be3a5-4456-4088-b211-893977910ae8"}}
api_test.go:169: ✓ текст сохранён целиком, обход лимита через TrimSpace закрыт
--- PASS: TestMessageTextPreservedAndLengthOnOriginal (0.13s)
=== RUN TestSessionRejectsJSONBody
api_test.go:175: → POST /auth/sessions с телом должен быть 400 даже при верном Basic
2026/12/01 21:58:20 method=POST path=/api/v1/users status=201 request_id=4702c48c-ae62-4d8b-9459-aa7f93354c99 duration_ms=41
api_test.go:176: создан body_user_47c84eb3 id=259cf23e-b500-45c6-a4a4-fd9ad627d635
2026/12/01 21:58:20 method=POST path=/api/v1/auth/sessions status=400 request_id=db4fe7a3-692a-4a42-9ae2-db59eb3812c3 duration_ms=0
api_test.go:180: status=400 body={"error":{"code":"invalid_request","message":"session create must not have a body","request_id":"db4fe7a3-692a-4a42-9ae2-db59eb3812c3"}}
api_test.go:184: ✓ вход без JSON body
--- PASS: TestSessionRejectsJSONBody (0.04s)
=== RUN TestWrongPasswordLogoutAndIgnoredUserHeader
api_test.go:190: → неверный пароль, Basic на бизнес-методе, X-User-Id, logout
2026/12/01 21:58:20 method=POST path=/api/v1/users status=201 request_id=0e24ac2c-0c6e-47ab-a915-a57c98b5e4d3 duration_ms=39
api_test.go:191: создан auth_user_60120960 id=955239fa-f3a5-4737-8e3f-c00c40b32077
2026/12/01 21:58:20 method=POST path=/api/v1/users status=201 request_id=59e9dcc2-22f6-4280-a109-a74ba7070b0e duration_ms=46
api_test.go:192: создан auth_other_ff97a54b id=8009bbd5-046d-4702-9844-2be9733a9a8e
2026/12/01 21:58:20 method=POST path=/api/v1/auth/sessions status=401 request_id=795f78de-89b2-4542-8f6c-192574eaf557 duration_ms=40
api_test.go:197: status=401 body={"error":{"code":"unauthorized","message":"authentication required","request_id":"795f78de-89b2-4542-8f6c-192574eaf557"}}
2026/12/01 21:58:20 method=POST path=/api/v1/auth/sessions status=201 request_id=5c396ef7-e7e6-4cc8-8c8e-abb36124e26c duration_ms=44
api_test.go:202: сессия выпущена, длина токена=64 (значение не печатаем)
2026/12/01 21:58:20 method=GET path=/api/v1/users/me status=401 request_id=d37ca73f-f190-4e96-b8b6-a37c6e0c8ec3 duration_ms=0
api_test.go:206: status=401 body={"error":{"code":"unauthorized","message":"authentication required","request_id":"d37ca73f-f190-4e96-b8b6-a37c6e0c8ec3"}}
2026/12/01 21:58:20 method=GET path=/api/v1/users/me status=401 request_id=9d4f3028-4329-4c23-a026-c0e4f83069b8 duration_ms=0
api_test.go:212: status=401 body={"error":{"code":"unauthorized","message":"authentication required","request_id":"9d4f3028-4329-4c23-a026-c0e4f83069b8"}}
2026/12/01 21:58:20 method=GET path=/api/v1/users/me status=200 request_id=344cc38a-abc2-41ef-8101-1bc7fc6da90c duration_ms=3
api_test.go:221: status=200 body={"created_at":"2026-12-01T18:58:20.782Z","display_name":"Студент","id":"955239fa-f3a5-4737-8e3f-c00c40b32077","username":"auth_user_60120960"}
2026/12/01 21:58:20 method=DELETE path=/api/v1/auth/sessions/current status=204 request_id=4dea947a-4a64-42e6-8865-016f2730e0a1 duration_ms=1
api_test.go:227: logout status=204
2026/12/01 21:58:20 method=GET path=/api/v1/users/me status=401 request_id=bcee10b4-ce00-44bb-a6f4-6e13abcde533 duration_ms=0
2026/12/01 21:58:20 method=DELETE path=/api/v1/auth/sessions/current status=401 request_id=83f18ace-154b-44a9-b51c-69f1f1c0b33f duration_ms=0
api_test.go:239: ✓ пароль, заголовки и отзыв сессии
--- PASS: TestWrongPasswordLogoutAndIgnoredUserHeader (0.18s)
=== RUN TestSessionExpiry
api_test.go:245: → SESSION_TTL=2s: тот же токен после паузы должен стать 401, TTL рестартом API не продлевается
2026/12/01 21:58:20 method=POST path=/api/v1/users status=201 request_id=92390952-2a6e-4535-844d-b3a942cf7cac duration_ms=46
api_test.go:246: создан ttl_user_a50e6a08 id=842a69d2-df63-42b9-b2cc-c8e2e40c6694
2026/12/01 21:58:21 method=POST path=/api/v1/auth/sessions status=201 request_id=e2bcf62f-497d-4d92-bb34-5c7eed7448c5 duration_ms=38
api_test.go:247: сессия выпущена, длина токена=64 (значение не печатаем)
2026/12/01 21:58:23 method=GET path=/api/v1/users/me status=401 request_id=5ca7186d-cda1-4ac5-b69b-150f053b6f50 duration_ms=8
api_test.go:250: status=401 body={"error":{"code":"unauthorized","message":"authentication required","request_id":"5ca7186d-cda1-4ac5-b69b-150f053b6f50"}}
api_test.go:254: ✓ истёкшая сессия отклонена
--- PASS: TestSessionExpiry (2.60s)
=== RUN TestDuplicateUsernameRace
api_test.go:261: → 8 параллельных регистраций username=race_0c6a2408
2026/12/01 21:58:23 method=POST path=/api/v1/users status=201 request_id=c5464434-7861-48bf-96ea-8b44de41b8a1 duration_ms=161
2026/12/01 21:58:23 method=POST path=/api/v1/users status=409 request_id=4e786af4-a6ed-49e2-9165-485a8374a646 duration_ms=164
2026/12/01 21:58:23 method=POST path=/api/v1/users status=409 request_id=cd3f721f-8d9d-4a2e-9505-7fd8730d0271 duration_ms=170
2026/12/01 21:58:23 method=POST path=/api/v1/users status=409 request_id=ef1567c4-546a-4769-911e-84798b799fde duration_ms=174
2026/12/01 21:58:23 method=POST path=/api/v1/users status=409 request_id=de488d01-7201-4bee-8d06-526a4103da49 duration_ms=184
2026/12/01 21:58:23 method=POST path=/api/v1/users status=409 request_id=92859392-a110-40f8-97f0-5743d85cc259 duration_ms=190
2026/12/01 21:58:23 method=POST path=/api/v1/users status=409 request_id=10b3529e-cf19-42c1-9fcb-70ff09dc15a2 duration_ms=193
2026/12/01 21:58:23 method=POST path=/api/v1/users status=409 request_id=b32b8951-a848-4da2-b7c3-19edd6785dcc duration_ms=192
api_test.go:286: created=1 conflict=7
api_test.go:290: ✓ UNIQUE username выдержал гонку
--- PASS: TestDuplicateUsernameRace (0.21s)
=== RUN TestChatCreateRollsBack
2026/12/01 21:58:23 method=POST path=/api/v1/users status=201 request_id=ed124d67-9de6-4347-a6a7-090b7f054f97 duration_ms=95
api_test.go:296: создан roll_user_23809c71 id=e59c6c39-205f-4e63-94bb-a994c652a6e1
2026/12/01 21:58:23 method=POST path=/api/v1/auth/sessions status=201 request_id=19f51a3a-39d3-4de6-a3e0-5e1b5b810ac1 duration_ms=125
api_test.go:297: сессия выпущена, длина токена=64 (значение не печатаем)
api_test.go:300: → создание чата с несуществующим участником должно откатиться, title=rollback-40fe1ea5-338d-4677-842f-64d46c961c7a
2026/12/01 21:58:24 method=POST path=/api/v1/chats status=400 request_id=4d905396-ea54-41e3-99f1-7fc4e466730a duration_ms=74
api_test.go:303: status=400 body={"error":{"code":"invalid_request","message":"unknown member","request_id":"4d905396-ea54-41e3-99f1-7fc4e466730a"}}
api_test.go:311: строк chats с этим title после ошибки: 0
api_test.go:315: ✓ транзакция создания чата откатилась
--- PASS: TestChatCreateRollsBack (0.35s)
=== RUN TestPaginationPages
api_test.go:321: → три сообщения, две страницы limit=2, затем последняя
2026/12/01 21:58:24 method=POST path=/api/v1/users status=201 request_id=50fb4eb0-83d9-41f4-9e57-678e9b7f8929 duration_ms=118
api_test.go:322: создан page_user_a4e05751 id=065d6c5c-8bc3-41a8-b243-69b13b8b41fb
2026/12/01 21:58:24 method=POST path=/api/v1/auth/sessions status=201 request_id=ebcb85ea-9ea5-4154-8994-ff87da181d46 duration_ms=105
api_test.go:323: сессия выпущена, длина токена=64 (значение не печатаем)
2026/12/01 21:58:24 method=POST path=/api/v1/chats status=201 request_id=d6deb008-4673-4ed7-a2b6-910129fc0999 duration_ms=64
2026/12/01 21:58:25 method=POST path=/api/v1/chats/e9b883c6-23dc-4852-af0b-a13e98e471d3/messages status=201 request_id=37e33cf8-db6d-4d2a-b88b-157bb728701f duration_ms=840
2026/12/01 21:58:25 method=POST path=/api/v1/chats/e9b883c6-23dc-4852-af0b-a13e98e471d3/messages status=201 request_id=056b77b1-5ab0-4901-aaad-e925ee12b110 duration_ms=53
2026/12/01 21:58:25 method=POST path=/api/v1/chats/e9b883c6-23dc-4852-af0b-a13e98e471d3/messages status=201 request_id=181d1090-5444-49e6-9141-5949f5a56ddb duration_ms=51
2026/12/01 21:58:25 method=GET path=/api/v1/chats/e9b883c6-23dc-4852-af0b-a13e98e471d3/messages status=200 request_id=ea4699d4-fff3-4974-bac6-6f1e37248473 duration_ms=20
api_test.go:333: status=200 body={"items":[{"attachment_ids":[],"chat_id":"e9b883c6-23dc-4852-af0b-a13e98e471d3","created_at":"2026-12-01T18:58:25.213Z","id":"1b705c14-1605-4081-a2b5-8ad8456780b1","sender_id":"065d6c5c-8bc3-41a8-b243-69b13b8b41fb","text":"раз"},{"attachment_ids":[],"chat_id":"e9b883c6-23dc-4852-af0b-a13e98e471d3","created_at":"2026-12-01T18:58:25.295Z","id":"8b9de1d1-ba76-467a-82d7-180e232bcad3","sender_id":"0...
2026/12/01 21:58:25 method=GET path=/api/v1/chats/e9b883c6-23dc-4852-af0b-a13e98e471d3/messages status=200 request_id=860e674e-b6be-49c7-9aac-e5c9cc784f79 duration_ms=15
api_test.go:341: status=200 body={"items":[{"attachment_ids":[],"chat_id":"e9b883c6-23dc-4852-af0b-a13e98e471d3","created_at":"2026-12-01T18:58:25.350Z","id":"c5cbcf53-1283-44ab-9c76-544a2fb45ffa","sender_id":"065d6c5c-8bc3-41a8-b243-69b13b8b41fb","text":"три"}],"next_cursor":null}
api_test.go:347: ✓ keyset обошёл историю без зависания cursor
--- PASS: TestPaginationPages (1.33s)
=== RUN TestRedisDownIsNotAnonymous
api_test.go:351: → закрытый клиент Redis: вход и Bearer дают 503, а не 200 от анонима
2026/12/01 21:58:25 method=POST path=/api/v1/users status=201 request_id=de10c4ef-991c-41b3-96d1-bf42593b2ca2 duration_ms=91
api_test.go:363: создан redis_down_7d513082 id=090460d5-7c4e-4b88-b503-e5a9d3226f7e
2026/12/01 21:58:25 method=POST path=/api/v1/auth/sessions status=503 request_id=7c510476-9042-427a-9b25-e16e6e856e1f duration_ms=55
api_test.go:367: status=503 body={"error":{"code":"unavailable","message":"dependency unavailable","request_id":"7c510476-9042-427a-9b25-e16e6e856e1f"}}
2026/12/01 21:58:25 method=GET path=/api/v1/users/me status=503 request_id=c1078896-8c33-49ed-9ef0-a002cac5ee1b duration_ms=0
api_test.go:374: status=503 body={"error":{"code":"unavailable","message":"dependency unavailable","request_id":"c1078896-8c33-49ed-9ef0-a002cac5ee1b"}}
api_test.go:378: ✓ сбой Redis не стал анонимным доступом
--- PASS: TestRedisDownIsNotAnonymous (0.18s)
=== RUN TestPostgresDownIsNotAnonymous
api_test.go:382: → закрытый пул PostgreSQL: ready/me/login дают 503, без тела пользователя
2026/12/01 21:58:25 method=POST path=/api/v1/users status=201 request_id=dd446fea-3f11-42ba-af0d-0d6ef95a4ac7 duration_ms=92
api_test.go:385: создан pg_down_6890d887 id=f354397a-9f92-4f72-bfd0-954dcc89620d
2026/12/01 21:58:25 method=POST path=/api/v1/auth/sessions status=201 request_id=b86f6d6a-65f8-4a66-9d92-db8d4b3c19d5 duration_ms=80
api_test.go:386: сессия выпущена, длина токена=64 (значение не печатаем)
2026/12/01 21:58:25 method=GET path=/health/ready status=503 request_id=dcf2de7b-cd42-40a8-a8d7-043e27dcacf8 duration_ms=0
api_test.go:407: status=503 body={"error":{"code":"unavailable","message":"dependency unavailable","request_id":"dcf2de7b-cd42-40a8-a8d7-043e27dcacf8"}}
2026/12/01 21:58:25 method=GET path=/api/v1/users/me status=503 request_id=bf2b58b4-ab13-4ece-9ce9-b969bdd10011 duration_ms=6
api_test.go:414: status=503 body={"error":{"code":"unavailable","message":"dependency unavailable","request_id":"bf2b58b4-ab13-4ece-9ce9-b969bdd10011"}}
2026/12/01 21:58:25 method=POST path=/api/v1/auth/sessions status=503 request_id=2ac57497-134b-4d79-b8c0-3af19b8c0318 duration_ms=0
api_test.go:421: status=503 body={"error":{"code":"unavailable","message":"dependency unavailable","request_id":"2ac57497-134b-4d79-b8c0-3af19b8c0318"}}
api_test.go:425: ✓ сбой PostgreSQL не стал анонимным доступом
--- PASS: TestPostgresDownIsNotAnonymous (0.35s)
=== RUN TestIdempotencyReplayAndConflict
api_test.go:431: → повтор того же Idempotency-Key возвращает то же сообщение; другой body — 409
2026/12/01 21:58:26 method=POST path=/api/v1/users status=201 request_id=b6d52aa5-57de-499a-819e-2acc9893ad12 duration_ms=93
api_test.go:432: создан idem_user_bb1be8da id=438e4803-1ef9-4231-9a73-81f09683491d
2026/12/01 21:58:26 method=POST path=/api/v1/auth/sessions status=201 request_id=e5ebf5ae-1868-43a0-88ce-14f295b43cc1 duration_ms=94
api_test.go:433: сессия выпущена, длина токена=64 (значение не печатаем)
2026/12/01 21:58:26 method=POST path=/api/v1/chats status=201 request_id=2d15ae62-70b5-497e-8993-d372f10aa325 duration_ms=18
2026/12/01 21:58:26 method=POST path=/api/v1/chats/f32bc877-b405-46f1-92fc-bc98071d6d46/messages status=201 request_id=7ce1c18c-53ae-4cbb-81f8-d2ce9e84dcfb duration_ms=76
api_test.go:441: status=201 body={"attachment_ids":[],"chat_id":"f32bc877-b405-46f1-92fc-bc98071d6d46","created_at":"2026-12-01T18:58:26.177Z","id":"7fdf9b0f-e773-4f46-9931-7148077033f9","sender_id":"438e4803-1ef9-4231-9a73-81f09683491d","text":"один раз"}
2026/12/01 21:58:26 method=POST path=/api/v1/chats/f32bc877-b405-46f1-92fc-bc98071d6d46/messages status=201 request_id=6bb81834-8f2c-4a70-aec7-baf076765e76 duration_ms=48
api_test.go:447: status=201 body={"attachment_ids":[],"chat_id":"f32bc877-b405-46f1-92fc-bc98071d6d46","created_at":"2026-12-01T18:58:26.177Z","id":"7fdf9b0f-e773-4f46-9931-7148077033f9","sender_id":"438e4803-1ef9-4231-9a73-81f09683491d","text":"один раз"}
2026/12/01 21:58:26 method=POST path=/api/v1/chats/f32bc877-b405-46f1-92fc-bc98071d6d46/messages status=409 request_id=07971910-e817-4d7a-841e-36d066644e59 duration_ms=16
api_test.go:456: status=409 body={"error":{"code":"conflict","message":"idempotency key reused with different body","request_id":"07971910-e817-4d7a-841e-36d066644e59"}}
api_test.go:460: ✓ replay и conflict по Idempotency-Key
--- PASS: TestIdempotencyReplayAndConflict (0.36s)
=== RUN TestIdempotencyKeyRequiredAndConcurrent
api_test.go:466: → нет ключа → 400; 8 параллельных POST с одним ключом → ровно одно сообщение
2026/12/01 21:58:26 method=POST path=/api/v1/users status=201 request_id=247fa258-dcba-4cfa-adf5-c0f0a26ff240 duration_ms=68
api_test.go:467: создан idem_race_f933771c id=0eeffbb0-7628-42b6-9636-0510df2804e6
2026/12/01 21:58:26 method=POST path=/api/v1/auth/sessions status=201 request_id=f6052d41-121f-4b49-a6b6-7481cf47bd99 duration_ms=91
api_test.go:468: сессия выпущена, длина токена=64 (значение не печатаем)
2026/12/01 21:58:26 method=POST path=/api/v1/chats status=201 request_id=d7c99c26-deec-44d0-aff8-66d4823889f4 duration_ms=36
2026/12/01 21:58:26 method=POST path=/api/v1/chats/bd337ceb-3dd7-4e88-801c-55542cc480ae/messages status=400 request_id=7c6f8ca2-f6ef-48c0-9b04-969eb6be75a6 duration_ms=3
api_test.go:486: status=400 body={"error":{"code":"invalid_request","message":"invalid or missing Idempotency-Key","request_id":"7c6f8ca2-f6ef-48c0-9b04-969eb6be75a6"}}
2026/12/01 21:58:26 method=POST path=/api/v1/chats/bd337ceb-3dd7-4e88-801c-55542cc480ae/messages status=201 request_id=b62c8e15-6573-4bd7-91d4-6c644c9f179b duration_ms=35
2026/12/01 21:58:26 method=POST path=/api/v1/chats/bd337ceb-3dd7-4e88-801c-55542cc480ae/messages status=201 request_id=14beadb8-5085-48d6-949d-7f4a3867b9f1 duration_ms=115
2026/12/01 21:58:26 method=POST path=/api/v1/chats/bd337ceb-3dd7-4e88-801c-55542cc480ae/messages status=201 request_id=2d165347-5e21-428e-ae4a-90594088f938 duration_ms=124
2026/12/01 21:58:26 method=POST path=/api/v1/chats/bd337ceb-3dd7-4e88-801c-55542cc480ae/messages status=201 request_id=38fc339c-db82-4f11-a4d6-f38d1dd13687 duration_ms=165
2026/12/01 21:58:26 method=POST path=/api/v1/chats/bd337ceb-3dd7-4e88-801c-55542cc480ae/messages status=201 request_id=28e7a700-c5dc-48fc-af18-e5d95ed9a522 duration_ms=206
2026/12/01 21:58:26 method=POST path=/api/v1/chats/bd337ceb-3dd7-4e88-801c-55542cc480ae/messages status=201 request_id=5035a00a-e588-44d2-9c1d-97af983a33fc duration_ms=235
2026/12/01 21:58:26 method=POST path=/api/v1/chats/bd337ceb-3dd7-4e88-801c-55542cc480ae/messages status=201 request_id=61baef3e-7844-4e29-9b31-b2ca16daffa7 duration_ms=263
2026/12/01 21:58:26 method=POST path=/api/v1/chats/bd337ceb-3dd7-4e88-801c-55542cc480ae/messages status=201 request_id=8ca65086-ec39-41a4-adcb-eadf8599ac99 duration_ms=284
api_test.go:518: unique message ids=1
api_test.go:522: ✓ ключ обязателен; конкурентный повтор не плодит дубли
--- PASS: TestIdempotencyKeyRequiredAndConcurrent (0.50s)
=== RUN TestInstanceIDHeaderPresent
api_test.go:528: → каждый ответ содержит непустой X-Instance-Id
api_test.go:530: status=200 body={"status":"ok"}
api_test.go:534: ✓ X-Instance-Id=test-instance
--- PASS: TestInstanceIDHeaderPresent (0.01s)
=== RUN TestAttachmentRoundTripAndAccessControl
attachments_test.go:203: → PNG и JPEG: 201 ready, sha256/size, download без redirect, доступ только участникам
2026/12/01 21:58:26 method=POST path=/api/v1/users status=201 request_id=4cac634f-6bcd-4e1b-a2bf-675fb5ac4dc0 duration_ms=119
attachments_test.go:206: создан att_alice_beba8c7a id=52f047c5-76bf-4994-a75c-97692db69ebe
2026/12/01 21:58:27 method=POST path=/api/v1/users status=201 request_id=59ca935b-347d-4699-9a78-35f1155798b7 duration_ms=81
attachments_test.go:207: создан att_bob_a197f321 id=10a0d1f1-155c-4c77-8339-13943e287693
2026/12/01 21:58:27 method=POST path=/api/v1/users status=201 request_id=c23d2232-acc3-461e-800b-1e10cabefeba duration_ms=94
attachments_test.go:208: создан att_eve_56c7c11f id=344e75bd-61ba-455c-a733-0a56b0d518f1
2026/12/01 21:58:27 method=POST path=/api/v1/auth/sessions status=201 request_id=4be591eb-25c3-406a-87c1-606e566c0638 duration_ms=83
attachments_test.go:209: сессия выпущена, длина токена=64 (значение не печатаем)
2026/12/01 21:58:27 method=POST path=/api/v1/auth/sessions status=201 request_id=2cf32395-d229-4a6f-b63b-6c2886868e6f duration_ms=75
attachments_test.go:210: сессия выпущена, длина токена=64 (значение не печатаем)
2026/12/01 21:58:27 method=POST path=/api/v1/auth/sessions status=201 request_id=6a516cdf-e480-47b1-b80f-c5c2743d94bd duration_ms=72
attachments_test.go:211: сессия выпущена, длина токена=64 (значение не печатаем)
2026/12/01 21:58:27 method=POST path=/api/v1/chats status=201 request_id=2ac75104-39d3-426f-9e4b-a3dce45fe6f4 duration_ms=26
2026/12/01 21:58:27 method=POST path=/api/v1/chats/fc640630-c6c2-4f88-83af-1bf15dbf47e8/attachments status=201 request_id=0727cea8-ea30-43a6-a8ed-b5a819b5c9dd duration_ms=106
2026/12/01 21:58:27 method=GET path=/api/v1/attachments/92a7bc63-a93e-4d70-983b-c9de531dd51f status=200 request_id=53f5c019-6ffa-4e19-8b48-b0038fb99751 duration_ms=35
2026/12/01 21:58:27 method=GET path=/api/v1/attachments/92a7bc63-a93e-4d70-983b-c9de531dd51f/content status=200 request_id=e436dba5-325d-4436-838e-7ecf778ac224 duration_ms=17
2026/12/01 21:58:27 method=POST path=/api/v1/chats/fc640630-c6c2-4f88-83af-1bf15dbf47e8/attachments status=201 request_id=72f981e9-1c37-423d-a78b-c2bf0de9f6db duration_ms=23
2026/12/01 21:58:27 method=GET path=/api/v1/attachments/92a7bc63-a93e-4d70-983b-c9de531dd51f status=404 request_id=c8eb1d0d-5715-4a46-acab-c6f21f3c31b5 duration_ms=5
attachments_test.go:259: status=404 body={"error":{"code":"not_found","message":"object not found","request_id":"c8eb1d0d-5715-4a46-acab-c6f21f3c31b5"}}
2026/12/01 21:58:27 method=GET path=/api/v1/attachments/92a7bc63-a93e-4d70-983b-c9de531dd51f/content status=404 request_id=1c9f04dc-2e31-4201-a4bd-b919060acd41 duration_ms=6
attachments_test.go:259: status=404 body={"error":{"code":"not_found","message":"object not found","request_id":"1c9f04dc-2e31-4201-a4bd-b919060acd41"}}
2026/12/01 21:58:27 method=POST path=/api/v1/chats/fc640630-c6c2-4f88-83af-1bf15dbf47e8/attachments status=404 request_id=d17e8504-270a-4b02-83ea-d4fa9f53d871 duration_ms=5
2026/12/01 21:58:27 method=POST path=/api/v1/chats/fc640630-c6c2-4f88-83af-1bf15dbf47e8/attachments status=401 request_id=46290ebd-eb92-4455-8fa9-a90fb3ed3a40 duration_ms=0
2026/12/01 21:58:27 method=GET path=/api/v1/attachments/92a7bc63-a93e-4d70-983b-c9de531dd51f/content status=404 request_id=c235c189-f690-4c2f-913e-9fd9687f606f duration_ms=4
2026/12/01 21:58:27 method=GET path=/api/v1/attachments/d976811c-5091-47fd-a36d-415a1fbf9135 status=404 request_id=660db267-9c77-4daf-a438-34439be0cf37 duration_ms=4
2026/12/01 21:58:27 method=POST path=/api/v1/chats/fc640630-c6c2-4f88-83af-1bf15dbf47e8/messages status=201 request_id=848301d0-1274-4d17-9f3f-93711f213809 duration_ms=42
attachments_test.go:288: status=201 body={"attachment_ids":["4fc0786e-181b-42bf-a57c-132e907ec9d9","92a7bc63-a93e-4d70-983b-c9de531dd51f"],"chat_id":"fc640630-c6c2-4f88-83af-1bf15dbf47e8","created_at":"2026-12-01T18:58:27.620Z","id":"dd3fec40-8719-46b3-a7c6-4925989a2816","sender_id":"52f047c5-76bf-4994-a75c-97692db69ebe","text":"смотри"}
2026/12/01 21:58:27 method=POST path=/api/v1/chats/fc640630-c6c2-4f88-83af-1bf15dbf47e8/messages status=201 request_id=c77748ec-3cba-4025-a8af-6694fd88314b duration_ms=73
2026/12/01 21:58:27 method=POST path=/api/v1/chats/fc640630-c6c2-4f88-83af-1bf15dbf47e8/messages status=409 request_id=17a61b62-52b0-4f4f-b145-09b416c0a477 duration_ms=154
2026/12/01 21:58:27 method=GET path=/api/v1/chats/fc640630-c6c2-4f88-83af-1bf15dbf47e8/messages status=200 request_id=4a559191-04ba-48c1-aa1c-02705f563dc1 duration_ms=10
2026/12/01 21:58:27 method=GET path=/api/v1/chats/fc640630-c6c2-4f88-83af-1bf15dbf47e8/messages status=404 request_id=2e497bc2-98ff-48da-99b9-81c69f7ec277 duration_ms=4
attachments_test.go:319: ✓ upload/download/доступ/replay работают, внутренние ключи не раскрываются
--- PASS: TestAttachmentRoundTripAndAccessControl (1.08s)
=== RUN TestAttachmentTooLarge
attachments_test.go:324: → ровно 10 MiB проходит лимит размера (дальше 415 как не-картинка), 10 MiB+1 → 413
2026/12/01 21:58:27 method=POST path=/api/v1/users status=201 request_id=7ddf73ed-7547-4fa9-a3d8-03e9465a116c duration_ms=79
attachments_test.go:325: создан att_big_4daf86e1 id=5c53a092-69eb-4ff5-aad4-a3c6ee32e54b
2026/12/01 21:58:28 method=POST path=/api/v1/auth/sessions status=201 request_id=c2637bf9-fef7-4d7a-8bf1-52f714c2a2e9 duration_ms=109
attachments_test.go:325: сессия выпущена, длина токена=64 (значение не печатаем)
2026/12/01 21:58:28 method=POST path=/api/v1/chats status=201 request_id=86de037b-8e29-445d-bf39-76f1379ea800 duration_ms=65
2026/12/01 21:58:28 method=POST path=/api/v1/chats/590943e6-2f84-4949-9693-e9f7491d0caa/attachments status=415 request_id=c8bbd92c-04d4-4c60-b651-5d4f985c4cec duration_ms=12
attachments_test.go:330: status=415 body={"error":{"code":"unsupported_media_type","message":"file is not a valid png/jpeg image","request_id":"c8bbd92c-04d4-4c60-b651-5d4f985c4cec"}}
2026/12/01 21:58:28 method=POST path=/api/v1/chats/590943e6-2f84-4949-9693-e9f7491d0caa/attachments status=413 request_id=41339836-1f40-4b44-a378-c3a99a00bd7e duration_ms=23
attachments_test.go:337: status=413 body={"error":{"code":"payload_too_large","message":"file is too large","request_id":"41339836-1f40-4b44-a378-c3a99a00bd7e"}}
2026/12/01 21:58:28 method=POST path=/api/v1/chats/590943e6-2f84-4949-9693-e9f7491d0caa/attachments status=413 request_id=26981107-e12b-4837-b792-b66507780156 duration_ms=13
2026/12/01 21:58:28 method=POST path=/api/v1/chats/590943e6-2f84-4949-9693-e9f7491d0caa/attachments status=413 request_id=63e28e6e-8647-4c32-b818-a87a34c2414a duration_ms=13
attachments_test.go:364: ✓ лимит байтов: граница точная, работает и для chunked
--- PASS: TestAttachmentTooLarge (0.35s)
=== RUN TestAttachmentPixelLimit
attachments_test.go:369: → 8000x5000 (=40 млн) принимается, 8000x5001 → 413
2026/12/01 21:58:28 method=POST path=/api/v1/users status=201 request_id=7977b741-beeb-4148-a60d-c93c8ba2e4eb duration_ms=113
attachments_test.go:370: создан att_px_bdccb3ce id=266b62fa-b97d-4ffe-9202-249d4588811d
2026/12/01 21:58:28 method=POST path=/api/v1/auth/sessions status=201 request_id=7d10af1a-c3e8-45af-a0b0-4f464f1e7478 duration_ms=77
attachments_test.go:370: сессия выпущена, длина токена=64 (значение не печатаем)
2026/12/01 21:58:28 method=POST path=/api/v1/chats status=201 request_id=813271a0-a99a-4640-94e4-a754c7175c00 duration_ms=21
attachments_test.go:373: PNG 8000x5000 занимает 9860 байт на проводе
2026/12/01 21:58:28 method=POST path=/api/v1/chats/7a1cc0b4-8d4f-42a3-8300-424040002866/attachments status=201 request_id=4236df5b-99a6-4123-a959-69c730da1b9f duration_ms=34
2026/12/01 21:58:28 method=POST path=/api/v1/chats/7a1cc0b4-8d4f-42a3-8300-424040002866/attachments status=413 request_id=5025a303-9fef-45df-861d-caf5912ec300 duration_ms=1
attachments_test.go:381: status=413 body={"error":{"code":"payload_too_large","message":"image has too many pixels","request_id":"5025a303-9fef-45df-861d-caf5912ec300"}}
attachments_test.go:385: ✓ лимит пикселей по заголовку, без полного декода
--- PASS: TestAttachmentPixelLimit (0.30s)
=== RUN TestAttachmentCorruptAndMimeSpoof
attachments_test.go:390: → мусор, усечённые PNG/JPEG, битый CRC, GIF под видом PNG, подмена Content-Type
2026/12/01 21:58:28 method=POST path=/api/v1/users status=201 request_id=66ac9f5a-7066-4be2-b19c-f83795e84866 duration_ms=58
attachments_test.go:391: создан att_bad_a481e386 id=1cc1f865-5c4a-496a-96ae-c9cac266be6f
2026/12/01 21:58:28 method=POST path=/api/v1/auth/sessions status=201 request_id=6f9c2986-fb7e-4a7f-9c94-89c3cfcdd16b duration_ms=66
attachments_test.go:391: сессия выпущена, длина токена=64 (значение не печатаем)
2026/12/01 21:58:28 method=POST path=/api/v1/chats status=201 request_id=36f7eaf7-2703-4a2d-b032-8aca09670074 duration_ms=13
2026/12/01 21:58:28 method=POST path=/api/v1/chats/9eea2ac0-9591-4857-b412-3ff3c13f874d/attachments status=415 request_id=bf76714c-b8de-41e0-84aa-fc31aae1484e duration_ms=1
attachments_test.go:419: случайные байты как png → 415
2026/12/01 21:58:28 method=POST path=/api/v1/chats/9eea2ac0-9591-4857-b412-3ff3c13f874d/attachments status=415 request_id=5edb8ff9-3701-4f03-ab14-a278cbec3536 duration_ms=3
attachments_test.go:419: пустое тело → 415
2026/12/01 21:58:28 method=POST path=/api/v1/chats/9eea2ac0-9591-4857-b412-3ff3c13f874d/attachments status=415 request_id=9ce7f04f-9843-4e1a-aa7e-2ad30e67876c duration_ms=2
attachments_test.go:419: усечённый PNG → 415
2026/12/01 21:58:28 method=POST path=/api/v1/chats/9eea2ac0-9591-4857-b412-3ff3c13f874d/attachments status=415 request_id=08835f47-f805-45b4-b59c-9351a2d67756 duration_ms=2
attachments_test.go:419: усечённый JPEG → 415
2026/12/01 21:58:28 method=POST path=/api/v1/chats/9eea2ac0-9591-4857-b412-3ff3c13f874d/attachments status=415 request_id=2aeb65a6-7105-45d1-bcde-168f34398f93 duration_ms=4
attachments_test.go:419: PNG с битым CRC → 415
2026/12/01 21:58:28 method=POST path=/api/v1/chats/9eea2ac0-9591-4857-b412-3ff3c13f874d/attachments status=415 request_id=88f84fd9-0199-4186-9ba8-2f0359178163 duration_ms=4
attachments_test.go:419: GIF под видом PNG → 415
2026/12/01 21:58:28 method=POST path=/api/v1/chats/9eea2ac0-9591-4857-b412-3ff3c13f874d/attachments status=415 request_id=28d1a37a-6741-45df-a5d6-9bfbb8c0487a duration_ms=4
attachments_test.go:419: PNG под видом JPEG (спуфинг) → 415
2026/12/01 21:58:28 method=POST path=/api/v1/chats/9eea2ac0-9591-4857-b412-3ff3c13f874d/attachments status=415 request_id=eb181878-746c-4f6e-8f43-b4880f63871c duration_ms=5
attachments_test.go:419: JPEG под видом PNG (спуфинг) → 415
2026/12/01 21:58:28 method=POST path=/api/v1/chats/9eea2ac0-9591-4857-b412-3ff3c13f874d/attachments status=415 request_id=e4e4ed50-c1db-45e5-8df0-cca87f425598 duration_ms=2
attachments_test.go:419: валидный PNG, но Content-Type text/plain → 415
2026/12/01 21:58:28 method=POST path=/api/v1/chats/9eea2ac0-9591-4857-b412-3ff3c13f874d/attachments status=415 request_id=a3710935-96cf-43f2-9a86-46abe7c3bfe5 duration_ms=4
attachments_test.go:419: валидный PNG без Content-Type → 415
2026/12/01 21:58:28 method=POST path=/api/v1/chats/9eea2ac0-9591-4857-b412-3ff3c13f874d/attachments status=415 request_id=83018bb6-5829-41fe-8899-ed9059c31595 duration_ms=2
attachments_test.go:419: валидный PNG, Content-Type image/gif → 415
2026/12/01 21:58:28 method=POST path=/api/v1/chats/9eea2ac0-9591-4857-b412-3ff3c13f874d/attachments status=201 request_id=8a1d010b-4bb9-4735-a135-a19f214c57eb duration_ms=18
attachments_test.go:437: ✓ все повреждённые/подменённые файлы → 415, строки в БД не создаются
--- PASS: TestAttachmentCorruptAndMimeSpoof (0.22s)
=== RUN TestAttachmentFilenameValidation
attachments_test.go:441: → filename: '/', '\', NUL, управляющие, пустое, >255 → 400; unicode и пробелы допустимы
2026/12/01 21:58:28 method=POST path=/api/v1/users status=201 request_id=b6b1cb24-14d3-45b4-934b-8a006871e950 duration_ms=69
attachments_test.go:442: создан att_name_9df1d75b id=c8d128d9-fbc0-40df-9bd8-12670b7302c0
2026/12/01 21:58:28 method=POST path=/api/v1/auth/sessions status=201 request_id=8179cd47-c2f9-4009-9c7d-39b1b67315bd duration_ms=78
attachments_test.go:442: сессия выпущена, длина токена=64 (значение не печатаем)
2026/12/01 21:58:28 method=POST path=/api/v1/chats status=201 request_id=e1565082-23ea-4e6a-a4a6-de15d3580ceb duration_ms=21
2026/12/01 21:58:28 method=POST path=/api/v1/chats/f7573d23-efef-4737-a87d-f1df80895ea2/attachments status=400 request_id=a7250d4d-d76d-47a4-b08d-a6f937cef85d duration_ms=6
2026/12/01 21:58:28 method=POST path=/api/v1/chats/f7573d23-efef-4737-a87d-f1df80895ea2/attachments status=400 request_id=4de33619-7269-4b1d-a7c9-852adc070070 duration_ms=4
2026/12/01 21:58:28 method=POST path=/api/v1/chats/f7573d23-efef-4737-a87d-f1df80895ea2/attachments status=400 request_id=9252b043-2b3e-4c88-ad8b-559f33e5516c duration_ms=5
2026/12/01 21:58:28 method=POST path=/api/v1/chats/f7573d23-efef-4737-a87d-f1df80895ea2/attachments status=400 request_id=d38cbb64-8eb6-406b-9032-8fbaa61ca02c duration_ms=3
2026/12/01 21:58:28 method=POST path=/api/v1/chats/f7573d23-efef-4737-a87d-f1df80895ea2/attachments status=400 request_id=6fe424c9-30fb-4b8b-895f-71c26717f549 duration_ms=4
2026/12/01 21:58:28 method=POST path=/api/v1/chats/f7573d23-efef-4737-a87d-f1df80895ea2/attachments status=400 request_id=0301271b-874d-4e4e-881e-31b44e2ffaa7 duration_ms=6
2026/12/01 21:58:28 method=POST path=/api/v1/chats/f7573d23-efef-4737-a87d-f1df80895ea2/attachments status=400 request_id=c8afc6a1-205f-439e-90d3-8a9d3eafd4f4 duration_ms=4
2026/12/01 21:58:29 method=POST path=/api/v1/chats/f7573d23-efef-4737-a87d-f1df80895ea2/attachments status=400 request_id=8ec00a28-c791-4a1c-8025-884e061060c1 duration_ms=5
2026/12/01 21:58:29 method=POST path=/api/v1/chats/f7573d23-efef-4737-a87d-f1df80895ea2/attachments status=400 request_id=044e7764-dfb5-49e9-b0d9-511d6be71873 duration_ms=4
2026/12/01 21:58:29 method=POST path=/api/v1/chats/f7573d23-efef-4737-a87d-f1df80895ea2/attachments status=400 request_id=b4690595-c901-43d5-8d1a-7d49c64cafb7 duration_ms=3
2026/12/01 21:58:29 method=POST path=/api/v1/chats/f7573d23-efef-4737-a87d-f1df80895ea2/attachments status=400 request_id=d3a06ad0-b41e-4761-9411-c12a399dca2f duration_ms=2
2026/12/01 21:58:29 method=POST path=/api/v1/chats/f7573d23-efef-4737-a87d-f1df80895ea2/attachments status=201 request_id=7e3ac971-0b03-4f6d-997e-6832d2741084 duration_ms=25
2026/12/01 21:58:29 method=POST path=/api/v1/chats/f7573d23-efef-4737-a87d-f1df80895ea2/attachments status=201 request_id=d36b3f2b-4b57-454b-ace9-ff5287a9a609 duration_ms=28
2026/12/01 21:58:29 method=POST path=/api/v1/chats/f7573d23-efef-4737-a87d-f1df80895ea2/attachments status=201 request_id=42167528-fb9c-493e-8606-a7b4c6a53979 duration_ms=48
attachments_test.go:472: ✓ опасные имена отклоняются, обычные Unicode-имена сохраняются как есть
--- PASS: TestAttachmentFilenameValidation (0.36s)
=== RUN TestMessageAttachmentRules
attachments_test.go:478: → foreign attachment_id, вложение другого чата, неизвестный id, лимиты и пустой текст
2026/12/01 21:58:29 method=POST path=/api/v1/users status=201 request_id=8e8e0095-2b8c-4f2d-9b3d-305c6147b0df duration_ms=113
attachments_test.go:481: создан rule_alice_2d2d808f id=a67c47d3-22bc-4087-bae4-8e83a820a6cf
2026/12/01 21:58:29 method=POST path=/api/v1/users status=201 request_id=d5781525-6dfe-4926-bc7a-e761673c1e17 duration_ms=84
attachments_test.go:482: создан rule_mal_84aad169 id=9e7c51c4-60c2-4dd5-8fba-58471ba1ab7d
2026/12/01 21:58:29 method=POST path=/api/v1/auth/sessions status=201 request_id=d2902ce2-f94d-40d4-ba83-d24d67b5152c duration_ms=44
attachments_test.go:483: сессия выпущена, длина токена=64 (значение не печатаем)
2026/12/01 21:58:29 method=POST path=/api/v1/auth/sessions status=201 request_id=c84e6ef6-0209-4471-bfab-38a5c95345ea duration_ms=40
attachments_test.go:484: сессия выпущена, длина токена=64 (значение не печатаем)
2026/12/01 21:58:29 method=POST path=/api/v1/chats status=201 request_id=15e28a73-d0c4-47b7-8296-8c47944234cf duration_ms=3
2026/12/01 21:58:29 method=POST path=/api/v1/chats status=201 request_id=c39dbc33-fa72-4c35-bfb7-3be3c8f1069f duration_ms=4
2026/12/01 21:58:29 method=POST path=/api/v1/chats status=201 request_id=f43ee995-6ebe-42ac-9fa0-ade5d47615ab duration_ms=4
2026/12/01 21:58:29 method=POST path=/api/v1/chats/d06577ab-a895-422d-9d52-dac6f1a03c8c/attachments status=201 request_id=066126fb-b2dc-49f5-b687-a15b1a19933e duration_ms=16
2026/12/01 21:58:29 method=POST path=/api/v1/chats/bf63182a-abdc-494b-bf4d-694807d6e416/attachments status=201 request_id=97246851-0ba5-424f-acd5-7d0a3f195144 duration_ms=16
2026/12/01 21:58:29 method=POST path=/api/v1/chats/d06577ab-a895-422d-9d52-dac6f1a03c8c/messages status=404 request_id=b3ce92ba-259d-44e1-988c-7b17e582be99 duration_ms=24
attachments_test.go:499: status=404 body={"error":{"code":"not_found","message":"object not found","request_id":"b3ce92ba-259d-44e1-988c-7b17e582be99"}}
2026/12/01 21:58:29 method=POST path=/api/v1/chats/339a4757-ac97-40e7-a5e4-8f434d2c2f67/messages status=404 request_id=78b3b2db-ff0d-4669-805f-bfdb1046fa24 duration_ms=7
attachments_test.go:505: status=404 body={"error":{"code":"not_found","message":"object not found","request_id":"78b3b2db-ff0d-4669-805f-bfdb1046fa24"}}
2026/12/01 21:58:29 method=POST path=/api/v1/chats/d06577ab-a895-422d-9d52-dac6f1a03c8c/messages status=404 request_id=9598d50b-cf00-4477-9d47-41712665b6d7 duration_ms=4
2026/12/01 21:58:29 method=POST path=/api/v1/chats/d06577ab-a895-422d-9d52-dac6f1a03c8c/messages status=404 request_id=238574b1-c495-40b3-9a8e-cda6ce5d6481 duration_ms=4
2026/12/01 21:58:29 method=GET path=/api/v1/chats/d06577ab-a895-422d-9d52-dac6f1a03c8c/messages status=200 request_id=b03d7207-96c1-4c41-a835-e80cb5c29364 duration_ms=2
2026/12/01 21:58:29 method=POST path=/api/v1/chats/d06577ab-a895-422d-9d52-dac6f1a03c8c/messages status=400 request_id=82d0a6dd-a779-46dc-926a-5694082c6a14 duration_ms=0
2026/12/01 21:58:29 method=POST path=/api/v1/chats/d06577ab-a895-422d-9d52-dac6f1a03c8c/messages status=400 request_id=82131a11-f938-455b-a064-0a4c03b3d7b3 duration_ms=0
2026/12/01 21:58:29 method=POST path=/api/v1/chats/d06577ab-a895-422d-9d52-dac6f1a03c8c/messages status=400 request_id=bf7f0b83-9906-4e24-b2e1-a3727d976409 duration_ms=0
2026/12/01 21:58:29 method=POST path=/api/v1/chats/d06577ab-a895-422d-9d52-dac6f1a03c8c/messages status=400 request_id=75c74a2a-cfb2-4f00-b32a-bc6d05da3591 duration_ms=0
2026/12/01 21:58:29 method=POST path=/api/v1/chats/d06577ab-a895-422d-9d52-dac6f1a03c8c/messages status=201 request_id=b904c6ba-872c-481d-bc59-8b21566a7730 duration_ms=10
2026/12/01 21:58:29 method=POST path=/api/v1/chats/d06577ab-a895-422d-9d52-dac6f1a03c8c/attachments status=201 request_id=296431a9-422f-4ebe-a331-4dbaaeaca62e duration_ms=12
2026/12/01 21:58:29 method=POST path=/api/v1/chats/d06577ab-a895-422d-9d52-dac6f1a03c8c/attachments status=201 request_id=689372ca-14d6-4beb-88b8-e76256c78e91 duration_ms=13
2026/12/01 21:58:29 method=POST path=/api/v1/chats/d06577ab-a895-422d-9d52-dac6f1a03c8c/attachments status=201 request_id=cb5d495b-1376-47da-8738-03129f7540d7 duration_ms=28
2026/12/01 21:58:29 method=POST path=/api/v1/chats/d06577ab-a895-422d-9d52-dac6f1a03c8c/attachments status=201 request_id=a625301e-4457-4f63-ac66-d41ab621be2e duration_ms=9
2026/12/01 21:58:29 method=POST path=/api/v1/chats/d06577ab-a895-422d-9d52-dac6f1a03c8c/attachments status=201 request_id=df98dbf4-2b78-4f18-8b94-44f389b39a50 duration_ms=8
2026/12/01 21:58:29 method=POST path=/api/v1/chats/d06577ab-a895-422d-9d52-dac6f1a03c8c/attachments status=201 request_id=eb5ace50-5bc6-410b-9ae2-ce6450fe33c1 duration_ms=6
2026/12/01 21:58:29 method=POST path=/api/v1/chats/d06577ab-a895-422d-9d52-dac6f1a03c8c/attachments status=201 request_id=e19c3fda-00b0-450f-ae9b-f577664635f9 duration_ms=16
2026/12/01 21:58:29 method=POST path=/api/v1/chats/d06577ab-a895-422d-9d52-dac6f1a03c8c/attachments status=201 request_id=2bac7d09-f774-413a-849f-5715485d058e duration_ms=10
2026/12/01 21:58:29 method=POST path=/api/v1/chats/d06577ab-a895-422d-9d52-dac6f1a03c8c/attachments status=201 request_id=46652804-bddd-4f08-85a3-763f25644c89 duration_ms=16
2026/12/01 21:58:29 method=POST path=/api/v1/chats/d06577ab-a895-422d-9d52-dac6f1a03c8c/attachments status=201 request_id=a36c77bd-8f19-4894-97b2-98d9100e817c duration_ms=30
2026/12/01 21:58:29 method=POST path=/api/v1/chats/d06577ab-a895-422d-9d52-dac6f1a03c8c/messages status=201 request_id=0e077bd7-b102-4a1b-a116-039c3adfab07 duration_ms=45
2026/12/01 21:58:29 method=POST path=/api/v1/chats/d06577ab-a895-422d-9d52-dac6f1a03c8c/messages status=201 request_id=a6be3265-5d54-4ce2-ad99-07ecc7ee1c68 duration_ms=33
attachments_test.go:565: ✓ чужое/другой чат/неизвестное → 404, лимиты → 400, пустой текст только с вложением
--- PASS: TestMessageAttachmentRules (0.64s)
=== RUN TestS3DownGivesLimitedError
attachments_test.go:571: → API с недоступным S3: upload/ready → 503, без утечек и полуфабрикатов в БД
2026/12/01 21:58:29 method=POST path=/api/v1/users status=201 request_id=7a6cccf3-47d2-490d-8e87-fc530fde19c8 duration_ms=66
attachments_test.go:580: создан att_down_25eeb87b id=5f2b6d44-5c30-44ec-b566-81fbe27fe220
2026/12/01 21:58:29 method=POST path=/api/v1/auth/sessions status=201 request_id=f41dcf59-4c9f-4fc9-8ec4-87bda5964e45 duration_ms=48
attachments_test.go:580: сессия выпущена, длина токена=64 (значение не печатаем)
2026/12/01 21:58:29 method=POST path=/api/v1/chats status=201 request_id=d972f16f-0c5f-45d5-a65b-c781e0ae62c6 duration_ms=5
2026/12/01 21:58:31 request_id=a805df0d-e338-45e2-9c1d-d943d429b426 attachment_put_failed err=object store unavailable
2026/12/01 21:58:31 method=POST path=/api/v1/chats/8a6d80a2-dd26-4056-8a77-6a73968b8239/attachments status=503 request_id=a805df0d-e338-45e2-9c1d-d943d429b426 duration_ms=1515
attachments_test.go:591: upload при лежащем S3: status=503 за 1.516s body={"error":{"code":"unavailable","message":"dependency unavailable","request_id":"a805df0d-e338-45e2-9c1d-d943d429b426"}}
2026/12/01 21:58:32 method=GET path=/health/ready status=503 request_id=9bf4e6dd-96f5-41cd-809a-84f1861a2734 duration_ms=703
attachments_test.go:616: ✓ лежащий S3 → 503 без деталей, ready=503, live=200, БД чиста
--- PASS: TestS3DownGivesLimitedError (2.37s)
=== RUN TestCompensationWhenPostgresFailsAfterPut
attachments_test.go:633: → отказ PG после успешного PUT: объект удаляется компенсацией
2026/12/01 21:58:32 method=POST path=/api/v1/users status=201 request_id=2d3d9918-2a1f-4a50-9b6f-f3b95d45dbb0 duration_ms=82
attachments_test.go:635: создан att_comp_4b586851 id=b35bceff-ae42-4556-aa6e-d0f6e1df1938
2026/12/01 21:58:32 method=POST path=/api/v1/auth/sessions status=201 request_id=c72adeeb-9085-439c-a8e4-63e053d75a28 duration_ms=50
attachments_test.go:635: сессия выпущена, длина токена=64 (значение не печатаем)
2026/12/01 21:58:32 method=POST path=/api/v1/chats status=201 request_id=8d71c20a-b369-4c8c-ad88-b6e9d013a4f5 duration_ms=5
2026/12/01 21:58:32 request_id=dd2b5886-12a1-4baf-babf-0493879c2c90 attachment_compensated key=attachments/84fc1350-72dc-4ebc-8356-59a9a6844213/3f6af15f-0a5f-4cf8-adf6-5751acce28d4 (PG insert не удался, объект удалён)
2026/12/01 21:58:32 method=POST path=/api/v1/chats/84fc1350-72dc-4ebc-8356-59a9a6844213/attachments status=503 request_id=dd2b5886-12a1-4baf-babf-0493879c2c90 duration_ms=17
attachments_test.go:668: status=503 body={"error":{"code":"unavailable","message":"dependency unavailable","request_id":"dd2b5886-12a1-4baf-babf-0493879c2c90"}}
key=attachments/84fc1350-72dc-4ebc-8356-59a9a6844213/3f6af15f-0a5f-4cf8-adf6-5751acce28d4
attachments_test.go:682: ✓ orphan после отказа PG удалён сразу; если бы удаление не удалось — его уберёт reconciler
--- PASS: TestCompensationWhenPostgresFailsAfterPut (0.22s)
=== RUN TestConcurrentUploads
attachments_test.go:687: → 12 параллельных загрузок: все 201, уникальные id, sha256 совпадает
2026/12/01 21:58:32 method=POST path=/api/v1/users status=201 request_id=b5a93c03-7b3d-4e9b-addb-7635ab6b8b86 duration_ms=39
attachments_test.go:688: создан att_conc_85e68ede id=68ffe16b-f50a-499f-b480-41d6aecd49ec
2026/12/01 21:58:32 method=POST path=/api/v1/auth/sessions status=201 request_id=2c659ceb-212a-4304-8b36-69630965b3dc duration_ms=32
attachments_test.go:688: сессия выпущена, длина токена=64 (значение не печатаем)
2026/12/01 21:58:32 method=POST path=/api/v1/chats status=201 request_id=b6a5f0d7-1e78-480b-89af-a63f638b1932 duration_ms=1
2026/12/01 21:58:32 method=POST path=/api/v1/chats/8633cf35-0472-4270-b41f-ca967df21189/attachments status=201 request_id=133c62e2-0a7e-4f36-a70c-e8729cbba6dd duration_ms=42
2026/12/01 21:58:32 method=POST path=/api/v1/chats/8633cf35-0472-4270-b41f-ca967df21189/attachments status=201 request_id=6a06818b-94c5-4606-a808-2f2dc258a3c1 duration_ms=41
2026/12/01 21:58:32 method=POST path=/api/v1/chats/8633cf35-0472-4270-b41f-ca967df21189/attachments status=201 request_id=74a535e6-9a97-4612-9408-08556a195ce3 duration_ms=45
2026/12/01 21:58:32 method=POST path=/api/v1/chats/8633cf35-0472-4270-b41f-ca967df21189/attachments status=201 request_id=bcbc44c9-0d4e-43d4-9888-da300d444777 duration_ms=50
2026/12/01 21:58:32 method=POST path=/api/v1/chats/8633cf35-0472-4270-b41f-ca967df21189/attachments status=201 request_id=ddef005c-4035-4892-a33b-457382986bd8 duration_ms=58
2026/12/01 21:58:32 method=POST path=/api/v1/chats/8633cf35-0472-4270-b41f-ca967df21189/attachments status=201 request_id=6abe3e08-5493-4e00-bec0-45f11410bffa duration_ms=62
2026/12/01 21:58:32 method=POST path=/api/v1/chats/8633cf35-0472-4270-b41f-ca967df21189/attachments status=201 request_id=55edd557-90c7-4a23-a6f8-6236bce19c8a duration_ms=66
2026/12/01 21:58:32 method=POST path=/api/v1/chats/8633cf35-0472-4270-b41f-ca967df21189/attachments status=201 request_id=12827294-8fc6-44b7-9705-a3b7b57484a1 duration_ms=68
2026/12/01 21:58:32 method=POST path=/api/v1/chats/8633cf35-0472-4270-b41f-ca967df21189/attachments status=201 request_id=dbcd6ff5-e984-4404-9244-82fde35fb20d duration_ms=75
2026/12/01 21:58:32 method=POST path=/api/v1/chats/8633cf35-0472-4270-b41f-ca967df21189/attachments status=201 request_id=64efc355-998c-40ba-8cee-159280bbb56d duration_ms=78
2026/12/01 21:58:32 method=POST path=/api/v1/chats/8633cf35-0472-4270-b41f-ca967df21189/attachments status=201 request_id=8e78f9f4-3775-4de5-a5db-39a8175c77f7 duration_ms=74
2026/12/01 21:58:32 method=POST path=/api/v1/chats/8633cf35-0472-4270-b41f-ca967df21189/attachments status=201 request_id=c959d8e8-f0a8-43e7-830d-dd6d30343702 duration_ms=77
2026/12/01 21:58:32 method=GET path=/api/v1/attachments/d7dc21a4-a15f-4aad-a596-e3f4e0b645a9/content status=200 request_id=49ddad0a-4318-4467-9f01-f6533f9b010b duration_ms=24
2026/12/01 21:58:32 method=GET path=/api/v1/attachments/46cc28c2-6b00-4961-ad8a-0cfd678d04b7/content status=200 request_id=90f23104-cb67-4945-9262-00bcf108b97b duration_ms=32
2026/12/01 21:58:32 method=GET path=/api/v1/attachments/66f80456-6c14-4538-89a7-2359fc13bb4b/content status=200 request_id=dbc51978-1977-49a4-8ca8-d47fdc5fc5dc duration_ms=6
2026/12/01 21:58:32 method=GET path=/api/v1/attachments/4e6536c7-550f-4ad0-8259-0da355cb40c1/content status=200 request_id=e67435e0-b036-425e-be71-b5b432eba508 duration_ms=3
2026/12/01 21:58:32 method=GET path=/api/v1/attachments/13bb5198-4505-4d1a-a889-b50445970f61/content status=200 request_id=d66d5f55-4067-4f5e-a069-3bda2aab1d53 duration_ms=4
2026/12/01 21:58:32 method=GET path=/api/v1/attachments/9c36ddcd-1b64-49a8-8578-0fb3b70f70a5/content status=200 request_id=022ddf3a-b2a7-4294-a140-ea19c1b071fe duration_ms=7
2026/12/01 21:58:32 method=GET path=/api/v1/attachments/9608e69f-275c-443a-8400-f167aad7abf4/content status=200 request_id=916e2848-0c5c-4335-8f4c-4b386ea3c565 duration_ms=8
2026/12/01 21:58:32 method=GET path=/api/v1/attachments/c77839fd-d7f5-4b8c-9757-52bd0a22c624/content status=200 request_id=9367eaae-c5ed-4170-8463-8b1a44de72b3 duration_ms=8
2026/12/01 21:58:32 method=GET path=/api/v1/attachments/3b07eb6e-96a6-4a7b-976d-d1a5b727a6b7/content status=200 request_id=ab82c88e-7a45-498b-acea-0735e5a6df98 duration_ms=5
2026/12/01 21:58:32 method=GET path=/api/v1/attachments/8a97b163-ab17-4f16-8217-c67d55d4c5f9/content status=200 request_id=a12c7567-4c5f-4f63-9b78-ac76585b6177 duration_ms=8
2026/12/01 21:58:32 method=GET path=/api/v1/attachments/2dd2df8b-2a62-48b3-8714-58d456528644/content status=200 request_id=ff00108e-4e98-4713-bc5a-25d59fbea2b9 duration_ms=6
2026/12/01 21:58:32 method=GET path=/api/v1/attachments/a2fa0804-5e6f-4d1b-9740-66e7aa8d9613/content status=200 request_id=ae20b934-4cc7-478a-86e8-9eb0e62bf36e duration_ms=3
attachments_test.go:722: ✓ параллельные загрузки целы
--- PASS: TestConcurrentUploads (0.29s)
=== RUN TestObjectKeyIsServerAssigned
attachments_test.go:727: → ключ объекта = attachments/{chat}/{id}; filename в ключ не попадает
2026/12/01 21:58:32 method=POST path=/api/v1/users status=201 request_id=6477b5e5-fc58-4df9-b421-e79013b0c792 duration_ms=50
attachments_test.go:728: создан att_key_e09ba1ad id=a638e6af-0a06-4131-8b42-87ad79599f15
2026/12/01 21:58:32 method=POST path=/api/v1/auth/sessions status=201 request_id=53303bcb-9119-40aa-90b4-76c97b180702 duration_ms=38
attachments_test.go:728: сессия выпущена, длина токена=64 (значение не печатаем)
2026/12/01 21:58:32 method=POST path=/api/v1/chats status=201 request_id=37a65e64-d59e-4a19-87aa-0c3b35e7d423 duration_ms=4
2026/12/01 21:58:32 method=POST path=/api/v1/chats/7bb6c813-d438-4e05-bff5-076d254f1d65/attachments status=201 request_id=deb0513a-a897-45a0-91e5-25a4b92ff65c duration_ms=5
attachments_test.go:742: ✓ ключ серверный: attachments/7bb6c813-d438-4e05-bff5-076d254f1d65/9af53ef4-05d3-4842-923c-de3c10dc9068
--- PASS: TestObjectKeyIsServerAssigned (0.11s)
PASS
ok gavrilenko-sxdees/lab4/student-tests 12.953s