fix(student-tests):lab4 parse JSON body for 201 uploads

This commit is contained in:
Голиков Maximillian Антон
2026-10-23 11:27:08 +03:00
parent e799879f9e
commit fa3e919ad4
+4 -2
View File
@@ -20,9 +20,11 @@ def upload(c, actor, chat, content, content_type, filename='x.png', expected=201
actor=actor,
raw=content,
headers={'Content-Type': content_type},
schema='Attachment',
)
def main():
args = arguments('Негативные сценарии вложений')
c = Client(args.base_url, args.ca_file)
@@ -35,10 +37,10 @@ def main():
'11 MiB: ожидался payload_too_large')
# 2. Битый PNG (обрезанный header) -> 415
broken = SAMPLE[:100]
broken = b'\x89PNG\r\n\x1a\n' + b'\x00' * 32
r = upload(c, alice, chat, broken, 'image/png', expected=415)
check(r['json']['error']['code'] == 'unsupported_media_type',
'битый PNG: ожидался unsupported_media_type')
'битый PNG (нет IHDR): ожидался unsupported_media_type')
# 3. MIME-подмена: PNG-байты с Content-Type image/jpeg -> 201, но content_type image/png
r = upload(c, alice, chat, SAMPLE, 'image/jpeg')