server/api_test: Adjust expected error message for Go 1.18
Right now Fedora doesn't ship Go 1.17, only Go 1.18beta.  That
version emits a different error message for incompatible TLS
versions.  Adjust our unit test to handle both.
(Also, a motivation for me is to cross-check the new CI configuration
after )
@@ -609,6 +609,8 @@ EKTcWGekdmdDPsHloRNtsiCa697B2O9IFA==
desc string
wantErr bool
errString string
+ // Errors may also match this
+ errStrings []string
client *http.Client
ciphers []uint16
}
@@ -653,7 +655,8 @@ EKTcWGekdmdDPsHloRNtsiCa697B2O9IFA==
{
desc: "TLS1.1 should fail",
wantErr: true,
- errString: "protocol version not supported",
+ 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{
@@ -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)
}
}
