lab4
This commit is contained in:
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
# Grade 4 criteria (negative): 11 MiB body → 413 payload_too_large (not 500).
|
||||
set -eu
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
|
||||
register_user alice
|
||||
create_chat 'too-large' "[\"$USER_ID\"]"
|
||||
|
||||
big=$(mktemp)
|
||||
# Valid PNG magic + padding to 11 MiB so Content-Length triggers early reject.
|
||||
dd if=/dev/zero of="$big" bs=1M count=11 status=none
|
||||
# Prepend PNG signature so it's not rejected as empty before size check.
|
||||
printf '\x89PNG\r\n\x1a\n' | dd of="$big" conv=notrunc status=none 2>/dev/null || true
|
||||
|
||||
upload_file "$CHAT_ID" "$big" 'huge.png' 'image/png'
|
||||
rm -f "$big"
|
||||
expect_code 413
|
||||
code=$(printf '%s' "$HTTP_BODY" | jq -r .error.code)
|
||||
assert_eq "$code" payload_too_large error_code
|
||||
|
||||
printf 'PASS test_attachment_too_large\n'
|
||||
Reference in New Issue
Block a user