feat(scada): add project monitoring replay
Generic Container CI/CD / test-build-publish (push) Successful in 3m39s
Server CI/CD v2 / build-test-publish-and-deploy (push) Successful in 3m39s

This commit is contained in:
2026-11-04 14:27:21 +08:00
parent f25423dec4
commit 26fa5d1909
53 changed files with 5153 additions and 20 deletions
+21
View File
@@ -300,6 +300,27 @@ def binding(task=False):
return value
@pytest.mark.parametrize("tool_name", ["run_burst_detection", "query_element_history"])
def test_replay_binding_denies_unscoped_computations_and_history(tool_name):
bound = binding(task=True)
bound.replay_context = {"replay_id": str(uuid4()), "knowledge_cutoff": "2026-10-08T01:00:00+00:00", "batch_sequence": 1}
with pytest.raises(HTTPException) as error:
asyncio.run(query_service.authorize_query(SimpleNamespace(), bound, TOOLS[tool_name], SimpleNamespace()))
assert error.value.status_code == 403
def test_replay_binding_denies_future_and_allows_device_metadata(monkeypatch):
bound = binding(task=True)
bound.replay_context = {"replay_id": str(uuid4()), "knowledge_cutoff": "2026-10-08T01:00:00+00:00", "batch_sequence": 1}
args = SimpleNamespace(start=datetime(2026, 10, 8, tzinfo=timezone.utc),
end=datetime(2026, 10, 8, 2, tzinfo=timezone.utc))
with pytest.raises(HTTPException) as error:
asyncio.run(query_service.authorize_query(SimpleNamespace(), bound, TOOLS["query_scada_readings"], args))
assert error.value.status_code == 422
monkeypatch.setattr(query_service, "permissions_for_context", lambda _: PERMISSIONS)
asyncio.run(query_service.authorize_query(SimpleNamespace(project=object()), bound, TOOLS["list_scada_devices"], SimpleNamespace()))
@pytest.mark.parametrize("seconds", [30, 120, 240])
def test_all_tools_advertise_the_effective_host_request_budget(runtime, seconds):
app, client, _, _ = runtime