From a6fe03ae2e5d4d5bc569b90b1708170591717006 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Sun, 6 Sep 2015 17:14:41 -0400 Subject: [PATCH] credentials.TLSInfo: export State --- credentials/credentials.go | 2 +- test/end2end_test.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/credentials/credentials.go b/credentials/credentials.go index 4c1f0437..cde38dc4 100644 --- a/credentials/credentials.go +++ b/credentials/credentials.go @@ -119,7 +119,7 @@ type TransportAuthenticator interface { // TLSInfo contains the auth information for a TLS authenticated connection. // It implements the AuthInfo interface. type TLSInfo struct { - state tls.ConnectionState + State tls.ConnectionState } func (t TLSInfo) AuthType() string { diff --git a/test/end2end_test.go b/test/end2end_test.go index b1862b09..b33467a2 100644 --- a/test/end2end_test.go +++ b/test/end2end_test.go @@ -117,16 +117,20 @@ func (s *testServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (* if !ok { grpclog.Fatalf("Failed to get AuthInfo from ctx.") } - var authType string + var authType, serverName string switch info := authInfo.(type) { case credentials.TLSInfo: authType = info.AuthType() + serverName = info.State.ServerName default: grpclog.Fatalf("Unknown AuthInfo type") } if authType != s.security { grpclog.Fatalf("Wrong auth type: got %q, want %q", authType, s.security) } + if serverName != "x.test.youtube.com" { + return nil, fmt.Errorf("Unknown server name %q", serverName) + } } // Simulate some service delay.