forked from mtusi2026/mtusi2026lab4
lab4
This commit is contained in:
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
# Non-member → 404 on GET metadata and /content (no leak).
|
||||
set -eu
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
|
||||
png="$FIXTURES/tiny.png"
|
||||
[ -f "$png" ] || die "missing fixture $png"
|
||||
|
||||
register_user alice
|
||||
ALICE_ID=$USER_ID
|
||||
ALICE_TOK=$TOKEN
|
||||
register_user eve
|
||||
EVE_TOK=$TOKEN
|
||||
|
||||
TOKEN=$ALICE_TOK
|
||||
create_chat 'foreign' "[\"$ALICE_ID\"]"
|
||||
upload_file "$CHAT_ID" "$png" 'tiny.png' 'image/png'
|
||||
expect_code 201
|
||||
AID=$(printf '%s' "$HTTP_BODY" | jq -r .id)
|
||||
|
||||
http_json GET "/api/v1/attachments/$AID" -H "Authorization: Bearer $EVE_TOK"
|
||||
expect_code 404
|
||||
assert_eq "$(printf '%s' "$HTTP_BODY" | jq -r .error.code)" not_found meta
|
||||
|
||||
http_json GET "/api/v1/attachments/$AID/content" -H "Authorization: Bearer $EVE_TOK"
|
||||
expect_code 404
|
||||
assert_eq "$(printf '%s' "$HTTP_BODY" | jq -r .error.code)" not_found content
|
||||
|
||||
http_json GET "/api/v1/attachments/$AID"
|
||||
expect_code 401
|
||||
|
||||
printf 'PASS test_attachment_foreign\n'
|
||||
Reference in New Issue
Block a user