Files
ProxMenux/AppImage/scripts/tests/test_notification_burst_toggle_inheritance.py
T
MacRimiandClaude Opus 5 da8a480eff Add audit and reports page, and a change journal
ProxMenux modifies the host: it rewrites configuration files, installs packages, enables services. Until now nobody could say afterwards what had changed, and showing the script does not answer that question — a four-hundred-line function may alter two values, and the reader has no way to know which two. This adds the two halves of an answer.

The change journal records what ProxMenux does as it does it. Eleven bash primitives capture the previous state, apply the change and record it in the same step, writing to a spool that the Monitor reads back. One hundred and thirteen functions across twenty-five scripts are instrumented, covering post-install, shared storage, security tooling, container conversions, disk operations and the PVE 8 to 9 upgrade path. The page shows the difference — rotate 7 becoming rotate 14 — and never the script. Restore and backup scripts are deliberately left out: a restore puts the host back to a state some other script already recorded.

The Audit and reports page answers the other half: what state is this host in, regardless of who put it there. Forty-three checks across seven areas read the host and classify each result as critical, warning, observation, conformant, unverified or not applicable, with the evidence they read attached to each one. A declared policy lets the reader say what this particular host is expected to do — which guests must have a backup, which storages are essential — so the report judges the host against its own intent rather than a generic template. An inventory records the hardware, network and guest topology behind those readings, a comparison shows what moved between two runs, and six report profiles produce a printable document scoped to what the reader needs. Everything is available in the eight supported languages.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-08 21:06:04 +02:00

67 lines
2.0 KiB
Python

import sys
import unittest
from pathlib import Path
SCRIPTS_DIR = Path(__file__).resolve().parents[1]
if str(SCRIPTS_DIR) not in sys.path:
sys.path.insert(0, str(SCRIPTS_DIR))
import notification_manager # noqa: E402
class RecordingChannel:
def __init__(self):
self.calls = 0
def send(self, title, body, severity, data):
self.calls += 1
return {"success": True, "error": ""}
class NotificationBurstToggleInheritanceTests(unittest.TestCase):
def setUp(self):
self.channel = RecordingChannel()
self.manager = notification_manager.NotificationManager()
self.manager._channels = {"email": self.channel}
self.manager._config = {
"email.enabled": "true",
"email.events.services": "true",
"email.rich_format": "false",
"email.event.kernel_warning": "false",
"ai_enabled": "false",
}
def test_hidden_summary_inherits_source_event_toggle(self):
delivered = self.manager._dispatch_to_channels(
"host: +1 more system problem",
"One additional issue",
"WARNING",
"burst_system",
{"event_type": "kernel_warning", "hostname": "host"},
"aggregator",
)
self.assertFalse(delivered)
self.assertEqual(self.channel.calls, 0)
def test_generic_summary_inherits_source_event_category(self):
self.manager._config.update({
"email.event.oom_kill": "true",
"email.events.services": "false",
"email.events.other": "true",
})
delivered = self.manager._dispatch_to_channels(
"host: related events",
"One additional issue",
"WARNING",
"burst_generic",
{"event_type": "oom_kill", "hostname": "host"},
"aggregator",
)
self.assertFalse(delivered)
self.assertEqual(self.channel.calls, 0)
if __name__ == "__main__":
unittest.main()