2021-09-28 12:42:01 +02:00
|
|
|
package netxlite
|
2021-09-07 17:09:30 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"crypto/x509"
|
|
|
|
"errors"
|
|
|
|
"io"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
|
|
"github.com/lucas-clemente/quic-go"
|
|
|
|
"github.com/pion/stun"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestClassifyGenericError(t *testing.T) {
|
2021-09-07 22:10:29 +02:00
|
|
|
// Please, keep this list sorted in the same order
|
|
|
|
// in which checks appear on the code
|
|
|
|
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Run("for input being already an ErrWrapper", func(t *testing.T) {
|
|
|
|
err := &ErrWrapper{Failure: FailureEOFError}
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyGenericError(err) != FailureEOFError {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("did not classify existing ErrWrapper correctly")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for a system call error", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyGenericError(EWOULDBLOCK) != FailureOperationWouldBlock {
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Fatal("unexpected results")
|
2021-09-07 17:09:30 +02:00
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
// Now we enter into classifyWithStringSuffix. We test it here
|
|
|
|
// since we want to test the ClassifyGenericError in is
|
|
|
|
// entirety here and the classifyWithStringSuffix function
|
|
|
|
// is just an implementation detail.
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for operation was canceled", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyGenericError(errors.New("operation was canceled")) != FailureInterrupted {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Run("for EOF", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyGenericError(io.EOF) != FailureEOFError {
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Fatal("unexpected result")
|
2021-09-07 17:09:30 +02:00
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for context deadline exceeded", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyGenericError(context.DeadlineExceeded) != FailureGenericTimeoutError {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected results")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for stun's transaction is timed out", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyGenericError(stun.ErrTransactionTimeOut) != FailureGenericTimeoutError {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected results")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for i/o timeout", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyGenericError(errors.New("i/o timeout")) != FailureGenericTimeoutError {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected results")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for TLS handshake timeout", func(t *testing.T) {
|
|
|
|
err := errors.New("net/http: TLS handshake timeout")
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyGenericError(err) != FailureGenericTimeoutError {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected results")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for no such host", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyGenericError(errors.New("no such host")) != FailureDNSNXDOMAINError {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected results")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-27 16:48:46 +02:00
|
|
|
t.Run("for dns server misbehaving", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyGenericError(errors.New("dns server misbehaving")) != FailureDNSServerMisbehaving {
|
2021-09-27 16:48:46 +02:00
|
|
|
t.Fatal("unexpected results")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("for no answer from DNS server", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyGenericError(errors.New("no answer from DNS server")) != FailureDNSNoAnswer {
|
2021-09-27 16:48:46 +02:00
|
|
|
t.Fatal("unexpected results")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-09-27 14:40:25 +02:00
|
|
|
t.Run("for use of closed network connection", func(t *testing.T) {
|
|
|
|
err := errors.New("read tcp 10.0.2.15:56948->93.184.216.34:443: use of closed network connection")
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyGenericError(err) != FailureConnectionAlreadyClosed {
|
2021-09-27 14:40:25 +02:00
|
|
|
t.Fatal("unexpected results")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
// Now we're back in ClassifyGenericError
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for context.Canceled", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyGenericError(context.Canceled) != FailureInterrupted {
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Fatal("unexpected result")
|
2021-09-07 17:09:30 +02:00
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for unknown errors", func(t *testing.T) {
|
|
|
|
t.Run("with an IPv4 address", func(t *testing.T) {
|
2021-09-27 14:40:25 +02:00
|
|
|
input := errors.New("read tcp 10.0.2.15:56948->93.184.216.34:443: some error")
|
|
|
|
expected := "unknown_failure: read tcp [scrubbed]->[scrubbed]: some error"
|
2022-07-01 12:22:22 +02:00
|
|
|
out := ClassifyGenericError(input)
|
2021-09-07 22:10:29 +02:00
|
|
|
if out != expected {
|
|
|
|
t.Fatal(cmp.Diff(expected, out))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("with an IPv6 address", func(t *testing.T) {
|
2021-09-27 14:40:25 +02:00
|
|
|
input := errors.New("read tcp [::1]:56948->[::1]:443: some error")
|
|
|
|
expected := "unknown_failure: read tcp [scrubbed]->[scrubbed]: some error"
|
2022-07-01 12:22:22 +02:00
|
|
|
out := ClassifyGenericError(input)
|
2021-09-07 22:10:29 +02:00
|
|
|
if out != expected {
|
|
|
|
t.Fatal(cmp.Diff(expected, out))
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 17:09:30 +02:00
|
|
|
})
|
2021-09-07 22:10:29 +02:00
|
|
|
}
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
func TestClassifyQUICHandshakeError(t *testing.T) {
|
|
|
|
// Please, keep this list sorted in the same order
|
|
|
|
// in which checks appear on the code
|
|
|
|
|
|
|
|
t.Run("for input being already an ErrWrapper", func(t *testing.T) {
|
|
|
|
err := &ErrWrapper{Failure: FailureEOFError}
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyQUICHandshakeError(err) != FailureEOFError {
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Fatal("did not classify existing ErrWrapper correctly")
|
2021-09-07 17:09:30 +02:00
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for incompatible quic version", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyQUICHandshakeError(&quic.VersionNegotiationError{}) != FailureQUICIncompatibleVersion {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected results")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for stateless reset", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyQUICHandshakeError(&quic.StatelessResetError{}) != FailureConnectionReset {
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Fatal("unexpected results")
|
2021-09-07 17:09:30 +02:00
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for handshake timeout", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyQUICHandshakeError(&quic.HandshakeTimeoutError{}) != FailureGenericTimeoutError {
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Fatal("unexpected results")
|
2021-09-07 17:09:30 +02:00
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for idle timeout", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyQUICHandshakeError(&quic.IdleTimeoutError{}) != FailureGenericTimeoutError {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected results")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for connection refused", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyQUICHandshakeError(&quic.TransportError{ErrorCode: quic.ConnectionRefused}) != FailureConnectionRefused {
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Fatal("unexpected results")
|
2021-09-07 17:09:30 +02:00
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for bad certificate", func(t *testing.T) {
|
|
|
|
var err quic.TransportErrorCode = quicTLSAlertBadCertificate
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyQUICHandshakeError(&quic.TransportError{ErrorCode: err}) != FailureSSLInvalidCertificate {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected results")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for unsupported certificate", func(t *testing.T) {
|
|
|
|
var err quic.TransportErrorCode = quicTLSAlertUnsupportedCertificate
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyQUICHandshakeError(&quic.TransportError{ErrorCode: err}) != FailureSSLInvalidCertificate {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected results")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for certificate expired", func(t *testing.T) {
|
|
|
|
var err quic.TransportErrorCode = quicTLSAlertCertificateExpired
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyQUICHandshakeError(&quic.TransportError{ErrorCode: err}) != FailureSSLInvalidCertificate {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected results")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for certificate revoked", func(t *testing.T) {
|
|
|
|
var err quic.TransportErrorCode = quicTLSAlertCertificateRevoked
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyQUICHandshakeError(&quic.TransportError{ErrorCode: err}) != FailureSSLInvalidCertificate {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected results")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for certificate unknown", func(t *testing.T) {
|
|
|
|
var err quic.TransportErrorCode = quicTLSAlertCertificateUnknown
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyQUICHandshakeError(&quic.TransportError{ErrorCode: err}) != FailureSSLInvalidCertificate {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected results")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for decrypt error", func(t *testing.T) {
|
|
|
|
var err quic.TransportErrorCode = quicTLSAlertDecryptError
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyQUICHandshakeError(&quic.TransportError{ErrorCode: err}) != FailureSSLFailedHandshake {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected results")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for handshake failure", func(t *testing.T) {
|
|
|
|
var err quic.TransportErrorCode = quicTLSAlertHandshakeFailure
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyQUICHandshakeError(&quic.TransportError{ErrorCode: err}) != FailureSSLFailedHandshake {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected results")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for unknown CA", func(t *testing.T) {
|
2021-09-07 17:09:30 +02:00
|
|
|
var err quic.TransportErrorCode = quicTLSAlertUnknownCA
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyQUICHandshakeError(&quic.TransportError{ErrorCode: err}) != FailureSSLUnknownAuthority {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected results")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 22:10:29 +02:00
|
|
|
t.Run("for unrecognized hostname", func(t *testing.T) {
|
2021-09-07 17:09:30 +02:00
|
|
|
var err quic.TransportErrorCode = quicTLSUnrecognizedName
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyQUICHandshakeError(&quic.TransportError{ErrorCode: err}) != FailureSSLInvalidHostname {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected results")
|
2021-09-09 00:07:38 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("for a TransportError wrapping an OONI error", func(t *testing.T) {
|
|
|
|
err := &quic.TransportError{
|
|
|
|
ErrorCode: quic.InternalError,
|
|
|
|
ErrorMessage: FailureHostUnreachable,
|
|
|
|
}
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyQUICHandshakeError(err) != FailureHostUnreachable {
|
2021-09-09 00:07:38 +02:00
|
|
|
t.Fatal("unexpected results")
|
2021-09-07 17:09:30 +02:00
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Run("for another kind of error", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyQUICHandshakeError(io.EOF) != FailureEOFError {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestClassifyResolverError(t *testing.T) {
|
2021-09-07 22:10:29 +02:00
|
|
|
// Please, keep this list sorted in the same order
|
|
|
|
// in which checks appear on the code
|
|
|
|
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Run("for input being already an ErrWrapper", func(t *testing.T) {
|
|
|
|
err := &ErrWrapper{Failure: FailureEOFError}
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyResolverError(err) != FailureEOFError {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("did not classify existing ErrWrapper correctly")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Run("for ErrDNSBogon", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyResolverError(ErrDNSBogon) != FailureDNSBogonError {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-27 16:48:46 +02:00
|
|
|
t.Run("for refused", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyResolverError(ErrOODNSRefused) != FailureDNSRefusedError {
|
2021-09-27 16:48:46 +02:00
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2022-05-13 19:25:22 +02:00
|
|
|
t.Run("for servfail", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyResolverError(ErrOODNSServfail) != FailureDNSServfailError {
|
2022-05-13 19:25:22 +02:00
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2022-05-14 19:38:46 +02:00
|
|
|
t.Run("for dns reply with wrong queryID", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyResolverError(ErrDNSReplyWithWrongQueryID) != FailureDNSReplyWithWrongQueryID {
|
2022-05-14 19:38:46 +02:00
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2022-05-28 15:10:30 +02:00
|
|
|
t.Run("for EAI_NODATA returned by Android's getaddrinfo", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyResolverError(ErrAndroidDNSCacheNoData) != FailureAndroidDNSCacheNoData {
|
2022-05-28 15:10:30 +02:00
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Run("for another kind of error", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyResolverError(io.EOF) != FailureEOFError {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestClassifyTLSHandshakeError(t *testing.T) {
|
2021-09-07 22:10:29 +02:00
|
|
|
// Please, keep this list sorted in the same order
|
|
|
|
// in which checks appear on the code
|
|
|
|
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Run("for input being already an ErrWrapper", func(t *testing.T) {
|
|
|
|
err := &ErrWrapper{Failure: FailureEOFError}
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyTLSHandshakeError(err) != FailureEOFError {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("did not classify existing ErrWrapper correctly")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Run("for x509.HostnameError", func(t *testing.T) {
|
|
|
|
var err x509.HostnameError
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyTLSHandshakeError(err) != FailureSSLInvalidHostname {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Run("for x509.UnknownAuthorityError", func(t *testing.T) {
|
|
|
|
var err x509.UnknownAuthorityError
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyTLSHandshakeError(err) != FailureSSLUnknownAuthority {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Run("for x509.CertificateInvalidError", func(t *testing.T) {
|
|
|
|
var err x509.CertificateInvalidError
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyTLSHandshakeError(err) != FailureSSLInvalidCertificate {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
|
|
|
})
|
2021-09-07 20:39:32 +02:00
|
|
|
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Run("for another kind of error", func(t *testing.T) {
|
2022-07-01 12:22:22 +02:00
|
|
|
if ClassifyTLSHandshakeError(io.EOF) != FailureEOFError {
|
2021-09-07 17:09:30 +02:00
|
|
|
t.Fatal("unexpected result")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|