diff --git a/tests/test_tray_actions.py b/tests/test_tray_actions.py index 3907341..199bb34 100644 --- a/tests/test_tray_actions.py +++ b/tests/test_tray_actions.py @@ -71,6 +71,19 @@ class TestActions(unittest.TestCase): self.assertEqual(len(runner.calls), 1) self.assertEqual(opened, ["https://127.0.0.1:8787/"]) + def test_open_dashboard_returns_early_when_start_fails(self): + # is-active -> inactive, then start -> failure + runner = _Recorder([_proc(out="inactive"), + _proc(rc=1, err="Access denied")]) + opened = [] + res = actions.open_dashboard(Config(), runner, opener=opened.append) + self.assertFalse(res.ok) + self.assertEqual(runner.calls[0], + ["systemctl", "is-active", "enodia-sentinel-web.service"]) + self.assertEqual(runner.calls[1], + ["systemctl", "start", "enodia-sentinel-web.service"]) + self.assertEqual(opened, []) + def test_run_check_counts_findings(self): runner = _Recorder([_proc(out=json.dumps([{"signature": "rsh"}, {"signature": "suid"}]))])