refactor(netxlite): add factories to create TLS handshakers (#460)
See https://github.com/ooni/probe/issues/1591
This commit is contained in:
parent
6a1e92cace
commit
5b8df394b1
5 changed files with 61 additions and 3 deletions
|
|
@ -6,12 +6,13 @@ import (
|
|||
"net"
|
||||
"testing"
|
||||
|
||||
"github.com/apex/log"
|
||||
utls "gitlab.com/yawning/utls.git"
|
||||
)
|
||||
|
||||
func TestUTLSHandshakerChrome(t *testing.T) {
|
||||
h := &tlsHandshakerConfigurable{
|
||||
NewConn: NewConnUTLS(&utls.HelloChrome_Auto),
|
||||
NewConn: newConnUTLS(&utls.HelloChrome_Auto),
|
||||
}
|
||||
cfg := &tls.Config{ServerName: "google.com"}
|
||||
conn, err := net.Dial("tcp", "google.com:443")
|
||||
|
|
@ -26,3 +27,21 @@ func TestUTLSHandshakerChrome(t *testing.T) {
|
|||
t.Fatal("nil connection")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewTLSHandshakerUTLSTypes(t *testing.T) {
|
||||
th := NewTLSHandshakerUTLS(log.Log, &utls.HelloChrome_83)
|
||||
thl, okay := th.(*tlsHandshakerLogger)
|
||||
if !okay {
|
||||
t.Fatal("invalid type")
|
||||
}
|
||||
if thl.Logger != log.Log {
|
||||
t.Fatal("invalid logger")
|
||||
}
|
||||
thc, okay := thl.TLSHandshaker.(*tlsHandshakerConfigurable)
|
||||
if !okay {
|
||||
t.Fatal("invalid type")
|
||||
}
|
||||
if thc.NewConn == nil {
|
||||
t.Fatal("expected non-nil NewConn")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue