mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Tolerate additional error messages in TLS unit tests
This commit is contained in:
parent
1ea07d482a
commit
cff4eeef9f
@ -26,7 +26,7 @@ import (
|
|||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/util/diff"
|
"k8s.io/apimachinery/pkg/util/diff"
|
||||||
@ -56,7 +56,7 @@ func TestDialURL(t *testing.T) {
|
|||||||
},
|
},
|
||||||
"secure, no roots": {
|
"secure, no roots": {
|
||||||
TLSConfig: &tls.Config{InsecureSkipVerify: false},
|
TLSConfig: &tls.Config{InsecureSkipVerify: false},
|
||||||
ExpectError: "unknown authority",
|
ExpectError: "unknown authority|not trusted",
|
||||||
},
|
},
|
||||||
"secure with roots": {
|
"secure with roots": {
|
||||||
TLSConfig: &tls.Config{InsecureSkipVerify: false, RootCAs: roots},
|
TLSConfig: &tls.Config{InsecureSkipVerify: false, RootCAs: roots},
|
||||||
@ -76,7 +76,7 @@ func TestDialURL(t *testing.T) {
|
|||||||
"secure, no roots, custom dial": {
|
"secure, no roots, custom dial": {
|
||||||
TLSConfig: &tls.Config{InsecureSkipVerify: false},
|
TLSConfig: &tls.Config{InsecureSkipVerify: false},
|
||||||
Dial: d.DialContext,
|
Dial: d.DialContext,
|
||||||
ExpectError: "unknown authority",
|
ExpectError: "unknown authority|not trusted",
|
||||||
},
|
},
|
||||||
"secure with roots, custom dial": {
|
"secure with roots, custom dial": {
|
||||||
TLSConfig: &tls.Config{InsecureSkipVerify: false, RootCAs: roots},
|
TLSConfig: &tls.Config{InsecureSkipVerify: false, RootCAs: roots},
|
||||||
@ -154,7 +154,7 @@ func TestDialURL(t *testing.T) {
|
|||||||
if tc.ExpectError == "" {
|
if tc.ExpectError == "" {
|
||||||
t.Errorf("%s: expected no error, got %q", k, err.Error())
|
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())
|
t.Errorf("%s: expected error containing %q, got %q", k, tc.ExpectError, err.Error())
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -50,7 +50,7 @@ const (
|
|||||||
errBadCertificate = "Get .*: remote error: tls: bad certificate"
|
errBadCertificate = "Get .*: remote error: tls: bad certificate"
|
||||||
errNoConfiguration = "invalid configuration: no configuration has been provided"
|
errNoConfiguration = "invalid configuration: no configuration has been provided"
|
||||||
errMissingCertPath = "invalid configuration: unable to read %s %s for %s due to open %s: .*"
|
errMissingCertPath = "invalid configuration: unable to read %s %s for %s due to open %s: .*"
|
||||||
errSignedByUnknownCA = "Get .*: x509: certificate signed by unknown authority"
|
errSignedByUnknownCA = "Get .*: x509: .*(unknown authority|not standards compliant|not trusted)"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
Loading…
Reference in New Issue
Block a user