feat: upgrade oohttp and propagate changes (#461)
Part of https://github.com/ooni/probe/issues/1506
This commit is contained in:
parent
5b8df394b1
commit
b834af83ac
8 changed files with 95 additions and 35 deletions
|
|
@ -3,8 +3,11 @@ package netxlite
|
|||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"net"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/apex/log"
|
||||
utls "gitlab.com/yawning/utls.git"
|
||||
|
|
@ -45,3 +48,37 @@ func TestNewTLSHandshakerUTLSTypes(t *testing.T) {
|
|||
t.Fatal("expected non-nil NewConn")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUTLSConnHandshakeNotInterrupted(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
conn := &utlsConn{
|
||||
testableHandshake: func() error {
|
||||
return nil
|
||||
},
|
||||
}
|
||||
err := conn.HandshakeContext(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUTLSConnHandshakeInterrupted(t *testing.T) {
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(1)
|
||||
sigch := make(chan interface{})
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond)
|
||||
defer cancel()
|
||||
conn := &utlsConn{
|
||||
testableHandshake: func() error {
|
||||
defer wg.Done()
|
||||
<-sigch
|
||||
return nil
|
||||
},
|
||||
}
|
||||
err := conn.HandshakeContext(ctx)
|
||||
if !errors.Is(err, context.DeadlineExceeded) {
|
||||
t.Fatal("not the error we expected", err)
|
||||
}
|
||||
close(sigch)
|
||||
wg.Wait()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue