func TestOKWithoutServerName(t *testing.T) { fdStart := countTCPFiles() config := &tls.Config{ RootCAs: cert.PoolContainingCert(), ServerName: "localhost", // we manually set a ServerName to make sure it doesn't get sent } conn, err := Dial("tcp", ADDR, false, config) assert.NoError(t, err, "Unable to dial") serverName := <-receivedServerNames assert.Empty(t, serverName, "Unexpected ServerName on server") assert.False(t, config.InsecureSkipVerify, "Original config shouldn't have been modified, but it was") closeAndCountFDs(t, conn, err, fdStart) }
func TestNotOKWithoutServerName(t *testing.T) { fdStart := countTCPFiles() conn, err := Dial("tcp", ADDR, true, &tls.Config{ ServerName: "localhost", }) assert.Error(t, err, "There should have been a problem dialing") if err != nil { assert.Contains(t, err.Error(), CERTIFICATE_ERROR, "Wrong error on dial") } serverName := <-receivedServerNames assert.Empty(t, serverName, "Unexpected ServerName on server") closeAndCountFDs(t, conn, err, fdStart) }