fix clear investi

This commit is contained in:
larssand
2026-07-06 16:49:30 +02:00
parent 49ac7e2958
commit 649c29a8c2
8 changed files with 88 additions and 7 deletions

View File

@@ -48,6 +48,14 @@ class ConfigTests(unittest.TestCase):
self.assertEqual(public["graylog_mcp_call_timeout_seconds"], 6)
self.assertEqual(public["graylog_mcp_poll_timeout_seconds"], 180)
def test_llm_timeout_setting_is_numeric_and_bounded(self):
with tempfile.TemporaryDirectory() as directory:
store = ConfigStore(str(Path(directory) / "config.json"))
public = store.update({"llm_timeout": "0"})
self.assertEqual(public["llm_timeout"], 1)
public = store.update({"llm_timeout": "300"})
self.assertEqual(public["llm_timeout"], 300)
def test_graylog_tls_verify_can_be_disabled(self):
with tempfile.TemporaryDirectory() as directory:
store = ConfigStore(str(Path(directory) / "config.json"))

View File

@@ -57,6 +57,11 @@ class DashboardTests(unittest.TestCase):
self.assertIn("incidentNotice", HTML)
self.assertIn("Incident marked", HTML)
def test_dashboard_can_clear_stored_incident_states(self):
self.assertIn('id="clearResolvedIncidents"', HTML)
self.assertIn('id="clearAllIncidents"', HTML)
self.assertIn("/api/incidents/clear", HTML)
def test_dashboard_does_not_clear_streams_when_picker_is_unloaded(self):
self.assertIn("const streamValues = Object.values(window.streamSelection || {})", HTML)
self.assertIn("if (streamValues.length)", HTML)
@@ -76,6 +81,10 @@ class DashboardTests(unittest.TestCase):
self.assertIn("assessment unavailable", HTML)
self.assertIn("Ollama assessment: unavailable", HTML)
def test_dashboard_exposes_ollama_assessment_timeout_setting(self):
self.assertIn('name="llm_timeout"', HTML)
self.assertIn("llm_timeout: config.llm_timeout || 180", HTML)
if __name__ == "__main__":
unittest.main()

View File

@@ -37,3 +37,17 @@ class IncidentTests(unittest.TestCase):
first = build_incidents([], {"alice": [{"score": 15, "reason": "new login country", "stream_id": "windows"}]}, [])[0]
second = build_incidents([], {"alice": [{"score": 25, "reason": "new source ip", "stream_id": "windows"}]}, [])[0]
self.assertEqual(first["id"], second["id"])
def test_incident_store_can_clear_resolved_or_all_states(self):
with tempfile.TemporaryDirectory() as directory:
store = IncidentStore(str(Path(directory) / "incidents.json"))
store.update("one", "resolved")
store.update("two", "acknowledged")
resolved = store.clear(status="resolved")
self.assertEqual(resolved, {"removed": 1, "remaining": 1, "status": "resolved"})
self.assertEqual(set(store.entries()), {"two"})
all_items = store.clear()
self.assertEqual(all_items, {"removed": 1, "remaining": 0, "status": "all"})
self.assertEqual(store.entries(), {})