From 53a85efe92e9ec17b72d760b70801f476c058de3 Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Tue, 29 Mar 2022 08:57:31 -0400 Subject: [PATCH] Tolerate additional error messages in TLS unit tests Kubernetes-commit: cff4eeef9f1880b42b8c3d3b8f3a27a89540dbe0 --- pkg/util/proxy/dial_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/util/proxy/dial_test.go b/pkg/util/proxy/dial_test.go index 47c24c2a9..a35d30846 100644 --- a/pkg/util/proxy/dial_test.go +++ b/pkg/util/proxy/dial_test.go @@ -26,7 +26,7 @@ import ( "net/http/httptest" "net/url" "reflect" - "strings" + "regexp" "testing" "k8s.io/apimachinery/pkg/util/diff" @@ -56,7 +56,7 @@ func TestDialURL(t *testing.T) { }, "secure, no roots": { TLSConfig: &tls.Config{InsecureSkipVerify: false}, - ExpectError: "unknown authority", + ExpectError: "unknown authority|not trusted", }, "secure with roots": { TLSConfig: &tls.Config{InsecureSkipVerify: false, RootCAs: roots}, @@ -76,7 +76,7 @@ func TestDialURL(t *testing.T) { "secure, no roots, custom dial": { TLSConfig: &tls.Config{InsecureSkipVerify: false}, Dial: d.DialContext, - ExpectError: "unknown authority", + ExpectError: "unknown authority|not trusted", }, "secure with roots, custom dial": { TLSConfig: &tls.Config{InsecureSkipVerify: false, RootCAs: roots}, @@ -154,7 +154,7 @@ func TestDialURL(t *testing.T) { if tc.ExpectError == "" { t.Errorf("%s: expected no error, got %q", k, err.Error()) } - if !strings.Contains(err.Error(), tc.ExpectError) { + if tc.ExpectError != "" && !regexp.MustCompile(tc.ExpectError).MatchString(err.Error()) { t.Errorf("%s: expected error containing %q, got %q", k, tc.ExpectError, err.Error()) } return