2021-06-08 11:24:13 +02:00
|
|
|
package tlsdialer_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"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-09-06 14:12:30 +02:00
|
|
|
dialer := &netxlite.TLSDialerLegacy{Dialer: netxlite.DefaultDialer,
|
2021-06-25 12:21:34 +02:00
|
|
|
TLSHandshaker: &netxlite.TLSHandshakerLogger{
|
2021-06-25 20:51:59 +02:00
|
|
|
TLSHandshaker: &netxlite.TLSHandshakerConfigurable{},
|
2022-01-03 13:53:23 +01:00
|
|
|
DebugLogger: log.Log,
|
2021-06-08 11:24:13 +02:00
|
|
|
},
|
|
|
|
}
|
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()
|
|
|
|
}
|