Skip to content

Commit

Permalink
Tolerate additional error messages in TLS unit tests
Browse files Browse the repository at this point in the history
Kubernetes-commit: cff4eeef9f1880b42b8c3d3b8f3a27a89540dbe0
  • Loading branch information
liggitt authored and k8s-publishing-bot committed Mar 29, 2022
1 parent 00f0711 commit 53a85ef
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/util/proxy/dial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"net/http/httptest"
"net/url"
"reflect"
"strings"
"regexp"
"testing"

"k8s.io/apimachinery/pkg/util/diff"
Expand Down Expand Up @@ -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},
Expand All @@ -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},
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 53a85ef

Please sign in to comment.