This test makes sure that the authority client handshake gets is the endpoint in dial target, not the resolved ip address.
(t *testing.T)
| 429 | // This test makes sure that the authority client handshake gets is the endpoint |
| 430 | // in dial target, not the resolved ip address. |
| 431 | func (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. |
nothing calls this directly
no test coverage detected