TestClientHandshakeInfo adds attributes to the resolver.Address passes to NewHTTP2Client and verifies that these attributes are received by the transport credential handshaker.
(t *testing.T)
| 2699 | // NewHTTP2Client and verifies that these attributes are received by the |
| 2700 | // transport credential handshaker. |
| 2701 | func (s) TestClientHandshakeInfo(t *testing.T) { |
| 2702 | server := setUpServerOnly(t, 0, &ServerConfig{BufferPool: mem.DefaultBufferPool()}, pingpong) |
| 2703 | defer server.stop() |
| 2704 | |
| 2705 | const ( |
| 2706 | testAttrKey = "foo" |
| 2707 | testAttrVal = "bar" |
| 2708 | ) |
| 2709 | addr := resolver.Address{ |
| 2710 | Addr: "localhost:" + server.port, |
| 2711 | Attributes: attributes.New(testAttrKey, testAttrVal), |
| 2712 | } |
| 2713 | ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) |
| 2714 | defer cancel() |
| 2715 | creds := &attrTransportCreds{} |
| 2716 | |
| 2717 | copts := ConnectOptions{ |
| 2718 | TransportCredentials: creds, |
| 2719 | ChannelzParent: channelzSubChannel(t), |
| 2720 | BufferPool: mem.DefaultBufferPool(), |
| 2721 | } |
| 2722 | tr, err := NewHTTP2Client(ctx, ctx, addr, copts, func(GoAwayInfo) {}) |
| 2723 | if err != nil { |
| 2724 | t.Fatalf("NewHTTP2Client(): %v", err) |
| 2725 | } |
| 2726 | defer tr.Close(fmt.Errorf("closed manually by test")) |
| 2727 | |
| 2728 | wantAttr := attributes.New(testAttrKey, testAttrVal) |
| 2729 | if gotAttr := creds.attr; !cmp.Equal(gotAttr, wantAttr, cmp.AllowUnexported(attributes.Attributes{})) { |
| 2730 | t.Fatalf("received attributes %v in creds, want %v", gotAttr, wantAttr) |
| 2731 | } |
| 2732 | } |
| 2733 | |
| 2734 | // TestClientHandshakeInfoDialer adds attributes to the resolver.Address passes to |
| 2735 | // NewHTTP2Client and verifies that these attributes are received by a custom |
nothing calls this directly
no test coverage detected