From 973fb98b91961841da0caef8da613d7dac16f3a6 Mon Sep 17 00:00:00 2001 From: denis Date: Sat, 17 Oct 2026 12:48:28 +0200 Subject: [PATCH] check_deploy: author.html is expected behind the login (302) when the backend is active; check admin and static files Co-Authored-By: Claude Sonnet 5.5 --- docs/site/en/host/operations.md | 2 +- docs/site/fr/host/operations.md | 2 +- scripts/check_deploy.sh | 21 ++++++++++++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/docs/site/en/host/operations.md b/docs/site/en/host/operations.md index d905587..2e6d301 100644 --- a/docs/site/en/host/operations.md +++ b/docs/site/en/host/operations.md @@ -65,7 +65,7 @@ service if it was running). See the ports in use: `ss -ltnp`. | go back to the previous site version | `./scripts/server_update.sh --rollback` | | simulate an update | `./scripts/server_update.sh --dry-run` | | see the server state | `./scripts/vps_doctor.sh` | -| check the published site | `./scripts/check_deploy.sh https://domain` | +| check the published site | `./scripts/check_deploy.sh https://domain` (with the backend: `author.html` must answer **302** to the login, and so must the administration; without a backend, `author.html` is public) | | manage authors | `https://domain/api/admin/` or `./scripts/server_manage.sh create_author ada` | | read the logs | `journalctl -u pyquest -f`; `/var/log/nginx/error.log` | diff --git a/docs/site/fr/host/operations.md b/docs/site/fr/host/operations.md index 6ee8e56..4d9d0b0 100644 --- a/docs/site/fr/host/operations.md +++ b/docs/site/fr/host/operations.md @@ -65,7 +65,7 @@ service s'il tournait). Voir les ports utilisés : `ss -ltnp`. | revenir à la version précédente du site | `./scripts/server_update.sh --rollback` | | simuler une mise à jour | `./scripts/server_update.sh --dry-run` | | voir l'état du serveur | `./scripts/vps_doctor.sh` | -| contrôler le site publié | `./scripts/check_deploy.sh https://domaine` | +| contrôler le site publié | `./scripts/check_deploy.sh https://domaine` (avec le backend : `author.html` doit répondre **302** vers la connexion, l'administration aussi ; sans backend, `author.html` est public) | | gérer les auteurs | `https://domaine/api/admin/` ou `./scripts/server_manage.sh create_author ada` | | lire les journaux | `journalctl -u pyquest -f` ; `/var/log/nginx/error.log` | diff --git a/scripts/check_deploy.sh b/scripts/check_deploy.sh index 0dab01a..20e1d2f 100755 --- a/scripts/check_deploy.sh +++ b/scripts/check_deploy.sh @@ -41,7 +41,26 @@ expect_header "${BASE}/service-worker.js" Cache-Control no-cache expect_header "${BASE}/css/base.css" Content-Type text/css expect_header "${BASE}/manifest.webmanifest" Content-Type manifest+json expect_status "${BASE}/levels/manifest.json" 200 -expect_status "${BASE}/author.html" 200 + +# Éditeur de niveaux : derrière le backend il est protégé (302 vers la connexion) ; sans backend il est public (200). +author_code="$(status "${BASE}/author.html")" +author_location="$(header "${BASE}/author.html" Location)" +if [[ "${author_code}" == 302 && "${author_location}" == *"/api/auth/login/"* ]]; then + ok "author.html protégé par connexion (302 vers /api/auth/login/)" + expect_status "${BASE}/api/auth/login/" 200 + expect_header "${BASE}/api/auth/login/" Content-Type text/html + # Le contrôle interne réservé à nginx ne doit pas être joignable de l'extérieur. + expect_status "${BASE}/api/auth/check/" 404 + # Administration : redirige vers sa connexion ; ses fichiers statiques sont servis par nginx. + admin_code="$(status "${BASE}/api/admin/")" + if [[ "${admin_code}" == 302 ]]; then ok "administration protégée (302 vers sa connexion)"; else ko "/api/admin/ : 302 attendu, reçu ${admin_code}"; fi + expect_status "${BASE}/api/static/admin/css/base.css" 200 + expect_header "${BASE}/api/static/admin/css/base.css" Content-Type text/css +elif [[ "${author_code}" == 200 ]]; then + info "author.html est PUBLIC (200) : normal sans backend Django, sinon l'accès authentifié n'est pas actif" +else + ko "author.html : 200 (public) ou 302 vers la connexion attendus, reçu ${author_code}" +fi if [[ "${BASE}" == https://* ]]; then redirect="$(curl -s -o /dev/null -w '%{http_code}' --max-time 20 "http://${BASE#https://}/")"