Files
pulse/internal/notifications/webhook_security_test.go
T
rcourtman 1cf92e6c10 Pin metadata GET zero-record payload contract
Adds TestContract_MetadataGetPayloadsUseZeroRecordsInsteadOf404: empty
guest/docker metadata maps must serialize as {} (never null) and a
missing resource must return a 200 zero record echoing the requested ID
(never a 404). This is the proof companion to the
metadata_handlers_shared.go consolidation in the previous commit — it
was authored with that change but lost to a shared-index race at commit
time.
2026-06-10 10:53:57 +01:00

25 lines
549 B
Go

package notifications
import (
"strings"
"testing"
)
func TestSendWebhookRequestRevalidatesURL(t *testing.T) {
nm := NewNotificationManager("")
defer nm.Stop()
webhook := WebhookConfig{
Name: "blocked",
URL: "http://127.0.0.1/webhook",
}
err := nm.sendWebhookRequest(webhook, []byte(`{}`), "alert", "test-alert:alert")
if err == nil {
t.Fatalf("expected validation error for localhost webhook URL")
}
if !strings.Contains(err.Error(), "webhook URL validation failed") {
t.Fatalf("expected validation error, got %v", err)
}
}