add a test for using the tls.Config.ServerName as the hostname

This commit is contained in:
Marten Seemann
2017-06-20 09:28:40 +02:00
parent 25f901bee3
commit 967dc7cb46

View File

@@ -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