diff options
Diffstat (limited to 'test/core/security')
-rw-r--r-- | test/core/security/BUILD | 40 | ||||
-rw-r--r-- | test/core/security/auth_context_test.cc (renamed from test/core/security/auth_context_test.c) | 0 | ||||
-rw-r--r-- | test/core/security/create_jwt.cc (renamed from test/core/security/create_jwt.c) | 6 | ||||
-rw-r--r-- | test/core/security/credentials_test.cc (renamed from test/core/security/credentials_test.c) | 11 | ||||
-rw-r--r-- | test/core/security/fetch_oauth2.cc (renamed from test/core/security/fetch_oauth2.c) | 2 | ||||
-rw-r--r-- | test/core/security/json_token_test.cc (renamed from test/core/security/json_token_test.c) | 6 | ||||
-rw-r--r-- | test/core/security/jwt_verifier_test.cc (renamed from test/core/security/jwt_verifier_test.c) | 4 | ||||
-rw-r--r-- | test/core/security/oauth2_utils.cc (renamed from test/core/security/oauth2_utils.c) | 0 | ||||
-rw-r--r-- | test/core/security/oauth2_utils.h | 8 | ||||
-rw-r--r-- | test/core/security/print_google_default_creds_token.cc (renamed from test/core/security/print_google_default_creds_token.c) | 10 | ||||
-rw-r--r-- | test/core/security/secure_endpoint_test.cc (renamed from test/core/security/secure_endpoint_test.c) | 9 | ||||
-rw-r--r-- | test/core/security/security_connector_test.cc (renamed from test/core/security/security_connector_test.c) | 0 | ||||
-rw-r--r-- | test/core/security/ssl_credentials_test.cc (renamed from test/core/security/ssl_credentials_test.c) | 0 | ||||
-rw-r--r-- | test/core/security/ssl_server_fuzzer.cc (renamed from test/core/security/ssl_server_fuzzer.c) | 7 | ||||
-rw-r--r-- | test/core/security/verify_jwt.cc (renamed from test/core/security/verify_jwt.c) | 8 |
15 files changed, 55 insertions, 56 deletions
diff --git a/test/core/security/BUILD b/test/core/security/BUILD index 83b1747648..7cd3ae58da 100644 --- a/test/core/security/BUILD +++ b/test/core/security/BUILD @@ -22,8 +22,8 @@ load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") grpc_fuzzer( name = "ssl_server_fuzzer", - srcs = ["ssl_server_fuzzer.c"], - language = "C", + srcs = ["ssl_server_fuzzer.cc"], + language = "C++", corpus = "corpus", deps = [ "//:gpr", @@ -35,17 +35,17 @@ grpc_fuzzer( grpc_cc_library( name = "oauth2_utils", - srcs = ["oauth2_utils.c"], + srcs = ["oauth2_utils.cc"], hdrs = ["oauth2_utils.h"], - language = "C", + language = "C++", deps = ["//:grpc"], visibility = ["//test/cpp:__subpackages__"], ) grpc_cc_test( name = "auth_context_test", - srcs = ["auth_context_test.c"], - language = "C", + srcs = ["auth_context_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -56,8 +56,8 @@ grpc_cc_test( grpc_cc_test( name = "credentials_test", - srcs = ["credentials_test.c"], - language = "C", + srcs = ["credentials_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -68,8 +68,8 @@ grpc_cc_test( grpc_cc_test( name = "secure_endpoint_test", - srcs = ["secure_endpoint_test.c"], - language = "C", + srcs = ["secure_endpoint_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -81,8 +81,8 @@ grpc_cc_test( grpc_cc_test( name = "security_connector_test", - srcs = ["security_connector_test.c"], - language = "C", + srcs = ["security_connector_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -93,8 +93,8 @@ grpc_cc_test( grpc_cc_test( name = "ssl_credentials_test", - srcs = ["ssl_credentials_test.c"], - language = "C", + srcs = ["ssl_credentials_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -105,8 +105,8 @@ grpc_cc_test( grpc_cc_binary( name = "create_jwt", - srcs = ["create_jwt.c"], - language = "C", + srcs = ["create_jwt.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -115,8 +115,8 @@ grpc_cc_binary( grpc_cc_binary( name = "fetch_oauth2", - srcs = ["fetch_oauth2.c"], - language = "C", + srcs = ["fetch_oauth2.cc"], + language = "C++", deps = [ ":oauth2_utils", "//:gpr", @@ -126,8 +126,8 @@ grpc_cc_binary( grpc_cc_binary( name = "verify_jwt", - srcs = ["verify_jwt.c"], - language = "C", + srcs = ["verify_jwt.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", diff --git a/test/core/security/auth_context_test.c b/test/core/security/auth_context_test.cc index 3ab9190689..3ab9190689 100644 --- a/test/core/security/auth_context_test.c +++ b/test/core/security/auth_context_test.cc diff --git a/test/core/security/create_jwt.c b/test/core/security/create_jwt.cc index 327179c9de..95f3615074 100644 --- a/test/core/security/create_jwt.c +++ b/test/core/security/create_jwt.cc @@ -54,9 +54,9 @@ void create_jwt(const char* json_key_file_path, const char* service_url, } int main(int argc, char** argv) { - char* scope = NULL; - char* json_key_file_path = NULL; - char* service_url = NULL; + const char* scope = NULL; + const char* json_key_file_path = NULL; + const char* service_url = NULL; grpc_init(); gpr_cmdline* cl = gpr_cmdline_create("create_jwt"); gpr_cmdline_add_string(cl, "json_key", "File path of the json key.", diff --git a/test/core/security/credentials_test.c b/test/core/security/credentials_test.cc index 3962d35d3a..9b575c4bc5 100644 --- a/test/core/security/credentials_test.c +++ b/test/core/security/credentials_test.cc @@ -47,7 +47,8 @@ static grpc_channel_credentials* grpc_mock_channel_credentials_create( const grpc_channel_credentials_vtable* vtable) { - grpc_channel_credentials* c = gpr_malloc(sizeof(*c)); + grpc_channel_credentials* c = + static_cast<grpc_channel_credentials*>(gpr_malloc(sizeof(*c))); memset(c, 0, sizeof(*c)); c->type = "mock"; c->vtable = vtable; @@ -125,7 +126,7 @@ static char* test_json_key_str(void) { size_t result_len = strlen(test_json_key_str_part1) + strlen(test_json_key_str_part2) + strlen(test_json_key_str_part3); - char* result = gpr_malloc(result_len + 1); + char* result = static_cast<char*>(gpr_malloc(result_len + 1)); char* current = result; strcpy(result, test_json_key_str_part1); current += strlen(test_json_key_str_part1); @@ -366,7 +367,8 @@ static void check_request_metadata(grpc_exec_ctx* exec_ctx, void* arg, static request_metadata_state* make_request_metadata_state( grpc_error* expected_error, const expected_md* expected, size_t expected_size) { - request_metadata_state* state = gpr_zalloc(sizeof(*state)); + request_metadata_state* state = + static_cast<request_metadata_state*>(gpr_zalloc(sizeof(*state))); state->expected_error = expected_error; state->expected = expected; state->expected_size = expected_size; @@ -937,7 +939,8 @@ static int default_creds_gce_detection_httpcli_get_success_override( grpc_millis deadline, grpc_closure* on_done, grpc_httpcli_response* response) { *response = http_response(200, ""); - grpc_http_header* headers = gpr_malloc(sizeof(*headers) * 1); + grpc_http_header* headers = + static_cast<grpc_http_header*>(gpr_malloc(sizeof(*headers) * 1)); headers[0].key = gpr_strdup("Metadata-Flavor"); headers[0].value = gpr_strdup("Google"); response->hdr_count = 1; diff --git a/test/core/security/fetch_oauth2.c b/test/core/security/fetch_oauth2.cc index 42f68fc7d1..fa8036e581 100644 --- a/test/core/security/fetch_oauth2.c +++ b/test/core/security/fetch_oauth2.cc @@ -44,7 +44,7 @@ static grpc_call_credentials* create_refresh_token_creds( int main(int argc, char** argv) { grpc_call_credentials* creds = NULL; char* json_key_file_path = NULL; - char* json_refresh_token_file_path = NULL; + const char* json_refresh_token_file_path = NULL; char* token = NULL; int use_gce = 0; char* scope = NULL; diff --git a/test/core/security/json_token_test.c b/test/core/security/json_token_test.cc index 4159367abe..a06e1d05ce 100644 --- a/test/core/security/json_token_test.c +++ b/test/core/security/json_token_test.cc @@ -81,7 +81,7 @@ static char* test_json_key_str(const char* bad_part3) { const char* part3 = bad_part3 != NULL ? bad_part3 : test_json_key_str_part3; size_t result_len = strlen(test_json_key_str_part1) + strlen(test_json_key_str_part2) + strlen(part3); - char* result = gpr_malloc(result_len + 1); + char* result = static_cast<char*>(gpr_malloc(result_len + 1)); char* current = result; strcpy(result, test_json_key_str_part1); current += strlen(test_json_key_str_part1); @@ -211,12 +211,12 @@ static grpc_json* parse_json_part_from_jwt(const char* str, size_t len, char* decoded; grpc_json* json; grpc_slice slice; - b64 = gpr_malloc(len + 1); + b64 = static_cast<char*>(gpr_malloc(len + 1)); strncpy(b64, str, len); b64[len] = '\0'; slice = grpc_base64_decode(&exec_ctx, b64, 1); GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(slice)); - decoded = gpr_malloc(GRPC_SLICE_LENGTH(slice) + 1); + decoded = static_cast<char*>(gpr_malloc(GRPC_SLICE_LENGTH(slice) + 1)); strncpy(decoded, (const char*)GRPC_SLICE_START_PTR(slice), GRPC_SLICE_LENGTH(slice)); decoded[GRPC_SLICE_LENGTH(slice)] = '\0'; diff --git a/test/core/security/jwt_verifier_test.c b/test/core/security/jwt_verifier_test.cc index 0e16dc958e..6858b36141 100644 --- a/test/core/security/jwt_verifier_test.c +++ b/test/core/security/jwt_verifier_test.cc @@ -292,7 +292,7 @@ static void test_bad_subject_claims_failure(void) { static char* json_key_str(const char* last_part) { size_t result_len = strlen(json_key_str_part1) + strlen(json_key_str_part2) + strlen(last_part); - char* result = gpr_malloc(result_len + 1); + char* result = static_cast<char*>(gpr_malloc(result_len + 1)); char* current = result; strcpy(result, json_key_str_part1); current += strlen(json_key_str_part1); @@ -305,7 +305,7 @@ static char* json_key_str(const char* last_part) { static char* good_google_email_keys(void) { size_t result_len = strlen(good_google_email_keys_part1) + strlen(good_google_email_keys_part2); - char* result = gpr_malloc(result_len + 1); + char* result = static_cast<char*>(gpr_malloc(result_len + 1)); char* current = result; strcpy(result, good_google_email_keys_part1); current += strlen(good_google_email_keys_part1); diff --git a/test/core/security/oauth2_utils.c b/test/core/security/oauth2_utils.cc index fda3d96e18..fda3d96e18 100644 --- a/test/core/security/oauth2_utils.c +++ b/test/core/security/oauth2_utils.cc diff --git a/test/core/security/oauth2_utils.h b/test/core/security/oauth2_utils.h index 5e33ef4f43..5ad2e398e1 100644 --- a/test/core/security/oauth2_utils.h +++ b/test/core/security/oauth2_utils.h @@ -21,17 +21,9 @@ #include "src/core/lib/security/credentials/credentials.h" -#ifdef __cplusplus -extern "C" { -#endif - /* 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_call_credentials* creds); -#ifdef __cplusplus -} -#endif - #endif /* GRPC_TEST_CORE_SECURITY_OAUTH2_UTILS_H */ diff --git a/test/core/security/print_google_default_creds_token.c b/test/core/security/print_google_default_creds_token.cc index c5d4e9c3ea..a57180b57d 100644 --- a/test/core/security/print_google_default_creds_token.c +++ b/test/core/security/print_google_default_creds_token.cc @@ -43,7 +43,7 @@ typedef struct { static void on_metadata_response(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { - synchronizer* sync = arg; + synchronizer* sync = static_cast<synchronizer*>(arg); if (error != GRPC_ERROR_NONE) { fprintf(stderr, "Fetching token failed: %s\n", grpc_error_string(error)); } else { @@ -67,9 +67,11 @@ int main(int argc, char** argv) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; synchronizer sync; grpc_channel_credentials* creds = NULL; - char* service_url = "https://test.foo.google.com/Foo"; + const char* service_url = "https://test.foo.google.com/Foo"; grpc_auth_metadata_context context; gpr_cmdline* cl = gpr_cmdline_create("print_google_default_creds_token"); + grpc_pollset* pollset = nullptr; + grpc_error* error = nullptr; gpr_cmdline_add_string(cl, "service_url", "Service URL for the token request.", &service_url); gpr_cmdline_parse(cl, argc, argv); @@ -86,14 +88,14 @@ int main(int argc, char** argv) { } memset(&sync, 0, sizeof(sync)); - grpc_pollset* pollset = gpr_zalloc(grpc_pollset_size()); + pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size()); grpc_pollset_init(pollset, &sync.mu); sync.pops = grpc_polling_entity_create_from_pollset(pollset); sync.is_done = false; GRPC_CLOSURE_INIT(&sync.on_request_metadata, on_metadata_response, &sync, grpc_schedule_on_exec_ctx); - grpc_error* error = GRPC_ERROR_NONE; + error = GRPC_ERROR_NONE; if (grpc_call_credentials_get_request_metadata( &exec_ctx, ((grpc_composite_channel_credentials*)creds)->call_creds, &sync.pops, context, &sync.md_array, &sync.on_request_metadata, diff --git a/test/core/security/secure_endpoint_test.c b/test/core/security/secure_endpoint_test.cc index b772c30956..11d1e5fcf4 100644 --- a/test/core/security/secure_endpoint_test.c +++ b/test/core/security/secure_endpoint_test.cc @@ -52,10 +52,11 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair( grpc_endpoint_test_fixture f; grpc_endpoint_pair tcp; - grpc_arg a[] = {{.key = GRPC_ARG_TCP_READ_CHUNK_SIZE, - .type = GRPC_ARG_INTEGER, - .value.integer = (int)slice_size}}; - grpc_channel_args args = {.num_args = GPR_ARRAY_SIZE(a), .args = a}; + grpc_arg a[1]; + a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE); + a[0].type = GRPC_ARG_INTEGER; + a[0].value.integer = (int)slice_size; + grpc_channel_args args = {GPR_ARRAY_SIZE(a), a}; tcp = grpc_iomgr_create_endpoint_pair("fixture", &args); grpc_endpoint_add_to_pollset(&exec_ctx, tcp.client, g_pollset); grpc_endpoint_add_to_pollset(&exec_ctx, tcp.server, g_pollset); diff --git a/test/core/security/security_connector_test.c b/test/core/security/security_connector_test.cc index a0c1e93532..a0c1e93532 100644 --- a/test/core/security/security_connector_test.c +++ b/test/core/security/security_connector_test.cc diff --git a/test/core/security/ssl_credentials_test.c b/test/core/security/ssl_credentials_test.cc index 76ee32b001..76ee32b001 100644 --- a/test/core/security/ssl_credentials_test.c +++ b/test/core/security/ssl_credentials_test.cc diff --git a/test/core/security/ssl_server_fuzzer.c b/test/core/security/ssl_server_fuzzer.cc index 7d6b3409b3..5c5153b505 100644 --- a/test/core/security/ssl_server_fuzzer.c +++ b/test/core/security/ssl_server_fuzzer.cc @@ -42,15 +42,16 @@ struct handshake_state { static void on_handshake_done(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { - grpc_handshaker_args* args = arg; - struct handshake_state* state = args->user_data; + grpc_handshaker_args* args = static_cast<grpc_handshaker_args*>(arg); + struct handshake_state* state = + static_cast<struct handshake_state*>(args->user_data); GPR_ASSERT(state->done_callback_called == false); state->done_callback_called = true; // The fuzzer should not pass the handshake. GPR_ASSERT(error != GRPC_ERROR_NONE); } -int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { struct grpc_memory_counters counters; if (squelch) gpr_set_log_function(dont_log); if (leak_check) grpc_memory_counters_init(); diff --git a/test/core/security/verify_jwt.c b/test/core/security/verify_jwt.cc index 08adb6e463..e0e22d16f9 100644 --- a/test/core/security/verify_jwt.c +++ b/test/core/security/verify_jwt.cc @@ -47,7 +47,7 @@ static void print_usage_and_exit(gpr_cmdline* cl, const char* argv0) { static void on_jwt_verification_done(grpc_exec_ctx* exec_ctx, void* user_data, grpc_jwt_verifier_status status, grpc_jwt_claims* claims) { - synchronizer* sync = user_data; + synchronizer* sync = static_cast<synchronizer*>(user_data); sync->success = (status == GRPC_JWT_VERIFIER_OK); if (sync->success) { @@ -75,8 +75,8 @@ int main(int argc, char** argv) { synchronizer sync; grpc_jwt_verifier* verifier; gpr_cmdline* cl; - char* jwt = NULL; - char* aud = NULL; + const char* jwt = NULL; + const char* aud = NULL; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_init(); @@ -92,7 +92,7 @@ int main(int argc, char** argv) { grpc_init(); - sync.pollset = gpr_zalloc(grpc_pollset_size()); + sync.pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(sync.pollset, &sync.mu); sync.is_done = 0; |