Files
pipelines/internal/server/notification_web_test.go
T

26 lines
852 B
Go

package server
import "testing"
func TestRunNotificationWebClick(t *testing.T) {
for _, tc := range []struct{ base, want string }{
{"https://pipelines.example.com", "https://pipelines.example.com/runs/20"},
{"http://10.0.0.75:8095/", "http://10.0.0.75:8095/runs/20"},
{"", "pipelines://run/20"}, // Existing Android-only installations.
{"javascript:alert(1)", ""},
{"https://user:password@example.com", ""},
{"https://example.com?token=secret", ""},
{"https://example.com/#fragment", ""},
{"https://example.com/subpath", ""}, // Web app uses origin-root routes.
{"/runs", ""},
{"https://example.com\r\nClick:bad", ""},
} {
t.Run(tc.base, func(t *testing.T) {
t.Setenv("PIPELINES_WEB_PUBLIC_URL", tc.base)
if got := runAttentionClick(20); got != tc.want {
t.Fatalf("click = %q, want %q", got, tc.want)
}
})
}
}