2021-06-08 11:24:13 +02:00
|
|
|
package tlsdialer_test
|
2021-02-02 12:05:47 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"crypto/tls"
|
|
|
|
"io"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2021-06-08 11:24:13 +02:00
|
|
|
"github.com/ooni/probe-cli/v3/internal/engine/netx/tlsdialer"
|
2021-06-25 11:07:26 +02:00
|
|
|
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
2021-02-02 12:05:47 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestSystemTLSHandshakerEOFError(t *testing.T) {
|
2021-06-25 20:51:59 +02:00
|
|
|
h := &netxlite.TLSHandshakerConfigurable{}
|
2021-06-08 11:24:13 +02:00
|
|
|
conn, _, err := h.Handshake(context.Background(), tlsdialer.EOFConn{}, &tls.Config{
|
2021-02-02 12:05:47 +01:00
|
|
|
ServerName: "x.org",
|
|
|
|
})
|
|
|
|
if err != io.EOF {
|
|
|
|
t.Fatal("not the error that we expected")
|
|
|
|
}
|
|
|
|
if conn != nil {
|
|
|
|
t.Fatal("expected nil con here")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type SetDeadlineConn struct {
|
2021-06-08 11:24:13 +02:00
|
|
|
tlsdialer.EOFConn
|
2021-02-02 12:05:47 +01:00
|
|
|
deadlines []time.Time
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *SetDeadlineConn) SetDeadline(t time.Time) error {
|
|
|
|
c.deadlines = append(c.deadlines, t)
|
|
|
|
return nil
|
|
|
|
}
|