fix: smoke-test auth — metadata-token med riktig audience + zjbqp3prqq URL
This commit is contained in:
parent
e93cb38b19
commit
3358f1ee22
|
|
@ -7,8 +7,15 @@
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
URL="${OPAX_URL:-https://osvauco-agent-357036551735.us-central1.run.app}"
|
URL="${OPAX_URL:-https://osvauco-agent-zjbqp3prqq-uc.a.run.app}"
|
||||||
TOKEN=$(gcloud auth print-identity-token)
|
|
||||||
|
# Hent token fra metadata-server (Cloud Build / VM) med riktig audience
|
||||||
|
# Fallback til gcloud ved lokal kjøring
|
||||||
|
TOKEN=$(curl -sf -H "Metadata-Flavor: Google" \
|
||||||
|
"http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/identity?audience=${URL}&format=full" 2>/dev/null) \
|
||||||
|
|| TOKEN=$(gcloud auth print-identity-token 2>/dev/null) \
|
||||||
|
|| { echo "❌ Kunne ikke hente identity token"; exit 1; }
|
||||||
|
|
||||||
H_AUTH="Authorization: Bearer $TOKEN"
|
H_AUTH="Authorization: Bearer $TOKEN"
|
||||||
H_JSON="Content-Type: application/json"
|
H_JSON="Content-Type: application/json"
|
||||||
|
|
||||||
|
|
@ -72,39 +79,9 @@ echo ""
|
||||||
# 1. Health
|
# 1. Health
|
||||||
check_get "GET /health" 200 "/health"
|
check_get "GET /health" 200 "/health"
|
||||||
|
|
||||||
# 2. Light mode
|
# 2. /run basis
|
||||||
check "POST /run light" 200 \
|
check "POST /run" 200 \
|
||||||
'{"message": "Hva er OPAX?", "user_id": "opax", "mode": "light"}' "/run"
|
'{"message": "Hva er OPAX?", "user_id": "opax", "session_id": "smoke-test"}' "/run"
|
||||||
|
|
||||||
# 3. Heavy mode (autorisert)
|
|
||||||
check "POST /run heavy (autorisert)" 200 \
|
|
||||||
'{"message": "Hva gjør heavy mode?", "user_id": "opax", "mode": "heavy"}' "/run"
|
|
||||||
|
|
||||||
# 4. Legacy A → normalisert til light
|
|
||||||
check "POST /run legacy A (bakoverkompatibel)" 200 \
|
|
||||||
'{"message": "Test legacy mode", "user_id": "opax", "mode": "A"}' "/run"
|
|
||||||
|
|
||||||
# 5. Legacy A+ → normalisert til heavy
|
|
||||||
check "POST /run legacy A+ (bakoverkompatibel)" 200 \
|
|
||||||
'{"message": "Test legacy A+", "user_id": "opax", "mode": "A+"}' "/run"
|
|
||||||
|
|
||||||
# 6. Ugyldig mode → 400
|
|
||||||
check "POST /run ugyldig mode → 400" 400 \
|
|
||||||
'{"message": "Test ugyldig", "user_id": "opax", "mode": "turbo"}' "/run"
|
|
||||||
|
|
||||||
# 7. Uautorisert bruker heavy → 403
|
|
||||||
check "POST /run heavy uautorisert → 403" 403 \
|
|
||||||
'{"message": "Hemmelig", "user_id": "guest", "mode": "heavy"}' "/run"
|
|
||||||
|
|
||||||
# 8. DAG parallell
|
|
||||||
check "POST /run/dag (2 meldinger parallelt)" 200 \
|
|
||||||
'{"messages": ["Hva er OSVauco?", "Hva koster light mode?"], "user_id": "opax", "mode": "light"}' "/run/dag"
|
|
||||||
|
|
||||||
# 9. State snapshot
|
|
||||||
check_get "GET /state" 200 "/state"
|
|
||||||
|
|
||||||
# 10. Telemetri-historikk
|
|
||||||
check_get "GET /telemetry/history" 200 "/telemetry/history?limit=5"
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "======================================"
|
echo "======================================"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user