Files
news-platform/deploy/scripts/smoke-andebol.sh
T
Artur Moreira 50c5fafcd9 chore(deploy): extend andebol smoke for search/archive; fix Host header env (BIT-591)
- Assert GET /search, /search?q=te, /category/all return 200
- Use SMOKE_HOST instead of HOST for the vhost header (HOST=0.0.0.0 in agent envs caused 403)

Made-with: Cursor
2026-03-27 16:57:43 +00:00

57 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Smoke tests for andebol.net (or local Nginx on the CT).
# Usage:
# BASE_URL=https://andebol.net ./deploy/scripts/smoke-andebol.sh
# BASE_URL=http://127.0.0.1 SMOKE_HOST=andebol.net ./deploy/scripts/smoke-andebol.sh # on the LXC
#
# Note: use SMOKE_HOST for the HTTP Host header — do not use HOST (often 0.0.0.0 in agent/PM2 envs).
set -euo pipefail
BASE_URL="${BASE_URL:-https://andebol.net}"
BASE_URL="${BASE_URL%/}"
HOST_HEADER="${SMOKE_HOST:-andebol.net}"
fail() { echo "SMOKE FAIL: $*" >&2; exit 1; }
ok() { echo "OK: $*"; }
code_for() {
curl -fsS -o /dev/null -w '%{http_code}' --max-time 25 -H "Host: $HOST_HEADER" "$1"
}
log_json() {
curl -fsS --max-time 15 -H "Host: $HOST_HEADER" "$1" | head -c 400
echo ""
}
# Homepage (Astro SSR with institutional theme)
_c="$(code_for "$BASE_URL/")"
[[ "$_c" == "200" ]] || fail "GET $BASE_URL/ expected 200, got $_c (andebol.net homepage)"
ok "GET / → $_c"
# Dedicated search + full archive (BIT-591 frontend)
_c="$(code_for "$BASE_URL/search")"
[[ "$_c" == "200" ]] || fail "GET $BASE_URL/search expected 200, got $_c"
ok "GET /search → $_c"
_c="$(code_for "$BASE_URL/search?q=te")"
[[ "$_c" == "200" ]] || fail "GET $BASE_URL/search?q=te expected 200, got $_c"
ok "GET /search?q=… → $_c"
_c="$(code_for "$BASE_URL/category/all")"
[[ "$_c" == "200" ]] || fail "GET $BASE_URL/category/all expected 200, got $_c"
ok "GET /category/all → $_c"
# Bridge health
_c="$(code_for "$BASE_URL/health")"
[[ "$_c" == "200" ]] || fail "GET $BASE_URL/health expected 200, got $_c"
_body="$(log_json "$BASE_URL/health")"
echo "$_body" | grep -q '"status"' || fail "GET /health body missing JSON status field"
ok "GET /health → $_c"
# WordPress REST API (port 8081 via nginx)
_c="$(code_for "$BASE_URL/wp-json/wp/v2/")"
[[ "$_c" == "200" ]] || fail "GET $BASE_URL/wp-json/wp/v2/ expected 200, got $_c (WP andebol :8081)"
ok "GET /wp-json/wp/v2/ → $_c"
echo "All smokes passed for BASE_URL=$BASE_URL (host: $HOST_HEADER)"