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

Method TestGRPCMethodAccessibleToCredsViaContextRequestInfo

test/creds_test.go:196–215  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

194func (m *methodTestCreds) RequireTransportSecurity() bool { return false }
195
196func (s) TestGRPCMethodAccessibleToCredsViaContextRequestInfo(t *testing.T) {
197 const wantMethod = "/grpc.testing.TestService/EmptyCall"
198 te := newTest(t, env{name: "context-request-info", network: "tcp"})
199 te.userAgent = testAppUA
200 te.startServer(&testServer{security: te.e.security})
201 defer te.tearDown()
202
203 cc := te.clientConn(grpc.WithPerRPCCredentials(&methodTestCreds{}))
204 tc := testgrpc.NewTestServiceClient(cc)
205
206 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
207 defer cancel()
208 if _, err := tc.EmptyCall(ctx, &testpb.Empty{}); status.Convert(err).Message() != wantMethod {
209 t.Fatalf("ss.client.EmptyCall(_, _) = _, %v; want _, _.Message()=%q", err, wantMethod)
210 }
211
212 if _, err := tc.EmptyCall(ctx, &testpb.Empty{}, grpc.WaitForReady(true)); status.Convert(err).Message() != wantMethod {
213 t.Fatalf("ss.client.EmptyCall(_, _) = _, %v; want _, _.Message()=%q", err, wantMethod)
214 }
215}
216
217const clientAlwaysFailCredErrorMsg = "clientAlwaysFailCred always fails"
218

Callers

nothing calls this directly

Calls 10

EmptyCallMethod · 0.95
WithPerRPCCredentialsFunction · 0.92
ConvertFunction · 0.92
WaitForReadyFunction · 0.92
MessageMethod · 0.80
newTestFunction · 0.70
FatalfMethod · 0.65
startServerMethod · 0.45
tearDownMethod · 0.45
clientConnMethod · 0.45

Tested by

no test coverage detected