MCPcopy
hub / github.com/grpc/grpc-go / TestServerCredsInvalidHandshakeInfo

Method TestServerCredsInvalidHandshakeInfo

credentials/xds/xds_server_test.go:119–131  ·  view source on GitHub ↗

TestServerCredsInvalidHandshakeInfo verifies scenarios where the passed in HandshakeInfo is invalid because it does not contain the expected certificate providers.

(t *testing.T)

Source from the content-addressed store, hash-verified

117// HandshakeInfo is invalid because it does not contain the expected certificate
118// providers.
119func (s) TestServerCredsInvalidHandshakeInfo(t *testing.T) {
120 opts := ServerOptions{FallbackCreds: &errorCreds{}}
121 creds, err := NewServerCredentials(opts)
122 if err != nil {
123 t.Fatalf("NewServerCredentials(%v) failed: %v", opts, err)
124 }
125
126 info := xdsinternal.NewHandshakeInfo(&fakeProvider{}, nil, nil, false, "", false, false)
127 conn := newWrappedConn(nil, info, time.Time{})
128 if _, _, err := creds.ServerHandshake(conn); err == nil {
129 t.Fatal("ServerHandshake succeeded without identity certificate provider in HandshakeInfo")
130 }
131}
132
133// TestServerCredsProviderFailure verifies the cases where an expected
134// certificate provider is missing in the HandshakeInfo value in the context.

Callers

nothing calls this directly

Calls 5

NewServerCredentialsFunction · 0.85
newWrappedConnFunction · 0.85
FatalfMethod · 0.65
ServerHandshakeMethod · 0.65
FatalMethod · 0.65

Tested by

no test coverage detected