Files

37 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
BASE=${BASE:-https://api.ttstd.com/launcher}
AUTH_FILE=${AUTH_FILE:-/opt/vibe-launcher/auth.env}
. "$AUTH_FILE"
echo "== healthz =="
curl -fsS "$BASE/healthz"; echo
echo "== device layout =="
curl -fsS -H "Authorization: Bearer $DEVICE_TOKEN" -D /tmp/launcher-device.headers \
-o /tmp/launcher-device.json "$BASE/api/layout"
grep -i '^X-Layout-Revision:' /tmp/launcher-device.headers
echo "== admin layout =="
curl -fsS -H "Authorization: Bearer $ADMIN_TOKEN" -D /tmp/launcher-admin.headers \
-o /tmp/launcher-admin.json "$BASE/api/admin/layout"
TAG=$(sed -n 's/^[Ee][Tt][Aa][Gg]: //p' /tmp/launcher-admin.headers | tr -d '\r')
echo "ETag=$TAG"
echo "== missing If-Match =="
curl -sS -o /tmp/launcher-428.json -w '%{http_code}\n' -X PUT \
-H "Authorization: Bearer $ADMIN_TOKEN" -H 'Content-Type: application/json' \
--data @/tmp/launcher-admin.json "$BASE/api/admin/layout"
cat /tmp/launcher-428.json; echo
echo "== invalid layout =="
curl -sS -o /tmp/launcher-422.json -w '%{http_code}\n' -X PUT \
-H "Authorization: Bearer $ADMIN_TOKEN" -H "If-Match: $TAG" \
-H 'Content-Type: application/json' \
--data '{"schemaVersion":2,"pages":[]}' "$BASE/api/admin/layout"
head -c 200 /tmp/launcher-422.json; echo
echo "== history =="
curl -fsS -H "Authorization: Bearer $ADMIN_TOKEN" "$BASE/api/admin/history"; echo