Skip to content

Commit

Permalink
Authority overwrite only works if TLS is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
rodaine committed Feb 13, 2017
1 parent c7430a0 commit 4ad16bc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
16 changes: 16 additions & 0 deletions clientconn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 _, <nil>", 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()
Expand Down
3 changes: 2 additions & 1 deletion transport/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4ad16bc

Please sign in to comment.