package server import ( "testing" ) func TestPublicNotificationSetup(t *testing.T) { t.Setenv("PIPELINES_NTFY_URL", "http://ntfy/pipelines") t.Setenv("PIPELINES_NTFY_TOKEN", "private-token") t.Setenv("PIPELINES_NTFY_PUBLIC_URL", "http://10.0.0.249:8090") found := false for _, endpoint := range notificationEndpoints() { if endpoint.Destination == "system" { found = true if endpoint.ServerURL != "http://10.0.0.249:8090" || endpoint.Topic != "pipelines" { t.Fatal(endpoint) } } } if !found { t.Fatal("missing destination") } for _, value := range []string{"http://user:secret@example.com", "http://example.com?token=secret", "file:///tmp/secret", "http://example.com/topic"} { if publicNtfyBase(value) != "" { t.Fatal("unsafe public URL accepted", value) } } t.Setenv("PIPELINES_NTFY_PUBLIC_URL", "") for _, endpoint := range notificationEndpoints() { if endpoint.ServerURL != "" { t.Fatal("internal URL exposed", endpoint) } } }