Phase 3 : hardening qualite de code - typage strict, securite, dead code, a11y
Config strictement stricte partout (ruff, mypy --strict, bandit, vulture, import-linter, eslint, stylelint), aucune regle desactivee "pour ne pas casser le build" - l'existant a ete corrige pour la satisfaire plutot que l'inverse. Hooks pre-commit locaux (language: system) bloquants. - Typage mypy --strict propage a tout le moteur (db, screens, auth, core, ai, routes, puis publish/scripts/tests/app.py/build_css.py). - Securite : fuite de handle fichier Windows corrigee dans l'export SCORM (routes/publish/export_scorm.py), CSRF/RNG non-crypto/xAPI documentes (# nosec, # NOSONAR justifies), nouveau db.json_for_script() (echappe "</script>" dans le JSON embarque en <script>, 25 sites). - Architecture : imports circulaires/F811 nettoyes, contrats import-linter respectes, code mort retire (vulture). - Accessibilite : 69 champs de formulaire sans label correctement associe corriges (for/id ou aria-label) sur 11 templates. - ESLint/Stylelint : lot mecanique JS/CSS, regles ajustees puis appliquees (aucune desactivee sans verification individuelle). - Tests : isolation du compte admin partage (nettoyage ponctuel + fixture de teardown automatique en filet de securite), suite complete verte (591 tests Python, 241 tests JS). - SonarQube Community Build self-heberge (Docker + PostgreSQL) : rapport complet analyse point par point, faux positifs documentes. - .gitattributes ajoute (LF force) : core.autocrlf=true sur cette machine faisait echouer ESLint (linebreak-style) via un bug connu de git (checkout "en place" qui ignore l'eol force sur un fichier deja present sur disque - contourne en supprimant puis recreant chaque fichier suivi). djLint (H021, styles inline) volontairement saute pour ce commit - backlog assume, deja documente, traite dans un lot separe. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
7db4803b93
commit
c57420c8c9
+34
-21
@@ -2,22 +2,28 @@
|
||||
routes/publish/xapi_settings.py) — le mot de passe ne doit JAMAIS
|
||||
ressortir en clair (seulement un booléen `password_set`), et un POST
|
||||
sans mot de passe ne doit pas écraser celui déjà enregistré."""
|
||||
|
||||
from flask.testing import FlaskClient
|
||||
|
||||
from tests.test_auth import anon_client # noqa: F401
|
||||
|
||||
|
||||
def test_xapi_settings_get_defaults_to_empty(client, game):
|
||||
def test_xapi_settings_get_defaults_to_empty(client: FlaskClient, game: str) -> None:
|
||||
resp = client.get(f"/game/{game}/xapi-settings")
|
||||
assert resp.status_code == 200
|
||||
body = resp.get_json()
|
||||
assert body == {"endpoint": "", "login": "", "password_set": False}
|
||||
|
||||
|
||||
def test_xapi_settings_post_then_get_round_trip(client, game):
|
||||
resp = client.post(f"/game/{game}/xapi-settings", json={
|
||||
"endpoint": "https://lrs.example.com/xapi/",
|
||||
"login": "monlogin",
|
||||
"password": "monmotdepasse",
|
||||
})
|
||||
def test_xapi_settings_post_then_get_round_trip(client: FlaskClient, game: str) -> None:
|
||||
resp = client.post(
|
||||
f"/game/{game}/xapi-settings",
|
||||
json={
|
||||
"endpoint": "https://lrs.example.com/xapi/",
|
||||
"login": "monlogin",
|
||||
"password": "monmotdepasse",
|
||||
},
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert resp.get_json() == {"ok": True}
|
||||
|
||||
@@ -29,30 +35,37 @@ def test_xapi_settings_post_then_get_round_trip(client, game):
|
||||
assert "password" not in body
|
||||
|
||||
|
||||
def test_xapi_settings_post_with_blank_password_keeps_the_existing_one(client, game):
|
||||
client.post(f"/game/{game}/xapi-settings", json={
|
||||
"endpoint": "https://lrs.example.com/xapi/",
|
||||
"login": "monlogin",
|
||||
"password": "monmotdepasse",
|
||||
})
|
||||
def test_xapi_settings_post_with_blank_password_keeps_the_existing_one(client: FlaskClient, game: str) -> None:
|
||||
client.post(
|
||||
f"/game/{game}/xapi-settings",
|
||||
json={
|
||||
"endpoint": "https://lrs.example.com/xapi/",
|
||||
"login": "monlogin",
|
||||
"password": "monmotdepasse",
|
||||
},
|
||||
)
|
||||
|
||||
resp = client.post(f"/game/{game}/xapi-settings", json={
|
||||
"endpoint": "https://lrs.example.com/xapi/v2/",
|
||||
"login": "monlogin",
|
||||
"password": "",
|
||||
})
|
||||
resp = client.post(
|
||||
f"/game/{game}/xapi-settings",
|
||||
json={
|
||||
"endpoint": "https://lrs.example.com/xapi/v2/",
|
||||
"login": "monlogin",
|
||||
"password": "",
|
||||
},
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
|
||||
import db
|
||||
|
||||
settings = db.get_xapi_settings(game)
|
||||
assert settings["endpoint"] == "https://lrs.example.com/xapi/v2/"
|
||||
assert settings["password"] == "monmotdepasse"
|
||||
assert settings["password"] == "monmotdepasse" # nosec B105 # noqa: S105 - identifiants factices d'un LRS de test (lrs.example.com), jamais un vrai compte
|
||||
|
||||
|
||||
def test_xapi_settings_route_is_isolated_like_other_game_routes(anon_client):
|
||||
def test_xapi_settings_route_is_isolated_like_other_game_routes(anon_client: FlaskClient) -> None: # noqa: F811 - anon_client est un fixture pytest (voir tests.test_auth), pas une vraie redefinition - pyflakes ne comprend pas l'injection de fixture par parametre
|
||||
"""Même garde d'accès que /game/<slug>/publish (core/auth_guard.py) —
|
||||
aucune vérification supplémentaire écrite pour cette route."""
|
||||
from tests.test_auth import _register, _confirm_2fa, _complete_onboarding, _cleanup_project
|
||||
from tests.test_auth import _cleanup_project, _complete_onboarding, _confirm_2fa, _register
|
||||
|
||||
_register(anon_client, "xapisettingsisolation@example.com")
|
||||
_confirm_2fa(anon_client)
|
||||
|
||||
Reference in New Issue
Block a user