This commit is contained in:
Jonas Bengtsson
2026-09-19 18:08:02 +02:00
parent a16a01b1e7
commit 680ad7a624
14 changed files with 483 additions and 14 deletions
+21
View File
@@ -224,6 +224,27 @@ def client(db_session, monkeypatch):
# The PKI client-cert endpoint validates the dynsec client exists.
monkeypatch.setattr(pki_router, "dynsec_client", fake)
# The control sidecar is not running in tests: fake its responses so
# deploy/system endpoints can be exercised (broker_alive always true).
from app.routers import broker as broker_router
from app.routers import system as system_router
def _fake_call_control(path, *, method="POST", json_body=None):
if path == "/deploy":
return {
"status": "deployed",
"broker_healthy": True,
"validation": {"valid": True},
}
if path == "/restart":
return {"status": "restarting"}
if path == "/status":
return {"broker_pid_alive": True, "config_file": "/mosquitto/config/mosquitto.conf"}
raise AssertionError(f"unexpected control path in tests: {path}")
monkeypatch.setattr(broker_router, "_call_control", _fake_call_control)
monkeypatch.setattr(system_router, "_call_control", _fake_call_control)
with TestClient(main_module.app) as test_client:
yield test_client