fit: complete lab4, fix P1.1-P1.3, add Track 1 presigned

This commit is contained in:
2026-11-06 04:23:59 +03:00
parent 3223dd469a
commit 7741b66fd2
16 changed files with 577 additions and 219 deletions
+9 -4
View File
@@ -27,14 +27,12 @@ assert_eq "$CT" "image/png" content_type_header
# PUT bytes on the compose network (MinIO ports stay unpublished by default).
ROOT="$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)"
COMPOSE="docker compose --env-file $ROOT/.env -f $ROOT/compose.yaml"
$COMPOSE run --rm --no-deps \
put_code=$($COMPOSE run --rm --no-deps \
-v "$png:/tmp/up.bin:ro" \
--entrypoint curl api \
-sS -m 60 -o /dev/null -w '%{http_code}' \
-X PUT -H "Content-Type: $CT" --data-binary @/tmp/up.bin \
"$UPLOAD_URL" > /tmp/du_put_code.$$
put_code=$(cat /tmp/du_put_code.$$)
rm -f /tmp/du_put_code.$$
"$UPLOAD_URL")
[ "$put_code" = "200" ] || die "presigned PUT expected 200 got $put_code"
http_json POST "/api/v1/direct-uploads/$UPLOAD_ID/complete" \
@@ -45,6 +43,13 @@ assert_eq "$(printf '%s' "$HTTP_BODY" | jq -r .sha256)" "$want_sha" sha256
assert_eq "$(printf '%s' "$HTTP_BODY" | jq -r .id)" "$UPLOAD_ID" attachment_id
out=$(mktemp)
replay_code=$($COMPOSE run --rm --no-deps \
--entrypoint curl api \
-sS -m 60 -o /dev/null -w '%{http_code}' \
-X PUT -H "Content-Type: $CT" --data-binary 'replay-content-12345' \
"$UPLOAD_URL")
[ "$replay_code" = "200" ] || die "replay PUT expected 200 got $replay_code"
curl -sS -m 60 -o "$out" -H "Authorization: Bearer $ALICE_TOKEN" \
"$BASE_URL/api/v1/attachments/$UPLOAD_ID/content"
assert_eq "$(sha256_file "$out")" "$want_sha" download_sha256