Liaison d'appareil sur og/og-dev, validation du jeton draco et ouverture de la session de l'admin local. Sélecteur prod/dev (Configuration + premier lancement), admin local par défaut admin/chab30, sans impact sur le web Docker. Inclut BUG-126 (runtime python-embed/_pth + copie de backend/frontend + signature updater opt-in) et BUG-127 (retour /liaison même hôte).
73 lines
2.7 KiB
Python
73 lines
2.7 KiB
Python
"""Garde-fous des scripts de build desktop (BUG-126).
|
|
|
|
Sans dépendance : lecture texte de `desktop/build-windows.bat` et
|
|
`desktop/build-linux.sh`, suffisante pour verrouiller les régressions qui
|
|
rendaient l'exe Windows inutilisable (module `encodings` introuvable, runtime
|
|
absent à côté de l'exe) et l'invite interactive du mot de passe updater.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
DESKTOP = Path(__file__).resolve().parent.parent / "desktop"
|
|
WINDOWS_SCRIPT = DESKTOP / "build-windows.bat"
|
|
LINUX_SCRIPT = DESKTOP / "build-linux.sh"
|
|
|
|
|
|
def _read(path: Path) -> str:
|
|
return path.read_text(encoding="utf-8")
|
|
|
|
|
|
def test_windows_pth_is_written_explicitly() -> None:
|
|
"""`python311._pth` doit contenir stdlib + site + racine de l'exe.
|
|
|
|
L'ancien script ajoutait deux lignes au fichier de l'archive ; un état
|
|
partiel (ou un fichier déjà réécrit) laissait un `_pth` sans
|
|
`python311.zip` ni `.` → `ModuleNotFoundError: No module named
|
|
'encodings'`, backend mort, interface sans CSS.
|
|
"""
|
|
script = _read(WINDOWS_SCRIPT)
|
|
|
|
assert "echo python311.zip" in script
|
|
assert "echo import site" in script
|
|
assert "echo .." in script
|
|
assert ">> python-embed\\python311._pth" not in script
|
|
assert ">> \"%OUTDIR%\\python-embed\\python311._pth\"" not in script
|
|
|
|
|
|
def test_windows_copies_full_runtime_next_to_exe() -> None:
|
|
"""L'exe résout `python-embed/`, `backend/` et `frontend/` à côté de lui."""
|
|
script = _read(WINDOWS_SCRIPT)
|
|
|
|
assert "for %%D in (python-embed backend frontend) do" in script
|
|
assert "xcopy /E /I /Q /Y \"%%D\" \"%OUTDIR%\\%%D\"" in script
|
|
|
|
|
|
def test_windows_runs_from_script_directory() -> None:
|
|
"""Un appel `desktop\\build-windows.bat` ne doit pas nettoyer le dépôt."""
|
|
script = _read(WINDOWS_SCRIPT).lower()
|
|
assert 'cd /d "%~dp0"' in script
|
|
# Un exe encore lancé verrouille sa cible (Access is denied) : le build
|
|
# doit fermer l'application avant de recompiler.
|
|
assert "taskkill /f /im obsigate-desktop.exe" in script
|
|
|
|
|
|
def test_windows_verifies_runtime_before_building() -> None:
|
|
script = _read(WINDOWS_SCRIPT)
|
|
|
|
assert 'if not exist "python-embed\\python.exe"' in script
|
|
assert "import encodings, uvicorn, fastapi, pyotp" in script
|
|
|
|
|
|
def test_updater_signing_is_opt_in_without_password_prompt() -> None:
|
|
"""Pas de `.sig` et aucune invite si le mot de passe n'est pas fourni."""
|
|
windows = _read(WINDOWS_SCRIPT)
|
|
linux = _read(LINUX_SCRIPT)
|
|
|
|
for script in (windows, linux):
|
|
assert "TAURI_SIGNING_PRIVATE_KEY_PASSWORD" in script
|
|
assert "TAURI_SIGNING_PRIVATE_KEY_PATH" in script
|
|
assert "--ci" in script
|
|
|
|
assert "set /p TAURI_SIGNING_PRIVATE_KEY=" not in windows
|