提交 d9aca3d0 编写于 作者: S Steven Powell

make dashboard URL check more strict

上级 af4364ba
......@@ -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
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册