Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions pkg/server/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,10 @@ EKTcWGekdmdDPsHloRNtsiCa697B2O9IFA==
desc string
wantErr bool
errString string
client *http.Client
ciphers []uint16
// Errors may also match this
errStrings []string
client *http.Client
ciphers []uint16
}

tests := []testCase{
Expand Down Expand Up @@ -651,9 +653,10 @@ EKTcWGekdmdDPsHloRNtsiCa697B2O9IFA==
},
},
{
desc: "TLS1.1 should fail",
wantErr: true,
errString: "protocol version not supported",
desc: "TLS1.1 should fail",
wantErr: true,
errStrings: []string{"protocol version not supported", // go < 1.18
"no supported versions satisfy MinVersion and MaxVersion"}, // go >= 1.18
client: &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
Expand Down Expand Up @@ -706,7 +709,20 @@ EKTcWGekdmdDPsHloRNtsiCa697B2O9IFA==
}
}
if c.wantErr {
if !strings.Contains(fmt.Sprintf("%v", err), c.errString) {
errstr := fmt.Sprintf("%v", err)
if c.errStrings != nil {
matches := false
for _, expected := range c.errStrings {
if strings.Contains(errstr, expected) {
matches = true
break
}
}
if !matches {
expected := strings.Join(c.errStrings, " or ")
t.Fatalf("want: %s\n got: %v", expected, err)
}
} else if !strings.Contains(errstr, c.errString) {
t.Fatalf("want: %s\n got: %v", c.errString, err)
}
}
Expand Down