(t *testing.T, e env)
| 373 | } |
| 374 | |
| 375 | func testPerRPCCredentialsViaDialOptionsAndCallOptions(t *testing.T, e env) { |
| 376 | te := newTest(t, e) |
| 377 | te.perRPCCreds = testPerRPCCredentials{authdata: authdata} |
| 378 | // When credentials are provided via both dial options and call options, |
| 379 | // we apply both sets. |
| 380 | te.tapHandle = func(ctx context.Context, _ *tap.Info) (context.Context, error) { |
| 381 | md, ok := metadata.FromIncomingContext(ctx) |
| 382 | if !ok { |
| 383 | return ctx, fmt.Errorf("couldn't find metadata in context") |
| 384 | } |
| 385 | for k, vwant := range authdata { |
| 386 | vgot, ok := md[k] |
| 387 | if !ok { |
| 388 | return ctx, fmt.Errorf("couldn't find metadata for key %v", k) |
| 389 | } |
| 390 | if len(vgot) != 2 { |
| 391 | return ctx, fmt.Errorf("len of value for key %v was %v, want 2", k, len(vgot)) |
| 392 | } |
| 393 | if vgot[0] != vwant || vgot[1] != vwant { |
| 394 | return ctx, fmt.Errorf("value for %v was %v, want [%v, %v]", k, vgot, vwant, vwant) |
| 395 | } |
| 396 | } |
| 397 | return ctx, nil |
| 398 | } |
| 399 | te.startServer(&testServer{security: e.security}) |
| 400 | defer te.tearDown() |
| 401 | |
| 402 | cc := te.clientConn() |
| 403 | tc := testgrpc.NewTestServiceClient(cc) |
| 404 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 405 | defer cancel() |
| 406 | if _, err := tc.EmptyCall(ctx, &testpb.Empty{}, grpc.PerRPCCredentials(testPerRPCCredentials{authdata: authdata})); err != nil { |
| 407 | t.Fatalf("Test failed. Reason: %v", err) |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | const testAuthority = "test.auth.ori.ty" |
| 412 |
no test coverage detected