Simplify condition for certificate error
Instead of two `expired certificate` and `bad certificate` comparisons, we can just check for `certificate` in error output. This satisfies us when checking there is something wrong with the certificate. Co-authored-by: Scott Blum <dragonsinth@gmail.com>
This commit is contained in:
parent
a418397a77
commit
744827a432
|
|
@ -213,10 +213,7 @@ func TestBrokenTLS_ClientHasExpiredCert(t *testing.T) {
|
||||||
e.Close()
|
e.Close()
|
||||||
t.Fatal("expecting TLS failure setting up server and client")
|
t.Fatal("expecting TLS failure setting up server and client")
|
||||||
}
|
}
|
||||||
// Go 1.21 uses "expired certificate" in the error message.
|
if !strings.Contains(err.Error(), "certificate") {
|
||||||
// Older Go versions use a simpler "bad certificate".
|
|
||||||
// `runtime.Version()` exists, but we don't want to parse a version String for comparison.
|
|
||||||
if !strings.Contains(err.Error(), "expired certificate") && !strings.Contains(err.Error(), "bad certificate") {
|
|
||||||
t.Fatalf("expecting TLS certificate error, got: %v", err)
|
t.Fatalf("expecting TLS certificate error, got: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue