Files
rootnode-academy/infra/scripts/production-smoke-test.sh
T
ced4568 f3c356951c test(preprod): two-host routing simulation, drill suite, CI security scanning
- infra/scripts/simulate-two-host/: real two-Docker-network simulation
  (Gateway genuinely isolated from any Lab bridge network) proving the
  Lab Host Router fix - 13/13 real assertions (HTTP+WebSocket through the
  Router, Alice/Bob isolation, garbage/destroyed tokens, mTLS-only Router
  access).
- infra/scripts/drills/: Lab Host loss/rebuild (9/9), deployment rollback,
  CI-fails-closed (6 required failure modes), fake cohort dress rehearsal
  (14/14, one continuous narrative through the real app).
- infra/ci/gitea-workflows/build-and-test.yml: new security-scan job
  (npm audit, gitleaks, hadolint, shellcheck, trivy - all free/open-source),
  severity policy in docs/SECURITY_SCANNING.md (CRITICAL/HIGH blocks,
  MEDIUM/LOW reported only). Gates build-images alongside regression.

Found and fixed two real pre-existing bugs via the CI-fails-closed drill:
staging-smoke-test.sh and production-smoke-test.sh both had a classic
set -e gotcha (curl ... && echo "OK" as one statement - a failing command
that isn't last in an && chain doesn't trigger -e) that let an
unreachable/broken endpoint fall through silently instead of failing the
smoke test.

platform/test/e2e-phase3a.js updated for the new paginated
/api/admin/audit-events response shape (Phase 4.1 pagination work).
2026-08-24 20:16:00 -05:00

35 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Production post-deploy smoke test — deliberately read-only/non-destructive (never creates
# real students/cohorts against production data). Confirms the deployed services are actually
# up after a deploy/rollback, before calling the deploy "done."
set -euo pipefail
PROD_URL="${PRODUCTION_URL:?set PRODUCTION_URL, e.g. https://academy.example.com}"
# Phase 4.1 §23: every `curl ... && echo "OK"` below used to be one statement — under `set -e`,
# a failing command that isn't the LAST one in an && list does not trigger the shell to exit (a
# well-known bash gotcha), so an unreachable/broken production endpoint used to fall through
# silently instead of failing this script. Split into two statements each, so the real exit
# status is what `set -e` sees. Found by infra/scripts/drills/test-ci-fails-closed.sh.
echo "==> Gateway health"
curl -sf "$PROD_URL/healthz" > /dev/null
echo "OK"
echo "==> TLS certificate is valid and not expiring soon"
EXPIRY=$(echo | openssl s_client -connect "$(echo "$PROD_URL" | sed -e 's#https://##')":443 -servername "$(echo "$PROD_URL" | sed -e 's#https://##')" 2>/dev/null | openssl x509 -noout -enddate | cut -d= -f2)
echo "Certificate expires: $EXPIRY"
echo "==> Roster endpoint responds (public, unauthenticated, read-only)"
curl -sf "$PROD_URL/api/roster/cohorts" > /dev/null
echo "OK"
echo "==> Admin login page loads (does not attempt to log in)"
curl -sf "$PROD_URL/admin" -o /dev/null -w '%{http_code}\n' | grep -q 200
echo "OK"
echo
echo "OK: production smoke test passed. For a full functional check (owner/instructor login,"
echo "cohort, Prepare Labs, student flow, assessment, Capstone), work through"
echo "docs/PRODUCTION_VALIDATION_CHECKLIST.md's ACADEMY section manually — deliberately not"
echo "automated against real production data."