fix(netxlite): http3 transport needs logging by default (#492)

Adapt other places where it was not using a logger to either choose
a reasonable logger or disable logging for backwards compat.

See https://github.com/ooni/probe/issues/1591
This commit is contained in:
Simone Basso 2021-09-08 20:49:01 +02:00 committed by GitHub
commit e68adec9a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 16 deletions

View file

@ -7,6 +7,7 @@ import (
"net/http"
"testing"
"github.com/apex/log"
"github.com/lucas-clemente/quic-go"
"github.com/lucas-clemente/quic-go/http3"
"github.com/ooni/probe-cli/v3/internal/netxlite/mocks"
@ -80,8 +81,12 @@ func TestNewHTTP3Transport(t *testing.T) {
t.Run("creates the correct type chain", func(t *testing.T) {
qd := &mocks.QUICDialer{}
config := &tls.Config{}
txp := NewHTTP3Transport(qd, config)
h3txp := txp.(*http3Transport)
txp := NewHTTP3Transport(log.Log, qd, config)
logger := txp.(*httpTransportLogger)
if logger.Logger != log.Log {
t.Fatal("invalid logger")
}
h3txp := logger.HTTPTransport.(*http3Transport)
if h3txp.dialer != qd {
t.Fatal("invalid dialer")
}