diff options
Diffstat (limited to 'test')
34 files changed, 364 insertions, 392 deletions
diff --git a/test/core/client_config/lb_policies_test.c b/test/core/client_config/lb_policies_test.c index 8498e1d827..cd9aa942e2 100644 --- a/test/core/client_config/lb_policies_test.c +++ b/test/core/client_config/lb_policies_test.c @@ -303,8 +303,8 @@ int *perform_request(servers_fixture *f, grpc_channel *client, s_idx = -1; while ((ev = grpc_completion_queue_next( - f->cq, n_millis_time(s_idx == -1 ? 3000 : 200), NULL)).type != - GRPC_QUEUE_TIMEOUT) { + f->cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1), NULL)) + .type != GRPC_QUEUE_TIMEOUT) { GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); read_tag = ((int)(gpr_intptr)ev.tag); gpr_log(GPR_DEBUG, "EVENT: success:%d, type:%d, tag:%d iter:%d", @@ -315,6 +315,7 @@ int *perform_request(servers_fixture *f, grpc_channel *client, s_idx = read_tag - 1000; s_valid[s_idx] = 1; connection_sequence[iter_num] = s_idx; + break; } else if (read_tag == 1) { gpr_log(GPR_DEBUG, "client timed out"); GPR_ASSERT(ev.success); @@ -453,6 +454,8 @@ void run_spec(const test_spec *spec) { int *actual_connection_sequence; request_data rdata; servers_fixture *f; + grpc_channel_args args; + grpc_arg arg; rdata.call_details = gpr_malloc(sizeof(grpc_call_details) * spec->num_servers); f = setup_servers("127.0.0.1", &rdata, spec->num_servers); @@ -462,7 +465,14 @@ void run_spec(const test_spec *spec) { f->num_servers, ",", NULL); gpr_asprintf(&client_hostport, "ipv4:%s?lb_policy=round_robin", servers_hostports_str); - client = grpc_insecure_channel_create(client_hostport, NULL, NULL); + + arg.type = GRPC_ARG_INTEGER; + arg.key = "grpc.testing.fixed_reconnect_backoff"; + arg.value.integer = 100; + args.num_args = 1; + args.args = &arg; + + client = grpc_insecure_channel_create(client_hostport, &args, NULL); gpr_log(GPR_INFO, "Testing '%s' with servers=%s client=%s", spec->description, servers_hostports_str, client_hostport); diff --git a/test/core/end2end/data/server1_cert.c b/test/core/end2end/data/server1_cert.c index d31f2e2d0e..82d65cf551 100644 --- a/test/core/end2end/data/server1_cert.c +++ b/test/core/end2end/data/server1_cert.c @@ -34,82 +34,82 @@ const char test_server1_cert[] = { 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x43, 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43, 0x6d, 0x7a, 0x43, 0x43, - 0x41, 0x67, 0x53, 0x67, 0x41, 0x77, 0x49, 0x42, 0x41, 0x67, 0x49, 0x42, - 0x41, 0x7a, 0x41, 0x4e, 0x42, 0x67, 0x6b, 0x71, 0x68, 0x6b, 0x69, 0x47, - 0x39, 0x77, 0x30, 0x42, 0x41, 0x51, 0x55, 0x46, 0x41, 0x44, 0x42, 0x57, + 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43, 0x6e, 0x44, 0x43, 0x43, + 0x41, 0x67, 0x57, 0x67, 0x41, 0x77, 0x49, 0x42, 0x41, 0x67, 0x49, 0x42, + 0x42, 0x7a, 0x41, 0x4e, 0x42, 0x67, 0x6b, 0x71, 0x68, 0x6b, 0x69, 0x47, + 0x39, 0x77, 0x30, 0x42, 0x41, 0x51, 0x73, 0x46, 0x41, 0x44, 0x42, 0x57, 0x4d, 0x51, 0x73, 0x77, 0x43, 0x51, 0x59, 0x44, 0x56, 0x51, 0x51, 0x47, 0x45, 0x77, 0x4a, 0x42, 0x56, 0x54, 0x45, 0x54, 0x0a, 0x4d, 0x42, 0x45, - 0x47, 0x41, 0x31, 0x55, 0x45, 0x43, 0x41, 0x77, 0x4b, 0x55, 0x32, 0x39, + 0x47, 0x41, 0x31, 0x55, 0x45, 0x43, 0x42, 0x4d, 0x4b, 0x55, 0x32, 0x39, 0x74, 0x5a, 0x53, 0x31, 0x54, 0x64, 0x47, 0x46, 0x30, 0x5a, 0x54, 0x45, - 0x68, 0x4d, 0x42, 0x38, 0x47, 0x41, 0x31, 0x55, 0x45, 0x43, 0x67, 0x77, + 0x68, 0x4d, 0x42, 0x38, 0x47, 0x41, 0x31, 0x55, 0x45, 0x43, 0x68, 0x4d, 0x59, 0x53, 0x57, 0x35, 0x30, 0x5a, 0x58, 0x4a, 0x75, 0x5a, 0x58, 0x51, 0x67, 0x56, 0x32, 0x6c, 0x6b, 0x5a, 0x32, 0x6c, 0x30, 0x63, 0x79, 0x42, 0x51, 0x0a, 0x64, 0x48, 0x6b, 0x67, 0x54, 0x48, 0x52, 0x6b, 0x4d, 0x51, - 0x38, 0x77, 0x44, 0x51, 0x59, 0x44, 0x56, 0x51, 0x51, 0x44, 0x44, 0x41, + 0x38, 0x77, 0x44, 0x51, 0x59, 0x44, 0x56, 0x51, 0x51, 0x44, 0x45, 0x77, 0x5a, 0x30, 0x5a, 0x58, 0x4e, 0x30, 0x59, 0x32, 0x45, 0x77, 0x48, 0x68, - 0x63, 0x4e, 0x4d, 0x54, 0x51, 0x77, 0x4e, 0x7a, 0x49, 0x79, 0x4d, 0x44, - 0x59, 0x77, 0x4d, 0x44, 0x55, 0x33, 0x57, 0x68, 0x63, 0x4e, 0x4d, 0x6a, - 0x51, 0x77, 0x4e, 0x7a, 0x45, 0x35, 0x0a, 0x4d, 0x44, 0x59, 0x77, 0x4d, - 0x44, 0x55, 0x33, 0x57, 0x6a, 0x42, 0x6b, 0x4d, 0x51, 0x73, 0x77, 0x43, + 0x63, 0x4e, 0x4d, 0x54, 0x55, 0x78, 0x4d, 0x54, 0x41, 0x30, 0x4d, 0x44, + 0x49, 0x79, 0x4d, 0x44, 0x49, 0x30, 0x57, 0x68, 0x63, 0x4e, 0x4d, 0x6a, + 0x55, 0x78, 0x4d, 0x54, 0x41, 0x78, 0x0a, 0x4d, 0x44, 0x49, 0x79, 0x4d, + 0x44, 0x49, 0x30, 0x57, 0x6a, 0x42, 0x6c, 0x4d, 0x51, 0x73, 0x77, 0x43, 0x51, 0x59, 0x44, 0x56, 0x51, 0x51, 0x47, 0x45, 0x77, 0x4a, 0x56, 0x55, 0x7a, 0x45, 0x52, 0x4d, 0x41, 0x38, 0x47, 0x41, 0x31, 0x55, 0x45, 0x43, 0x42, 0x4d, 0x49, 0x53, 0x57, 0x78, 0x73, 0x61, 0x57, 0x35, 0x76, 0x61, 0x58, 0x4d, 0x78, 0x45, 0x44, 0x41, 0x4f, 0x42, 0x67, 0x4e, 0x56, 0x0a, 0x42, 0x41, 0x63, 0x54, 0x42, 0x30, 0x4e, 0x6f, 0x61, 0x57, 0x4e, 0x68, - 0x5a, 0x32, 0x38, 0x78, 0x46, 0x44, 0x41, 0x53, 0x42, 0x67, 0x4e, 0x56, - 0x42, 0x41, 0x6f, 0x54, 0x43, 0x30, 0x64, 0x76, 0x62, 0x32, 0x64, 0x73, - 0x5a, 0x53, 0x42, 0x4a, 0x62, 0x6d, 0x4d, 0x75, 0x4d, 0x52, 0x6f, 0x77, - 0x47, 0x41, 0x59, 0x44, 0x56, 0x51, 0x51, 0x44, 0x46, 0x42, 0x45, 0x71, - 0x4c, 0x6e, 0x52, 0x6c, 0x0a, 0x63, 0x33, 0x51, 0x75, 0x5a, 0x32, 0x39, - 0x76, 0x5a, 0x32, 0x78, 0x6c, 0x4c, 0x6d, 0x4e, 0x76, 0x62, 0x54, 0x43, - 0x42, 0x6e, 0x7a, 0x41, 0x4e, 0x42, 0x67, 0x6b, 0x71, 0x68, 0x6b, 0x69, - 0x47, 0x39, 0x77, 0x30, 0x42, 0x41, 0x51, 0x45, 0x46, 0x41, 0x41, 0x4f, - 0x42, 0x6a, 0x51, 0x41, 0x77, 0x67, 0x59, 0x6b, 0x43, 0x67, 0x59, 0x45, - 0x41, 0x34, 0x63, 0x4d, 0x56, 0x4a, 0x79, 0x67, 0x73, 0x0a, 0x4a, 0x55, - 0x6d, 0x6c, 0x67, 0x4d, 0x4d, 0x7a, 0x67, 0x64, 0x69, 0x30, 0x68, 0x31, - 0x58, 0x6f, 0x43, 0x52, 0x37, 0x2b, 0x77, 0x77, 0x31, 0x70, 0x6f, 0x70, - 0x30, 0x34, 0x4f, 0x4d, 0x4d, 0x79, 0x79, 0x37, 0x48, 0x2f, 0x69, 0x30, - 0x50, 0x4a, 0x32, 0x57, 0x36, 0x59, 0x33, 0x35, 0x2b, 0x62, 0x34, 0x43, - 0x4d, 0x38, 0x51, 0x72, 0x6b, 0x59, 0x65, 0x45, 0x61, 0x66, 0x55, 0x47, - 0x44, 0x4f, 0x0a, 0x52, 0x59, 0x58, 0x36, 0x79, 0x56, 0x2f, 0x63, 0x48, - 0x47, 0x47, 0x73, 0x44, 0x2f, 0x78, 0x30, 0x32, 0x79, 0x65, 0x36, 0x65, - 0x79, 0x31, 0x55, 0x44, 0x74, 0x6b, 0x47, 0x41, 0x44, 0x2f, 0x6d, 0x70, - 0x44, 0x45, 0x78, 0x38, 0x59, 0x43, 0x72, 0x6a, 0x41, 0x63, 0x31, 0x56, - 0x66, 0x76, 0x74, 0x38, 0x46, 0x6b, 0x36, 0x43, 0x6e, 0x31, 0x57, 0x56, - 0x49, 0x78, 0x56, 0x2f, 0x4a, 0x33, 0x30, 0x0a, 0x33, 0x78, 0x6a, 0x42, - 0x73, 0x46, 0x67, 0x42, 0x79, 0x51, 0x35, 0x35, 0x52, 0x42, 0x70, 0x31, - 0x4f, 0x4c, 0x5a, 0x66, 0x56, 0x4c, 0x6f, 0x36, 0x41, 0x6c, 0x65, 0x42, - 0x44, 0x53, 0x62, 0x63, 0x78, 0x61, 0x45, 0x43, 0x41, 0x77, 0x45, 0x41, - 0x41, 0x61, 0x4e, 0x72, 0x4d, 0x47, 0x6b, 0x77, 0x43, 0x51, 0x59, 0x44, - 0x56, 0x52, 0x30, 0x54, 0x42, 0x41, 0x49, 0x77, 0x41, 0x44, 0x41, 0x4c, - 0x0a, 0x42, 0x67, 0x4e, 0x56, 0x48, 0x51, 0x38, 0x45, 0x42, 0x41, 0x4d, - 0x43, 0x42, 0x65, 0x41, 0x77, 0x54, 0x77, 0x59, 0x44, 0x56, 0x52, 0x30, - 0x52, 0x42, 0x45, 0x67, 0x77, 0x52, 0x6f, 0x49, 0x51, 0x4b, 0x69, 0x35, - 0x30, 0x5a, 0x58, 0x4e, 0x30, 0x4c, 0x6d, 0x64, 0x76, 0x62, 0x32, 0x64, - 0x73, 0x5a, 0x53, 0x35, 0x6d, 0x63, 0x6f, 0x49, 0x59, 0x64, 0x32, 0x46, - 0x30, 0x5a, 0x58, 0x4a, 0x36, 0x0a, 0x62, 0x32, 0x39, 0x70, 0x4c, 0x6e, - 0x52, 0x6c, 0x63, 0x33, 0x51, 0x75, 0x5a, 0x32, 0x39, 0x76, 0x5a, 0x32, - 0x78, 0x6c, 0x4c, 0x6d, 0x4a, 0x6c, 0x67, 0x68, 0x49, 0x71, 0x4c, 0x6e, - 0x52, 0x6c, 0x63, 0x33, 0x51, 0x75, 0x65, 0x57, 0x39, 0x31, 0x64, 0x48, - 0x56, 0x69, 0x5a, 0x53, 0x35, 0x6a, 0x62, 0x32, 0x32, 0x48, 0x42, 0x4d, - 0x43, 0x6f, 0x41, 0x51, 0x4d, 0x77, 0x44, 0x51, 0x59, 0x4a, 0x0a, 0x4b, - 0x6f, 0x5a, 0x49, 0x68, 0x76, 0x63, 0x4e, 0x41, 0x51, 0x45, 0x46, 0x42, - 0x51, 0x41, 0x44, 0x67, 0x59, 0x45, 0x41, 0x4d, 0x32, 0x49, 0x69, 0x30, - 0x4c, 0x67, 0x54, 0x47, 0x62, 0x4a, 0x31, 0x6a, 0x34, 0x6f, 0x71, 0x58, - 0x39, 0x62, 0x78, 0x56, 0x63, 0x78, 0x6d, 0x2b, 0x2f, 0x52, 0x35, 0x59, - 0x66, 0x38, 0x6f, 0x69, 0x30, 0x61, 0x5a, 0x71, 0x54, 0x4a, 0x6c, 0x6e, - 0x4c, 0x59, 0x53, 0x0a, 0x77, 0x58, 0x63, 0x42, 0x79, 0x6b, 0x78, 0x54, - 0x78, 0x31, 0x38, 0x31, 0x73, 0x37, 0x57, 0x79, 0x66, 0x4a, 0x34, 0x39, - 0x57, 0x77, 0x72, 0x59, 0x58, 0x6f, 0x37, 0x38, 0x7a, 0x54, 0x44, 0x41, - 0x6e, 0x66, 0x31, 0x6d, 0x61, 0x30, 0x66, 0x50, 0x71, 0x33, 0x65, 0x34, - 0x6d, 0x70, 0x73, 0x70, 0x76, 0x79, 0x6e, 0x64, 0x4c, 0x68, 0x31, 0x61, - 0x2b, 0x4f, 0x61, 0x72, 0x48, 0x61, 0x31, 0x65, 0x0a, 0x61, 0x54, 0x30, - 0x44, 0x49, 0x49, 0x59, 0x6b, 0x37, 0x71, 0x65, 0x45, 0x61, 0x31, 0x59, - 0x63, 0x56, 0x6c, 0x6a, 0x78, 0x32, 0x4b, 0x79, 0x4c, 0x64, 0x30, 0x72, - 0x31, 0x42, 0x42, 0x41, 0x66, 0x72, 0x77, 0x79, 0x47, 0x61, 0x45, 0x50, - 0x56, 0x65, 0x4a, 0x51, 0x56, 0x59, 0x57, 0x61, 0x4f, 0x4a, 0x52, 0x55, - 0x32, 0x77, 0x65, 0x2f, 0x4b, 0x44, 0x34, 0x6f, 0x6a, 0x66, 0x39, 0x73, - 0x3d, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x43, + 0x5a, 0x32, 0x38, 0x78, 0x46, 0x54, 0x41, 0x54, 0x42, 0x67, 0x4e, 0x56, + 0x42, 0x41, 0x6f, 0x54, 0x44, 0x45, 0x56, 0x34, 0x59, 0x57, 0x31, 0x77, + 0x62, 0x47, 0x55, 0x73, 0x49, 0x45, 0x4e, 0x76, 0x4c, 0x6a, 0x45, 0x61, + 0x4d, 0x42, 0x67, 0x47, 0x41, 0x31, 0x55, 0x45, 0x41, 0x78, 0x51, 0x52, + 0x4b, 0x69, 0x35, 0x30, 0x0a, 0x5a, 0x58, 0x4e, 0x30, 0x4c, 0x6d, 0x64, + 0x76, 0x62, 0x32, 0x64, 0x73, 0x5a, 0x53, 0x35, 0x6a, 0x62, 0x32, 0x30, + 0x77, 0x67, 0x5a, 0x38, 0x77, 0x44, 0x51, 0x59, 0x4a, 0x4b, 0x6f, 0x5a, + 0x49, 0x68, 0x76, 0x63, 0x4e, 0x41, 0x51, 0x45, 0x42, 0x42, 0x51, 0x41, + 0x44, 0x67, 0x59, 0x30, 0x41, 0x4d, 0x49, 0x47, 0x4a, 0x41, 0x6f, 0x47, + 0x42, 0x41, 0x4f, 0x48, 0x44, 0x46, 0x53, 0x63, 0x6f, 0x0a, 0x4c, 0x43, + 0x56, 0x4a, 0x70, 0x59, 0x44, 0x44, 0x4d, 0x34, 0x48, 0x59, 0x74, 0x49, + 0x64, 0x56, 0x36, 0x41, 0x6b, 0x65, 0x2f, 0x73, 0x4d, 0x4e, 0x61, 0x61, + 0x4b, 0x64, 0x4f, 0x44, 0x6a, 0x44, 0x4d, 0x73, 0x75, 0x78, 0x2f, 0x34, + 0x74, 0x44, 0x79, 0x64, 0x6c, 0x75, 0x6d, 0x4e, 0x2b, 0x66, 0x6d, 0x2b, + 0x41, 0x6a, 0x50, 0x45, 0x4b, 0x35, 0x47, 0x48, 0x68, 0x47, 0x6e, 0x31, + 0x42, 0x67, 0x0a, 0x7a, 0x6b, 0x57, 0x46, 0x2b, 0x73, 0x6c, 0x66, 0x33, + 0x42, 0x78, 0x68, 0x72, 0x41, 0x2f, 0x38, 0x64, 0x4e, 0x73, 0x6e, 0x75, + 0x6e, 0x73, 0x74, 0x56, 0x41, 0x37, 0x5a, 0x42, 0x67, 0x41, 0x2f, 0x35, + 0x71, 0x51, 0x78, 0x4d, 0x66, 0x47, 0x41, 0x71, 0x34, 0x77, 0x48, 0x4e, + 0x56, 0x58, 0x37, 0x37, 0x66, 0x42, 0x5a, 0x4f, 0x67, 0x70, 0x39, 0x56, + 0x6c, 0x53, 0x4d, 0x56, 0x66, 0x79, 0x64, 0x0a, 0x39, 0x4e, 0x38, 0x59, + 0x77, 0x62, 0x42, 0x59, 0x41, 0x63, 0x6b, 0x4f, 0x65, 0x55, 0x51, 0x61, + 0x64, 0x54, 0x69, 0x32, 0x58, 0x31, 0x53, 0x36, 0x4f, 0x67, 0x4a, 0x58, + 0x67, 0x51, 0x30, 0x6d, 0x33, 0x4d, 0x57, 0x68, 0x41, 0x67, 0x4d, 0x42, + 0x41, 0x41, 0x47, 0x6a, 0x61, 0x7a, 0x42, 0x70, 0x4d, 0x41, 0x6b, 0x47, + 0x41, 0x31, 0x55, 0x64, 0x45, 0x77, 0x51, 0x43, 0x4d, 0x41, 0x41, 0x77, + 0x0a, 0x43, 0x77, 0x59, 0x44, 0x56, 0x52, 0x30, 0x50, 0x42, 0x41, 0x51, + 0x44, 0x41, 0x67, 0x58, 0x67, 0x4d, 0x45, 0x38, 0x47, 0x41, 0x31, 0x55, + 0x64, 0x45, 0x51, 0x52, 0x49, 0x4d, 0x45, 0x61, 0x43, 0x45, 0x43, 0x6f, + 0x75, 0x64, 0x47, 0x56, 0x7a, 0x64, 0x43, 0x35, 0x6e, 0x62, 0x32, 0x39, + 0x6e, 0x62, 0x47, 0x55, 0x75, 0x5a, 0x6e, 0x4b, 0x43, 0x47, 0x48, 0x64, + 0x68, 0x64, 0x47, 0x56, 0x79, 0x0a, 0x65, 0x6d, 0x39, 0x76, 0x61, 0x53, + 0x35, 0x30, 0x5a, 0x58, 0x4e, 0x30, 0x4c, 0x6d, 0x64, 0x76, 0x62, 0x32, + 0x64, 0x73, 0x5a, 0x53, 0x35, 0x69, 0x5a, 0x59, 0x49, 0x53, 0x4b, 0x69, + 0x35, 0x30, 0x5a, 0x58, 0x4e, 0x30, 0x4c, 0x6e, 0x6c, 0x76, 0x64, 0x58, + 0x52, 0x31, 0x59, 0x6d, 0x55, 0x75, 0x59, 0x32, 0x39, 0x74, 0x68, 0x77, + 0x54, 0x41, 0x71, 0x41, 0x45, 0x44, 0x4d, 0x41, 0x30, 0x47, 0x0a, 0x43, + 0x53, 0x71, 0x47, 0x53, 0x49, 0x62, 0x33, 0x44, 0x51, 0x45, 0x42, 0x43, + 0x77, 0x55, 0x41, 0x41, 0x34, 0x47, 0x42, 0x41, 0x4a, 0x46, 0x58, 0x56, + 0x69, 0x66, 0x51, 0x4e, 0x75, 0x62, 0x31, 0x4c, 0x55, 0x50, 0x34, 0x4a, + 0x6c, 0x6e, 0x58, 0x35, 0x6c, 0x58, 0x4e, 0x6c, 0x6f, 0x38, 0x46, 0x78, + 0x5a, 0x32, 0x61, 0x31, 0x32, 0x41, 0x46, 0x51, 0x73, 0x2b, 0x62, 0x7a, + 0x6f, 0x4a, 0x36, 0x0a, 0x68, 0x4d, 0x30, 0x34, 0x34, 0x45, 0x44, 0x6a, + 0x71, 0x79, 0x78, 0x55, 0x71, 0x53, 0x62, 0x56, 0x65, 0x50, 0x4b, 0x30, + 0x6e, 0x69, 0x33, 0x77, 0x31, 0x66, 0x48, 0x51, 0x42, 0x35, 0x72, 0x59, + 0x39, 0x79, 0x59, 0x43, 0x35, 0x66, 0x38, 0x47, 0x37, 0x61, 0x71, 0x71, + 0x54, 0x59, 0x31, 0x51, 0x4f, 0x68, 0x6f, 0x55, 0x6b, 0x38, 0x5a, 0x54, + 0x53, 0x54, 0x52, 0x70, 0x6e, 0x6b, 0x54, 0x68, 0x0a, 0x79, 0x34, 0x6a, + 0x6a, 0x64, 0x76, 0x54, 0x5a, 0x65, 0x4c, 0x44, 0x56, 0x42, 0x6c, 0x75, + 0x65, 0x5a, 0x55, 0x54, 0x44, 0x52, 0x6d, 0x79, 0x32, 0x66, 0x65, 0x59, + 0x35, 0x61, 0x5a, 0x49, 0x55, 0x31, 0x38, 0x76, 0x46, 0x44, 0x4b, 0x30, + 0x38, 0x64, 0x54, 0x47, 0x30, 0x41, 0x38, 0x37, 0x70, 0x70, 0x70, 0x75, + 0x76, 0x31, 0x4c, 0x4e, 0x49, 0x52, 0x33, 0x6c, 0x6f, 0x76, 0x65, 0x55, + 0x38, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x43, 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x00}; diff --git a/test/core/end2end/fixtures/h2_fakesec.c b/test/core/end2end/fixtures/h2_fakesec.c index 3e64cc08e8..bc009e1df1 100644 --- a/test/core/end2end/fixtures/h2_fakesec.c +++ b/test/core/end2end/fixtures/h2_fakesec.c @@ -73,14 +73,14 @@ static void process_auth_failure(void *state, grpc_auth_context *ctx, cb(user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL); } -static void chttp2_init_client_secure_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *client_args, - grpc_credentials *creds) { +static void chttp2_init_client_secure_fullstack( + grpc_end2end_test_fixture *f, grpc_channel_args *client_args, + grpc_channel_credentials *creds) { fullstack_secure_fixture_data *ffd = f->fixture_data; f->client = grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL); GPR_ASSERT(f->client != NULL); - grpc_credentials_release(creds); + grpc_channel_credentials_release(creds); } static void chttp2_init_server_secure_fullstack( @@ -106,7 +106,7 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { static void chttp2_init_client_fake_secure_fullstack( grpc_end2end_test_fixture *f, grpc_channel_args *client_args) { - grpc_credentials *fake_ts_creds = + grpc_channel_credentials *fake_ts_creds = grpc_fake_transport_security_credentials_create(); chttp2_init_client_secure_fullstack(f, client_args, fake_ts_creds); } diff --git a/test/core/end2end/fixtures/h2_oauth2.c b/test/core/end2end/fixtures/h2_oauth2.c index 10db6c2c6a..7a34cc67d8 100644 --- a/test/core/end2end/fixtures/h2_oauth2.c +++ b/test/core/end2end/fixtures/h2_oauth2.c @@ -118,14 +118,14 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( return f; } -static void chttp2_init_client_secure_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *client_args, - grpc_credentials *creds) { +static void chttp2_init_client_secure_fullstack( + grpc_end2end_test_fixture *f, grpc_channel_args *client_args, + grpc_channel_credentials *creds) { fullstack_secure_fixture_data *ffd = f->fixture_data; f->client = grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL); GPR_ASSERT(f->client != NULL); - grpc_credentials_release(creds); + grpc_channel_credentials_release(creds); } static void chttp2_init_server_secure_fullstack( @@ -151,12 +151,12 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack( grpc_end2end_test_fixture *f, grpc_channel_args *client_args) { - grpc_credentials *ssl_creds = + grpc_channel_credentials *ssl_creds = grpc_ssl_credentials_create(test_root_cert, NULL, NULL); - grpc_credentials *oauth2_creds = + grpc_call_credentials *oauth2_creds = grpc_md_only_test_credentials_create("Authorization", oauth2_md, 1); - grpc_credentials *ssl_oauth2_creds = - grpc_composite_credentials_create(ssl_creds, oauth2_creds, NULL); + grpc_channel_credentials *ssl_oauth2_creds = + grpc_composite_channel_credentials_create(ssl_creds, oauth2_creds, NULL); grpc_arg ssl_name_override = {GRPC_ARG_STRING, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, {"foo.test.google.fr"}}; @@ -164,8 +164,8 @@ static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack( grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1); chttp2_init_client_secure_fullstack(f, new_client_args, ssl_oauth2_creds); grpc_channel_args_destroy(new_client_args); - grpc_credentials_release(ssl_creds); - grpc_credentials_release(oauth2_creds); + grpc_channel_credentials_release(ssl_creds); + grpc_call_credentials_release(oauth2_creds); } static int fail_server_auth_check(grpc_channel_args *server_args) { diff --git a/test/core/end2end/fixtures/h2_ssl+poll.c b/test/core/end2end/fixtures/h2_ssl+poll.c index c2f41f4886..37e1758f00 100644 --- a/test/core/end2end/fixtures/h2_ssl+poll.c +++ b/test/core/end2end/fixtures/h2_ssl+poll.c @@ -76,14 +76,14 @@ static void process_auth_failure(void *state, grpc_auth_context *ctx, cb(user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL); } -static void chttp2_init_client_secure_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *client_args, - grpc_credentials *creds) { +static void chttp2_init_client_secure_fullstack( + grpc_end2end_test_fixture *f, grpc_channel_args *client_args, + grpc_channel_credentials *creds) { fullstack_secure_fixture_data *ffd = f->fixture_data; f->client = grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL); GPR_ASSERT(f->client != NULL); - grpc_credentials_release(creds); + grpc_channel_credentials_release(creds); } static void chttp2_init_server_secure_fullstack( @@ -109,7 +109,8 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { static void chttp2_init_client_simple_ssl_secure_fullstack( grpc_end2end_test_fixture *f, grpc_channel_args *client_args) { - grpc_credentials *ssl_creds = grpc_ssl_credentials_create(NULL, NULL, NULL); + grpc_channel_credentials *ssl_creds = + grpc_ssl_credentials_create(NULL, NULL, NULL); grpc_arg ssl_name_override = {GRPC_ARG_STRING, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, {"foo.test.google.fr"}}; diff --git a/test/core/end2end/fixtures/h2_ssl.c b/test/core/end2end/fixtures/h2_ssl.c index 896c60c507..f5a006bd08 100644 --- a/test/core/end2end/fixtures/h2_ssl.c +++ b/test/core/end2end/fixtures/h2_ssl.c @@ -76,14 +76,14 @@ static void process_auth_failure(void *state, grpc_auth_context *ctx, cb(user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL); } -static void chttp2_init_client_secure_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *client_args, - grpc_credentials *creds) { +static void chttp2_init_client_secure_fullstack( + grpc_end2end_test_fixture *f, grpc_channel_args *client_args, + grpc_channel_credentials *creds) { fullstack_secure_fixture_data *ffd = f->fixture_data; f->client = grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL); GPR_ASSERT(f->client != NULL); - grpc_credentials_release(creds); + grpc_channel_credentials_release(creds); } static void chttp2_init_server_secure_fullstack( @@ -109,7 +109,8 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { static void chttp2_init_client_simple_ssl_secure_fullstack( grpc_end2end_test_fixture *f, grpc_channel_args *client_args) { - grpc_credentials *ssl_creds = grpc_ssl_credentials_create(NULL, NULL, NULL); + grpc_channel_credentials *ssl_creds = + grpc_ssl_credentials_create(NULL, NULL, NULL); grpc_arg ssl_name_override = {GRPC_ARG_STRING, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, {"foo.test.google.fr"}}; diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.c b/test/core/end2end/fixtures/h2_ssl_proxy.c index 413a8b84cd..7233cdbe2d 100644 --- a/test/core/end2end/fixtures/h2_ssl_proxy.c +++ b/test/core/end2end/fixtures/h2_ssl_proxy.c @@ -66,7 +66,8 @@ static grpc_server *create_proxy_server(const char *port) { static grpc_channel *create_proxy_client(const char *target) { grpc_channel *channel; - grpc_credentials *ssl_creds = grpc_ssl_credentials_create(NULL, NULL, NULL); + grpc_channel_credentials *ssl_creds = + grpc_ssl_credentials_create(NULL, NULL, NULL); grpc_arg ssl_name_override = {GRPC_ARG_STRING, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, {"foo.test.google.fr"}}; @@ -74,7 +75,7 @@ static grpc_channel *create_proxy_client(const char *target) { client_args.num_args = 1; client_args.args = &ssl_name_override; channel = grpc_secure_channel_create(ssl_creds, target, &client_args, NULL); - grpc_credentials_release(ssl_creds); + grpc_channel_credentials_release(ssl_creds); return channel; } @@ -104,15 +105,15 @@ static void process_auth_failure(void *state, grpc_auth_context *ctx, cb(user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL); } -static void chttp2_init_client_secure_fullstack(grpc_end2end_test_fixture *f, - grpc_channel_args *client_args, - grpc_credentials *creds) { +static void chttp2_init_client_secure_fullstack( + grpc_end2end_test_fixture *f, grpc_channel_args *client_args, + grpc_channel_credentials *creds) { fullstack_secure_fixture_data *ffd = f->fixture_data; f->client = grpc_secure_channel_create( creds, grpc_end2end_proxy_get_client_target(ffd->proxy), client_args, NULL); GPR_ASSERT(f->client != NULL); - grpc_credentials_release(creds); + grpc_channel_credentials_release(creds); } static void chttp2_init_server_secure_fullstack( @@ -138,7 +139,8 @@ void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { static void chttp2_init_client_simple_ssl_secure_fullstack( grpc_end2end_test_fixture *f, grpc_channel_args *client_args) { - grpc_credentials *ssl_creds = grpc_ssl_credentials_create(NULL, NULL, NULL); + grpc_channel_credentials *ssl_creds = + grpc_ssl_credentials_create(NULL, NULL, NULL); grpc_arg ssl_name_override = {GRPC_ARG_STRING, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, {"foo.test.google.fr"}}; diff --git a/test/core/end2end/tests/call_creds.c b/test/core/end2end/tests/call_creds.c index 4aeade1336..bbfad21b62 100644 --- a/test/core/end2end/tests/call_creds.c +++ b/test/core/end2end/tests/call_creds.c @@ -132,27 +132,6 @@ static void print_auth_context(int is_client, const grpc_auth_context *ctx) { } } -static void test_call_creds_failure(grpc_end2end_test_config config) { - grpc_call *c; - grpc_credentials *creds = NULL; - grpc_end2end_test_fixture f = - begin_test(config, "test_call_creds_failure", 0); - gpr_timespec deadline = five_seconds_time(); - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT(c); - - /* Try with credentials unfit to be set on a call (channel creds). */ - creds = grpc_fake_transport_security_credentials_create(); - GPR_ASSERT(grpc_call_set_credentials(c, creds) != GRPC_CALL_OK); - grpc_credentials_release(creds); - - grpc_call_destroy(c); - - end_test(&f); - config.tear_down_data(&f); -} - static void request_response_with_payload_and_call_creds( const char *test_name, grpc_end2end_test_config config, override_mode mode) { @@ -180,7 +159,7 @@ static void request_response_with_payload_and_call_creds( char *details = NULL; size_t details_capacity = 0; int was_cancelled = 2; - grpc_credentials *creds = NULL; + grpc_call_credentials *creds = NULL; grpc_auth_context *s_auth_context = NULL; grpc_auth_context *c_auth_context = NULL; @@ -197,7 +176,7 @@ static void request_response_with_payload_and_call_creds( case NONE: break; case OVERRIDE: - grpc_credentials_release(creds); + grpc_call_credentials_release(creds); creds = grpc_google_iam_credentials_create(overridden_iam_token, overridden_iam_selector, NULL); GPR_ASSERT(creds != NULL); @@ -207,7 +186,7 @@ static void request_response_with_payload_and_call_creds( GPR_ASSERT(grpc_call_set_credentials(c, NULL) == GRPC_CALL_OK); break; } - grpc_credentials_release(creds); + grpc_call_credentials_release(creds); grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); @@ -412,7 +391,7 @@ static void test_request_with_server_rejecting_client_creds( gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - grpc_credentials *creds; + grpc_call_credentials *creds; f = begin_test(config, "test_request_with_server_rejecting_client_creds", 1); cqv = cq_verifier_create(f.cq); @@ -424,7 +403,7 @@ static void test_request_with_server_rejecting_client_creds( creds = grpc_google_iam_credentials_create(iam_token, iam_selector, NULL); GPR_ASSERT(creds != NULL); GPR_ASSERT(grpc_call_set_credentials(c, creds) == GRPC_CALL_OK); - grpc_credentials_release(creds); + grpc_call_credentials_release(creds); grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); @@ -490,7 +469,6 @@ static void test_request_with_server_rejecting_client_creds( void grpc_end2end_tests(grpc_end2end_test_config config) { if (config.feature_mask & FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS) { - test_call_creds_failure(config); test_request_response_with_payload_and_call_creds(config); test_request_response_with_payload_and_overridden_call_creds(config); test_request_response_with_payload_and_deleted_call_creds(config); diff --git a/test/core/security/credentials_test.c b/test/core/security/credentials_test.c index 5c1e0f4b94..dcb35e5309 100644 --- a/test/core/security/credentials_test.c +++ b/test/core/security/credentials_test.c @@ -50,11 +50,24 @@ #include <openssl/rsa.h> +/* -- Mock channel credentials. -- */ + +static grpc_channel_credentials *grpc_mock_channel_credentials_create( + const grpc_channel_credentials_vtable *vtable) { + grpc_channel_credentials *c = gpr_malloc(sizeof(*c)); + memset(c, 0, sizeof(*c)); + c->type = "mock"; + c->vtable = vtable; + gpr_ref_init(&c->refcount, 1); + return c; +} + +/* -- Constants. -- */ + static const char test_google_iam_authorization_token[] = "blahblahblhahb"; static const char test_google_iam_authority_selector[] = "respectmyauthoritah"; static const char test_oauth2_bearer_token[] = "Bearer blaaslkdjfaslkdfasdsfasf"; -static const char test_root_cert[] = "I am the root!"; /* This JSON key was generated with the GCE console and revoked immediately. The identifiers have been changed as well. @@ -113,6 +126,8 @@ static const char test_signed_jwt[] = static const char test_service_url[] = "https://foo.com/foo.v1"; static const char other_test_service_url[] = "https://bar.com/bar.v1"; +/* -- Utils. -- */ + static char *test_json_key_str(void) { size_t result_len = strlen(test_json_key_str_part1) + strlen(test_json_key_str_part2) + @@ -141,6 +156,8 @@ static grpc_httpcli_response http_response(int status, const char *body) { return response; } +/* -- Tests. -- */ + static void test_empty_md_store(void) { grpc_credentials_md_store *store = grpc_credentials_md_store_create(0); GPR_ASSERT(store->num_entries == 0); @@ -219,7 +236,7 @@ static void test_oauth2_token_fetcher_creds_parsing_ok(void) { GPR_ASSERT(token_lifetime.tv_sec == 3599); GPR_ASSERT(token_lifetime.tv_nsec == 0); GPR_ASSERT(token_md->num_entries == 1); - GPR_ASSERT(gpr_slice_str_cmp(token_md->entries[0].key, "Authorization") == 0); + GPR_ASSERT(gpr_slice_str_cmp(token_md->entries[0].key, "authorization") == 0); GPR_ASSERT(gpr_slice_str_cmp(token_md->entries[0].value, "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_") == 0); @@ -319,7 +336,7 @@ static void check_google_iam_metadata(grpc_exec_ctx *exec_ctx, void *user_data, grpc_credentials_md *md_elems, size_t num_md, grpc_credentials_status status) { - grpc_credentials *c = (grpc_credentials *)user_data; + grpc_call_credentials *c = (grpc_call_credentials *)user_data; expected_md emd[] = {{GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, test_google_iam_authorization_token}, {GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, @@ -327,17 +344,15 @@ static void check_google_iam_metadata(grpc_exec_ctx *exec_ctx, void *user_data, GPR_ASSERT(status == GRPC_CREDENTIALS_OK); GPR_ASSERT(num_md == 2); check_metadata(emd, md_elems, num_md); - grpc_credentials_unref(c); + grpc_call_credentials_unref(c); } static void test_google_iam_creds(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_credentials *creds = grpc_google_iam_credentials_create( + grpc_call_credentials *creds = grpc_google_iam_credentials_create( test_google_iam_authorization_token, test_google_iam_authority_selector, NULL); - GPR_ASSERT(grpc_credentials_has_request_metadata(creds)); - GPR_ASSERT(grpc_credentials_has_request_metadata_only(creds)); - grpc_credentials_get_request_metadata(&exec_ctx, creds, NULL, + grpc_call_credentials_get_request_metadata(&exec_ctx, creds, NULL, test_service_url, check_google_iam_metadata, creds); grpc_exec_ctx_finish(&exec_ctx); @@ -348,81 +363,58 @@ static void check_access_token_metadata(grpc_exec_ctx *exec_ctx, grpc_credentials_md *md_elems, size_t num_md, grpc_credentials_status status) { - grpc_credentials *c = (grpc_credentials *)user_data; + grpc_call_credentials *c = (grpc_call_credentials *)user_data; expected_md emd[] = {{GRPC_AUTHORIZATION_METADATA_KEY, "Bearer blah"}}; GPR_ASSERT(status == GRPC_CREDENTIALS_OK); GPR_ASSERT(num_md == 1); check_metadata(emd, md_elems, num_md); - grpc_credentials_unref(c); + grpc_call_credentials_unref(c); } static void test_access_token_creds(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_credentials *creds = grpc_access_token_credentials_create("blah", NULL); - GPR_ASSERT(grpc_credentials_has_request_metadata(creds)); - GPR_ASSERT(grpc_credentials_has_request_metadata_only(creds)); - GPR_ASSERT(strcmp(creds->type, GRPC_CREDENTIALS_TYPE_OAUTH2) == 0); - grpc_credentials_get_request_metadata(&exec_ctx, creds, NULL, - test_service_url, - check_access_token_metadata, creds); + grpc_call_credentials *creds = + grpc_access_token_credentials_create("blah", NULL); + GPR_ASSERT(strcmp(creds->type, GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == 0); + grpc_call_credentials_get_request_metadata( + &exec_ctx, creds, NULL, test_service_url, check_access_token_metadata, + creds); grpc_exec_ctx_finish(&exec_ctx); } -static void check_ssl_oauth2_composite_metadata( +static grpc_security_status check_channel_oauth2_create_security_connector( + grpc_channel_credentials *c, grpc_call_credentials *call_creds, + const char *target, const grpc_channel_args *args, + grpc_channel_security_connector **sc, grpc_channel_args **new_args) { + GPR_ASSERT(strcmp(c->type, "mock") == 0); + GPR_ASSERT(call_creds != NULL); + GPR_ASSERT(strcmp(call_creds->type, GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == 0); + return GRPC_SECURITY_OK; +} + +static void test_channel_oauth2_composite_creds(void) { + grpc_channel_args *new_args; + grpc_channel_credentials_vtable vtable = { + NULL, check_channel_oauth2_create_security_connector}; + grpc_channel_credentials *channel_creds = + grpc_mock_channel_credentials_create(&vtable); + grpc_call_credentials *oauth2_creds = + grpc_access_token_credentials_create("blah", NULL); + grpc_channel_credentials *channel_oauth2_creds = + grpc_composite_channel_credentials_create(channel_creds, oauth2_creds, + NULL); + grpc_channel_credentials_release(channel_creds); + grpc_call_credentials_release(oauth2_creds); + GPR_ASSERT(grpc_channel_credentials_create_security_connector( + channel_oauth2_creds, NULL, NULL, NULL, &new_args) == + GRPC_SECURITY_OK); + grpc_channel_credentials_release(channel_oauth2_creds); +} + +static void check_oauth2_google_iam_composite_metadata( grpc_exec_ctx *exec_ctx, void *user_data, grpc_credentials_md *md_elems, size_t num_md, grpc_credentials_status status) { - grpc_credentials *c = (grpc_credentials *)user_data; - expected_md emd[] = { - {GRPC_AUTHORIZATION_METADATA_KEY, test_oauth2_bearer_token}}; - GPR_ASSERT(status == GRPC_CREDENTIALS_OK); - GPR_ASSERT(num_md == 1); - check_metadata(emd, md_elems, num_md); - grpc_credentials_unref(c); -} - -static void test_ssl_oauth2_composite_creds(void) { - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_credentials *ssl_creds = - grpc_ssl_credentials_create(test_root_cert, NULL, NULL); - const grpc_credentials_array *creds_array; - grpc_credentials *oauth2_creds = grpc_md_only_test_credentials_create( - "Authorization", test_oauth2_bearer_token, 0); - grpc_credentials *composite_creds = - grpc_composite_credentials_create(ssl_creds, oauth2_creds, NULL); - grpc_credentials_unref(ssl_creds); - grpc_credentials_unref(oauth2_creds); - GPR_ASSERT(strcmp(composite_creds->type, GRPC_CREDENTIALS_TYPE_COMPOSITE) == - 0); - GPR_ASSERT(grpc_credentials_has_request_metadata(composite_creds)); - GPR_ASSERT(!grpc_credentials_has_request_metadata_only(composite_creds)); - creds_array = grpc_composite_credentials_get_credentials(composite_creds); - GPR_ASSERT(creds_array->num_creds == 2); - GPR_ASSERT(strcmp(creds_array->creds_array[0]->type, - GRPC_CREDENTIALS_TYPE_SSL) == 0); - GPR_ASSERT(strcmp(creds_array->creds_array[1]->type, - GRPC_CREDENTIALS_TYPE_OAUTH2) == 0); - grpc_credentials_get_request_metadata( - &exec_ctx, composite_creds, NULL, test_service_url, - check_ssl_oauth2_composite_metadata, composite_creds); - grpc_exec_ctx_finish(&exec_ctx); -} - -void test_ssl_fake_transport_security_composite_creds_failure(void) { - grpc_credentials *ssl_creds = grpc_ssl_credentials_create(NULL, NULL, NULL); - grpc_credentials *fake_transport_security_creds = - grpc_fake_transport_security_credentials_create(); - - /* 2 connector credentials: should not work. */ - GPR_ASSERT(grpc_composite_credentials_create( - ssl_creds, fake_transport_security_creds, NULL) == NULL); - grpc_credentials_unref(ssl_creds); - grpc_credentials_unref(fake_transport_security_creds); -} - -static void check_ssl_oauth2_google_iam_composite_metadata( - grpc_exec_ctx *exec_ctx, void *user_data, grpc_credentials_md *md_elems, - size_t num_md, grpc_credentials_status status) { - grpc_credentials *c = (grpc_credentials *)user_data; + grpc_call_credentials *c = (grpc_call_credentials *)user_data; expected_md emd[] = { {GRPC_AUTHORIZATION_METADATA_KEY, test_oauth2_bearer_token}, {GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, @@ -432,51 +424,88 @@ static void check_ssl_oauth2_google_iam_composite_metadata( GPR_ASSERT(status == GRPC_CREDENTIALS_OK); GPR_ASSERT(num_md == 3); check_metadata(emd, md_elems, num_md); - grpc_credentials_unref(c); + grpc_call_credentials_unref(c); } -static void test_ssl_oauth2_google_iam_composite_creds(void) { +static void test_oauth2_google_iam_composite_creds(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_credentials *ssl_creds = - grpc_ssl_credentials_create(test_root_cert, NULL, NULL); - const grpc_credentials_array *creds_array; - grpc_credentials *oauth2_creds = grpc_md_only_test_credentials_create( - "Authorization", test_oauth2_bearer_token, 0); - grpc_credentials *aux_creds = - grpc_composite_credentials_create(ssl_creds, oauth2_creds, NULL); - grpc_credentials *google_iam_creds = grpc_google_iam_credentials_create( + const grpc_call_credentials_array *creds_array; + grpc_call_credentials *oauth2_creds = grpc_md_only_test_credentials_create( + "authorization", test_oauth2_bearer_token, 0); + grpc_call_credentials *google_iam_creds = grpc_google_iam_credentials_create( test_google_iam_authorization_token, test_google_iam_authority_selector, NULL); - grpc_credentials *composite_creds = - grpc_composite_credentials_create(aux_creds, google_iam_creds, NULL); - grpc_credentials_unref(ssl_creds); - grpc_credentials_unref(oauth2_creds); - grpc_credentials_unref(aux_creds); - grpc_credentials_unref(google_iam_creds); - GPR_ASSERT(strcmp(composite_creds->type, GRPC_CREDENTIALS_TYPE_COMPOSITE) == - 0); - GPR_ASSERT(grpc_credentials_has_request_metadata(composite_creds)); - GPR_ASSERT(!grpc_credentials_has_request_metadata_only(composite_creds)); - creds_array = grpc_composite_credentials_get_credentials(composite_creds); - GPR_ASSERT(creds_array->num_creds == 3); + grpc_call_credentials *composite_creds = + grpc_composite_call_credentials_create(oauth2_creds, google_iam_creds, NULL); + grpc_call_credentials_unref(oauth2_creds); + grpc_call_credentials_unref(google_iam_creds); + GPR_ASSERT( + strcmp(composite_creds->type, GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE) == 0); + creds_array = + grpc_composite_call_credentials_get_credentials(composite_creds); + GPR_ASSERT(creds_array->num_creds == 2); GPR_ASSERT(strcmp(creds_array->creds_array[0]->type, - GRPC_CREDENTIALS_TYPE_SSL) == 0); + GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == 0); GPR_ASSERT(strcmp(creds_array->creds_array[1]->type, - GRPC_CREDENTIALS_TYPE_OAUTH2) == 0); - GPR_ASSERT(strcmp(creds_array->creds_array[2]->type, - GRPC_CREDENTIALS_TYPE_IAM) == 0); - grpc_credentials_get_request_metadata( + GRPC_CALL_CREDENTIALS_TYPE_IAM) == 0); + grpc_call_credentials_get_request_metadata( &exec_ctx, composite_creds, NULL, test_service_url, - check_ssl_oauth2_google_iam_composite_metadata, composite_creds); + check_oauth2_google_iam_composite_metadata, composite_creds); grpc_exec_ctx_finish(&exec_ctx); } +static grpc_security_status +check_channel_oauth2_google_iam_create_security_connector( + grpc_channel_credentials *c, grpc_call_credentials *call_creds, + const char *target, const grpc_channel_args *args, + grpc_channel_security_connector **sc, grpc_channel_args **new_args) { + const grpc_call_credentials_array *creds_array; + GPR_ASSERT(strcmp(c->type, "mock") == 0); + GPR_ASSERT(call_creds != NULL); + GPR_ASSERT(strcmp(call_creds->type, GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE) == + 0); + creds_array = grpc_composite_call_credentials_get_credentials(call_creds); + GPR_ASSERT(strcmp(creds_array->creds_array[0]->type, + GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == 0); + GPR_ASSERT(strcmp(creds_array->creds_array[1]->type, + GRPC_CALL_CREDENTIALS_TYPE_IAM) == 0); + return GRPC_SECURITY_OK; +} + +static void test_channel_oauth2_google_iam_composite_creds(void) { + grpc_channel_args *new_args; + grpc_channel_credentials_vtable vtable = { + NULL, check_channel_oauth2_google_iam_create_security_connector}; + grpc_channel_credentials *channel_creds = + grpc_mock_channel_credentials_create(&vtable); + grpc_call_credentials *oauth2_creds = + grpc_access_token_credentials_create("blah", NULL); + grpc_channel_credentials *channel_oauth2_creds = + grpc_composite_channel_credentials_create(channel_creds, oauth2_creds, NULL); + grpc_call_credentials *google_iam_creds = grpc_google_iam_credentials_create( + test_google_iam_authorization_token, test_google_iam_authority_selector, + NULL); + grpc_channel_credentials *channel_oauth2_iam_creds = + grpc_composite_channel_credentials_create(channel_oauth2_creds, + google_iam_creds, NULL); + grpc_channel_credentials_release(channel_creds); + grpc_call_credentials_release(oauth2_creds); + grpc_channel_credentials_release(channel_oauth2_creds); + grpc_call_credentials_release(google_iam_creds); + + GPR_ASSERT(grpc_channel_credentials_create_security_connector( + channel_oauth2_iam_creds, NULL, NULL, NULL, &new_args) == + GRPC_SECURITY_OK); + + grpc_channel_credentials_release(channel_oauth2_iam_creds); +} + static void on_oauth2_creds_get_metadata_success( grpc_exec_ctx *exec_ctx, void *user_data, grpc_credentials_md *md_elems, size_t num_md, grpc_credentials_status status) { GPR_ASSERT(status == GRPC_CREDENTIALS_OK); GPR_ASSERT(num_md == 1); - GPR_ASSERT(gpr_slice_str_cmp(md_elems[0].key, "Authorization") == 0); + GPR_ASSERT(gpr_slice_str_cmp(md_elems[0].key, "authorization") == 0); GPR_ASSERT(gpr_slice_str_cmp(md_elems[0].value, "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_") == 0); @@ -545,15 +574,13 @@ static int httpcli_get_should_not_be_called( static void test_compute_engine_creds_success(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_credentials *compute_engine_creds = + grpc_call_credentials *compute_engine_creds = grpc_google_compute_engine_credentials_create(NULL); - GPR_ASSERT(grpc_credentials_has_request_metadata(compute_engine_creds)); - GPR_ASSERT(grpc_credentials_has_request_metadata_only(compute_engine_creds)); /* First request: http get should be called. */ grpc_httpcli_set_override(compute_engine_httpcli_get_success_override, httpcli_post_should_not_be_called); - grpc_credentials_get_request_metadata( + grpc_call_credentials_get_request_metadata( &exec_ctx, compute_engine_creds, NULL, test_service_url, on_oauth2_creds_get_metadata_success, (void *)test_user_data); grpc_exec_ctx_flush(&exec_ctx); @@ -561,27 +588,25 @@ static void test_compute_engine_creds_success(void) { /* Second request: the cached token should be served directly. */ grpc_httpcli_set_override(httpcli_get_should_not_be_called, httpcli_post_should_not_be_called); - grpc_credentials_get_request_metadata( + grpc_call_credentials_get_request_metadata( &exec_ctx, compute_engine_creds, NULL, test_service_url, on_oauth2_creds_get_metadata_success, (void *)test_user_data); grpc_exec_ctx_finish(&exec_ctx); - grpc_credentials_unref(compute_engine_creds); + grpc_call_credentials_unref(compute_engine_creds); grpc_httpcli_set_override(NULL, NULL); } static void test_compute_engine_creds_failure(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_credentials *compute_engine_creds = + grpc_call_credentials *compute_engine_creds = grpc_google_compute_engine_credentials_create(NULL); grpc_httpcli_set_override(compute_engine_httpcli_get_failure_override, httpcli_post_should_not_be_called); - GPR_ASSERT(grpc_credentials_has_request_metadata(compute_engine_creds)); - GPR_ASSERT(grpc_credentials_has_request_metadata_only(compute_engine_creds)); - grpc_credentials_get_request_metadata( + grpc_call_credentials_get_request_metadata( &exec_ctx, compute_engine_creds, NULL, test_service_url, on_oauth2_creds_get_metadata_failure, (void *)test_user_data); - grpc_credentials_unref(compute_engine_creds); + grpc_call_credentials_unref(compute_engine_creds); grpc_httpcli_set_override(NULL, NULL); grpc_exec_ctx_finish(&exec_ctx); } @@ -631,16 +656,14 @@ static int refresh_token_httpcli_post_failure( static void test_refresh_token_creds_success(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_credentials *refresh_token_creds = + grpc_call_credentials *refresh_token_creds = grpc_google_refresh_token_credentials_create(test_refresh_token_str, NULL); - GPR_ASSERT(grpc_credentials_has_request_metadata(refresh_token_creds)); - GPR_ASSERT(grpc_credentials_has_request_metadata_only(refresh_token_creds)); /* First request: http get should be called. */ grpc_httpcli_set_override(httpcli_get_should_not_be_called, refresh_token_httpcli_post_success); - grpc_credentials_get_request_metadata( + grpc_call_credentials_get_request_metadata( &exec_ctx, refresh_token_creds, NULL, test_service_url, on_oauth2_creds_get_metadata_success, (void *)test_user_data); grpc_exec_ctx_flush(&exec_ctx); @@ -648,29 +671,27 @@ static void test_refresh_token_creds_success(void) { /* Second request: the cached token should be served directly. */ grpc_httpcli_set_override(httpcli_get_should_not_be_called, httpcli_post_should_not_be_called); - grpc_credentials_get_request_metadata( + grpc_call_credentials_get_request_metadata( &exec_ctx, refresh_token_creds, NULL, test_service_url, on_oauth2_creds_get_metadata_success, (void *)test_user_data); grpc_exec_ctx_flush(&exec_ctx); - grpc_credentials_unref(refresh_token_creds); + grpc_call_credentials_unref(refresh_token_creds); grpc_httpcli_set_override(NULL, NULL); grpc_exec_ctx_finish(&exec_ctx); } static void test_refresh_token_creds_failure(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_credentials *refresh_token_creds = + grpc_call_credentials *refresh_token_creds = grpc_google_refresh_token_credentials_create(test_refresh_token_str, NULL); grpc_httpcli_set_override(httpcli_get_should_not_be_called, refresh_token_httpcli_post_failure); - GPR_ASSERT(grpc_credentials_has_request_metadata(refresh_token_creds)); - GPR_ASSERT(grpc_credentials_has_request_metadata_only(refresh_token_creds)); - grpc_credentials_get_request_metadata( + grpc_call_credentials_get_request_metadata( &exec_ctx, refresh_token_creds, NULL, test_service_url, on_oauth2_creds_get_metadata_failure, (void *)test_user_data); - grpc_credentials_unref(refresh_token_creds); + grpc_call_credentials_unref(refresh_token_creds); grpc_httpcli_set_override(NULL, NULL); grpc_exec_ctx_finish(&exec_ctx); } @@ -730,7 +751,7 @@ static void on_jwt_creds_get_metadata_success(grpc_exec_ctx *exec_ctx, gpr_asprintf(&expected_md_value, "Bearer %s", test_signed_jwt); GPR_ASSERT(status == GRPC_CREDENTIALS_OK); GPR_ASSERT(num_md == 1); - GPR_ASSERT(gpr_slice_str_cmp(md_elems[0].key, "Authorization") == 0); + GPR_ASSERT(gpr_slice_str_cmp(md_elems[0].key, "authorization") == 0); GPR_ASSERT(gpr_slice_str_cmp(md_elems[0].value, expected_md_value) == 0); GPR_ASSERT(user_data != NULL); GPR_ASSERT(strcmp((const char *)user_data, test_user_data) == 0); @@ -751,15 +772,13 @@ static void on_jwt_creds_get_metadata_failure(grpc_exec_ctx *exec_ctx, static void test_jwt_creds_success(void) { char *json_key_string = test_json_key_str(); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_credentials *jwt_creds = + grpc_call_credentials *jwt_creds = grpc_service_account_jwt_access_credentials_create( json_key_string, grpc_max_auth_token_lifetime, NULL); - GPR_ASSERT(grpc_credentials_has_request_metadata(jwt_creds)); - GPR_ASSERT(grpc_credentials_has_request_metadata_only(jwt_creds)); /* First request: jwt_encode_and_sign should be called. */ grpc_jwt_encode_and_sign_set_override(encode_and_sign_jwt_success); - grpc_credentials_get_request_metadata( + grpc_call_credentials_get_request_metadata( &exec_ctx, jwt_creds, NULL, test_service_url, on_jwt_creds_get_metadata_success, (void *)test_user_data); grpc_exec_ctx_flush(&exec_ctx); @@ -767,7 +786,7 @@ static void test_jwt_creds_success(void) { /* Second request: the cached token should be served directly. */ grpc_jwt_encode_and_sign_set_override( encode_and_sign_jwt_should_not_be_called); - grpc_credentials_get_request_metadata( + grpc_call_credentials_get_request_metadata( &exec_ctx, jwt_creds, NULL, test_service_url, on_jwt_creds_get_metadata_success, (void *)test_user_data); grpc_exec_ctx_flush(&exec_ctx); @@ -775,32 +794,30 @@ static void test_jwt_creds_success(void) { /* Third request: Different service url so jwt_encode_and_sign should be called again (no caching). */ grpc_jwt_encode_and_sign_set_override(encode_and_sign_jwt_success); - grpc_credentials_get_request_metadata( + grpc_call_credentials_get_request_metadata( &exec_ctx, jwt_creds, NULL, other_test_service_url, on_jwt_creds_get_metadata_success, (void *)test_user_data); grpc_exec_ctx_flush(&exec_ctx); gpr_free(json_key_string); - grpc_credentials_unref(jwt_creds); + grpc_call_credentials_unref(jwt_creds); grpc_jwt_encode_and_sign_set_override(NULL); } static void test_jwt_creds_signing_failure(void) { char *json_key_string = test_json_key_str(); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_credentials *jwt_creds = + grpc_call_credentials *jwt_creds = grpc_service_account_jwt_access_credentials_create( json_key_string, grpc_max_auth_token_lifetime, NULL); - GPR_ASSERT(grpc_credentials_has_request_metadata(jwt_creds)); - GPR_ASSERT(grpc_credentials_has_request_metadata_only(jwt_creds)); grpc_jwt_encode_and_sign_set_override(encode_and_sign_jwt_failure); - grpc_credentials_get_request_metadata( + grpc_call_credentials_get_request_metadata( &exec_ctx, jwt_creds, NULL, test_service_url, on_jwt_creds_get_metadata_failure, (void *)test_user_data); gpr_free(json_key_string); - grpc_credentials_unref(jwt_creds); + grpc_call_credentials_unref(jwt_creds); grpc_jwt_encode_and_sign_set_override(NULL); grpc_exec_ctx_finish(&exec_ctx); } @@ -818,52 +835,39 @@ static void set_google_default_creds_env_var_with_file_contents( gpr_free(creds_file_name); } -static grpc_credentials *composite_inner_creds(grpc_credentials *creds, - const char *inner_creds_type) { - size_t i; - grpc_composite_credentials *composite; - GPR_ASSERT(strcmp(creds->type, GRPC_CREDENTIALS_TYPE_COMPOSITE) == 0); - composite = (grpc_composite_credentials *)creds; - for (i = 0; i < composite->inner.num_creds; i++) { - grpc_credentials *c = composite->inner.creds_array[i]; - if (strcmp(c->type, inner_creds_type) == 0) return c; - } - GPR_ASSERT(0); /* Not found. */ -} - static void test_google_default_creds_auth_key(void) { grpc_service_account_jwt_access_credentials *jwt; - grpc_credentials *creds; + grpc_composite_channel_credentials *creds; char *json_key = test_json_key_str(); grpc_flush_cached_google_default_credentials(); set_google_default_creds_env_var_with_file_contents( "json_key_google_default_creds", json_key); gpr_free(json_key); - creds = grpc_google_default_credentials_create(); + creds = (grpc_composite_channel_credentials *) + grpc_google_default_credentials_create(); GPR_ASSERT(creds != NULL); - jwt = (grpc_service_account_jwt_access_credentials *)composite_inner_creds( - creds, GRPC_CREDENTIALS_TYPE_JWT); + jwt = (grpc_service_account_jwt_access_credentials *)creds->call_creds; GPR_ASSERT( strcmp(jwt->key.client_id, "777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent.com") == 0); - grpc_credentials_unref(creds); + grpc_channel_credentials_unref(&creds->base); gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */ } static void test_google_default_creds_access_token(void) { grpc_google_refresh_token_credentials *refresh; - grpc_credentials *creds; + grpc_composite_channel_credentials *creds; grpc_flush_cached_google_default_credentials(); set_google_default_creds_env_var_with_file_contents( "refresh_token_google_default_creds", test_refresh_token_str); - creds = grpc_google_default_credentials_create(); + creds = (grpc_composite_channel_credentials *) + grpc_google_default_credentials_create(); GPR_ASSERT(creds != NULL); - refresh = (grpc_google_refresh_token_credentials *)composite_inner_creds( - creds, GRPC_CREDENTIALS_TYPE_OAUTH2); + refresh = (grpc_google_refresh_token_credentials *)creds->call_creds; GPR_ASSERT(strcmp(refresh->refresh_token.client_id, "32555999999.apps.googleusercontent.com") == 0); - grpc_credentials_unref(creds); + grpc_channel_credentials_unref(&creds->base); gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */ } @@ -935,7 +939,7 @@ static void plugin_destroy(void *state) { } static void test_metadata_plugin_success(void) { - grpc_credentials *creds; + grpc_call_credentials *creds; plugin_state state = PLUGIN_INITIAL_STATE; grpc_metadata_credentials_plugin plugin; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -946,17 +950,17 @@ static void test_metadata_plugin_success(void) { creds = grpc_metadata_credentials_create_from_plugin(plugin, NULL); GPR_ASSERT(state == PLUGIN_INITIAL_STATE); - grpc_credentials_get_request_metadata( + grpc_call_credentials_get_request_metadata( &exec_ctx, creds, NULL, test_service_url, on_plugin_metadata_received_success, NULL); GPR_ASSERT(state == PLUGIN_GET_METADATA_CALLED_STATE); - grpc_credentials_release(creds); + grpc_call_credentials_release(creds); GPR_ASSERT(state == PLUGIN_DESTROY_CALLED_STATE); grpc_exec_ctx_finish(&exec_ctx); } static void test_metadata_plugin_failure(void) { - grpc_credentials *creds; + grpc_call_credentials *creds; plugin_state state = PLUGIN_INITIAL_STATE; grpc_metadata_credentials_plugin plugin; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -967,11 +971,11 @@ static void test_metadata_plugin_failure(void) { creds = grpc_metadata_credentials_create_from_plugin(plugin, NULL); GPR_ASSERT(state == PLUGIN_INITIAL_STATE); - grpc_credentials_get_request_metadata( + grpc_call_credentials_get_request_metadata( &exec_ctx, creds, NULL, test_service_url, on_plugin_metadata_received_failure, NULL); GPR_ASSERT(state == PLUGIN_GET_METADATA_CALLED_STATE); - grpc_credentials_release(creds); + grpc_call_credentials_release(creds); GPR_ASSERT(state == PLUGIN_DESTROY_CALLED_STATE); grpc_exec_ctx_finish(&exec_ctx); } @@ -993,8 +997,9 @@ int main(int argc, char **argv) { test_oauth2_token_fetcher_creds_parsing_missing_token_lifetime(); test_google_iam_creds(); test_access_token_creds(); - test_ssl_oauth2_composite_creds(); - test_ssl_oauth2_google_iam_composite_creds(); + test_channel_oauth2_composite_creds(); + test_oauth2_google_iam_composite_creds(); + test_channel_oauth2_google_iam_composite_creds(); test_compute_engine_creds_success(); test_compute_engine_creds_failure(); test_refresh_token_creds_success(); diff --git a/test/core/security/fetch_oauth2.c b/test/core/security/fetch_oauth2.c index 764d8da9b6..ee1178cbdd 100644 --- a/test/core/security/fetch_oauth2.c +++ b/test/core/security/fetch_oauth2.c @@ -46,7 +46,7 @@ #include "src/core/support/file.h" #include "test/core/security/oauth2_utils.h" -static grpc_credentials *create_refresh_token_creds( +static grpc_call_credentials *create_refresh_token_creds( const char *json_refresh_token_file_path) { int success; gpr_slice refresh_token = @@ -60,7 +60,7 @@ static grpc_credentials *create_refresh_token_creds( } int main(int argc, char **argv) { - grpc_credentials *creds = NULL; + grpc_call_credentials *creds = NULL; char *json_key_file_path = NULL; char *json_refresh_token_file_path = NULL; char *token = NULL; @@ -115,7 +115,7 @@ int main(int argc, char **argv) { printf("Got token: %s.\n", token); gpr_free(token); } - grpc_credentials_release(creds); + grpc_call_credentials_release(creds); gpr_cmdline_destroy(cl); grpc_shutdown(); return 0; diff --git a/test/core/security/oauth2_utils.c b/test/core/security/oauth2_utils.c index f99d170592..fcfe8a6377 100644 --- a/test/core/security/oauth2_utils.c +++ b/test/core/security/oauth2_utils.c @@ -75,7 +75,8 @@ static void on_oauth2_response(grpc_exec_ctx *exec_ctx, void *user_data, static void do_nothing(grpc_exec_ctx *exec_ctx, void *unused, int success) {} -char *grpc_test_fetch_oauth2_token_with_credentials(grpc_credentials *creds) { +char *grpc_test_fetch_oauth2_token_with_credentials( + grpc_call_credentials *creds) { oauth2_request request; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_closure do_nothing_closure; @@ -84,8 +85,8 @@ char *grpc_test_fetch_oauth2_token_with_credentials(grpc_credentials *creds) { grpc_closure_init(&do_nothing_closure, do_nothing, NULL); - grpc_credentials_get_request_metadata(&exec_ctx, creds, &request.pollset, "", - on_oauth2_response, &request); + grpc_call_credentials_get_request_metadata(&exec_ctx, creds, &request.pollset, + "", on_oauth2_response, &request); grpc_exec_ctx_finish(&exec_ctx); diff --git a/test/core/security/oauth2_utils.h b/test/core/security/oauth2_utils.h index 8082351b8a..b35fe7987f 100644 --- a/test/core/security/oauth2_utils.h +++ b/test/core/security/oauth2_utils.h @@ -42,7 +42,8 @@ extern "C" { /* Fetch oauth2 access token with a credentials object. Does not take ownership. Returns NULL on a failure. The caller should call gpr_free on the token. */ -char *grpc_test_fetch_oauth2_token_with_credentials(grpc_credentials *creds); +char *grpc_test_fetch_oauth2_token_with_credentials( + grpc_call_credentials *creds); #ifdef __cplusplus } diff --git a/test/core/security/print_google_default_creds_token.c b/test/core/security/print_google_default_creds_token.c index f207e05794..eb63724715 100644 --- a/test/core/security/print_google_default_creds_token.c +++ b/test/core/security/print_google_default_creds_token.c @@ -72,7 +72,7 @@ int main(int argc, char **argv) { int result = 0; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; synchronizer sync; - grpc_credentials *creds = NULL; + grpc_channel_credentials *creds = NULL; char *service_url = "https://test.foo.google.com/Foo"; gpr_cmdline *cl = gpr_cmdline_create("print_google_default_creds_token"); gpr_cmdline_add_string(cl, "service_url", @@ -91,9 +91,9 @@ int main(int argc, char **argv) { grpc_pollset_init(&sync.pollset); sync.is_done = 0; - grpc_credentials_get_request_metadata(&exec_ctx, creds, &sync.pollset, - service_url, on_metadata_response, - &sync); + grpc_call_credentials_get_request_metadata( + &exec_ctx, ((grpc_composite_channel_credentials *)creds)->call_creds, + &sync.pollset, service_url, on_metadata_response, &sync); gpr_mu_lock(GRPC_POLLSET_MU(&sync.pollset)); while (!sync.is_done) { @@ -107,7 +107,7 @@ int main(int argc, char **argv) { } gpr_mu_unlock(GRPC_POLLSET_MU(&sync.pollset)); - grpc_credentials_release(creds); + grpc_channel_credentials_release(creds); end: gpr_cmdline_destroy(cl); diff --git a/test/cpp/client/credentials_test.cc b/test/cpp/client/credentials_test.cc index 743ad065d1..418a54439a 100644 --- a/test/cpp/client/credentials_test.cc +++ b/test/cpp/client/credentials_test.cc @@ -46,8 +46,8 @@ class CredentialsTest : public ::testing::Test { }; TEST_F(CredentialsTest, InvalidGoogleRefreshToken) { - std::shared_ptr<Credentials> bad1 = GoogleRefreshTokenCredentials(""); - EXPECT_EQ(static_cast<Credentials*>(nullptr), bad1.get()); + std::shared_ptr<CallCredentials> bad1 = GoogleRefreshTokenCredentials(""); + EXPECT_EQ(static_cast<CallCredentials*>(nullptr), bad1.get()); } } // namespace testing diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index cfb6c21edc..74290c36d2 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -199,7 +199,7 @@ class AsyncEnd2endTest : public ::testing::TestWithParam<bool> { void ResetStub() { std::shared_ptr<Channel> channel = - CreateChannel(server_address_.str(), InsecureCredentials()); + CreateChannel(server_address_.str(), InsecureChannelCredentials()); stub_ = grpc::cpp::test::util::TestService::NewStub(channel); } @@ -749,7 +749,7 @@ TEST_P(AsyncEnd2endTest, ServerCheckDone) { TEST_P(AsyncEnd2endTest, UnimplementedRpc) { std::shared_ptr<Channel> channel = - CreateChannel(server_address_.str(), InsecureCredentials()); + CreateChannel(server_address_.str(), InsecureChannelCredentials()); std::unique_ptr<grpc::cpp::test::util::UnimplementedService::Stub> stub; stub = grpc::cpp::test::util::UnimplementedService::NewStub(channel); EchoRequest send_request; diff --git a/test/cpp/end2end/client_crash_test.cc b/test/cpp/end2end/client_crash_test.cc index 058e696166..116785bbf2 100644 --- a/test/cpp/end2end/client_crash_test.cc +++ b/test/cpp/end2end/client_crash_test.cc @@ -74,7 +74,7 @@ class CrashTest : public ::testing::Test { })); GPR_ASSERT(server_); return grpc::cpp::test::util::TestService::NewStub( - CreateChannel(addr, InsecureCredentials())); + CreateChannel(addr, InsecureChannelCredentials())); } void KillServer() { server_.reset(); } diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index c5c7185026..6da933302c 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -146,13 +146,13 @@ class TestAuthMetadataProcessor : public AuthMetadataProcessor { TestAuthMetadataProcessor(bool is_blocking) : is_blocking_(is_blocking) {} - std::shared_ptr<Credentials> GetCompatibleClientCreds() { + std::shared_ptr<CallCredentials> GetCompatibleClientCreds() { return MetadataCredentialsFromPlugin( std::unique_ptr<MetadataCredentialsPlugin>( new TestMetadataCredentialsPlugin(kGoodGuy, is_blocking_, true))); } - std::shared_ptr<Credentials> GetIncompatibleClientCreds() { + std::shared_ptr<CallCredentials> GetIncompatibleClientCreds() { return MetadataCredentialsFromPlugin( std::unique_ptr<MetadataCredentialsPlugin>( new TestMetadataCredentialsPlugin("Mr Hyde", is_blocking_, true))); @@ -407,7 +407,7 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> { } EXPECT_TRUE(is_server_started_); ChannelArguments args; - auto channel_creds = InsecureCredentials(); + auto channel_creds = InsecureChannelCredentials(); if (GetParam().use_tls) { SslCredentialsOptions ssl_opts = {test_root_cert, "", ""}; args.SetSslTargetNameOverride("foo.test.google.fr"); @@ -429,7 +429,7 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> { builder.RegisterService(proxy_service_.get()); proxy_server_ = builder.BuildAndStart(); - channel_ = CreateChannel(proxyaddr.str(), InsecureCredentials()); + channel_ = CreateChannel(proxyaddr.str(), InsecureChannelCredentials()); } stub_ = grpc::cpp::test::util::TestService::NewStub(channel_); @@ -575,6 +575,18 @@ void CancelRpc(ClientContext* context, int delay_us, TestServiceImpl* service) { context->TryCancel(); } +TEST_P(End2endTest, CancelRpcBeforeStart) { + ResetStub(); + EchoRequest request; + EchoResponse response; + ClientContext context; + request.set_message("hello"); + context.TryCancel(); + Status s = stub_->Echo(&context, request, &response); + EXPECT_EQ("", response.message()); + EXPECT_EQ(grpc::StatusCode::CANCELLED, s.error_code()); +} + // Client cancels request stream after sending two messages TEST_P(End2endTest, ClientCancelsRequestStream) { ResetStub(); @@ -751,7 +763,8 @@ TEST_P(End2endTest, ChannelStateTimeout) { std::ostringstream server_address; server_address << "127.0.0.1:" << port; // Channel to non-existing server - auto channel = CreateChannel(server_address.str(), InsecureCredentials()); + auto channel = + CreateChannel(server_address.str(), InsecureChannelCredentials()); // Start IDLE EXPECT_EQ(GRPC_CHANNEL_IDLE, channel->GetState(true)); @@ -971,33 +984,6 @@ TEST_P(SecureEnd2endTest, SimpleRpcWithHost) { EXPECT_TRUE(s.ok()); } -// rpc and stream should fail on bad credentials. -TEST_P(SecureEnd2endTest, BadCredentials) { - std::shared_ptr<Credentials> bad_creds = GoogleRefreshTokenCredentials(""); - EXPECT_EQ(static_cast<Credentials*>(nullptr), bad_creds.get()); - std::shared_ptr<Channel> channel = - CreateChannel(server_address_.str(), bad_creds); - std::unique_ptr<grpc::cpp::test::util::TestService::Stub> stub( - grpc::cpp::test::util::TestService::NewStub(channel)); - EchoRequest request; - EchoResponse response; - ClientContext context; - request.set_message("Hello"); - - Status s = stub->Echo(&context, request, &response); - EXPECT_EQ("", response.message()); - EXPECT_FALSE(s.ok()); - EXPECT_EQ(StatusCode::INVALID_ARGUMENT, s.error_code()); - EXPECT_EQ("Invalid credentials.", s.error_message()); - - ClientContext context2; - auto stream = stub->BidiStream(&context2); - s = stream->Finish(); - EXPECT_FALSE(s.ok()); - EXPECT_EQ(StatusCode::INVALID_ARGUMENT, s.error_code()); - EXPECT_EQ("Invalid credentials.", s.error_message()); -} - bool MetadataContains( const std::multimap<grpc::string_ref, grpc::string_ref>& metadata, const grpc::string& key, const grpc::string& value) { @@ -1055,7 +1041,7 @@ TEST_P(SecureEnd2endTest, SetPerCallCredentials) { EchoRequest request; EchoResponse response; ClientContext context; - std::shared_ptr<Credentials> creds = + std::shared_ptr<CallCredentials> creds = GoogleIAMCredentials("fake_token", "fake_selector"); context.set_credentials(creds); request.set_message("Hello"); @@ -1072,30 +1058,15 @@ TEST_P(SecureEnd2endTest, SetPerCallCredentials) { "fake_selector")); } -TEST_P(SecureEnd2endTest, InsecurePerCallCredentials) { - ResetStub(); - EchoRequest request; - EchoResponse response; - ClientContext context; - std::shared_ptr<Credentials> creds = InsecureCredentials(); - context.set_credentials(creds); - request.set_message("Hello"); - request.mutable_param()->set_echo_metadata(true); - - Status s = stub_->Echo(&context, request, &response); - EXPECT_EQ(StatusCode::CANCELLED, s.error_code()); - EXPECT_EQ("Failed to set credentials to rpc.", s.error_message()); -} - TEST_P(SecureEnd2endTest, OverridePerCallCredentials) { ResetStub(); EchoRequest request; EchoResponse response; ClientContext context; - std::shared_ptr<Credentials> creds1 = + std::shared_ptr<CallCredentials> creds1 = GoogleIAMCredentials("fake_token1", "fake_selector1"); context.set_credentials(creds1); - std::shared_ptr<Credentials> creds2 = + std::shared_ptr<CallCredentials> creds2 = GoogleIAMCredentials("fake_token2", "fake_selector2"); context.set_credentials(creds2); request.set_message("Hello"); diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc index 6a46916728..082119d6d5 100644 --- a/test/cpp/end2end/generic_end2end_test.cc +++ b/test/cpp/end2end/generic_end2end_test.cc @@ -120,7 +120,7 @@ class GenericEnd2endTest : public ::testing::Test { void ResetStub() { std::shared_ptr<Channel> channel = - CreateChannel(server_address_.str(), InsecureCredentials()); + CreateChannel(server_address_.str(), InsecureChannelCredentials()); generic_stub_.reset(new GenericStub(channel)); } diff --git a/test/cpp/end2end/mock_test.cc b/test/cpp/end2end/mock_test.cc index 80057d893e..bd34cfba67 100644 --- a/test/cpp/end2end/mock_test.cc +++ b/test/cpp/end2end/mock_test.cc @@ -244,7 +244,7 @@ class MockTest : public ::testing::Test { void ResetStub() { std::shared_ptr<Channel> channel = - CreateChannel(server_address_.str(), InsecureCredentials()); + CreateChannel(server_address_.str(), InsecureChannelCredentials()); stub_ = grpc::cpp::test::util::TestService::NewStub(channel); } diff --git a/test/cpp/end2end/server_crash_test_client.cc b/test/cpp/end2end/server_crash_test_client.cc index 17869362c2..2baefcbf42 100644 --- a/test/cpp/end2end/server_crash_test_client.cc +++ b/test/cpp/end2end/server_crash_test_client.cc @@ -58,7 +58,7 @@ using namespace gflags; int main(int argc, char** argv) { ParseCommandLineFlags(&argc, &argv, true); auto stub = grpc::cpp::test::util::TestService::NewStub( - grpc::CreateChannel(FLAGS_address, grpc::InsecureCredentials())); + grpc::CreateChannel(FLAGS_address, grpc::InsecureChannelCredentials())); EchoRequest request; EchoResponse response; diff --git a/test/cpp/end2end/shutdown_test.cc b/test/cpp/end2end/shutdown_test.cc index 0549bb8b5f..b1b18b2a7f 100644 --- a/test/cpp/end2end/shutdown_test.cc +++ b/test/cpp/end2end/shutdown_test.cc @@ -93,7 +93,7 @@ class ShutdownTest : public ::testing::Test { void ResetStub() { string target = "dns:localhost:" + to_string(port_); - channel_ = CreateChannel(target, InsecureCredentials()); + channel_ = CreateChannel(target, InsecureChannelCredentials()); stub_ = grpc::cpp::test::util::TestService::NewStub(channel_); } diff --git a/test/cpp/end2end/streaming_throughput_test.cc b/test/cpp/end2end/streaming_throughput_test.cc index d4ab1486cc..b7e103a1ae 100644 --- a/test/cpp/end2end/streaming_throughput_test.cc +++ b/test/cpp/end2end/streaming_throughput_test.cc @@ -160,7 +160,7 @@ class End2endTest : public ::testing::Test { void ResetStub() { std::shared_ptr<Channel> channel = - CreateChannel(server_address_.str(), InsecureCredentials()); + CreateChannel(server_address_.str(), InsecureChannelCredentials()); stub_ = grpc::cpp::test::util::TestService::NewStub(channel); } diff --git a/test/cpp/end2end/thread_stress_test.cc b/test/cpp/end2end/thread_stress_test.cc index 75a07d89c5..fb82b96135 100644 --- a/test/cpp/end2end/thread_stress_test.cc +++ b/test/cpp/end2end/thread_stress_test.cc @@ -190,7 +190,7 @@ class End2endTest : public ::testing::Test { void ResetStub() { std::shared_ptr<Channel> channel = - CreateChannel(server_address_.str(), InsecureCredentials()); + CreateChannel(server_address_.str(), InsecureChannelCredentials()); stub_ = grpc::cpp::test::util::TestService::NewStub(channel); } diff --git a/test/cpp/end2end/zookeeper_test.cc b/test/cpp/end2end/zookeeper_test.cc index d4c7f0489f..e88c0f9c68 100644 --- a/test/cpp/end2end/zookeeper_test.cc +++ b/test/cpp/end2end/zookeeper_test.cc @@ -157,7 +157,7 @@ class ZookeeperTest : public ::testing::Test { void ResetStub() { string target = "zookeeper://" + zookeeper_address_ + "/test"; - channel_ = CreateChannel(target, InsecureCredentials()); + channel_ = CreateChannel(target, InsecureChannelCredentials()); stub_ = std::move(grpc::cpp::test::util::TestService::NewStub(channel_)); } diff --git a/test/cpp/interop/client_helper.cc b/test/cpp/interop/client_helper.cc index 61b46d25aa..5caf0f2d1d 100644 --- a/test/cpp/interop/client_helper.cc +++ b/test/cpp/interop/client_helper.cc @@ -76,11 +76,11 @@ grpc::string GetServiceAccountJsonKey() { } grpc::string GetOauth2AccessToken() { - std::shared_ptr<Credentials> creds = GoogleComputeEngineCredentials(); - SecureCredentials* secure_creds = - dynamic_cast<SecureCredentials*>(creds.get()); + std::shared_ptr<CallCredentials> creds = GoogleComputeEngineCredentials(); + SecureCallCredentials* secure_creds = + dynamic_cast<SecureCallCredentials*>(creds.get()); GPR_ASSERT(secure_creds != nullptr); - grpc_credentials* c_creds = secure_creds->GetRawCreds(); + grpc_call_credentials* c_creds = secure_creds->GetRawCreds(); char* token = grpc_test_fetch_oauth2_token_with_credentials(c_creds); GPR_ASSERT(token != nullptr); gpr_log(GPR_INFO, "Get raw oauth2 access token: %s", token); @@ -98,13 +98,13 @@ std::shared_ptr<Channel> CreateChannelForTestCase( FLAGS_server_port); if (test_case == "compute_engine_creds") { - std::shared_ptr<Credentials> creds; + std::shared_ptr<CallCredentials> creds; GPR_ASSERT(FLAGS_use_tls); creds = GoogleComputeEngineCredentials(); return CreateTestChannel(host_port, FLAGS_server_host_override, FLAGS_use_tls, !FLAGS_use_test_ca, creds); } else if (test_case == "jwt_token_creds") { - std::shared_ptr<Credentials> creds; + std::shared_ptr<CallCredentials> creds; GPR_ASSERT(FLAGS_use_tls); grpc::string json_key = GetServiceAccountJsonKey(); std::chrono::seconds token_lifetime = std::chrono::hours(1); @@ -114,7 +114,7 @@ std::shared_ptr<Channel> CreateChannelForTestCase( FLAGS_use_tls, !FLAGS_use_test_ca, creds); } else if (test_case == "oauth2_auth_token") { grpc::string raw_token = GetOauth2AccessToken(); - std::shared_ptr<Credentials> creds = AccessTokenCredentials(raw_token); + std::shared_ptr<CallCredentials> creds = AccessTokenCredentials(raw_token); return CreateTestChannel(host_port, FLAGS_server_host_override, FLAGS_use_tls, !FLAGS_use_test_ca, creds); } else { diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index 46a5255e4c..6340007fa4 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -244,7 +244,7 @@ void InteropClient::DoPerRpcCreds(const grpc::string& json_key) { ClientContext context; std::chrono::seconds token_lifetime = std::chrono::hours(1); - std::shared_ptr<Credentials> creds = + std::shared_ptr<CallCredentials> creds = ServiceAccountJWTAccessCredentials(json_key, token_lifetime.count()); context.set_credentials(creds); diff --git a/test/cpp/interop/stress_interop_client.cc b/test/cpp/interop/stress_interop_client.cc index f8c55cf795..3be2571493 100644 --- a/test/cpp/interop/stress_interop_client.cc +++ b/test/cpp/interop/stress_interop_client.cc @@ -89,9 +89,9 @@ StressTestInteropClient::StressTestInteropClient( test_duration_secs_(test_duration_secs), sleep_duration_ms_(sleep_duration_ms) { // TODO(sreek): This will change once we add support for other tests - // that won't work with InsecureCredentials() + // that won't work with InsecureChannelCredentials() std::shared_ptr<Channel> channel( - CreateChannel(server_address, InsecureCredentials())); + CreateChannel(server_address, InsecureChannelCredentials())); interop_client_.reset(new InteropClient(channel, false)); } diff --git a/test/cpp/interop/stress_test.cc b/test/cpp/interop/stress_test.cc index 5d1419728e..018f4ab4f7 100644 --- a/test/cpp/interop/stress_test.cc +++ b/test/cpp/interop/stress_test.cc @@ -41,6 +41,7 @@ #include <grpc/support/time.h> #include <grpc++/create_channel.h> #include <grpc++/grpc++.h> +#include <grpc++/impl/thd.h> #include "test/cpp/interop/interop_client.h" #include "test/cpp/interop/stress_interop_client.h" @@ -80,7 +81,6 @@ DEFINE_string(test_cases, "", using std::make_pair; using std::pair; -using std::thread; using std::vector; using grpc::testing::kTestCaseList; @@ -202,7 +202,7 @@ int main(int argc, char** argv) { gpr_log(GPR_INFO, "Starting test(s).."); - vector<thread> test_threads; + vector<grpc::thread> test_threads; int thread_idx = 0; for (auto it = server_addresses.begin(); it != server_addresses.end(); it++) { StressTestInteropClient* client = new StressTestInteropClient( @@ -210,7 +210,7 @@ int main(int argc, char** argv) { FLAGS_sleep_duration_ms); test_threads.emplace_back( - thread(&StressTestInteropClient::MainLoop, client)); + grpc::thread(&StressTestInteropClient::MainLoop, client)); } for (auto it = test_threads.begin(); it != test_threads.end(); it++) { diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc index 2c6247deea..67bdcb2f32 100644 --- a/test/cpp/qps/driver.cc +++ b/test/cpp/qps/driver.cc @@ -162,7 +162,7 @@ std::unique_ptr<ScenarioResult> RunScenario( auto* servers = new ServerData[num_servers]; for (size_t i = 0; i < num_servers; i++) { servers[i].stub = WorkerService::NewStub( - CreateChannel(workers[i], InsecureCredentials())); + CreateChannel(workers[i], InsecureChannelCredentials())); ServerArgs args; result_server_config = server_config; *args.mutable_setup() = server_config; @@ -189,7 +189,7 @@ std::unique_ptr<ScenarioResult> RunScenario( auto* clients = new ClientData[num_clients]; for (size_t i = 0; i < num_clients; i++) { clients[i].stub = WorkerService::NewStub( - CreateChannel(workers[i + num_servers], InsecureCredentials())); + CreateChannel(workers[i + num_servers], InsecureChannelCredentials())); ClientArgs args; result_client_config = client_config; *args.mutable_setup() = client_config; diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h index 78779231d3..5caf3fe69a 100644 --- a/test/cpp/qps/report.h +++ b/test/cpp/qps/report.h @@ -115,8 +115,8 @@ class PerfDbReporter : public Reporter { test_name_(test_name), sys_info_(sys_info), tag_(tag) { - perf_db_client_.init( - grpc::CreateChannel(server_address, grpc::InsecureCredentials())); + perf_db_client_.init(grpc::CreateChannel( + server_address, grpc::InsecureChannelCredentials())); } ~PerfDbReporter() GRPC_OVERRIDE { SendData(); }; diff --git a/test/cpp/util/cli_call_test.cc b/test/cpp/util/cli_call_test.cc index 9c8d59987e..32cd8e4103 100644 --- a/test/cpp/util/cli_call_test.cc +++ b/test/cpp/util/cli_call_test.cc @@ -89,7 +89,8 @@ class CliCallTest : public ::testing::Test { void TearDown() GRPC_OVERRIDE { server_->Shutdown(); } void ResetStub() { - channel_ = CreateChannel(server_address_.str(), InsecureCredentials()); + channel_ = + CreateChannel(server_address_.str(), InsecureChannelCredentials()); stub_ = grpc::cpp::test::util::TestService::NewStub(channel_); } diff --git a/test/cpp/util/create_test_channel.cc b/test/cpp/util/create_test_channel.cc index f0d5bfc7eb..0cd9f9e767 100644 --- a/test/cpp/util/create_test_channel.cc +++ b/test/cpp/util/create_test_channel.cc @@ -58,13 +58,14 @@ namespace grpc { std::shared_ptr<Channel> CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, bool enable_ssl, bool use_prod_roots, - const std::shared_ptr<Credentials>& creds) { + const std::shared_ptr<CallCredentials>& creds) { ChannelArguments channel_args; if (enable_ssl) { const char* roots_certs = use_prod_roots ? "" : test_root_cert; SslCredentialsOptions ssl_opts = {roots_certs, "", ""}; - std::shared_ptr<Credentials> channel_creds = SslCredentials(ssl_opts); + std::shared_ptr<ChannelCredentials> channel_creds = + SslCredentials(ssl_opts); if (!server.empty() && !override_hostname.empty()) { channel_args.SetSslTargetNameOverride(override_hostname); @@ -72,11 +73,11 @@ std::shared_ptr<Channel> CreateTestChannel( const grpc::string& connect_to = server.empty() ? override_hostname : server; if (creds.get()) { - channel_creds = CompositeCredentials(creds, channel_creds); + channel_creds = CompositeChannelCredentials(channel_creds, creds); } return CreateCustomChannel(connect_to, channel_creds, channel_args); } else { - return CreateChannel(server, InsecureCredentials()); + return CreateChannel(server, InsecureChannelCredentials()); } } @@ -84,7 +85,7 @@ std::shared_ptr<Channel> CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, bool enable_ssl, bool use_prod_roots) { return CreateTestChannel(server, override_hostname, enable_ssl, - use_prod_roots, std::shared_ptr<Credentials>()); + use_prod_roots, std::shared_ptr<CallCredentials>()); } // Shortcut for end2end and interop tests. diff --git a/test/cpp/util/create_test_channel.h b/test/cpp/util/create_test_channel.h index a4750689a0..b50d653de3 100644 --- a/test/cpp/util/create_test_channel.h +++ b/test/cpp/util/create_test_channel.h @@ -51,7 +51,7 @@ std::shared_ptr<Channel> CreateTestChannel( std::shared_ptr<Channel> CreateTestChannel( const grpc::string& server, const grpc::string& override_hostname, bool enable_ssl, bool use_prod_roots, - const std::shared_ptr<Credentials>& creds); + const std::shared_ptr<CallCredentials>& creds); } // namespace grpc diff --git a/test/cpp/util/grpc_cli.cc b/test/cpp/util/grpc_cli.cc index 334b6efb6a..3f40b242fc 100644 --- a/test/cpp/util/grpc_cli.cc +++ b/test/cpp/util/grpc_cli.cc @@ -148,9 +148,9 @@ int main(int argc, char** argv) { std::stringstream input_stream; input_stream << input_file.rdbuf(); - std::shared_ptr<grpc::Credentials> creds; + std::shared_ptr<grpc::ChannelCredentials> creds; if (!FLAGS_enable_ssl) { - creds = grpc::InsecureCredentials(); + creds = grpc::InsecureChannelCredentials(); } else { if (FLAGS_use_auth) { creds = grpc::GoogleDefaultCredentials(); |