credentials.TLSInfo: export State
This commit is contained in:
@ -119,7 +119,7 @@ type TransportAuthenticator interface {
|
|||||||
// TLSInfo contains the auth information for a TLS authenticated connection.
|
// TLSInfo contains the auth information for a TLS authenticated connection.
|
||||||
// It implements the AuthInfo interface.
|
// It implements the AuthInfo interface.
|
||||||
type TLSInfo struct {
|
type TLSInfo struct {
|
||||||
state tls.ConnectionState
|
State tls.ConnectionState
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t TLSInfo) AuthType() string {
|
func (t TLSInfo) AuthType() string {
|
||||||
|
@ -117,16 +117,20 @@ func (s *testServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (*
|
|||||||
if !ok {
|
if !ok {
|
||||||
grpclog.Fatalf("Failed to get AuthInfo from ctx.")
|
grpclog.Fatalf("Failed to get AuthInfo from ctx.")
|
||||||
}
|
}
|
||||||
var authType string
|
var authType, serverName string
|
||||||
switch info := authInfo.(type) {
|
switch info := authInfo.(type) {
|
||||||
case credentials.TLSInfo:
|
case credentials.TLSInfo:
|
||||||
authType = info.AuthType()
|
authType = info.AuthType()
|
||||||
|
serverName = info.State.ServerName
|
||||||
default:
|
default:
|
||||||
grpclog.Fatalf("Unknown AuthInfo type")
|
grpclog.Fatalf("Unknown AuthInfo type")
|
||||||
}
|
}
|
||||||
if authType != s.security {
|
if authType != s.security {
|
||||||
grpclog.Fatalf("Wrong auth type: got %q, want %q", 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.
|
// Simulate some service delay.
|
||||||
|
Reference in New Issue
Block a user