b07890af4d
Auto-configure every relevant TLS field as close as possible to where it's actually used. As a side effect, add support for mocking the creation of a TLS connection, which should possibly be useful for uTLS? Work that is part of https://github.com/ooni/probe/issues/1505
34 lines
715 B
Go
34 lines
715 B
Go
package tlsdialer_test
|
|
|
|
import (
|
|
"net"
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/apex/log"
|
|
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
|
)
|
|
|
|
func TestTLSDialerSuccess(t *testing.T) {
|
|
if testing.Short() {
|
|
t.Skip("skip test in short mode")
|
|
}
|
|
log.SetLevel(log.DebugLevel)
|
|
dialer := &netxlite.TLSDialer{Dialer: new(net.Dialer),
|
|
TLSHandshaker: &netxlite.TLSHandshakerLogger{
|
|
TLSHandshaker: &netxlite.TLSHandshakerConfigurable{},
|
|
Logger: log.Log,
|
|
},
|
|
}
|
|
txp := &http.Transport{
|
|
DialTLSContext: dialer.DialTLSContext,
|
|
ForceAttemptHTTP2: true,
|
|
}
|
|
client := &http.Client{Transport: txp}
|
|
resp, err := client.Get("https://www.google.com")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
resp.Body.Close()
|
|
}
|