Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

test(notifications): cover receiver settings at monitor startup

pulse-triage[bot]f47472b817e4
diff --git a/docs/release-control/v6/internal/subsystems/notifications.md b/docs/release-control/v6/internal/subsystems/notifications.md
index 9164cb44d0..9f50bfee41 100644
--- a/docs/release-control/v6/internal/subsystems/notifications.md
+++ b/docs/release-control/v6/internal/subsystems/notifications.md
@@ -832,7 +832,11 @@ recipient delivery, candidate qualification or historical customer exposure.
monitor constructor twice against the same saved configuration without applying
notification-manager setters in the fixture. It checks initial routing, both
resolve choices, enabled/activation gating and encrypted webhook configuration
-restoration. The cases include webhook, Apprise, email and all destinations.
+restoration. Email and HTTP Apprise receiver settings are also saved and
+compared after each construction, including synthetic credentials, recipient
+lists, severity filters, email tag filters and enabled/disabled choices.
+No transport is invoked. The cases include webhook, Apprise, email and all
+destinations.
This boundary uses the configuration persistence API to save choices, not the
HTTP or browser save path. It does not start a new operating-system process,
diff --git a/internal/monitoring/monitor_notification_startup_test.go b/internal/monitoring/monitor_notification_startup_test.go
index 4580d91953..129abb1fe8 100644
--- a/internal/monitoring/monitor_notification_startup_test.go
+++ b/internal/monitoring/monitor_notification_startup_test.go
@@ -36,6 +36,25 @@ func TestNewRestoresSavedNotificationChoices(t *testing.T) {
if err := persistence.SaveWebhooks(webhooks); err != nil {
t.Fatal(err)
}
+ // Synthetic credentials only; no notification is sent by this test.
+ email := notifications.EmailConfig{
+ Enabled: tc.enabled, Provider: "custom", SMTPHost: "smtp.example.invalid", SMTPPort: 587,
+ Username: "fixture-user", Password: "synthetic-email-password", From: "[email protected]",
+ To: []string{"[email protected]", "[email protected]"}, StartTLS: true, RateLimit: 17,
+ MinimumSeverity: "critical", TagFilter: []string{"ops"}, TagMode: "all",
+ }
+ if err := persistence.SaveEmailConfig(email); err != nil {
+ t.Fatal(err)
+ }
+ apprise := notifications.AppriseConfig{
+ Enabled: tc.enabled, Mode: notifications.AppriseModeHTTP, CLIPath: "apprise",
+ Targets: []string{"json://example.invalid/alerts"}, TimeoutSeconds: 23,
+ ServerURL: "https://apprise.example.invalid", ConfigKey: "fixture-config",
+ APIKey: "synthetic-apprise-key", APIKeyHeader: "X-Fixture-Key", MinimumSeverity: "warning",
+ }
+ if err := persistence.SaveAppriseConfig(apprise); err != nil {
+ t.Fatal(err)
+ }
for startup := 0; startup < 2; startup++ {
func() {
m, err := New(&config.Config{DataPath: dir})
@@ -54,6 +73,12 @@ func TestNewRestoresSavedNotificationChoices(t *testing.T) {
if got := n.IsEnabled(); got != wantEnabled {
t.Errorf("startup %d enabled=%t, want %t", startup, got, wantEnabled)
}
+ if got := n.GetEmailConfig(); !reflect.DeepEqual(got, email) {
+ t.Errorf("startup %d did not restore saved email configuration", startup)
+ }
+ if got := n.GetAppriseConfig(); !reflect.DeepEqual(got, apprise) {
+ t.Errorf("startup %d did not restore saved Apprise configuration", startup)
+ }
if got := n.GetWebhooks(); !reflect.DeepEqual(got, webhooks) {
t.Errorf("startup %d did not restore saved webhook configuration", startup)
}