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

Method TestCredsBundleFromBalancer

test/balancer_test.go:147–176  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

145}
146
147func (s) TestCredsBundleFromBalancer(t *testing.T) {
148 balancer.Register(&testBalancer{
149 newSubConnOptions: balancer.NewSubConnOptions{
150 CredsBundle: &testCredsBundle{},
151 },
152 })
153 te := newTest(t, env{name: "creds-bundle", network: "tcp", balancer: ""})
154 te.tapHandle = authHandle
155 te.customDialOptions = []grpc.DialOption{
156 grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"loadBalancingConfig": [{"%s":{}}]}`, testBalancerName)),
157 grpc.WithAuthority("x.test.example.com"),
158 }
159 creds, err := credentials.NewServerTLSFromFile(testdata.Path("x509/server1_cert.pem"), testdata.Path("x509/server1_key.pem"))
160 if err != nil {
161 t.Fatalf("Failed to generate credentials %v", err)
162 }
163 te.customServerOptions = []grpc.ServerOption{
164 grpc.Creds(creds),
165 }
166 te.startServer(&testServer{})
167 defer te.tearDown()
168
169 cc := te.clientConn()
170 tc := testgrpc.NewTestServiceClient(cc)
171 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
172 defer cancel()
173 if _, err := tc.EmptyCall(ctx, &testpb.Empty{}); err != nil {
174 t.Fatalf("Test failed. Reason: %v", err)
175 }
176}
177
178func (s) TestPickExtraMetadata(t *testing.T) {
179 for _, e := range listTestEnv() {

Callers

nothing calls this directly

Calls 12

EmptyCallMethod · 0.95
RegisterFunction · 0.92
WithDefaultServiceConfigFunction · 0.92
WithAuthorityFunction · 0.92
NewServerTLSFromFileFunction · 0.92
PathFunction · 0.92
CredsFunction · 0.92
newTestFunction · 0.70
FatalfMethod · 0.65
startServerMethod · 0.45
tearDownMethod · 0.45
clientConnMethod · 0.45

Tested by

no test coverage detected