Files
mtusi2026lab4/evidence/attachments-before-strict-jpeg.txt
T

44 lines
2.0 KiB
Plaintext

..........................F [100%]
=================================== FAILURES ===================================
_____________________ test_truncated_jpeg_with_forged_eoi ______________________
scenario = (<client.Client object at 0x105defaa0>, {'id': '881b708c-1c42-4d33-a7ff-0a24d24180ed', 'user': {'id': '881b708c-1c42-4...-06T14:52:44.187538Z', 'member_ids': ['881b708c-1c42-4d33-a7ff-0a24d24180ed', 'e9f642b2-d052-420a-9f41-113bc79347fe']})
def test_truncated_jpeg_with_forged_eoi(scenario):
import random
stream = BytesIO()
Image.frombytes("RGB", (512, 512), random.Random(42).randbytes(512 * 512 * 3)).save(
stream, "JPEG", quality=95
)
original = stream.getvalue()
upload(scenario, data=original, name="real.jpg", mime="image/jpeg")
> upload(
scenario,
data=original[: len(original) // 2] + b"\xff\xd9",
name="broken.jpg",
mime="image/jpeg",
status=415,
)
student-tests/test_attachments.py:195:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
student-tests/test_attachments.py:30: in upload
return c.call(
tests/client.py:132: in call
check(status in allowed, method + ' ' + path.split('?')[0] + ': expected ' + str(allowed) + ', received ' + str(status))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
condition = False
message = 'POST /api/v1/chats/ed1d5486-a609-41e0-8066-e2abfcd078c0/attachments: expected [415], received 201'
def check(condition, message):
if not condition:
> raise Failure(message)
E client.Failure: POST /api/v1/chats/ed1d5486-a609-41e0-8066-e2abfcd078c0/attachments: expected [415], received 201
tests/client.py:24: Failure
=========================== short test summary info ============================
FAILED student-tests/test_attachments.py::test_truncated_jpeg_with_forged_eoi
1 failed, 26 passed in 0.93s