feat: add uTLS support in measurexlite (#918)

Closes https://github.com/ooni/probe/issues/2253 

Co-authored-by: decfox <decfox@github.com>
This commit is contained in:
DecFox 2022-09-07 18:49:53 +05:30 committed by GitHub
commit 59d8b6ecef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 136 additions and 1 deletions

View file

@ -0,0 +1,29 @@
package measurexlite
import (
"testing"
"time"
"github.com/ooni/probe-cli/v3/internal/model"
"github.com/ooni/probe-cli/v3/internal/model/mocks"
utls "gitlab.com/yawning/utls.git"
)
func TestNewTLSHandshakerUTLS(t *testing.T) {
t.Run("NewTLSHandshakerUTLS creates a wrapped TLSHandshaker", func(t *testing.T) {
underlying := &mocks.TLSHandshaker{}
zeroTime := time.Now()
trace := NewTrace(0, zeroTime)
trace.NewTLSHandshakerUTLSFn = func(dl model.DebugLogger, id *utls.ClientHelloID) model.TLSHandshaker {
return underlying
}
thx := trace.NewTLSHandshakerUTLS(model.DiscardLogger, &utls.HelloGolang)
thxt := thx.(*tlsHandshakerTrace)
if thxt.thx != underlying {
t.Fatal("invalid TLS handshaker")
}
if thxt.tx != trace {
t.Fatal("invalid trace")
}
})
}