feat(scada): add project monitoring replay
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user