2021-06-08 11:24:13 +02:00
|
|
|
package tlsdialer_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/apex/log"
|
2021-06-25 11:07:26 +02:00
|
|
|
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
2021-06-08 11:24:13 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestTLSDialerSuccess(t *testing.T) {
|
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("skip test in short mode")
|
|
|
|
}
|
|
|
|
log.SetLevel(log.DebugLevel)
|
2021-06-25 13:42:48 +02:00
|
|
|
dialer := &netxlite.TLSDialer{Dialer: new(net.Dialer),
|
2021-06-25 12:21:34 +02:00
|
|
|
TLSHandshaker: &netxlite.TLSHandshakerLogger{
|
2021-06-25 11:07:26 +02:00
|
|
|
TLSHandshaker: &netxlite.TLSHandshakerStdlib{},
|
2021-06-08 11:24:13 +02:00
|
|
|
Logger: log.Log,
|
|
|
|
},
|
|
|
|
}
|
2021-06-25 13:42:48 +02:00
|
|
|
txp := &http.Transport{
|
|
|
|
DialTLSContext: dialer.DialTLSContext,
|
|
|
|
ForceAttemptHTTP2: true,
|
|
|
|
}
|
2021-06-08 11:24:13 +02:00
|
|
|
client := &http.Client{Transport: txp}
|
|
|
|
resp, err := client.Get("https://www.google.com")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
resp.Body.Close()
|
|
|
|
}
|