fix(CI): smoke-test bruker access token via metadata-server direkte URL
This commit is contained in:
parent
4e12144152
commit
ff0c847fec
|
|
@ -58,7 +58,7 @@ steps:
|
|||
- '--quiet'
|
||||
|
||||
# Steg 5: Smoke test — verifiser at agenten svarer etter deploy
|
||||
# Bruker gcloud auth print-identity-token (fungerer i Cloud Build 2nd gen)
|
||||
# Bruker access token fra metadata-server (fungerer i Cloud Build 2nd gen)
|
||||
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
|
||||
id: smoke-test
|
||||
waitFor: ['deploy']
|
||||
|
|
@ -67,13 +67,14 @@ steps:
|
|||
- '-c'
|
||||
- |
|
||||
echo "=== Smoke Test ==="
|
||||
TOKEN=$$(gcloud auth print-identity-token \
|
||||
--audiences="https://${_CLOUD_RUN_URL}") \
|
||||
|| { echo "❌ Kunne ikke hente identity token"; exit 1; }
|
||||
TOKEN=$$(curl -sf \
|
||||
-H "Metadata-Flavor: Google" \
|
||||
"http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token" \
|
||||
| python3 -c "import sys,json; print(json.load(sys.stdin)['access_token'])") \
|
||||
|| { echo "❌ Kunne ikke hente access token"; exit 1; }
|
||||
|
||||
RESPONSE=$$(curl -sf \
|
||||
-H "Authorization: Bearer $$TOKEN" \
|
||||
-H "x-goog-authenticated-user-email: accounts.google.com:ci-test@vauco.no" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"user_id": "ci", "session_id": "smoke-$BUILD_ID", "message": "ping"}' \
|
||||
"https://${_CLOUD_RUN_URL}/run") \
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user