# attachments: lab4: files, limits, damaged images, MIME, filenames, access, attachment_ids # date: 2026-10-21 21:03:05, commit: 2dbed80 # command: python.exe student-tests/test_attachments.py # exit code: 0, 4.0 s sample.png: 111817 bytes, sha256 99ea7533c441..., downloaded by the other member, same bytes sample.jpg: 1492 bytes, sha256 c310b9a1c208..., downloaded by the other member, same bytes progressive.jpg: 1081 bytes, sha256 913df01aec84..., downloaded by the other member, same bytes interlaced.png: 79 bytes, sha256 38149222f78f..., downloaded by the other member, same bytes 1x1.png: 67 bytes, sha256 eaa4a94ea300..., downloaded by the other member, same bytes PASS: PNG, JPEG, progressive JPEG, interlaced PNG and 1x1 PNG are stored and returned byte for byte exactly 10485760 bytes (10 MiB) -> 201 10485761 bytes (10 MiB + 1) with Content-Length -> 413 before reading the body PASS: the 10 MiB limit is exact 12 MiB without Content-Length (chunked) -> 413 as soon as the 10 MiB limit is passed PASS: oversized streamed body is cut off, the API keeps working 8000x5000 = 40 000 000 pixels (38957 bytes compressed) -> 201 5ffe6847 8001x5000 = 40 005 000 pixels (38962 bytes) -> 413 header claims 100000x100000 in 65 bytes -> 413 from the header, nothing is decoded PASS: pixel limit is checked before decompression PNG cut in half (55908 bytes, image/png) -> 415 PNG without IEND (111805 bytes, image/png) -> 415 PNG with a flipped byte in IDAT (CRC mismatch) (111817 bytes, image/png) -> 415 PNG with garbage after IEND (111824 bytes, image/png) -> 415 PNG signature only (8 bytes, image/png) -> 415 PNG with less pixel data than the header says (68 bytes, image/png) -> 415 JPEG cut in half (746 bytes, image/jpeg) -> 415 JPEG header only (20 bytes, image/jpeg) -> 415 random bytes (1600 bytes, image/png) -> 415 plain text (28 bytes, image/jpeg) -> 415 empty body -> 400 PASS: damaged and foreign files are rejected with 415, never 500 PNG bytes sent as image/jpeg -> 415 JPEG bytes sent as image/png -> 415 GIF bytes sent as image/png -> 415 PNG sent as image/gif -> 415 PNG sent as text/html -> 415 PNG sent as application/octet-stream -> 415 PNG sent as multipart/form-data -> 415 PNG sent as 'IMAGE/PNG; charset=binary' -> 201, stored as image/png PASS: the type is taken from the content; a declared type that does not match is refused 13 dangerous or invalid names (path, slashes, NUL, control characters, empty, 256 chars) -> 400 no filename -> 400 Unicode, 255 chars, leading dots, %20 and ? are kept as display names only PASS: filename never becomes a path; dangerous names are refused outsider -> 404 for metadata and bytes (same as a non-existent id); no token -> 401; bad UUID -> 400 upload into someone else's / unknown chat -> 404, without token -> 401 variant=thumbnail -> 400 (not in the lab4 contract), variant=original -> 200 PASS: only chat members can see an attachment text='' with 2 attachments -> 201, order kept; any member may attach a file uploaded by another member history returns attachment_ids for every message, [] for a message without files; reuse is allowed attachment of another chat (author is a member of both) -> 404 own + foreign attachment -> 404 unknown attachment_id -> 404 outsider referencing an attachment of the chat -> 404 duplicate ids -> 400 11 ids -> 400 bad UUID -> 400 empty text without attachments -> 400 whitespace text without attachments -> 400 PASS: only attachments of the same chat can be linked; rejected requests change nothing same key + same attachments -> same 201; other attachments -> 409; missing field == [] PASS: Idempotency-Key covers attachment_ids sent 1.1 MB of a declared 5 MB body and closed the connection the API keeps serving uploads; nothing of the aborted request is visible (DB/S3 side is checked by test_consistency.py) PASS: an interrupted upload is dropped 11 passed, 0 failed