diff --git a/clientconn_test.go b/clientconn_test.go index ee159955..93e78a5a 100644 --- a/clientconn_test.go +++ b/clientconn_test.go @@ -97,6 +97,22 @@ func TestWithAuthority(t *testing.T) { } } +func TestWithAuthorityAndTLS(t *testing.T) { + overwriteServerName := "over.write.server.name" + creds, err := credentials.NewClientTLSFromFile(tlsDir+"ca.pem", overwriteServerName) + if err != nil { + t.Fatalf("Failed to create credentials %v", err) + } + conn, err := Dial("Non-Existent.Server:80", WithTransportCredentials(creds), WithAuthority("no.effect.authority")) + if err != nil { + t.Fatalf("Dial(_, _) = _, %v, want _, ", err) + } + conn.Close() + if conn.authority != overwriteServerName { + t.Fatalf("%v.authority = %v, want %v", conn, conn.authority, overwriteServerName) + } +} + func TestDialContextCancel(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) cancel() diff --git a/transport/transport.go b/transport/transport.go index 18d15f7e..caee54a8 100644 --- a/transport/transport.go +++ b/transport/transport.go @@ -374,7 +374,8 @@ func NewServerTransport(protocol string, conn net.Conn, config *ServerConfig) (S type ConnectOptions struct { // UserAgent is the application user agent. UserAgent string - // Authority is the :authority pseudo-header to use. + // Authority is the :authority pseudo-header to use. This field has no effect if + // TransportCredentials is set. Authority string // Dialer specifies how to dial a network address. Dialer func(context.Context, string) (net.Conn, error)