test: media smoke - direct-only download, file-name search

This commit is contained in:
2026-09-26 05:10:25 +02:00
parent 50f0f98c8e
commit ff0ab049e4
+10 -3
View File
@@ -47,6 +47,9 @@ MEDIA_ID=$(echo "$UPLOAD" | jq -r '.attachment.id // empty')
CREATED_POSTS+=("$MEDIA_ID")
tool lit-media-search '{"search":"LIT Smoke","missing_alt":true}' \
| jq -e --argjson id "$MEDIA_ID" '.items[] | select(.id == $id)' >/dev/null || fail "missing_alt search"
# The file name (lit-smoke.png) is searched too, not only title/caption ("LIT Smoke Bild").
tool lit-media-search '{"search":"lit-smoke"}' \
| jq -e --argjson id "$MEDIA_ID" '.items[] | select(.id == $id)' >/dev/null || fail "file-name search"
PREVIEW=$(rpc tools/call "{\"name\":\"lit-media-preview\",\"arguments\":{\"id\":$MEDIA_ID}}")
echo "$PREVIEW" | jq -e '.result.content[0].type == "image" and (.result.content[0].data | length) > 0' >/dev/null \
|| fail "media-preview: $PREVIEW"
@@ -59,9 +62,13 @@ BATCH_FAIL=$(ability lit/media-update "{\"items\":[{\"id\":$MEDIA_ID,\"alt\":\"g
[ "$(error_code "$BATCH_FAIL")" = "not_found" ] || fail "media-update batch with unknown id should refuse entirely: $BATCH_FAIL"
[ "$(wp post meta get "$MEDIA_ID" _wp_attachment_image_alt)" = "Testbild" ] \
|| fail "media-update batch refusal must not have changed anything"
ability lit/media-download "{\"id\":$MEDIA_ID}" | jq -e '.type == "resource" and .resource.mimeType == "image/png"' >/dev/null \
|| fail "media-download"
pass "upload, search, preview, update (single ok, mixed batch refused), download"
DOWNLOAD=$(rpc tools/call "{\"name\":\"lit-media-download\",\"arguments\":{\"id\":$MEDIA_ID}}")
echo "$DOWNLOAD" | jq -e '.result.content[0].type == "resource" and .result.content[0].resource.mimeType == "image/png"
and (.result.content[0].resource.blob | length) > 0' >/dev/null || fail "media-download: $DOWNLOAD"
# Direct-only tools are not public for the meta-tools (their results only work as direct tools).
DOWNLOAD_META=$(ability lit/media-download "{\"id\":$MEDIA_ID}")
echo "$DOWNLOAD_META" | jq -e 'has("__error")' >/dev/null || fail "media-download via execute-ability: $DOWNLOAD_META"
pass "upload, search, preview, update (single ok, mixed batch refused), download (direct only)"
# 3. Import protection
SSRF=$(tool lit-media-upload-from-url '{"url":"http://127.0.0.1/wp-login.php"}')