mirror of
git://f0xx.org/ac/ac-ms-template
synced 2026-07-29 04:18:00 +03:00
initial
This commit is contained in:
28
skeleton/scripts/smoke_shorten.sh
Executable file
28
skeleton/scripts/smoke_shorten.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/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"
|
||||
Reference in New Issue
Block a user