From c080a6beb64732301f90902aeaad8fee74afef50 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Tue, 2 Dec 2025 01:09:03 +0000 Subject: [PATCH] test: Add DNS resolution failure test for ValidateWebhookURL Tests the error path when webhook hostname cannot be resolved (78.1% to 81.2% coverage). --- internal/notifications/webhook_allowlist_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/internal/notifications/webhook_allowlist_test.go b/internal/notifications/webhook_allowlist_test.go index 9b83601..f39369a 100644 --- a/internal/notifications/webhook_allowlist_test.go +++ b/internal/notifications/webhook_allowlist_test.go @@ -287,3 +287,16 @@ func TestValidateWebhookURLWithAllowlist(t *testing.T) { t.Error("Expected error for link-local even with allowlist") } } + +func TestValidateWebhookURL_DNSResolutionFailure(t *testing.T) { + nm := NewNotificationManager("") + + // Use a hostname that will definitely not resolve + err := nm.ValidateWebhookURL("http://this-hostname-definitely-does-not-exist-12345.invalid/webhook") + if err == nil { + t.Error("Expected error for unresolvable hostname") + } + if !strings.Contains(err.Error(), "failed to resolve webhook hostname") { + t.Errorf("Expected DNS resolution error, got: %v", err) + } +}