1
0
mirror of git://f0xx.org/ac/ac-ms-template synced 2026-07-29 03:59:06 +03:00
Files
ac-ms-template/skeleton/scripts/smoke_shorten.sh
Anton Afanasyeu 1ca30210bd initial
2026-06-23 12:29:30 +02:00

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"