watcher: startup notification no longer says every endpoint works (closes #230) #241

Merged
clawbot merged 1 commits from issue-230-startup-notification-text into next 2026-10-02 08:42:35 +02:00
3 changed files with 18 additions and 5 deletions
Showing only changes of commit ddcb0dca07 - Show all commits
+2
View File
@@ -19,6 +19,8 @@ trial run of the finished image: https://git.eeqj.de/sneak/dnswatcher/issues/149
# Completed Steps # Completed Steps
- 2026-10-02: the startup notification no longer says every notification
endpoint works; it says it is a test sent to each of them (closes #230).
- 2026-10-02: a Mattermost webhook that answers an HTTP error is logged as - 2026-10-02: a Mattermost webhook that answers an HTTP error is logged as
`mattermost notification failed`, not as a Slack failure (closes #227). `mattermost notification failed`, not as a Slack failure (closes #227).
- 2026-10-02: durations in the log are written as text such as `2m0s`, not as a - 2026-10-02: durations in the log are written as text such as `2m0s`, not as a
+5 -3
View File
@@ -1154,8 +1154,9 @@ func (w *Watcher) saveState() {
// maybeSendTestNotification sends a startup status notification // maybeSendTestNotification sends a startup status notification
// after the first full scan completes, if SEND_TEST_NOTIFICATION // after the first full scan completes, if SEND_TEST_NOTIFICATION
// is enabled. The message is clearly informational ("all ok") // is enabled. The message is informational, not an error or anomaly
// and not an error or anomaly alert. // alert. It is written before it reaches any endpoint, so it claims
// nothing about whether the endpoints work.
func (w *Watcher) maybeSendTestNotification(ctx context.Context) { func (w *Watcher) maybeSendTestNotification(ctx context.Context) {
if !w.config.SendTestNotification { if !w.config.SendTestNotification {
return return
@@ -1167,7 +1168,8 @@ func (w *Watcher) maybeSendTestNotification(ctx context.Context) {
"dnswatcher has started and completed its initial scan.\n"+ "dnswatcher has started and completed its initial scan.\n"+
"Monitoring %d domain(s) and %d hostname(s).\n"+ "Monitoring %d domain(s) and %d hostname(s).\n"+
"Tracking %d port endpoint(s) and %d TLS certificate(s).\n"+ "Tracking %d port endpoint(s) and %d TLS certificate(s).\n"+
"All notification channels are working.", "This is a test notification, sent to every configured "+
"notification endpoint.",
len(snap.Domains), len(snap.Domains),
len(snap.Hostnames), len(snap.Hostnames),
len(snap.Ports), len(snap.Ports),
+11 -2
View File
@@ -875,18 +875,27 @@ func TestSendTestNotification_ViaRun(t *testing.T) {
notifications := deps.notifier.getNotifications() notifications := deps.notifier.getNotifications()
// No names are configured, so every count is 0.
wantMessage := "dnswatcher has started and completed its initial scan.\n" +
"Monitoring 0 domain(s) and 0 hostname(s).\n" +
"Tracking 0 port endpoint(s) and 0 TLS certificate(s).\n" +
"This is a test notification, sent to every configured " +
"notification endpoint."
found := false found := false
for _, n := range notifications { for _, n := range notifications {
if n.Priority == "success" && if n.Priority == "success" &&
n.Title == "✅ dnswatcher startup complete" { n.Title == "✅ dnswatcher startup complete" &&
n.Message == wantMessage {
found = true found = true
} }
} }
if !found { if !found {
t.Errorf( t.Errorf(
"expected startup test notification, got: %v", "expected startup test notification with message %q, got: %v",
wantMessage,
notifications, notifications,
) )
} }