fix: validate required schema and support bounded JPEG file objects

This commit is contained in:
2026-11-06 18:09:32 +03:00
parent 1779b5f036
commit 14c659fda4
5 changed files with 58 additions and 3 deletions
+14
View File
@@ -199,3 +199,17 @@ def test_truncated_jpeg_with_forged_eoi(scenario):
mime="image/jpeg",
status=415,
)
def test_internal_jpeg_bytesio_fallback():
import shutil
from messenger.attachments import validate_image
if shutil.which("djpeg") is None:
pytest.skip(
"Internal BytesIO helper requires host djpeg; HTTP JPEG validation runs in Docker regardless"
)
stream = BytesIO(image_bytes("JPEG"))
assert validate_image(stream, "image/jpeg") == ("image/jpeg", 32, 20)
assert stream.tell() == 0