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 (
|
||||
"bytes"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"net"
|
||||
"time"
|
||||
@@ -131,6 +132,24 @@ var _ = Describe("Client", func() {
|
||||
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) {
|
||||
testErr := errors.New("early handshake error")
|
||||
var dialErr error
|
||||
|
||||
Reference in New Issue
Block a user