#!/bin/sh # Truncated / corrupt PNG → 415 (not 500). set -eu . "$(dirname "$0")/lib.sh" register_user alice create_chat 'corrupt' "[\"$USER_ID\"]" bad=$(mktemp) # PNG magic + IHDR-looking garbage, truncated — fails stbi decode. printf '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x01\x00\x00\x00\x01\x00\x08\x02\x00\x00\x00' > "$bad" upload_file "$CHAT_ID" "$bad" 'broken.png' 'image/png' rm -f "$bad" expect_code 415 code=$(printf '%s' "$HTTP_BODY" | jq -r .error.code) assert_eq "$code" unsupported_media_type error_code printf 'PASS test_attachment_corrupted\n'