package statusview import ( "git.a-wan.net/alan/pipelines/internal/protocol" "strings" "testing" ) func TestOfflineStatusIncludesBothServicesAndRedactsURLCredentials(t *testing.T) { s := Offline("ws://user:password@localhost:8080/connect?token=secret#secret") text := strings.Join(Lines(s), "\n") for _, secret := range []string{"password", "token=", "secret", "user:"} { if strings.Contains(text, secret) { t.Fatal("credentials exposed", text) } } for _, expected := range []string{"Pipelines server", "unreachable", "ntfy", "unknown (server unavailable)", "8080"} { if !strings.Contains(text, expected) { t.Fatal("missing offline information", expected, text) } } } func TestUnconfiguredNtfyExplainsConnectedServerAndEndpointMismatch(t *testing.T) { text := strings.Join(NtfyLines(&protocol.SystemStatus{Ntfy: protocol.ServiceStatus{Health: "not configured"}}), "\n") for _, want := range []string{"connected Pipelines server", "docker compose port pipelines 8080", "--url / PIPELINES_URL"} { if !strings.Contains(text, want) { t.Fatal("missing endpoint diagnosis", want, text) } } }