Files
news-platform/deploy/scripts/smoke-andebol.sh
José AlvesandPaperclip f37d4f7318
Tests / writer-pipeline tests (push) Successful in 40s
Tests / bridge tests (push) Successful in 39s
Tests / frontend lib tests (push) Successful in 38s
Tests / writer-pipeline tests (pull_request) Successful in 47s
Tests / bridge tests (pull_request) Successful in 48s
Tests / frontend lib tests (pull_request) Successful in 49s
fix(devops): wp-login ops-only gate + smoke for branded auth (BIT-26754)
- Nginx: add auth_basic gate on wp-login.php (ops htpasswd, BIT-26754)
- deploy.sh: note htpasswd step 5 in post-deploy manual steps
- smoke-andebol.sh: update /entrar+/registar checks to verify branded
  Astro 200 (no WordPress strings); add wp-login.php 401/403 gate check;
  add /api/homepage latest ≥24 density check (BIT-26752)

Co-Authored-By: Paperclip <[email protected]>
2026-07-17 09:18:47 +00:00

80 lines
3.8 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"
# Branded auth UI (BIT-26753) — /entrar and /registar must serve Astro 200, no WordPress chrome
_c="$(curl -fsS -o /dev/null -w '%{http_code}' --max-time 25 -H "Host: $HOST_HEADER" "$BASE_URL/entrar" 2>/dev/null || true)"
[[ "$_c" == "200" ]] || fail "GET $BASE_URL/entrar expected 200 (Astro branded form), got $_c"
_body_entrar="$(curl -fsS --max-time 15 -H "Host: $HOST_HEADER" "$BASE_URL/entrar" 2>/dev/null || true)"
echo "$_body_entrar" | grep -qi 'WordPress' && fail "/entrar must not contain 'WordPress' (WP chrome leaked)"
echo "$_body_entrar" | grep -qi 'Entrar.*Andebol\|Andebol.*Entrar\|<title>Entrar' || fail "/entrar missing Andebol.net branded title"
ok "GET /entrar → $_c (Astro branded, no WordPress)"
_c="$(curl -fsS -o /dev/null -w '%{http_code}' --max-time 25 -H "Host: $HOST_HEADER" "$BASE_URL/registar" 2>/dev/null || true)"
[[ "$_c" == "200" ]] || fail "GET $BASE_URL/registar expected 200 (Astro branded form), got $_c"
ok "GET /registar → $_c"
# wp-login.php must NOT be publicly accessible (BIT-26754) — expect 401 (basic auth gate)
_c="$(curl -so /dev/null -w '%{http_code}' --max-time 15 -H "Host: $HOST_HEADER" "$BASE_URL/wp-login.php" 2>/dev/null || true)"
[[ "$_c" == "401" || "$_c" == "403" ]] || fail "GET $BASE_URL/wp-login.php expected 401/403 (ops gate), got $_c"
ok "GET /wp-login.php → $_c (ops-only gate active)"
# Homepage density: at least 24 latest items in bridge payload (BIT-26752)
_latest_count="$(curl -fsS --max-time 15 -H "Host: $HOST_HEADER" "$BASE_URL/api/homepage" 2>/dev/null \
| python3 -c 'import sys,json; d=json.load(sys.stdin); print(len(d.get("latest",[])))' 2>/dev/null || echo 0)"
[[ "$_latest_count" -ge 24 ]] || fail "Homepage /api/homepage latest count expected ≥24, got $_latest_count"
ok "GET /api/homepage latest count → $_latest_count ≥ 24"
echo "All smokes passed for BASE_URL=$BASE_URL (host: $HOST_HEADER)"