tls: fix error reporting in TestInvalidCerts

This commit is contained in:
Marten Seemann 2022-05-25 15:24:39 +02:00
parent 5c297a8700
commit 2f109aea68
1 changed files with 9 additions and 11 deletions

View File

@ -482,26 +482,24 @@ func TestInvalidCerts(t *testing.T) {
_, err := conn.Read([]byte{0})
clientErrChan <- err
}()
var clientErr error
select {
case clientErr = <-clientErrChan:
case <-time.After(250 * time.Millisecond):
t.Fatal("expected the server handshake to return")
}
require.Error(t, clientErr)
if clientErr.Error() != "remote error: tls: error decrypting message" &&
clientErr.Error() != "remote error: tls: bad certificate" {
case err := <-clientErrChan:
require.Error(t, err)
if err.Error() != "remote error: tls: error decrypting message" &&
err.Error() != "remote error: tls: bad certificate" {
t.Fatalf("unexpected error: %s", err.Error())
}
var serverErr error
select {
case serverErr = <-serverErrChan:
case <-time.After(250 * time.Millisecond):
t.Fatal("expected the server handshake to return")
}
require.Error(t, serverErr)
tr.checkErr(t, serverErr)
select {
case err := <-serverErrChan:
require.Error(t, err)
tr.checkErr(t, err)
case <-time.After(250 * time.Millisecond):
t.Fatal("expected the server handshake to return")
}
})
t.Run(fmt.Sprintf("server offending: %s", tr.name), func(t *testing.T) {