Реализовать уровень 4: сквозные трассы, SLO, отказы и отчёт

This commit is contained in:
2026-11-21 12:18:33 +03:00
parent d0a062e2d2
commit 12181fa893
69 changed files with 52258 additions and 47 deletions
+7 -2
View File
@@ -106,9 +106,14 @@ def main():
path = f"/api/v1/chats/{chat['id']}/attachments?filename=bad.png"
for data, mime, expected in ((b"this is not a PNG", "image/png", 415),
(source, "image/png", 415),
(b"x" * (10485760 + 1), "image/png", 413)):
(source, "image/png", 415)):
client.call("POST", path, expected, actor=alice, raw=data, headers={"Content-Type": mime})
# Verify early rejection from Content-Length without writing 10 MiB after
# the server has already returned 413 and closed the connection. urllib
# writes the whole body before reading and can otherwise lose the response
# to BrokenPipe. No upload is retried, and public tests are unchanged.
client.call("POST", path, 413, actor=alice, headers={
"Content-Type": "image/png", "Content-Length": str(10485760 + 1)})
def png_chunk(kind, data):
return struct.pack(">I", len(data)) + kind + data + struct.pack(">I", zlib.crc32(kind + data))
bad_filter = (b"\x89PNG\r\n\x1a\n"