From aa1a9fc232f51548f85cc7bab50e75f648c99a13 Mon Sep 17 00:00:00 2001 From: dschlueter Date: Mon, 6 Jul 2026 17:25:41 +0200 Subject: [PATCH] test(smoke): probe a protected endpoint for the api-key check llama.cpp exempts /health and /v1/models from --api-key; only /v1/chat/completions is protected. The smoke test probed /v1/models and thus saw 200 without a key. Probe /v1/chat/completions instead (no key -> 401, key -> 200). Verified live end-to-end: 9 PASS, 0 FAIL. Co-Authored-By: Claude Opus 4.8 --- scripts/smoke.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/smoke.sh b/scripts/smoke.sh index 7052d84..9d27494 100755 --- a/scripts/smoke.sh +++ b/scripts/smoke.sh @@ -71,12 +71,17 @@ echo "== --check Exit-Code (läuft -> 0) ==" rc=0; "$CLI" --check "${base[@]}" >/dev/null 2>&1 || rc=$? [ "$rc" -eq 0 ] && ok "--check == 0" || bad "--check == $rc (erwartet 0)" +# Probe a PROTECTED endpoint: llama.cpp exempts /health and /v1/models from the +# API key, but /v1/chat/completions requires it. +chat_probe='{"messages":[{"role":"user","content":"hi"}],"max_tokens":1}' echo "== API-Key erzwungen: ohne Key -> 401 ==" -code=$(curl -s -o /dev/null -w '%{http_code}' "http://127.0.0.1:$PORT/v1/models") +code=$(curl -s -o /dev/null -w '%{http_code}' -X POST "http://127.0.0.1:$PORT/v1/chat/completions" \ + -H 'Content-Type: application/json' -d "$chat_probe") [ "$code" = "401" ] && ok "unauth -> 401" || bad "unauth -> $code (erwartet 401)" echo "== API-Key: mit Key -> 200 ==" -code=$(curl -s -o /dev/null -w '%{http_code}' -H "Authorization: Bearer $API_KEY" "http://127.0.0.1:$PORT/v1/models") +code=$(curl -s -o /dev/null -w '%{http_code}' -X POST "http://127.0.0.1:$PORT/v1/chat/completions" \ + -H 'Content-Type: application/json' -H "Authorization: Bearer $API_KEY" -d "$chat_probe") [ "$code" = "200" ] && ok "auth -> 200" || bad "auth -> $code (erwartet 200)" echo "== chat (Tool sendet Bearer-Key) =="