Test open_dashboard early-return when web start fails

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Luna 2026-06-30 15:24:25 -07:00
parent 4545b2b5a2
commit a57cf4a16f

View file

@ -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"}]))])