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 <noreply@anthropic.com>
This commit is contained in:
parent
f83f36fdfb
commit
aa1a9fc232
1 changed files with 7 additions and 2 deletions
|
|
@ -71,12 +71,17 @@ echo "== --check Exit-Code (läuft -> 0) =="
|
||||||
rc=0; "$CLI" --check "${base[@]}" >/dev/null 2>&1 || rc=$?
|
rc=0; "$CLI" --check "${base[@]}" >/dev/null 2>&1 || rc=$?
|
||||||
[ "$rc" -eq 0 ] && ok "--check == 0" || bad "--check == $rc (erwartet 0)"
|
[ "$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 =="
|
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)"
|
[ "$code" = "401" ] && ok "unauth -> 401" || bad "unauth -> $code (erwartet 401)"
|
||||||
|
|
||||||
echo "== API-Key: mit Key -> 200 =="
|
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)"
|
[ "$code" = "200" ] && ok "auth -> 200" || bad "auth -> $code (erwartet 200)"
|
||||||
|
|
||||||
echo "== chat (Tool sendet Bearer-Key) =="
|
echo "== chat (Tool sendet Bearer-Key) =="
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue