fix(deploy): test-api.sh — fix login POST, sequences 400, settings/ampp path
This commit is contained in:
parent
115c7340ee
commit
96ef569720
1 changed files with 31 additions and 31 deletions
|
|
@ -26,7 +26,7 @@ header() { echo -e "\n${BLD}$1${NC}"; }
|
||||||
AUTH_ARGS=()
|
AUTH_ARGS=()
|
||||||
[[ -n "$TOKEN" ]] && AUTH_ARGS+=(-H "Authorization: Bearer $TOKEN")
|
[[ -n "$TOKEN" ]] && AUTH_ARGS+=(-H "Authorization: Bearer $TOKEN")
|
||||||
|
|
||||||
# GET — check HTTP status code (no -f so 4xx/5xx are visible)
|
# GET — check HTTP status code (no -f so 4xx/5xx are visible as their real code)
|
||||||
check_status() {
|
check_status() {
|
||||||
local label="$1" path="$2" want="$3"
|
local label="$1" path="$2" want="$3"
|
||||||
local got
|
local got
|
||||||
|
|
@ -88,38 +88,43 @@ fi
|
||||||
|
|
||||||
# ── Auth ─────────────────────────────────────────────────────────────────────
|
# ── Auth ─────────────────────────────────────────────────────────────────────
|
||||||
header "Auth"
|
header "Auth"
|
||||||
check_status "GET /auth/me" "/api/v1/auth/me" 200
|
check_status "GET /auth/me" "/api/v1/auth/me" 200
|
||||||
check_body "GET /auth/me returns username" "/api/v1/auth/me" '"username"'
|
check_body "GET /auth/me returns username" "/api/v1/auth/me" '"username"'
|
||||||
check_status "POST /auth/login (bad creds → 400)" "/api/v1/auth/login" 400
|
check_post "POST /auth/login (missing body → 400)" "/api/v1/auth/login" '{}' 400
|
||||||
|
|
||||||
# ── Assets ───────────────────────────────────────────────────────────────────
|
# ── Assets ───────────────────────────────────────────────────────────────────
|
||||||
header "Assets"
|
header "Assets"
|
||||||
check_status "GET /assets" "/api/v1/assets" 200
|
check_status "GET /assets" "/api/v1/assets" 200
|
||||||
check_body "GET /assets returns assets key" "/api/v1/assets" '"assets"'
|
check_body "GET /assets returns assets key" "/api/v1/assets" '"assets"'
|
||||||
check_status "GET /assets bogus id → 404" "/api/v1/assets/00000000-0000-0000-0000-000000000000" 404
|
check_status "GET /assets bogus id → 404" "/api/v1/assets/00000000-0000-0000-0000-000000000000" 404
|
||||||
|
|
||||||
# ── Projects ─────────────────────────────────────────────────────────────────
|
# ── Projects ─────────────────────────────────────────────────────────────────
|
||||||
header "Projects"
|
header "Projects"
|
||||||
check_status "GET /projects" "/api/v1/projects" 200
|
check_status "GET /projects" "/api/v1/projects" 200
|
||||||
check_body "GET /projects returns array" "/api/v1/projects" '['
|
check_body "GET /projects returns array" "/api/v1/projects" '['
|
||||||
|
|
||||||
# ── Jobs ─────────────────────────────────────────────────────────────────────
|
# ── Jobs ─────────────────────────────────────────────────────────────────────
|
||||||
header "Jobs"
|
header "Jobs"
|
||||||
check_status "GET /jobs" "/api/v1/jobs" 200
|
check_status "GET /jobs" "/api/v1/jobs" 200
|
||||||
check_body "GET /jobs returns array" "/api/v1/jobs" '['
|
check_body "GET /jobs returns array" "/api/v1/jobs" '['
|
||||||
|
|
||||||
# ── Recorders ────────────────────────────────────────────────────────────────
|
# ── Recorders ────────────────────────────────────────────────────────────────
|
||||||
header "Recorders"
|
header "Recorders"
|
||||||
check_status "GET /recorders" "/api/v1/recorders" 200
|
check_status "GET /recorders" "/api/v1/recorders" 200
|
||||||
|
|
||||||
# ── Sequences (Editor) ───────────────────────────────────────────────────────
|
# ── Sequences (requires project_id param) ────────────────────────────────────
|
||||||
header "Sequences"
|
header "Sequences"
|
||||||
check_status "GET /sequences" "/api/v1/sequences" 200
|
check_status "GET /sequences (no project_id → 400)" "/api/v1/sequences" 400
|
||||||
|
check_status "GET /sequences bogus project_id → 200" "/api/v1/sequences?project_id=00000000-0000-0000-0000-000000000000" 200
|
||||||
|
|
||||||
|
# ── Settings ─────────────────────────────────────────────────────────────────
|
||||||
|
header "Settings"
|
||||||
|
check_status "GET /settings/ampp" "/api/v1/settings/ampp" 200
|
||||||
|
|
||||||
# ── Cluster ──────────────────────────────────────────────────────────────────
|
# ── Cluster ──────────────────────────────────────────────────────────────────
|
||||||
header "Cluster"
|
header "Cluster"
|
||||||
check_status "GET /cluster" "/api/v1/cluster" 200
|
check_status "GET /cluster" "/api/v1/cluster" 200
|
||||||
check_body "GET /cluster returns array" "/api/v1/cluster" '['
|
check_body "GET /cluster returns array" "/api/v1/cluster" '['
|
||||||
|
|
||||||
# Heartbeat: register a temporary smoke-test node, verify it appears, remove it
|
# Heartbeat: register a temporary smoke-test node, verify it appears, remove it
|
||||||
TEST_HOST="smoke-test-$(date +%s)"
|
TEST_HOST="smoke-test-$(date +%s)"
|
||||||
|
|
@ -127,9 +132,9 @@ check_post "POST /cluster/heartbeat" "/api/v1/cluster/heartbeat" \
|
||||||
"{\"hostname\":\"$TEST_HOST\",\"role\":\"smoketest\",\"cpu_usage\":0,\"mem_used_mb\":512,\"mem_total_mb\":4096}" \
|
"{\"hostname\":\"$TEST_HOST\",\"role\":\"smoketest\",\"cpu_usage\":0,\"mem_used_mb\":512,\"mem_total_mb\":4096}" \
|
||||||
200
|
200
|
||||||
|
|
||||||
# Find the node we just created (match by hostname)
|
# Find the node we just registered (grab first UUID from array)
|
||||||
NODE_ID=$(curl -s "${AUTH_ARGS[@]}" "$BASE/api/v1/cluster" 2>/dev/null \
|
NODE_ID=$(curl -s "${AUTH_ARGS[@]}" "$BASE/api/v1/cluster" 2>/dev/null \
|
||||||
| grep -o "\"id\":\"[^\"]*\"" | head -1 | grep -o '[0-9a-f-]\{36\}' || true)
|
| grep -o '"id":"[^"]*"' | head -1 | grep -o '[0-9a-f-]\{36\}' || true)
|
||||||
|
|
||||||
if [[ -n "$NODE_ID" ]]; then
|
if [[ -n "$NODE_ID" ]]; then
|
||||||
pass "Cluster node visible in registry"
|
pass "Cluster node visible in registry"
|
||||||
|
|
@ -143,30 +148,25 @@ fi
|
||||||
|
|
||||||
# ── System / Containers ───────────────────────────────────────────────────────
|
# ── System / Containers ───────────────────────────────────────────────────────
|
||||||
header "System"
|
header "System"
|
||||||
check_status "GET /system/containers" "/api/v1/system/containers" 200
|
check_status "GET /system/containers" "/api/v1/system/containers" 200
|
||||||
check_body "Containers returns array" "/api/v1/system/containers" '['
|
check_body "Containers returns array" "/api/v1/system/containers" '['
|
||||||
|
|
||||||
# ── Capture (proxies to capture service) ─────────────────────────────────────
|
# ── Capture (proxies to capture service — 500 if container is down) ───────────
|
||||||
header "Capture"
|
header "Capture"
|
||||||
# /capture/status proxies to the capture container; 200 = service up, 5xx = capture unreachable
|
|
||||||
CAPTURE_CODE=$(curl -s -o /dev/null -w "%{http_code}" "${AUTH_ARGS[@]}" \
|
CAPTURE_CODE=$(curl -s -o /dev/null -w "%{http_code}" "${AUTH_ARGS[@]}" \
|
||||||
"$BASE/api/v1/capture/status" 2>/dev/null)
|
"$BASE/api/v1/capture/status" 2>/dev/null)
|
||||||
if [[ "$CAPTURE_CODE" == "200" ]]; then
|
if [[ "$CAPTURE_CODE" == "200" ]]; then
|
||||||
pass "GET /capture/status [HTTP 200]"
|
pass "GET /capture/status [HTTP 200]"
|
||||||
elif [[ "$CAPTURE_CODE" == "500" || "$CAPTURE_CODE" == "502" || "$CAPTURE_CODE" == "503" ]]; then
|
elif [[ "$CAPTURE_CODE" =~ ^5 ]]; then
|
||||||
skip "GET /capture/status [HTTP $CAPTURE_CODE]" "capture service unreachable (container down?)"
|
skip "GET /capture/status [HTTP $CAPTURE_CODE]" "capture service proxy error (container down?)"
|
||||||
else
|
else
|
||||||
fail "GET /capture/status [HTTP $CAPTURE_CODE]" "expected 200 or 5xx proxy error"
|
fail "GET /capture/status [HTTP $CAPTURE_CODE]" "expected 200 or 5xx"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ── Settings ─────────────────────────────────────────────────────────────────
|
|
||||||
header "Settings"
|
|
||||||
check_status "GET /settings" "/api/v1/settings" 200
|
|
||||||
|
|
||||||
# ── Users / Tokens ───────────────────────────────────────────────────────────
|
# ── Users / Tokens ───────────────────────────────────────────────────────────
|
||||||
header "Users / Tokens"
|
header "Users / Tokens"
|
||||||
check_status "GET /users" "/api/v1/users" 200
|
check_status "GET /users" "/api/v1/users" 200
|
||||||
check_status "GET /tokens" "/api/v1/tokens" 200
|
check_status "GET /tokens" "/api/v1/tokens" 200
|
||||||
|
|
||||||
# ── Summary ───────────────────────────────────────────────────────────────────
|
# ── Summary ───────────────────────────────────────────────────────────────────
|
||||||
TOTAL=$((PASS + FAIL + SKIP))
|
TOTAL=$((PASS + FAIL + SKIP))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue