mirror of
git://f0xx.org/ac/ac-ms-template
synced 2026-07-29 02:18:17 +03:00
29 lines
879 B
Bash
Executable File
29 lines
879 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Minimal deploy smoke — exits non-zero on failure.
|
|
set -euo pipefail
|
|
|
|
BASE="${BASE:-https://s.f0xx.org}"
|
|
BEARER="${BEARER:-}"
|
|
|
|
echo "==> health $BASE/api/v1/health"
|
|
body="$(curl -fsS "$BASE/api/v1/health")"
|
|
echo "$body" | grep -q '"status":"ok"' || { echo "health not ok: $body"; exit 1; }
|
|
|
|
if [[ -z "$BEARER" ]]; then
|
|
echo "SKIP shorten (set BEARER to run full smoke)"
|
|
exit 0
|
|
fi
|
|
|
|
echo "==> shorten POST"
|
|
resp="$(curl -fsS -X POST "$BASE/api/v1/shorten" \
|
|
-H 'Content-Type: application/json' \
|
|
-d '{"url":"https://example.com/smoke-'"$(date +%s)"'","bearer":"'"$BEARER"'","ttl":300}')"
|
|
echo "$resp"
|
|
short="$(echo "$resp" | sed -n 's/.*"u":"\([^"]*\)".*/\1/p')"
|
|
[[ -n "$short" ]] || { echo "no short url in response"; exit 1; }
|
|
|
|
echo "==> redirect HEAD"
|
|
curl -fsSI "$short" | grep -qi '^location:' || { echo "missing redirect"; exit 1; }
|
|
|
|
echo "OK"
|