forked from quic-go/quic-go
add a test for using the tls.Config.ServerName as the hostname
This commit is contained in:
@@ -2,6 +2,7 @@ package quic
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
@@ -131,6 +132,24 @@ var _ = Describe("Client", func() {
|
|||||||
close(done)
|
close(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("uses the tls.Config.ServerName as the hostname, if present", func(done Done) {
|
||||||
|
var hostname string
|
||||||
|
newClientSession = func(
|
||||||
|
_ connection,
|
||||||
|
h string,
|
||||||
|
_ protocol.VersionNumber,
|
||||||
|
_ protocol.ConnectionID,
|
||||||
|
_ *Config,
|
||||||
|
_ []protocol.VersionNumber,
|
||||||
|
) (packetHandler, <-chan handshakeEvent, error) {
|
||||||
|
hostname = h
|
||||||
|
return sess, nil, nil
|
||||||
|
}
|
||||||
|
go DialAddr("localhost:17890", &Config{TLSConfig: &tls.Config{ServerName: "foobar"}})
|
||||||
|
Eventually(func() string { return hostname }).Should(Equal("foobar"))
|
||||||
|
close(done)
|
||||||
|
})
|
||||||
|
|
||||||
It("returns an error that occurs while waiting for the connection to become secure", func(done Done) {
|
It("returns an error that occurs while waiting for the connection to become secure", func(done Done) {
|
||||||
testErr := errors.New("early handshake error")
|
testErr := errors.New("early handshake error")
|
||||||
var dialErr error
|
var dialErr error
|
||||||
|
|||||||
Reference in New Issue
Block a user