aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/security
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2017-10-23 15:33:21 -0700
committerGravatar Yash Tibrewal <yashkt@google.com>2017-10-25 16:23:01 -0700
commit34a57d0346afe95e11104462c30dc468b0cb0b89 (patch)
tree67db15f7b8b361e0618199dc55215f3b4d626201 /test/core/security
parentc563b583cb9b7fecc33971581368796d2df4759d (diff)
rename all test core files to cc and a lot of C++ style conversions
Diffstat (limited to 'test/core/security')
-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/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)7
-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_server_fuzzer.cc (renamed from test/core/security/ssl_server_fuzzer.c)5
-rw-r--r--test/core/security/verify_jwt.cc (renamed from test/core/security/verify_jwt.c)8
12 files changed, 33 insertions, 26 deletions
diff --git a/test/core/security/auth_context_test.c b/test/core/security/auth_context_test.cc
index 88daf28c99..88daf28c99 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 93ea27f425..2444dbeae7 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 34f310142c..dfc071b64a 100644
--- a/test/core/security/credentials_test.c
+++ b/test/core/security/credentials_test.cc
@@ -44,7 +44,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;
@@ -122,7 +123,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);
@@ -363,7 +364,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;
@@ -934,7 +936,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 3998cb51cd..1f1cf11545 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 6573f70e72..70661a111b 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 a4bfe0130e..b0b94ba250 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 73d6c5bc7d..73d6c5bc7d 100644
--- a/test/core/security/oauth2_utils.c
+++ b/test/core/security/oauth2_utils.cc
diff --git a/test/core/security/print_google_default_creds_token.c b/test/core/security/print_google_default_creds_token.cc
index 29c38dfdf8..81c992c4d6 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 839a05fa9b..fe7961d1d9 100644
--- a/test/core/security/secure_endpoint_test.c
+++ b/test/core/security/secure_endpoint_test.cc
@@ -52,9 +52,10 @@ 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_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 = {.num_args = GPR_ARRAY_SIZE(a), .args = a};
tcp = grpc_iomgr_create_endpoint_pair("fixture", &args);
grpc_endpoint_add_to_pollset(&exec_ctx, tcp.client, g_pollset);
diff --git a/test/core/security/security_connector_test.c b/test/core/security/security_connector_test.cc
index eecf0f462b..eecf0f462b 100644
--- a/test/core/security/security_connector_test.c
+++ b/test/core/security/security_connector_test.cc
diff --git a/test/core/security/ssl_server_fuzzer.c b/test/core/security/ssl_server_fuzzer.cc
index f9b754b8f2..9d43a416c3 100644
--- a/test/core/security/ssl_server_fuzzer.c
+++ b/test/core/security/ssl_server_fuzzer.cc
@@ -42,8 +42,9 @@ 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.
diff --git a/test/core/security/verify_jwt.c b/test/core/security/verify_jwt.cc
index cec6fb94b4..c6591cf546 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;