Error level log for configuration-related TLS errors with backends
Co-authored-by: Kevin Pollet <pollet.kevin@gmail.com>
This commit is contained in:
parent
b02946147d
commit
8ba99adc50
2 changed files with 72 additions and 2 deletions
|
@ -1,12 +1,15 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/traefik/traefik/v2/pkg/testhelpers"
|
||||
)
|
||||
|
||||
|
@ -35,3 +38,46 @@ func BenchmarkProxy(b *testing.B) {
|
|||
handler.ServeHTTP(w, req)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsTLSConfigError(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
err error
|
||||
expected bool
|
||||
}{
|
||||
{
|
||||
desc: "nil",
|
||||
},
|
||||
{
|
||||
desc: "TLS ECHRejectionError",
|
||||
err: &tls.ECHRejectionError{},
|
||||
},
|
||||
{
|
||||
desc: "TLS AlertError",
|
||||
err: tls.AlertError(0),
|
||||
},
|
||||
{
|
||||
desc: "Random error",
|
||||
err: errors.New("random error"),
|
||||
},
|
||||
{
|
||||
desc: "TLS RecordHeaderError",
|
||||
err: tls.RecordHeaderError{},
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
desc: "TLS CertificateVerificationError",
|
||||
err: &tls.CertificateVerificationError{},
|
||||
expected: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
actual := isTLSConfigError(test.err)
|
||||
require.Equal(t, test.expected, actual)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue