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

Method TestControlChannelCredsSuccess

balancer/rls/control_channel_test.go:309–351  ·  view source on GitHub ↗

TestControlChannelCredsSuccess tests creation of the control channel with different credentials, which are expected to succeed.

(t *testing.T)

Source from the content-addressed store, hash-verified

307// TestControlChannelCredsSuccess tests creation of the control channel with
308// different credentials, which are expected to succeed.
309func (s) TestControlChannelCredsSuccess(t *testing.T) {
310 serverCreds := makeTLSCreds(t, "x509/server1_cert.pem", "x509/server1_key.pem", "x509/client_ca_cert.pem")
311 clientCreds := makeTLSCreds(t, "x509/client1_cert.pem", "x509/client1_key.pem", "x509/server_ca_cert.pem")
312
313 tests := []struct {
314 name string
315 sopts []grpc.ServerOption
316 bopts balancer.BuildOptions
317 }{
318 {
319 name: "insecure",
320 sopts: nil,
321 bopts: balancer.BuildOptions{},
322 },
323 {
324 name: "transport creds only",
325 sopts: []grpc.ServerOption{grpc.Creds(serverCreds)},
326 bopts: balancer.BuildOptions{
327 DialCreds: clientCreds,
328 Authority: "x.test.example.com",
329 },
330 },
331 {
332 name: "creds bundle",
333 sopts: []grpc.ServerOption{
334 grpc.Creds(serverCreds),
335 grpc.UnaryInterceptor(callCredsValidatingServerInterceptor),
336 },
337 bopts: balancer.BuildOptions{
338 CredsBundle: &testCredsBundle{
339 transportCreds: clientCreds,
340 callCreds: &testPerRPCCredentials{callCreds: perRPCCredsData},
341 },
342 Authority: "x.test.example.com",
343 },
344 },
345 }
346 for _, test := range tests {
347 t.Run(test.name, func(t *testing.T) {
348 testControlChannelCredsSuccess(t, test.sopts, test.bopts)
349 })
350 }
351}
352
353func testControlChannelCredsFailure(t *testing.T, sopts []grpc.ServerOption, bopts balancer.BuildOptions, wantCode codes.Code, wantErrRegex *regexp.Regexp) {
354 // StartFakeRouteLookupServer a fake server.

Callers

nothing calls this directly

Calls 4

CredsFunction · 0.92
UnaryInterceptorFunction · 0.92
makeTLSCredsFunction · 0.70

Tested by

no test coverage detected