Skip to content

armgit / AiSOC

Public Imported from GitHub
0

Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.

fix(test): assert replay route contract on router objects (not the mutated app singleton)

Beenu Arora2c8b5b5e9b61
diff --git a/services/api/tests/test_replay_publish.py b/services/api/tests/test_replay_publish.py
index 176b665aa..dee16c6cb 100644
--- a/services/api/tests/test_replay_publish.py
+++ b/services/api/tests/test_replay_publish.py
@@ -97,15 +97,16 @@ def test_snapshot_shape_and_counts() -> None:
def test_routes_registered() -> None:
- # Assert against the fully-assembled FastAPI app (its routes carry the
- # resolved `/api/v1/...` paths), not the pre-mount APIRouter — the latter's
- # stored paths depend on include-order/prefix internals.
+ # Assert directly on the replay router objects' path contract. This is
+ # deterministic and independent of the global app singleton (which other
+ # tests in the full suite mutate) and of include-order/prefix resolution.
try:
- from app.main import app
+ from app.api.v1.endpoints import replay
except ModuleNotFoundError as exc: # pragma: no cover - local envs missing runtime deps
pytest.skip(f"API runtime dependency unavailable in this environment: {exc.name}")
- paths = {getattr(r, "path", "") for r in app.routes}
- assert "/api/v1/ledger/{run_id}/publish" in paths
- assert "/api/v1/ledger/{run_id}/publish/preview" in paths
- assert "/api/v1/r/{slug}" in paths
+ ledger_paths = {getattr(r, "path", "") for r in replay.router.routes}
+ public_paths = {getattr(r, "path", "") for r in replay.public_router.routes}
+ assert "/ledger/{run_id}/publish" in ledger_paths
+ assert "/ledger/{run_id}/publish/preview" in ledger_paths
+ assert "/r/{slug}" in public_paths