diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index cc7f19cd89..9cf735c840 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -559,7 +559,7 @@ func validateDashboardCmd(ctx context.Context, t *testing.T, profile string) { ss.Stop(t) }() - s, err := dashboardURL(ss.Stdout) + s, err := dashboardURL(t, ss.Stdout) if err != nil { if runtime.GOOS == "windows" { t.Skip(err) @@ -587,11 +587,18 @@ func validateDashboardCmd(ctx context.Context, t *testing.T, profile string) { } // dashboardURL gets the dashboard URL from the command stdout. -func dashboardURL(b *bufio.Reader) (string, error) { +func dashboardURL(t *testing.T, b *bufio.Reader) (string, error) { s := bufio.NewScanner(b) + + // match http://127.0.0.1:XXXXX/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ + dashURLRegexp, err := regexp.Compile(`^http:\/\/127\.0\.0\.1:[0-9]{5}\/api\/v1\/namespaces\/kubernetes-dashboard\/services\/http:kubernetes-dashboard:\/proxy\/$`) + if err != nil { + t.Fatalf("dashboard URL regex is invalid: %v", err) + } + for s.Scan() { l := s.Text() - if strings.HasPrefix(l, "http") { + if dashURLRegexp.MatchString(l) { return l, nil } }