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

Method TestCredsHandshakeAuthority

test/creds_test.go:431–458  ·  view source on GitHub ↗

This test makes sure that the authority client handshake gets is the endpoint in dial target, not the resolved ip address.

(t *testing.T)

Source from the content-addressed store, hash-verified

429// This test makes sure that the authority client handshake gets is the endpoint
430// in dial target, not the resolved ip address.
431func (s) TestCredsHandshakeAuthority(t *testing.T) {
432 lis, err := net.Listen("tcp", "localhost:0")
433 if err != nil {
434 t.Fatal(err)
435 }
436 cred := &authorityCheckCreds{}
437 s := grpc.NewServer()
438 go s.Serve(lis)
439 defer s.Stop()
440
441 r := manual.NewBuilderWithScheme("whatever")
442
443 cc, err := grpc.NewClient(r.Scheme()+":///"+testAuthority, grpc.WithTransportCredentials(cred), grpc.WithResolvers(r))
444 if err != nil {
445 t.Fatalf("grpc.NewClient(%q) = %v", lis.Addr().String(), err)
446 }
447 defer cc.Close()
448 cc.Connect()
449 r.UpdateState(resolver.State{Addresses: []resolver.Address{{Addr: lis.Addr().String()}}})
450
451 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
452 defer cancel()
453 testutils.AwaitState(ctx, t, cc, connectivity.Ready)
454
455 if cred.got != testAuthority {
456 t.Fatalf("client creds got authority: %q, want: %q", cred.got, testAuthority)
457 }
458}
459
460// This test makes sure that the authority client handshake gets is the endpoint
461// of the ServerName of the address when it is set.

Callers

nothing calls this directly

Calls 15

NewServerFunction · 0.92
NewBuilderWithSchemeFunction · 0.92
NewClientFunction · 0.92
WithTransportCredentialsFunction · 0.92
WithResolversFunction · 0.92
AwaitStateFunction · 0.92
FatalMethod · 0.65
ServeMethod · 0.65
StopMethod · 0.65
SchemeMethod · 0.65
FatalfMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected