fix(student-tests):lab4 parse JSON body for 201 uploads
This commit is contained in:
@@ -20,9 +20,11 @@ def upload(c, actor, chat, content, content_type, filename='x.png', expected=201
|
|||||||
actor=actor,
|
actor=actor,
|
||||||
raw=content,
|
raw=content,
|
||||||
headers={'Content-Type': content_type},
|
headers={'Content-Type': content_type},
|
||||||
|
schema='Attachment',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
args = arguments('Негативные сценарии вложений')
|
args = arguments('Негативные сценарии вложений')
|
||||||
c = Client(args.base_url, args.ca_file)
|
c = Client(args.base_url, args.ca_file)
|
||||||
@@ -35,10 +37,10 @@ def main():
|
|||||||
'11 MiB: ожидался payload_too_large')
|
'11 MiB: ожидался payload_too_large')
|
||||||
|
|
||||||
# 2. Битый PNG (обрезанный header) -> 415
|
# 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)
|
r = upload(c, alice, chat, broken, 'image/png', expected=415)
|
||||||
check(r['json']['error']['code'] == 'unsupported_media_type',
|
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
|
# 3. MIME-подмена: PNG-байты с Content-Type image/jpeg -> 201, но content_type image/png
|
||||||
r = upload(c, alice, chat, SAMPLE, 'image/jpeg')
|
r = upload(c, alice, chat, SAMPLE, 'image/jpeg')
|
||||||
|
|||||||
Reference in New Issue
Block a user