aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/security
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-11-03 09:09:36 -0700
committerGravatar Craig Tiller <ctiller@google.com>2017-11-03 09:09:36 -0700
commitbaa14a975ef92ee6fb301f0e684f56f18f2c55a7 (patch)
tree9a6cb2df58fe175e8abfccf2cbd40349726e46f3 /test/core/security
parentef68fe7239a89095f1eaa89c1dd28b2b7be2a3c7 (diff)
Update clang-format to 5.0
Diffstat (limited to 'test/core/security')
-rw-r--r--test/core/security/auth_context_test.c16
-rw-r--r--test/core/security/create_jwt.c18
-rw-r--r--test/core/security/credentials_test.c316
-rw-r--r--test/core/security/fetch_oauth2.c20
-rw-r--r--test/core/security/json_token_test.c98
-rw-r--r--test/core/security/jwt_verifier_test.c188
-rw-r--r--test/core/security/oauth2_utils.c28
-rw-r--r--test/core/security/oauth2_utils.h4
-rw-r--r--test/core/security/print_google_default_creds_token.c26
-rw-r--r--test/core/security/secure_endpoint_test.c38
-rw-r--r--test/core/security/security_connector_test.c84
-rw-r--r--test/core/security/ssl_credentials_test.c6
-rw-r--r--test/core/security/ssl_server_fuzzer.c30
-rw-r--r--test/core/security/verify_jwt.c30
14 files changed, 451 insertions, 451 deletions
diff --git a/test/core/security/auth_context_test.c b/test/core/security/auth_context_test.c
index 88daf28c99..3ab9190689 100644
--- a/test/core/security/auth_context_test.c
+++ b/test/core/security/auth_context_test.c
@@ -25,7 +25,7 @@
#include <grpc/support/log.h>
static void test_empty_context(void) {
- grpc_auth_context *ctx = grpc_auth_context_create(NULL);
+ grpc_auth_context* ctx = grpc_auth_context_create(NULL);
grpc_auth_property_iterator it;
gpr_log(GPR_INFO, "test_empty_context");
@@ -44,7 +44,7 @@ static void test_empty_context(void) {
}
static void test_simple_context(void) {
- grpc_auth_context *ctx = grpc_auth_context_create(NULL);
+ grpc_auth_context* ctx = grpc_auth_context_create(NULL);
grpc_auth_property_iterator it;
size_t i;
@@ -61,7 +61,7 @@ static void test_simple_context(void) {
strcmp(grpc_auth_context_peer_identity_property_name(ctx), "name") == 0);
it = grpc_auth_context_property_iterator(ctx);
for (i = 0; i < ctx->properties.count; i++) {
- const grpc_auth_property *p = grpc_auth_property_iterator_next(&it);
+ const grpc_auth_property* p = grpc_auth_property_iterator_next(&it);
GPR_ASSERT(p == &ctx->properties.array[i]);
}
GPR_ASSERT(grpc_auth_property_iterator_next(&it) == NULL);
@@ -82,8 +82,8 @@ static void test_simple_context(void) {
}
static void test_chained_context(void) {
- grpc_auth_context *chained = grpc_auth_context_create(NULL);
- grpc_auth_context *ctx = grpc_auth_context_create(chained);
+ grpc_auth_context* chained = grpc_auth_context_create(NULL);
+ grpc_auth_context* ctx = grpc_auth_context_create(chained);
grpc_auth_property_iterator it;
size_t i;
@@ -101,11 +101,11 @@ static void test_chained_context(void) {
strcmp(grpc_auth_context_peer_identity_property_name(ctx), "name") == 0);
it = grpc_auth_context_property_iterator(ctx);
for (i = 0; i < ctx->properties.count; i++) {
- const grpc_auth_property *p = grpc_auth_property_iterator_next(&it);
+ const grpc_auth_property* p = grpc_auth_property_iterator_next(&it);
GPR_ASSERT(p == &ctx->properties.array[i]);
}
for (i = 0; i < chained->properties.count; i++) {
- const grpc_auth_property *p = grpc_auth_property_iterator_next(&it);
+ const grpc_auth_property* p = grpc_auth_property_iterator_next(&it);
GPR_ASSERT(p == &chained->properties.array[i]);
}
GPR_ASSERT(grpc_auth_property_iterator_next(&it) == NULL);
@@ -129,7 +129,7 @@ static void test_chained_context(void) {
GRPC_AUTH_CONTEXT_UNREF(ctx, "test");
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_empty_context();
test_simple_context();
diff --git a/test/core/security/create_jwt.c b/test/core/security/create_jwt.c
index 93ea27f425..327179c9de 100644
--- a/test/core/security/create_jwt.c
+++ b/test/core/security/create_jwt.c
@@ -27,15 +27,15 @@
#include <grpc/support/cmdline.h>
#include <grpc/support/log.h>
-void create_jwt(const char *json_key_file_path, const char *service_url,
- const char *scope) {
+void create_jwt(const char* json_key_file_path, const char* service_url,
+ const char* scope) {
grpc_auth_json_key key;
- char *jwt;
+ char* jwt;
grpc_slice json_key_data;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"load_file", grpc_load_file(json_key_file_path, 1, &json_key_data)));
key = grpc_auth_json_key_create_from_string(
- (const char *)GRPC_SLICE_START_PTR(json_key_data));
+ (const char*)GRPC_SLICE_START_PTR(json_key_data));
grpc_slice_unref(json_key_data);
if (!grpc_auth_json_key_is_valid(&key)) {
fprintf(stderr, "Could not parse json key.\n");
@@ -53,12 +53,12 @@ void create_jwt(const char *json_key_file_path, const char *service_url,
gpr_free(jwt);
}
-int main(int argc, char **argv) {
- char *scope = NULL;
- char *json_key_file_path = NULL;
- char *service_url = NULL;
+int main(int argc, char** argv) {
+ char* scope = NULL;
+ char* json_key_file_path = NULL;
+ char* service_url = NULL;
grpc_init();
- gpr_cmdline *cl = gpr_cmdline_create("create_jwt");
+ gpr_cmdline* cl = gpr_cmdline_create("create_jwt");
gpr_cmdline_add_string(cl, "json_key", "File path of the json key.",
&json_key_file_path);
gpr_cmdline_add_string(cl, "scope",
diff --git a/test/core/security/credentials_test.c b/test/core/security/credentials_test.c
index 34f310142c..c6c7fa3b00 100644
--- a/test/core/security/credentials_test.c
+++ b/test/core/security/credentials_test.c
@@ -42,9 +42,9 @@
/* -- 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));
+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;
@@ -118,12 +118,12 @@ static const char test_method[] = "ThisIsNotAMethod";
/* -- Utils. -- */
-static char *test_json_key_str(void) {
+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 *current = result;
+ char* result = gpr_malloc(result_len + 1);
+ char* current = result;
strcpy(result, test_json_key_str_part1);
current += strlen(test_json_key_str_part1);
strcpy(current, test_json_key_str_part2);
@@ -132,11 +132,11 @@ static char *test_json_key_str(void) {
return result;
}
-static grpc_httpcli_response http_response(int status, const char *body) {
+static grpc_httpcli_response http_response(int status, const char* body) {
grpc_httpcli_response response;
memset(&response, 0, sizeof(grpc_httpcli_response));
response.status = status;
- response.body = gpr_strdup((char *)body);
+ response.body = gpr_strdup((char*)body);
response.body_length = strlen(body);
return response;
}
@@ -157,8 +157,8 @@ static void test_add_to_empty_md_array(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_credentials_mdelem_array md_array;
memset(&md_array, 0, sizeof(md_array));
- const char *key = "hello";
- const char *value = "there blah blah blah blah blah blah blah";
+ const char* key = "hello";
+ const char* value = "there blah blah blah blah blah blah blah";
grpc_mdelem md =
grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_copied_string(key),
grpc_slice_from_copied_string(value));
@@ -174,8 +174,8 @@ static void test_add_abunch_to_md_array(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_credentials_mdelem_array md_array;
memset(&md_array, 0, sizeof(md_array));
- const char *key = "hello";
- const char *value = "there blah blah blah blah blah blah blah";
+ const char* key = "hello";
+ const char* value = "there blah blah blah blah blah blah blah";
grpc_mdelem md =
grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_copied_string(key),
grpc_slice_from_copied_string(value));
@@ -299,22 +299,22 @@ static void test_oauth2_token_fetcher_creds_parsing_missing_token_lifetime(
}
typedef struct {
- const char *key;
- const char *value;
+ const char* key;
+ const char* value;
} expected_md;
typedef struct {
- grpc_error *expected_error;
- const expected_md *expected;
+ grpc_error* expected_error;
+ const expected_md* expected;
size_t expected_size;
grpc_credentials_mdelem_array md_array;
grpc_closure on_request_metadata;
- grpc_call_credentials *creds;
+ grpc_call_credentials* creds;
grpc_polling_entity pollent;
} request_metadata_state;
-static void check_metadata(const expected_md *expected,
- grpc_credentials_mdelem_array *md_array) {
+static void check_metadata(const expected_md* expected,
+ grpc_credentials_mdelem_array* md_array) {
for (size_t i = 0; i < md_array->size; ++i) {
size_t j;
for (j = 0; j < md_array->size; ++j) {
@@ -332,9 +332,9 @@ static void check_metadata(const expected_md *expected,
}
}
-static void check_request_metadata(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- request_metadata_state *state = (request_metadata_state *)arg;
+static void check_request_metadata(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error) {
+ request_metadata_state* state = (request_metadata_state*)arg;
gpr_log(GPR_INFO, "expected_error: %s",
grpc_error_string(state->expected_error));
gpr_log(GPR_INFO, "actual_error: %s", grpc_error_string(error));
@@ -360,10 +360,10 @@ static void check_request_metadata(grpc_exec_ctx *exec_ctx, void *arg,
gpr_free(state);
}
-static request_metadata_state *make_request_metadata_state(
- grpc_error *expected_error, const expected_md *expected,
+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 = gpr_zalloc(sizeof(*state));
state->expected_error = expected_error;
state->expected = expected;
state->expected_size = expected_size;
@@ -374,11 +374,11 @@ static request_metadata_state *make_request_metadata_state(
return state;
}
-static void run_request_metadata_test(grpc_exec_ctx *exec_ctx,
- grpc_call_credentials *creds,
+static void run_request_metadata_test(grpc_exec_ctx* exec_ctx,
+ grpc_call_credentials* creds,
grpc_auth_metadata_context auth_md_ctx,
- request_metadata_state *state) {
- grpc_error *error = GRPC_ERROR_NONE;
+ request_metadata_state* state) {
+ grpc_error* error = GRPC_ERROR_NONE;
if (grpc_call_credentials_get_request_metadata(
exec_ctx, creds, &state->pollent, auth_md_ctx, &state->md_array,
&state->on_request_metadata, &error)) {
@@ -394,9 +394,9 @@ static void test_google_iam_creds(void) {
test_google_iam_authorization_token},
{GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY,
test_google_iam_authority_selector}};
- request_metadata_state *state =
+ request_metadata_state* state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
- grpc_call_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);
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
@@ -409,9 +409,9 @@ static void test_google_iam_creds(void) {
static void test_access_token_creds(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
expected_md emd[] = {{GRPC_AUTHORIZATION_METADATA_KEY, "Bearer blah"}};
- request_metadata_state *state =
+ request_metadata_state* state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
- grpc_call_credentials *creds =
+ grpc_call_credentials* creds =
grpc_access_token_credentials_create("blah", NULL);
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
NULL};
@@ -422,10 +422,10 @@ static void test_access_token_creds(void) {
}
static grpc_security_status check_channel_oauth2_create_security_connector(
- grpc_exec_ctx *exec_ctx, 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) {
+ grpc_exec_ctx* exec_ctx, 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);
@@ -434,14 +434,14 @@ static grpc_security_status check_channel_oauth2_create_security_connector(
static void test_channel_oauth2_composite_creds(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args *new_args;
+ grpc_channel_args* new_args;
grpc_channel_credentials_vtable vtable = {
NULL, check_channel_oauth2_create_security_connector, NULL};
- grpc_channel_credentials *channel_creds =
+ grpc_channel_credentials* channel_creds =
grpc_mock_channel_credentials_create(&vtable);
- grpc_call_credentials *oauth2_creds =
+ grpc_call_credentials* oauth2_creds =
grpc_access_token_credentials_create("blah", NULL);
- grpc_channel_credentials *channel_oauth2_creds =
+ grpc_channel_credentials* channel_oauth2_creds =
grpc_composite_channel_credentials_create(channel_creds, oauth2_creds,
NULL);
grpc_channel_credentials_release(channel_creds);
@@ -461,23 +461,23 @@ static void test_oauth2_google_iam_composite_creds(void) {
test_google_iam_authorization_token},
{GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY,
test_google_iam_authority_selector}};
- request_metadata_state *state =
+ request_metadata_state* state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
NULL};
- grpc_call_credentials *oauth2_creds = grpc_md_only_test_credentials_create(
+ grpc_call_credentials* oauth2_creds = grpc_md_only_test_credentials_create(
&exec_ctx, "authorization", test_oauth2_bearer_token, 0);
- grpc_call_credentials *google_iam_creds = grpc_google_iam_credentials_create(
+ grpc_call_credentials* google_iam_creds = grpc_google_iam_credentials_create(
test_google_iam_authorization_token, test_google_iam_authority_selector,
NULL);
- grpc_call_credentials *composite_creds =
+ grpc_call_credentials* composite_creds =
grpc_composite_call_credentials_create(oauth2_creds, google_iam_creds,
NULL);
grpc_call_credentials_unref(&exec_ctx, oauth2_creds);
grpc_call_credentials_unref(&exec_ctx, google_iam_creds);
GPR_ASSERT(
strcmp(composite_creds->type, GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE) == 0);
- const grpc_call_credentials_array *creds_array =
+ const grpc_call_credentials_array* 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,
@@ -491,11 +491,11 @@ static void test_oauth2_google_iam_composite_creds(void) {
static grpc_security_status
check_channel_oauth2_google_iam_create_security_connector(
- grpc_exec_ctx *exec_ctx, 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;
+ grpc_exec_ctx* exec_ctx, 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) ==
@@ -510,20 +510,20 @@ check_channel_oauth2_google_iam_create_security_connector(
static void test_channel_oauth2_google_iam_composite_creds(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_args *new_args;
+ grpc_channel_args* new_args;
grpc_channel_credentials_vtable vtable = {
NULL, check_channel_oauth2_google_iam_create_security_connector, NULL};
- grpc_channel_credentials *channel_creds =
+ grpc_channel_credentials* channel_creds =
grpc_mock_channel_credentials_create(&vtable);
- grpc_call_credentials *oauth2_creds =
+ grpc_call_credentials* oauth2_creds =
grpc_access_token_credentials_create("blah", NULL);
- grpc_channel_credentials *channel_oauth2_creds =
+ 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(
+ 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_channel_credentials* channel_oauth2_iam_creds =
grpc_composite_channel_credentials_create(channel_oauth2_creds,
google_iam_creds, NULL);
grpc_channel_credentials_release(channel_creds);
@@ -540,7 +540,7 @@ static void test_channel_oauth2_google_iam_composite_creds(void) {
}
static void validate_compute_engine_http_request(
- const grpc_httpcli_request *request) {
+ const grpc_httpcli_request* request) {
GPR_ASSERT(request->handshaker != &grpc_httpcli_ssl);
GPR_ASSERT(strcmp(request->host, "metadata.google.internal") == 0);
GPR_ASSERT(
@@ -553,9 +553,9 @@ static void validate_compute_engine_http_request(
}
static int compute_engine_httpcli_get_success_override(
- grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
- grpc_millis deadline, grpc_closure *on_done,
- grpc_httpcli_response *response) {
+ grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
+ grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
validate_compute_engine_http_request(request);
*response = http_response(200, valid_oauth2_json_response);
GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
@@ -563,9 +563,9 @@ static int compute_engine_httpcli_get_success_override(
}
static int compute_engine_httpcli_get_failure_override(
- grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
- grpc_millis deadline, grpc_closure *on_done,
- grpc_httpcli_response *response) {
+ grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
+ grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
validate_compute_engine_http_request(request);
*response = http_response(403, "Not Authorized.");
GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
@@ -573,18 +573,18 @@ static int compute_engine_httpcli_get_failure_override(
}
static int httpcli_post_should_not_be_called(
- grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
- const char *body_bytes, size_t body_size, grpc_millis deadline,
- grpc_closure *on_done, grpc_httpcli_response *response) {
+ grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
+ const char* body_bytes, size_t body_size, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
GPR_ASSERT("HTTP POST should not be called" == NULL);
return 1;
}
-static int httpcli_get_should_not_be_called(grpc_exec_ctx *exec_ctx,
- const grpc_httpcli_request *request,
+static int httpcli_get_should_not_be_called(grpc_exec_ctx* exec_ctx,
+ const grpc_httpcli_request* request,
grpc_millis deadline,
- grpc_closure *on_done,
- grpc_httpcli_response *response) {
+ grpc_closure* on_done,
+ grpc_httpcli_response* response) {
GPR_ASSERT("HTTP GET should not be called" == NULL);
return 1;
}
@@ -593,13 +593,13 @@ static void test_compute_engine_creds_success(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
expected_md emd[] = {
{"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}};
- grpc_call_credentials *creds =
+ grpc_call_credentials* creds =
grpc_google_compute_engine_credentials_create(NULL);
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
NULL};
/* First request: http get should be called. */
- request_metadata_state *state =
+ request_metadata_state* state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_httpcli_set_override(compute_engine_httpcli_get_success_override,
httpcli_post_should_not_be_called);
@@ -621,13 +621,13 @@ static void test_compute_engine_creds_success(void) {
static void test_compute_engine_creds_failure(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- request_metadata_state *state = make_request_metadata_state(
+ request_metadata_state* state = make_request_metadata_state(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Error occured when fetching oauth2 token."),
NULL, 0);
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
NULL};
- grpc_call_credentials *creds =
+ grpc_call_credentials* creds =
grpc_google_compute_engine_credentials_create(NULL);
grpc_httpcli_set_override(compute_engine_httpcli_get_failure_override,
httpcli_post_should_not_be_called);
@@ -638,9 +638,9 @@ static void test_compute_engine_creds_failure(void) {
}
static void validate_refresh_token_http_request(
- const grpc_httpcli_request *request, const char *body, size_t body_size) {
+ const grpc_httpcli_request* request, const char* body, size_t body_size) {
/* The content of the assertion is tested extensively in json_token_test. */
- char *expected_body = NULL;
+ char* expected_body = NULL;
GPR_ASSERT(body != NULL);
GPR_ASSERT(body_size != 0);
gpr_asprintf(&expected_body, GRPC_REFRESH_TOKEN_POST_BODY_FORMAT_STRING,
@@ -661,9 +661,9 @@ static void validate_refresh_token_http_request(
}
static int refresh_token_httpcli_post_success(
- grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
- const char *body, size_t body_size, grpc_millis deadline,
- grpc_closure *on_done, grpc_httpcli_response *response) {
+ grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
+ const char* body, size_t body_size, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
validate_refresh_token_http_request(request, body, body_size);
*response = http_response(200, valid_oauth2_json_response);
GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
@@ -671,9 +671,9 @@ static int refresh_token_httpcli_post_success(
}
static int refresh_token_httpcli_post_failure(
- grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
- const char *body, size_t body_size, grpc_millis deadline,
- grpc_closure *on_done, grpc_httpcli_response *response) {
+ grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
+ const char* body, size_t body_size, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
validate_refresh_token_http_request(request, body, body_size);
*response = http_response(403, "Not Authorized.");
GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
@@ -686,11 +686,11 @@ static void test_refresh_token_creds_success(void) {
{"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}};
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
NULL};
- grpc_call_credentials *creds = grpc_google_refresh_token_credentials_create(
+ grpc_call_credentials* creds = grpc_google_refresh_token_credentials_create(
test_refresh_token_str, NULL);
/* First request: http get should be called. */
- request_metadata_state *state =
+ request_metadata_state* state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
refresh_token_httpcli_post_success);
@@ -712,13 +712,13 @@ static void test_refresh_token_creds_success(void) {
static void test_refresh_token_creds_failure(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- request_metadata_state *state = make_request_metadata_state(
+ request_metadata_state* state = make_request_metadata_state(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Error occured when fetching oauth2 token."),
NULL, 0);
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
NULL};
- grpc_call_credentials *creds = grpc_google_refresh_token_credentials_create(
+ grpc_call_credentials* 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);
@@ -729,7 +729,7 @@ static void test_refresh_token_creds_failure(void) {
}
static void validate_jwt_encode_and_sign_params(
- const grpc_auth_json_key *json_key, const char *scope,
+ const grpc_auth_json_key* json_key, const char* scope,
gpr_timespec token_lifetime) {
GPR_ASSERT(grpc_auth_json_key_is_valid(json_key));
GPR_ASSERT(json_key->private_key != NULL);
@@ -751,41 +751,41 @@ static void validate_jwt_encode_and_sign_params(
GPR_ASSERT(!gpr_time_cmp(token_lifetime, grpc_max_auth_token_lifetime()));
}
-static char *encode_and_sign_jwt_success(const grpc_auth_json_key *json_key,
- const char *audience,
+static char* encode_and_sign_jwt_success(const grpc_auth_json_key* json_key,
+ const char* audience,
gpr_timespec token_lifetime,
- const char *scope) {
+ const char* scope) {
validate_jwt_encode_and_sign_params(json_key, scope, token_lifetime);
return gpr_strdup(test_signed_jwt);
}
-static char *encode_and_sign_jwt_failure(const grpc_auth_json_key *json_key,
- const char *audience,
+static char* encode_and_sign_jwt_failure(const grpc_auth_json_key* json_key,
+ const char* audience,
gpr_timespec token_lifetime,
- const char *scope) {
+ const char* scope) {
validate_jwt_encode_and_sign_params(json_key, scope, token_lifetime);
return NULL;
}
-static char *encode_and_sign_jwt_should_not_be_called(
- const grpc_auth_json_key *json_key, const char *audience,
- gpr_timespec token_lifetime, const char *scope) {
+static char* encode_and_sign_jwt_should_not_be_called(
+ const grpc_auth_json_key* json_key, const char* audience,
+ gpr_timespec token_lifetime, const char* scope) {
GPR_ASSERT("grpc_jwt_encode_and_sign should not be called" == NULL);
return NULL;
}
-static grpc_service_account_jwt_access_credentials *creds_as_jwt(
- grpc_call_credentials *creds) {
+static grpc_service_account_jwt_access_credentials* creds_as_jwt(
+ grpc_call_credentials* creds) {
GPR_ASSERT(creds != NULL);
GPR_ASSERT(strcmp(creds->type, GRPC_CALL_CREDENTIALS_TYPE_JWT) == 0);
- return (grpc_service_account_jwt_access_credentials *)creds;
+ return (grpc_service_account_jwt_access_credentials*)creds;
}
static void test_jwt_creds_lifetime(void) {
- char *json_key_string = test_json_key_str();
+ char* json_key_string = test_json_key_str();
// Max lifetime.
- grpc_call_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(gpr_time_cmp(creds_as_jwt(jwt_creds)->jwt_lifetime,
@@ -814,19 +814,19 @@ static void test_jwt_creds_lifetime(void) {
}
static void test_jwt_creds_success(void) {
- char *json_key_string = test_json_key_str();
+ char* json_key_string = test_json_key_str();
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
NULL};
- char *expected_md_value;
+ char* expected_md_value;
gpr_asprintf(&expected_md_value, "Bearer %s", test_signed_jwt);
expected_md emd[] = {{"authorization", expected_md_value}};
- grpc_call_credentials *creds =
+ grpc_call_credentials* creds =
grpc_service_account_jwt_access_credentials_create(
json_key_string, grpc_max_auth_token_lifetime(), NULL);
/* First request: jwt_encode_and_sign should be called. */
- request_metadata_state *state =
+ request_metadata_state* state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_jwt_encode_and_sign_set_override(encode_and_sign_jwt_success);
run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
@@ -857,13 +857,13 @@ static void test_jwt_creds_success(void) {
}
static void test_jwt_creds_signing_failure(void) {
- char *json_key_string = test_json_key_str();
+ char* json_key_string = test_json_key_str();
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
NULL};
- request_metadata_state *state = make_request_metadata_state(
+ request_metadata_state* state = make_request_metadata_state(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Could not generate JWT."), NULL, 0);
- grpc_call_credentials *creds =
+ grpc_call_credentials* creds =
grpc_service_account_jwt_access_credentials_create(
json_key_string, grpc_max_auth_token_lifetime(), NULL);
@@ -877,10 +877,10 @@ static void test_jwt_creds_signing_failure(void) {
}
static void set_google_default_creds_env_var_with_file_contents(
- const char *file_prefix, const char *contents) {
+ const char* file_prefix, const char* contents) {
size_t contents_len = strlen(contents);
- char *creds_file_name;
- FILE *creds_file = gpr_tmpfile(file_prefix, &creds_file_name);
+ char* creds_file_name;
+ FILE* creds_file = gpr_tmpfile(file_prefix, &creds_file_name);
GPR_ASSERT(creds_file_name != NULL);
GPR_ASSERT(creds_file != NULL);
GPR_ASSERT(fwrite(contents, 1, contents_len, creds_file) == contents_len);
@@ -891,17 +891,17 @@ static void set_google_default_creds_env_var_with_file_contents(
static void test_google_default_creds_auth_key(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_service_account_jwt_access_credentials *jwt;
- grpc_composite_channel_credentials *creds;
- char *json_key = test_json_key_str();
+ grpc_service_account_jwt_access_credentials* jwt;
+ 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_composite_channel_credentials *)
+ creds = (grpc_composite_channel_credentials*)
grpc_google_default_credentials_create();
GPR_ASSERT(creds != NULL);
- jwt = (grpc_service_account_jwt_access_credentials *)creds->call_creds;
+ jwt = (grpc_service_account_jwt_access_credentials*)creds->call_creds;
GPR_ASSERT(
strcmp(jwt->key.client_id,
"777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent.com") ==
@@ -913,15 +913,15 @@ static void test_google_default_creds_auth_key(void) {
static void test_google_default_creds_refresh_token(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_google_refresh_token_credentials *refresh;
- grpc_composite_channel_credentials *creds;
+ grpc_google_refresh_token_credentials* refresh;
+ 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_composite_channel_credentials *)
+ creds = (grpc_composite_channel_credentials*)
grpc_google_default_credentials_create();
GPR_ASSERT(creds != NULL);
- refresh = (grpc_google_refresh_token_credentials *)creds->call_creds;
+ refresh = (grpc_google_refresh_token_credentials*)creds->call_creds;
GPR_ASSERT(strcmp(refresh->refresh_token.client_id,
"32555999999.apps.googleusercontent.com") == 0);
grpc_channel_credentials_unref(&exec_ctx, &creds->base);
@@ -930,11 +930,11 @@ static void test_google_default_creds_refresh_token(void) {
}
static int default_creds_gce_detection_httpcli_get_success_override(
- grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
- grpc_millis deadline, grpc_closure *on_done,
- grpc_httpcli_response *response) {
+ grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
+ 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 = gpr_malloc(sizeof(*headers) * 1);
headers[0].key = gpr_strdup("Metadata-Flavor");
headers[0].value = gpr_strdup("Google");
response->hdr_count = 1;
@@ -945,13 +945,13 @@ static int default_creds_gce_detection_httpcli_get_success_override(
return 1;
}
-static char *null_well_known_creds_path_getter(void) { return NULL; }
+static char* null_well_known_creds_path_getter(void) { return NULL; }
static void test_google_default_creds_gce(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
expected_md emd[] = {
{"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}};
- request_metadata_state *state =
+ request_metadata_state* state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
NULL};
@@ -964,8 +964,8 @@ static void test_google_default_creds_gce(void) {
grpc_httpcli_set_override(
default_creds_gce_detection_httpcli_get_success_override,
httpcli_post_should_not_be_called);
- grpc_composite_channel_credentials *creds =
- (grpc_composite_channel_credentials *)
+ grpc_composite_channel_credentials* creds =
+ (grpc_composite_channel_credentials*)
grpc_google_default_credentials_create();
/* Verify that the default creds actually embeds a GCE creds. */
@@ -981,7 +981,7 @@ static void test_google_default_creds_gce(void) {
GCE detection should not occur anymore either. */
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
httpcli_post_should_not_be_called);
- grpc_channel_credentials *cached_creds =
+ grpc_channel_credentials* cached_creds =
grpc_google_default_credentials_create();
GPR_ASSERT(cached_creds == &creds->base);
@@ -994,9 +994,9 @@ static void test_google_default_creds_gce(void) {
}
static int default_creds_gce_detection_httpcli_get_failure_override(
- grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
- grpc_millis deadline, grpc_closure *on_done,
- grpc_httpcli_response *response) {
+ grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
+ grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
/* No magic header. */
GPR_ASSERT(strcmp(request->http.path, "/") == 0);
GPR_ASSERT(strcmp(request->host, "metadata.google.internal") == 0);
@@ -1036,18 +1036,18 @@ typedef enum {
static const expected_md plugin_md[] = {{"foo", "bar"}, {"hi", "there"}};
static int plugin_get_metadata_success(
- void *state, grpc_auth_metadata_context context,
- grpc_credentials_plugin_metadata_cb cb, void *user_data,
+ void* state, grpc_auth_metadata_context context,
+ grpc_credentials_plugin_metadata_cb cb, void* user_data,
grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
- size_t *num_creds_md, grpc_status_code *status,
- const char **error_details) {
+ size_t* num_creds_md, grpc_status_code* status,
+ const char** error_details) {
GPR_ASSERT(strcmp(context.service_url, test_service_url) == 0);
GPR_ASSERT(strcmp(context.method_name, test_method) == 0);
GPR_ASSERT(context.channel_auth_context == NULL);
GPR_ASSERT(context.reserved == NULL);
GPR_ASSERT(GPR_ARRAY_SIZE(plugin_md) <
GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX);
- plugin_state *s = (plugin_state *)state;
+ plugin_state* s = (plugin_state*)state;
*s = PLUGIN_GET_METADATA_CALLED_STATE;
for (size_t i = 0; i < GPR_ARRAY_SIZE(plugin_md); ++i) {
memset(&creds_md[i], 0, sizeof(grpc_metadata));
@@ -1058,27 +1058,27 @@ static int plugin_get_metadata_success(
return true; // Synchronous return.
}
-static const char *plugin_error_details = "Could not get metadata for plugin.";
+static const char* plugin_error_details = "Could not get metadata for plugin.";
static int plugin_get_metadata_failure(
- void *state, grpc_auth_metadata_context context,
- grpc_credentials_plugin_metadata_cb cb, void *user_data,
+ void* state, grpc_auth_metadata_context context,
+ grpc_credentials_plugin_metadata_cb cb, void* user_data,
grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
- size_t *num_creds_md, grpc_status_code *status,
- const char **error_details) {
+ size_t* num_creds_md, grpc_status_code* status,
+ const char** error_details) {
GPR_ASSERT(strcmp(context.service_url, test_service_url) == 0);
GPR_ASSERT(strcmp(context.method_name, test_method) == 0);
GPR_ASSERT(context.channel_auth_context == NULL);
GPR_ASSERT(context.reserved == NULL);
- plugin_state *s = (plugin_state *)state;
+ plugin_state* s = (plugin_state*)state;
*s = PLUGIN_GET_METADATA_CALLED_STATE;
*status = GRPC_STATUS_UNAUTHENTICATED;
*error_details = gpr_strdup(plugin_error_details);
return true; // Synchronous return.
}
-static void plugin_destroy(void *state) {
- plugin_state *s = (plugin_state *)state;
+static void plugin_destroy(void* state) {
+ plugin_state* s = (plugin_state*)state;
*s = PLUGIN_DESTROY_CALLED_STATE;
}
@@ -1088,14 +1088,14 @@ static void test_metadata_plugin_success(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
NULL};
- request_metadata_state *md_state = make_request_metadata_state(
+ request_metadata_state* md_state = make_request_metadata_state(
GRPC_ERROR_NONE, plugin_md, GPR_ARRAY_SIZE(plugin_md));
plugin.state = &state;
plugin.get_metadata = plugin_get_metadata_success;
plugin.destroy = plugin_destroy;
- grpc_call_credentials *creds =
+ grpc_call_credentials* creds =
grpc_metadata_credentials_create_from_plugin(plugin, NULL);
GPR_ASSERT(state == PLUGIN_INITIAL_STATE);
run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, md_state);
@@ -1111,11 +1111,11 @@ static void test_metadata_plugin_failure(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
NULL};
- char *expected_error;
+ char* expected_error;
gpr_asprintf(&expected_error,
"Getting metadata from plugin failed with error: %s",
plugin_error_details);
- request_metadata_state *md_state = make_request_metadata_state(
+ request_metadata_state* md_state = make_request_metadata_state(
GRPC_ERROR_CREATE_FROM_COPIED_STRING(expected_error), NULL, 0);
gpr_free(expected_error);
@@ -1123,7 +1123,7 @@ static void test_metadata_plugin_failure(void) {
plugin.get_metadata = plugin_get_metadata_failure;
plugin.destroy = plugin_destroy;
- grpc_call_credentials *creds =
+ grpc_call_credentials* creds =
grpc_metadata_credentials_create_from_plugin(plugin, NULL);
GPR_ASSERT(state == PLUGIN_INITIAL_STATE);
run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, md_state);
@@ -1134,8 +1134,8 @@ static void test_metadata_plugin_failure(void) {
}
static void test_get_well_known_google_credentials_file_path(void) {
- char *path;
- char *home = gpr_getenv("HOME");
+ char* path;
+ char* home = gpr_getenv("HOME");
path = grpc_get_well_known_google_credentials_file_path();
GPR_ASSERT(path != NULL);
gpr_free(path);
@@ -1152,18 +1152,18 @@ static void test_get_well_known_google_credentials_file_path(void) {
static void test_channel_creds_duplicate_without_call_creds(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_credentials *channel_creds =
+ grpc_channel_credentials* channel_creds =
grpc_fake_transport_security_credentials_create();
- grpc_channel_credentials *dup =
+ grpc_channel_credentials* dup =
grpc_channel_credentials_duplicate_without_call_credentials(
channel_creds);
GPR_ASSERT(dup == channel_creds);
grpc_channel_credentials_unref(&exec_ctx, dup);
- grpc_call_credentials *call_creds =
+ grpc_call_credentials* call_creds =
grpc_access_token_credentials_create("blah", NULL);
- grpc_channel_credentials *composite_creds =
+ grpc_channel_credentials* composite_creds =
grpc_composite_channel_credentials_create(channel_creds, call_creds,
NULL);
grpc_call_credentials_unref(&exec_ctx, call_creds);
@@ -1178,7 +1178,7 @@ static void test_channel_creds_duplicate_without_call_creds(void) {
grpc_exec_ctx_finish(&exec_ctx);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_empty_md_array();
diff --git a/test/core/security/fetch_oauth2.c b/test/core/security/fetch_oauth2.c
index 3998cb51cd..42f68fc7d1 100644
--- a/test/core/security/fetch_oauth2.c
+++ b/test/core/security/fetch_oauth2.c
@@ -31,24 +31,24 @@
#include "src/core/lib/security/credentials/credentials.h"
#include "test/core/security/oauth2_utils.h"
-static grpc_call_credentials *create_refresh_token_creds(
- const char *json_refresh_token_file_path) {
+static grpc_call_credentials* create_refresh_token_creds(
+ const char* json_refresh_token_file_path) {
grpc_slice refresh_token;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"load_file",
grpc_load_file(json_refresh_token_file_path, 1, &refresh_token)));
return grpc_google_refresh_token_credentials_create(
- (const char *)GRPC_SLICE_START_PTR(refresh_token), NULL);
+ (const char*)GRPC_SLICE_START_PTR(refresh_token), NULL);
}
-int main(int argc, char **argv) {
- grpc_call_credentials *creds = NULL;
- char *json_key_file_path = NULL;
- char *json_refresh_token_file_path = NULL;
- char *token = NULL;
+int main(int argc, char** argv) {
+ grpc_call_credentials* creds = NULL;
+ char* json_key_file_path = NULL;
+ char* json_refresh_token_file_path = NULL;
+ char* token = NULL;
int use_gce = 0;
- char *scope = NULL;
- gpr_cmdline *cl = gpr_cmdline_create("fetch_oauth2");
+ char* scope = NULL;
+ gpr_cmdline* cl = gpr_cmdline_create("fetch_oauth2");
gpr_cmdline_add_string(cl, "json_refresh_token",
"File path of the json refresh token.",
&json_refresh_token_file_path);
diff --git a/test/core/security/json_token_test.c b/test/core/security/json_token_test.c
index 6573f70e72..4159367abe 100644
--- a/test/core/security/json_token_test.c
+++ b/test/core/security/json_token_test.c
@@ -77,12 +77,12 @@ static const char test_scope[] = "myperm1 myperm2";
static const char test_service_url[] = "https://foo.com/foo.v1";
-static char *test_json_key_str(const char *bad_part3) {
- const char *part3 = bad_part3 != NULL ? bad_part3 : test_json_key_str_part3;
+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 *current = result;
+ char* result = gpr_malloc(result_len + 1);
+ char* current = result;
strcpy(result, test_json_key_str_part1);
current += strlen(test_json_key_str_part1);
strcpy(current, test_json_key_str_part2);
@@ -92,7 +92,7 @@ static char *test_json_key_str(const char *bad_part3) {
}
static void test_parse_json_key_success(void) {
- char *json_string = test_json_key_str(NULL);
+ char* json_string = test_json_key_str(NULL);
grpc_auth_json_key json_key =
grpc_auth_json_key_create_from_string(json_string);
GPR_ASSERT(grpc_auth_json_key_is_valid(&json_key));
@@ -122,7 +122,7 @@ static void test_parse_json_key_failure_bad_json(void) {
"com\", \"client_id\": "
"\"777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent."
"com\", \"type\": \"service_account\" ";
- char *json_string = test_json_key_str(non_closing_part3);
+ char* json_string = test_json_key_str(non_closing_part3);
grpc_auth_json_key json_key =
grpc_auth_json_key_create_from_string(json_string);
GPR_ASSERT(!grpc_auth_json_key_is_valid(&json_key));
@@ -138,7 +138,7 @@ static void test_parse_json_key_failure_no_type(void) {
"com\", \"client_id\": "
"\"777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent."
"com\" }";
- char *json_string = test_json_key_str(no_type_part3);
+ char* json_string = test_json_key_str(no_type_part3);
grpc_auth_json_key json_key =
grpc_auth_json_key_create_from_string(json_string);
GPR_ASSERT(!grpc_auth_json_key_is_valid(&json_key));
@@ -153,7 +153,7 @@ static void test_parse_json_key_failure_no_client_id(void) {
"\"777-abaslkan11hlb6nmim3bpspl31ud@developer.gserviceaccount."
"com\", "
"\"type\": \"service_account\" }";
- char *json_string = test_json_key_str(no_client_id_part3);
+ char* json_string = test_json_key_str(no_client_id_part3);
grpc_auth_json_key json_key =
grpc_auth_json_key_create_from_string(json_string);
GPR_ASSERT(!grpc_auth_json_key_is_valid(&json_key));
@@ -167,7 +167,7 @@ static void test_parse_json_key_failure_no_client_email(void) {
"\"client_id\": "
"\"777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent."
"com\", \"type\": \"service_account\" }";
- char *json_string = test_json_key_str(no_client_email_part3);
+ char* json_string = test_json_key_str(no_client_email_part3);
grpc_auth_json_key json_key =
grpc_auth_json_key_create_from_string(json_string);
GPR_ASSERT(!grpc_auth_json_key_is_valid(&json_key));
@@ -182,7 +182,7 @@ static void test_parse_json_key_failure_no_private_key_id(void) {
"com\", \"client_id\": "
"\"777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent."
"com\", \"type\": \"service_account\" }";
- char *json_string = test_json_key_str(no_private_key_id_part3);
+ char* json_string = test_json_key_str(no_private_key_id_part3);
grpc_auth_json_key json_key =
grpc_auth_json_key_create_from_string(json_string);
GPR_ASSERT(!grpc_auth_json_key_is_valid(&json_key));
@@ -204,12 +204,12 @@ static void test_parse_json_key_failure_no_private_key(void) {
grpc_auth_json_key_destruct(&json_key);
}
-static grpc_json *parse_json_part_from_jwt(const char *str, size_t len,
- char **scratchpad) {
+static grpc_json* parse_json_part_from_jwt(const char* str, size_t len,
+ char** scratchpad) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- char *b64;
- char *decoded;
- grpc_json *json;
+ char* b64;
+ char* decoded;
+ grpc_json* json;
grpc_slice slice;
b64 = gpr_malloc(len + 1);
strncpy(b64, str, len);
@@ -217,7 +217,7 @@ static grpc_json *parse_json_part_from_jwt(const char *str, size_t len,
slice = grpc_base64_decode(&exec_ctx, b64, 1);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(slice));
decoded = gpr_malloc(GRPC_SLICE_LENGTH(slice) + 1);
- strncpy(decoded, (const char *)GRPC_SLICE_START_PTR(slice),
+ strncpy(decoded, (const char*)GRPC_SLICE_START_PTR(slice),
GRPC_SLICE_LENGTH(slice));
decoded[GRPC_SLICE_LENGTH(slice)] = '\0';
json = grpc_json_parse_string(decoded);
@@ -228,11 +228,11 @@ static grpc_json *parse_json_part_from_jwt(const char *str, size_t len,
return json;
}
-static void check_jwt_header(grpc_json *header) {
- grpc_json *ptr;
- grpc_json *alg = NULL;
- grpc_json *typ = NULL;
- grpc_json *kid = NULL;
+static void check_jwt_header(grpc_json* header) {
+ grpc_json* ptr;
+ grpc_json* alg = NULL;
+ grpc_json* typ = NULL;
+ grpc_json* kid = NULL;
for (ptr = header->child; ptr; ptr = ptr->next) {
if (strcmp(ptr->key, "alg") == 0) {
@@ -257,18 +257,18 @@ static void check_jwt_header(grpc_json *header) {
0);
}
-static void check_jwt_claim(grpc_json *claim, const char *expected_audience,
- const char *expected_scope) {
+static void check_jwt_claim(grpc_json* claim, const char* expected_audience,
+ const char* expected_scope) {
gpr_timespec expiration = gpr_time_0(GPR_CLOCK_REALTIME);
gpr_timespec issue_time = gpr_time_0(GPR_CLOCK_REALTIME);
gpr_timespec parsed_lifetime;
- grpc_json *iss = NULL;
- grpc_json *scope = NULL;
- grpc_json *aud = NULL;
- grpc_json *exp = NULL;
- grpc_json *iat = NULL;
- grpc_json *sub = NULL;
- grpc_json *ptr;
+ grpc_json* iss = NULL;
+ grpc_json* scope = NULL;
+ grpc_json* aud = NULL;
+ grpc_json* exp = NULL;
+ grpc_json* iat = NULL;
+ grpc_json* sub = NULL;
+ grpc_json* ptr;
for (ptr = claim->child; ptr; ptr = ptr->next) {
if (strcmp(ptr->key, "iss") == 0) {
@@ -323,13 +323,13 @@ static void check_jwt_claim(grpc_json *claim, const char *expected_audience,
GPR_ASSERT(parsed_lifetime.tv_sec == grpc_max_auth_token_lifetime().tv_sec);
}
-static void check_jwt_signature(const char *b64_signature, RSA *rsa_key,
- const char *signed_data,
+static void check_jwt_signature(const char* b64_signature, RSA* rsa_key,
+ const char* signed_data,
size_t signed_data_size) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- EVP_MD_CTX *md_ctx = EVP_MD_CTX_create();
- EVP_PKEY *key = EVP_PKEY_new();
+ EVP_MD_CTX* md_ctx = EVP_MD_CTX_create();
+ EVP_PKEY* key = EVP_PKEY_new();
grpc_slice sig = grpc_base64_decode(&exec_ctx, b64_signature, 1);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(sig));
@@ -352,38 +352,38 @@ static void check_jwt_signature(const char *b64_signature, RSA *rsa_key,
grpc_exec_ctx_finish(&exec_ctx);
}
-static char *service_account_creds_jwt_encode_and_sign(
- const grpc_auth_json_key *key) {
+static char* service_account_creds_jwt_encode_and_sign(
+ const grpc_auth_json_key* key) {
return grpc_jwt_encode_and_sign(key, GRPC_JWT_OAUTH2_AUDIENCE,
grpc_max_auth_token_lifetime(), test_scope);
}
-static char *jwt_creds_jwt_encode_and_sign(const grpc_auth_json_key *key) {
+static char* jwt_creds_jwt_encode_and_sign(const grpc_auth_json_key* key) {
return grpc_jwt_encode_and_sign(key, test_service_url,
grpc_max_auth_token_lifetime(), NULL);
}
-static void service_account_creds_check_jwt_claim(grpc_json *claim) {
+static void service_account_creds_check_jwt_claim(grpc_json* claim) {
check_jwt_claim(claim, GRPC_JWT_OAUTH2_AUDIENCE, test_scope);
}
-static void jwt_creds_check_jwt_claim(grpc_json *claim) {
+static void jwt_creds_check_jwt_claim(grpc_json* claim) {
check_jwt_claim(claim, test_service_url, NULL);
}
static void test_jwt_encode_and_sign(
- char *(*jwt_encode_and_sign_func)(const grpc_auth_json_key *),
- void (*check_jwt_claim_func)(grpc_json *)) {
- char *json_string = test_json_key_str(NULL);
- grpc_json *parsed_header = NULL;
- grpc_json *parsed_claim = NULL;
- char *scratchpad;
+ char* (*jwt_encode_and_sign_func)(const grpc_auth_json_key*),
+ void (*check_jwt_claim_func)(grpc_json*)) {
+ char* json_string = test_json_key_str(NULL);
+ grpc_json* parsed_header = NULL;
+ grpc_json* parsed_claim = NULL;
+ char* scratchpad;
grpc_auth_json_key json_key =
grpc_auth_json_key_create_from_string(json_string);
- const char *b64_signature;
+ const char* b64_signature;
size_t offset = 0;
- char *jwt = jwt_encode_and_sign_func(&json_key);
- const char *dot = strchr(jwt, '.');
+ char* jwt = jwt_encode_and_sign_func(&json_key);
+ const char* dot = strchr(jwt, '.');
GPR_ASSERT(dot != NULL);
parsed_header =
parse_json_part_from_jwt(jwt, (size_t)(dot - jwt), &scratchpad);
@@ -481,7 +481,7 @@ static void test_parse_refresh_token_failure_no_refresh_token(void) {
GPR_ASSERT(!grpc_auth_refresh_token_is_valid(&refresh_token));
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
test_parse_json_key_success();
test_parse_json_key_failure_bad_json();
diff --git a/test/core/security/jwt_verifier_test.c b/test/core/security/jwt_verifier_test.c
index a4bfe0130e..0e16dc958e 100644
--- a/test/core/security/jwt_verifier_test.c
+++ b/test/core/security/jwt_verifier_test.c
@@ -167,12 +167,12 @@ static const char invalid_claims[] =
typedef struct {
grpc_jwt_verifier_status expected_status;
- const char *expected_issuer;
- const char *expected_subject;
+ const char* expected_issuer;
+ const char* expected_subject;
} verifier_test_config;
static void test_jwt_issuer_email_domain(void) {
- const char *d = grpc_jwt_issuer_email_domain("https://foo.com");
+ const char* d = grpc_jwt_issuer_email_domain("https://foo.com");
GPR_ASSERT(d == NULL);
d = grpc_jwt_issuer_email_domain("foo.com");
GPR_ASSERT(d == NULL);
@@ -204,10 +204,10 @@ static void test_jwt_issuer_email_domain(void) {
}
static void test_claims_success(void) {
- grpc_jwt_claims *claims;
+ grpc_jwt_claims* claims;
grpc_slice s = grpc_slice_from_copied_string(claims_without_time_constraint);
- grpc_json *json = grpc_json_parse_string_with_len(
- (char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
+ grpc_json* json = grpc_json_parse_string_with_len(
+ (char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
GPR_ASSERT(json != NULL);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
@@ -224,10 +224,10 @@ static void test_claims_success(void) {
}
static void test_expired_claims_failure(void) {
- grpc_jwt_claims *claims;
+ grpc_jwt_claims* claims;
grpc_slice s = grpc_slice_from_copied_string(expired_claims);
- grpc_json *json = grpc_json_parse_string_with_len(
- (char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
+ grpc_json* json = grpc_json_parse_string_with_len(
+ (char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
gpr_timespec exp_iat = {100, 0, GPR_CLOCK_REALTIME};
gpr_timespec exp_exp = {120, 0, GPR_CLOCK_REALTIME};
gpr_timespec exp_nbf = {60, 0, GPR_CLOCK_REALTIME};
@@ -252,18 +252,18 @@ static void test_expired_claims_failure(void) {
static void test_invalid_claims_failure(void) {
grpc_slice s = grpc_slice_from_copied_string(invalid_claims);
- grpc_json *json = grpc_json_parse_string_with_len(
- (char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
+ grpc_json* json = grpc_json_parse_string_with_len(
+ (char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
GPR_ASSERT(grpc_jwt_claims_from_json(&exec_ctx, json, s) == NULL);
grpc_exec_ctx_finish(&exec_ctx);
}
static void test_bad_audience_claims_failure(void) {
- grpc_jwt_claims *claims;
+ grpc_jwt_claims* claims;
grpc_slice s = grpc_slice_from_copied_string(claims_without_time_constraint);
- grpc_json *json = grpc_json_parse_string_with_len(
- (char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
+ grpc_json* json = grpc_json_parse_string_with_len(
+ (char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
GPR_ASSERT(json != NULL);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
@@ -275,10 +275,10 @@ static void test_bad_audience_claims_failure(void) {
}
static void test_bad_subject_claims_failure(void) {
- grpc_jwt_claims *claims;
+ grpc_jwt_claims* claims;
grpc_slice s = grpc_slice_from_copied_string(claims_with_bad_subject);
- grpc_json *json = grpc_json_parse_string_with_len(
- (char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
+ grpc_json* json = grpc_json_parse_string_with_len(
+ (char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
GPR_ASSERT(json != NULL);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
@@ -289,11 +289,11 @@ static void test_bad_subject_claims_failure(void) {
grpc_exec_ctx_finish(&exec_ctx);
}
-static char *json_key_str(const char *last_part) {
+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 *current = result;
+ char* result = gpr_malloc(result_len + 1);
+ char* current = result;
strcpy(result, json_key_str_part1);
current += strlen(json_key_str_part1);
strcpy(current, json_key_str_part2);
@@ -302,18 +302,18 @@ static char *json_key_str(const char *last_part) {
return result;
}
-static char *good_google_email_keys(void) {
+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 *current = result;
+ char* result = gpr_malloc(result_len + 1);
+ char* current = result;
strcpy(result, good_google_email_keys_part1);
current += strlen(good_google_email_keys_part1);
strcpy(current, good_google_email_keys_part2);
return result;
}
-static grpc_httpcli_response http_response(int status, char *body) {
+static grpc_httpcli_response http_response(int status, char* body) {
grpc_httpcli_response response;
memset(&response, 0, sizeof(grpc_httpcli_response));
response.status = status;
@@ -323,17 +323,17 @@ static grpc_httpcli_response http_response(int status, char *body) {
}
static int httpcli_post_should_not_be_called(
- grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
- const char *body_bytes, size_t body_size, grpc_millis deadline,
- grpc_closure *on_done, grpc_httpcli_response *response) {
+ grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
+ const char* body_bytes, size_t body_size, grpc_millis deadline,
+ grpc_closure* on_done, grpc_httpcli_response* response) {
GPR_ASSERT("HTTP POST should not be called" == NULL);
return 1;
}
static int httpcli_get_google_keys_for_email(
- grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
- grpc_millis deadline, grpc_closure *on_done,
- grpc_httpcli_response *response) {
+ grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
+ grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
*response = http_response(200, good_google_email_keys());
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
GPR_ASSERT(strcmp(request->host, "www.googleapis.com") == 0);
@@ -345,21 +345,21 @@ static int httpcli_get_google_keys_for_email(
return 1;
}
-static void on_verification_success(grpc_exec_ctx *exec_ctx, void *user_data,
+static void on_verification_success(grpc_exec_ctx* exec_ctx, void* user_data,
grpc_jwt_verifier_status status,
- grpc_jwt_claims *claims) {
+ grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_OK);
GPR_ASSERT(claims != NULL);
- GPR_ASSERT(user_data == (void *)expected_user_data);
+ GPR_ASSERT(user_data == (void*)expected_user_data);
GPR_ASSERT(strcmp(grpc_jwt_claims_audience(claims), expected_audience) == 0);
grpc_jwt_claims_destroy(exec_ctx, claims);
}
static void test_jwt_verifier_google_email_issuer_success(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_jwt_verifier *verifier = grpc_jwt_verifier_create(NULL, 0);
- char *jwt = NULL;
- char *key_str = json_key_str(json_key_str_part3_for_google_email_issuer);
+ grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(NULL, 0);
+ char* jwt = NULL;
+ char* key_str = json_key_str(json_key_str_part3_for_google_email_issuer);
grpc_auth_json_key key = grpc_auth_json_key_create_from_string(key_str);
gpr_free(key_str);
GPR_ASSERT(grpc_auth_json_key_is_valid(&key));
@@ -370,7 +370,7 @@ static void test_jwt_verifier_google_email_issuer_success(void) {
grpc_auth_json_key_destruct(&key);
GPR_ASSERT(jwt != NULL);
grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience,
- on_verification_success, (void *)expected_user_data);
+ on_verification_success, (void*)expected_user_data);
grpc_jwt_verifier_destroy(&exec_ctx, verifier);
grpc_exec_ctx_finish(&exec_ctx);
gpr_free(jwt);
@@ -378,9 +378,9 @@ static void test_jwt_verifier_google_email_issuer_success(void) {
}
static int httpcli_get_custom_keys_for_email(
- grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
- grpc_millis deadline, grpc_closure *on_done,
- grpc_httpcli_response *response) {
+ grpc_exec_ctx* exec_ctx, const grpc_httpcli_request* request,
+ grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
*response = http_response(200, gpr_strdup(good_jwk_set));
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
GPR_ASSERT(strcmp(request->host, "keys.bar.com") == 0);
@@ -391,9 +391,9 @@ static int httpcli_get_custom_keys_for_email(
static void test_jwt_verifier_custom_email_issuer_success(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_jwt_verifier *verifier = grpc_jwt_verifier_create(&custom_mapping, 1);
- char *jwt = NULL;
- char *key_str = json_key_str(json_key_str_part3_for_custom_email_issuer);
+ grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(&custom_mapping, 1);
+ char* jwt = NULL;
+ char* key_str = json_key_str(json_key_str_part3_for_custom_email_issuer);
grpc_auth_json_key key = grpc_auth_json_key_create_from_string(key_str);
gpr_free(key_str);
GPR_ASSERT(grpc_auth_json_key_is_valid(&key));
@@ -404,17 +404,17 @@ static void test_jwt_verifier_custom_email_issuer_success(void) {
grpc_auth_json_key_destruct(&key);
GPR_ASSERT(jwt != NULL);
grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience,
- on_verification_success, (void *)expected_user_data);
+ on_verification_success, (void*)expected_user_data);
grpc_jwt_verifier_destroy(&exec_ctx, verifier);
grpc_exec_ctx_finish(&exec_ctx);
gpr_free(jwt);
grpc_httpcli_set_override(NULL, NULL);
}
-static int httpcli_get_jwk_set(grpc_exec_ctx *exec_ctx,
- const grpc_httpcli_request *request,
- grpc_millis deadline, grpc_closure *on_done,
- grpc_httpcli_response *response) {
+static int httpcli_get_jwk_set(grpc_exec_ctx* exec_ctx,
+ const grpc_httpcli_request* request,
+ grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
*response = http_response(200, gpr_strdup(good_jwk_set));
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
GPR_ASSERT(strcmp(request->host, "www.googleapis.com") == 0);
@@ -423,11 +423,11 @@ static int httpcli_get_jwk_set(grpc_exec_ctx *exec_ctx,
return 1;
}
-static int httpcli_get_openid_config(grpc_exec_ctx *exec_ctx,
- const grpc_httpcli_request *request,
+static int httpcli_get_openid_config(grpc_exec_ctx* exec_ctx,
+ const grpc_httpcli_request* request,
grpc_millis deadline,
- grpc_closure *on_done,
- grpc_httpcli_response *response) {
+ grpc_closure* on_done,
+ grpc_httpcli_response* response) {
*response = http_response(200, gpr_strdup(good_openid_config));
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
GPR_ASSERT(strcmp(request->host, "accounts.google.com") == 0);
@@ -440,9 +440,9 @@ static int httpcli_get_openid_config(grpc_exec_ctx *exec_ctx,
static void test_jwt_verifier_url_issuer_success(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_jwt_verifier *verifier = grpc_jwt_verifier_create(NULL, 0);
- char *jwt = NULL;
- char *key_str = json_key_str(json_key_str_part3_for_url_issuer);
+ grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(NULL, 0);
+ char* jwt = NULL;
+ char* key_str = json_key_str(json_key_str_part3_for_url_issuer);
grpc_auth_json_key key = grpc_auth_json_key_create_from_string(key_str);
gpr_free(key_str);
GPR_ASSERT(grpc_auth_json_key_is_valid(&key));
@@ -453,26 +453,26 @@ static void test_jwt_verifier_url_issuer_success(void) {
grpc_auth_json_key_destruct(&key);
GPR_ASSERT(jwt != NULL);
grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience,
- on_verification_success, (void *)expected_user_data);
+ on_verification_success, (void*)expected_user_data);
grpc_jwt_verifier_destroy(&exec_ctx, verifier);
grpc_exec_ctx_finish(&exec_ctx);
gpr_free(jwt);
grpc_httpcli_set_override(NULL, NULL);
}
-static void on_verification_key_retrieval_error(grpc_exec_ctx *exec_ctx,
- void *user_data,
+static void on_verification_key_retrieval_error(grpc_exec_ctx* exec_ctx,
+ void* user_data,
grpc_jwt_verifier_status status,
- grpc_jwt_claims *claims) {
+ grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR);
GPR_ASSERT(claims == NULL);
- GPR_ASSERT(user_data == (void *)expected_user_data);
+ GPR_ASSERT(user_data == (void*)expected_user_data);
}
-static int httpcli_get_bad_json(grpc_exec_ctx *exec_ctx,
- const grpc_httpcli_request *request,
- grpc_millis deadline, grpc_closure *on_done,
- grpc_httpcli_response *response) {
+static int httpcli_get_bad_json(grpc_exec_ctx* exec_ctx,
+ const grpc_httpcli_request* request,
+ grpc_millis deadline, grpc_closure* on_done,
+ grpc_httpcli_response* response) {
*response = http_response(200, gpr_strdup("{\"bad\": \"stuff\"}"));
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
GRPC_CLOSURE_SCHED(exec_ctx, on_done, GRPC_ERROR_NONE);
@@ -481,9 +481,9 @@ static int httpcli_get_bad_json(grpc_exec_ctx *exec_ctx,
static void test_jwt_verifier_url_issuer_bad_config(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_jwt_verifier *verifier = grpc_jwt_verifier_create(NULL, 0);
- char *jwt = NULL;
- char *key_str = json_key_str(json_key_str_part3_for_url_issuer);
+ grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(NULL, 0);
+ char* jwt = NULL;
+ char* key_str = json_key_str(json_key_str_part3_for_url_issuer);
grpc_auth_json_key key = grpc_auth_json_key_create_from_string(key_str);
gpr_free(key_str);
GPR_ASSERT(grpc_auth_json_key_is_valid(&key));
@@ -495,7 +495,7 @@ static void test_jwt_verifier_url_issuer_bad_config(void) {
GPR_ASSERT(jwt != NULL);
grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience,
on_verification_key_retrieval_error,
- (void *)expected_user_data);
+ (void*)expected_user_data);
grpc_jwt_verifier_destroy(&exec_ctx, verifier);
grpc_exec_ctx_finish(&exec_ctx);
gpr_free(jwt);
@@ -504,9 +504,9 @@ static void test_jwt_verifier_url_issuer_bad_config(void) {
static void test_jwt_verifier_bad_json_key(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_jwt_verifier *verifier = grpc_jwt_verifier_create(NULL, 0);
- char *jwt = NULL;
- char *key_str = json_key_str(json_key_str_part3_for_google_email_issuer);
+ grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(NULL, 0);
+ char* jwt = NULL;
+ char* key_str = json_key_str(json_key_str_part3_for_google_email_issuer);
grpc_auth_json_key key = grpc_auth_json_key_create_from_string(key_str);
gpr_free(key_str);
GPR_ASSERT(grpc_auth_json_key_is_valid(&key));
@@ -518,18 +518,18 @@ static void test_jwt_verifier_bad_json_key(void) {
GPR_ASSERT(jwt != NULL);
grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience,
on_verification_key_retrieval_error,
- (void *)expected_user_data);
+ (void*)expected_user_data);
grpc_jwt_verifier_destroy(&exec_ctx, verifier);
grpc_exec_ctx_finish(&exec_ctx);
gpr_free(jwt);
grpc_httpcli_set_override(NULL, NULL);
}
-static void corrupt_jwt_sig(char *jwt) {
+static void corrupt_jwt_sig(char* jwt) {
grpc_slice sig;
- char *bad_b64_sig;
- uint8_t *sig_bytes;
- char *last_dot = strrchr(jwt, '.');
+ char* bad_b64_sig;
+ uint8_t* sig_bytes;
+ char* last_dot = strrchr(jwt, '.');
GPR_ASSERT(last_dot != NULL);
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
@@ -546,20 +546,20 @@ static void corrupt_jwt_sig(char *jwt) {
grpc_slice_unref(sig);
}
-static void on_verification_bad_signature(grpc_exec_ctx *exec_ctx,
- void *user_data,
+static void on_verification_bad_signature(grpc_exec_ctx* exec_ctx,
+ void* user_data,
grpc_jwt_verifier_status status,
- grpc_jwt_claims *claims) {
+ grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_BAD_SIGNATURE);
GPR_ASSERT(claims == NULL);
- GPR_ASSERT(user_data == (void *)expected_user_data);
+ GPR_ASSERT(user_data == (void*)expected_user_data);
}
static void test_jwt_verifier_bad_signature(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_jwt_verifier *verifier = grpc_jwt_verifier_create(NULL, 0);
- char *jwt = NULL;
- char *key_str = json_key_str(json_key_str_part3_for_url_issuer);
+ grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(NULL, 0);
+ char* jwt = NULL;
+ char* key_str = json_key_str(json_key_str_part3_for_url_issuer);
grpc_auth_json_key key = grpc_auth_json_key_create_from_string(key_str);
gpr_free(key_str);
GPR_ASSERT(grpc_auth_json_key_is_valid(&key));
@@ -572,38 +572,38 @@ static void test_jwt_verifier_bad_signature(void) {
GPR_ASSERT(jwt != NULL);
grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience,
on_verification_bad_signature,
- (void *)expected_user_data);
+ (void*)expected_user_data);
gpr_free(jwt);
grpc_jwt_verifier_destroy(&exec_ctx, verifier);
grpc_exec_ctx_finish(&exec_ctx);
grpc_httpcli_set_override(NULL, NULL);
}
-static int httpcli_get_should_not_be_called(grpc_exec_ctx *exec_ctx,
- const grpc_httpcli_request *request,
+static int httpcli_get_should_not_be_called(grpc_exec_ctx* exec_ctx,
+ const grpc_httpcli_request* request,
grpc_millis deadline,
- grpc_closure *on_done,
- grpc_httpcli_response *response) {
+ grpc_closure* on_done,
+ grpc_httpcli_response* response) {
GPR_ASSERT(0);
return 1;
}
-static void on_verification_bad_format(grpc_exec_ctx *exec_ctx, void *user_data,
+static void on_verification_bad_format(grpc_exec_ctx* exec_ctx, void* user_data,
grpc_jwt_verifier_status status,
- grpc_jwt_claims *claims) {
+ grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_BAD_FORMAT);
GPR_ASSERT(claims == NULL);
- GPR_ASSERT(user_data == (void *)expected_user_data);
+ GPR_ASSERT(user_data == (void*)expected_user_data);
}
static void test_jwt_verifier_bad_format(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_jwt_verifier *verifier = grpc_jwt_verifier_create(NULL, 0);
+ grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(NULL, 0);
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
httpcli_post_should_not_be_called);
grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, "bad jwt",
expected_audience, on_verification_bad_format,
- (void *)expected_user_data);
+ (void*)expected_user_data);
grpc_jwt_verifier_destroy(&exec_ctx, verifier);
grpc_exec_ctx_finish(&exec_ctx);
grpc_httpcli_set_override(NULL, NULL);
@@ -613,7 +613,7 @@ static void test_jwt_verifier_bad_format(void) {
/* bad signature custom provided email*/
/* bad key */
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
test_jwt_issuer_email_domain();
diff --git a/test/core/security/oauth2_utils.c b/test/core/security/oauth2_utils.c
index 73d6c5bc7d..fda3d96e18 100644
--- a/test/core/security/oauth2_utils.c
+++ b/test/core/security/oauth2_utils.c
@@ -30,26 +30,26 @@
#include "src/core/lib/security/credentials/credentials.h"
typedef struct {
- gpr_mu *mu;
+ gpr_mu* mu;
grpc_polling_entity pops;
bool is_done;
- char *token;
+ char* token;
grpc_credentials_mdelem_array md_array;
grpc_closure closure;
} oauth2_request;
-static void on_oauth2_response(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- oauth2_request *request = (oauth2_request *)arg;
- char *token = NULL;
+static void on_oauth2_response(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error) {
+ oauth2_request* request = (oauth2_request*)arg;
+ char* token = NULL;
grpc_slice token_slice;
if (error != GRPC_ERROR_NONE) {
gpr_log(GPR_ERROR, "Fetching token failed: %s", grpc_error_string(error));
} else {
GPR_ASSERT(request->md_array.size == 1);
token_slice = GRPC_MDVALUE(request->md_array.md[0]);
- token = (char *)gpr_malloc(GRPC_SLICE_LENGTH(token_slice) + 1);
+ token = (char*)gpr_malloc(GRPC_SLICE_LENGTH(token_slice) + 1);
memcpy(token, GRPC_SLICE_START_PTR(token_slice),
GRPC_SLICE_LENGTH(token_slice));
token[GRPC_SLICE_LENGTH(token_slice)] = '\0';
@@ -65,18 +65,18 @@ static void on_oauth2_response(grpc_exec_ctx *exec_ctx, void *arg,
gpr_mu_unlock(request->mu);
}
-static void do_nothing(grpc_exec_ctx *exec_ctx, void *unused,
- grpc_error *error) {}
+static void do_nothing(grpc_exec_ctx* exec_ctx, void* unused,
+ grpc_error* error) {}
-char *grpc_test_fetch_oauth2_token_with_credentials(
- grpc_call_credentials *creds) {
+char* grpc_test_fetch_oauth2_token_with_credentials(
+ grpc_call_credentials* creds) {
oauth2_request request;
memset(&request, 0, sizeof(request));
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_closure do_nothing_closure;
grpc_auth_metadata_context null_ctx = {"", "", NULL, NULL};
- grpc_pollset *pollset = (grpc_pollset *)gpr_zalloc(grpc_pollset_size());
+ grpc_pollset* pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
grpc_pollset_init(pollset, &request.mu);
request.pops = grpc_polling_entity_create_from_pollset(pollset);
request.is_done = false;
@@ -87,7 +87,7 @@ char *grpc_test_fetch_oauth2_token_with_credentials(
GRPC_CLOSURE_INIT(&request.closure, on_oauth2_response, &request,
grpc_schedule_on_exec_ctx);
- grpc_error *error = GRPC_ERROR_NONE;
+ grpc_error* error = GRPC_ERROR_NONE;
if (grpc_call_credentials_get_request_metadata(
&exec_ctx, creds, &request.pops, null_ctx, &request.md_array,
&request.closure, &error)) {
@@ -99,7 +99,7 @@ char *grpc_test_fetch_oauth2_token_with_credentials(
gpr_mu_lock(request.mu);
while (!request.is_done) {
- grpc_pollset_worker *worker = NULL;
+ grpc_pollset_worker* worker = NULL;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx,
diff --git a/test/core/security/oauth2_utils.h b/test/core/security/oauth2_utils.h
index 15f68bd6d8..5e33ef4f43 100644
--- a/test/core/security/oauth2_utils.h
+++ b/test/core/security/oauth2_utils.h
@@ -27,8 +27,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_call_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 29c38dfdf8..c5d4e9c3ea 100644
--- a/test/core/security/print_google_default_creds_token.c
+++ b/test/core/security/print_google_default_creds_token.c
@@ -33,7 +33,7 @@
#include "src/core/lib/support/string.h"
typedef struct {
- gpr_mu *mu;
+ gpr_mu* mu;
grpc_polling_entity pops;
bool is_done;
@@ -41,13 +41,13 @@ typedef struct {
grpc_closure on_request_metadata;
} synchronizer;
-static void on_metadata_response(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- synchronizer *sync = arg;
+static void on_metadata_response(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error) {
+ synchronizer* sync = arg;
if (error != GRPC_ERROR_NONE) {
fprintf(stderr, "Fetching token failed: %s\n", grpc_error_string(error));
} else {
- char *token;
+ char* token;
GPR_ASSERT(sync->md_array.size == 1);
token = grpc_slice_to_c_string(GRPC_MDVALUE(sync->md_array.md[0]));
printf("\nGot token: %s\n\n", token);
@@ -62,14 +62,14 @@ static void on_metadata_response(grpc_exec_ctx *exec_ctx, void *arg,
gpr_mu_unlock(sync->mu);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
int result = 0;
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";
+ grpc_channel_credentials* creds = NULL;
+ 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");
+ gpr_cmdline* cl = gpr_cmdline_create("print_google_default_creds_token");
gpr_cmdline_add_string(cl, "service_url",
"Service URL for the token request.", &service_url);
gpr_cmdline_parse(cl, argc, argv);
@@ -86,16 +86,16 @@ int main(int argc, char **argv) {
}
memset(&sync, 0, sizeof(sync));
- grpc_pollset *pollset = gpr_zalloc(grpc_pollset_size());
+ grpc_pollset* 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;
+ grpc_error* error = GRPC_ERROR_NONE;
if (grpc_call_credentials_get_request_metadata(
- &exec_ctx, ((grpc_composite_channel_credentials *)creds)->call_creds,
+ &exec_ctx, ((grpc_composite_channel_credentials*)creds)->call_creds,
&sync.pops, context, &sync.md_array, &sync.on_request_metadata,
&error)) {
// Synchronous response. Invoke callback directly.
@@ -105,7 +105,7 @@ int main(int argc, char **argv) {
gpr_mu_lock(sync.mu);
while (!sync.is_done) {
- grpc_pollset_worker *worker = NULL;
+ grpc_pollset_worker* worker = NULL;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx,
diff --git a/test/core/security/secure_endpoint_test.c b/test/core/security/secure_endpoint_test.c
index 839a05fa9b..b772c30956 100644
--- a/test/core/security/secure_endpoint_test.c
+++ b/test/core/security/secure_endpoint_test.c
@@ -32,21 +32,21 @@
#include "src/core/tsi/fake_transport_security.h"
#include "test/core/util/test_config.h"
-static gpr_mu *g_mu;
-static grpc_pollset *g_pollset;
+static gpr_mu* g_mu;
+static grpc_pollset* g_pollset;
static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
- size_t slice_size, grpc_slice *leftover_slices, size_t leftover_nslices,
+ size_t slice_size, grpc_slice* leftover_slices, size_t leftover_nslices,
bool use_zero_copy_protector) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- tsi_frame_protector *fake_read_protector =
+ tsi_frame_protector* fake_read_protector =
tsi_create_fake_frame_protector(NULL);
- tsi_frame_protector *fake_write_protector =
+ tsi_frame_protector* fake_write_protector =
tsi_create_fake_frame_protector(NULL);
- tsi_zero_copy_grpc_protector *fake_read_zero_copy_protector =
+ tsi_zero_copy_grpc_protector* fake_read_zero_copy_protector =
use_zero_copy_protector ? tsi_create_fake_zero_copy_grpc_protector(NULL)
: NULL;
- tsi_zero_copy_grpc_protector *fake_write_zero_copy_protector =
+ tsi_zero_copy_grpc_protector* fake_write_zero_copy_protector =
use_zero_copy_protector ? tsi_create_fake_zero_copy_grpc_protector(NULL)
: NULL;
grpc_endpoint_test_fixture f;
@@ -70,12 +70,12 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
size_t still_pending_size;
size_t total_buffer_size = 8192;
size_t buffer_size = total_buffer_size;
- uint8_t *encrypted_buffer = (uint8_t *)gpr_malloc(buffer_size);
- uint8_t *cur = encrypted_buffer;
+ uint8_t* encrypted_buffer = (uint8_t*)gpr_malloc(buffer_size);
+ uint8_t* cur = encrypted_buffer;
grpc_slice encrypted_leftover;
for (i = 0; i < leftover_nslices; i++) {
grpc_slice plain = leftover_slices[i];
- uint8_t *message_bytes = GRPC_SLICE_START_PTR(plain);
+ uint8_t* message_bytes = GRPC_SLICE_START_PTR(plain);
size_t message_size = GRPC_SLICE_LENGTH(plain);
while (message_size > 0) {
size_t protected_buffer_size_to_send = buffer_size;
@@ -103,7 +103,7 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
buffer_size -= protected_buffer_size_to_send;
} while (still_pending_size > 0);
encrypted_leftover = grpc_slice_from_copied_buffer(
- (const char *)encrypted_buffer, total_buffer_size - buffer_size);
+ (const char*)encrypted_buffer, total_buffer_size - buffer_size);
f.client_ep = grpc_secure_endpoint_create(
fake_read_protector, fake_read_zero_copy_protector, tcp.client,
&encrypted_leftover, 1);
@@ -162,9 +162,9 @@ static grpc_endpoint_test_config configs[] = {
clean_up},
};
-static void inc_call_ctr(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
- ++*(int *)arg;
+static void inc_call_ctr(grpc_exec_ctx* exec_ctx, void* arg,
+ grpc_error* error) {
+ ++*(int*)arg;
}
static void test_leftover(grpc_endpoint_test_config config, size_t slice_size) {
@@ -200,18 +200,18 @@ static void test_leftover(grpc_endpoint_test_config config, size_t slice_size) {
clean_up();
}
-static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
- grpc_error *error) {
- grpc_pollset_destroy(exec_ctx, (grpc_pollset *)p);
+static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p,
+ grpc_error* error) {
+ grpc_pollset_destroy(exec_ctx, (grpc_pollset*)p);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_closure destroyed;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_test_init(argc, argv);
grpc_init();
- g_pollset = (grpc_pollset *)gpr_zalloc(grpc_pollset_size());
+ g_pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
grpc_pollset_init(g_pollset, &g_mu);
grpc_endpoint_tests(configs[0], g_pollset, g_mu);
grpc_endpoint_tests(configs[1], g_pollset, g_mu);
diff --git a/test/core/security/security_connector_test.c b/test/core/security/security_connector_test.c
index eecf0f462b..a0c1e93532 100644
--- a/test/core/security/security_connector_test.c
+++ b/test/core/security/security_connector_test.c
@@ -35,10 +35,10 @@
#include "src/core/tsi/transport_security.h"
#include "test/core/util/test_config.h"
-static int check_transport_security_type(const grpc_auth_context *ctx) {
+static int check_transport_security_type(const grpc_auth_context* ctx) {
grpc_auth_property_iterator it = grpc_auth_context_find_properties_by_name(
ctx, GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME);
- const grpc_auth_property *prop = grpc_auth_property_iterator_next(&it);
+ const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it);
if (prop == NULL) return 0;
if (strncmp(prop->value, GRPC_SSL_TRANSPORT_SECURITY_TYPE,
prop->value_length) != 0) {
@@ -49,11 +49,11 @@ static int check_transport_security_type(const grpc_auth_context *ctx) {
return 1;
}
-static int check_peer_property(const tsi_peer *peer,
- const tsi_peer_property *expected) {
+static int check_peer_property(const tsi_peer* peer,
+ const tsi_peer_property* expected) {
size_t i;
for (i = 0; i < peer->property_count; i++) {
- const tsi_peer_property *prop = &peer->properties[i];
+ const tsi_peer_property* prop = &peer->properties[i];
if ((strcmp(prop->name, expected->name) == 0) &&
(prop->value.length == expected->value.length) &&
(memcmp(prop->value.data, expected->value.data,
@@ -64,12 +64,12 @@ static int check_peer_property(const tsi_peer *peer,
return 0; /* Not found... */
}
-static int check_ssl_peer_equivalence(const tsi_peer *original,
- const tsi_peer *reconstructed) {
+static int check_ssl_peer_equivalence(const tsi_peer* original,
+ const tsi_peer* reconstructed) {
/* The reconstructed peer only has CN, SAN and pem cert properties. */
size_t i;
for (i = 0; i < original->property_count; i++) {
- const tsi_peer_property *prop = &original->properties[i];
+ const tsi_peer_property* prop = &original->properties[i];
if ((strcmp(prop->name, TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY) == 0) ||
(strcmp(prop->name, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY) ==
0) ||
@@ -83,7 +83,7 @@ static int check_ssl_peer_equivalence(const tsi_peer *original,
static void test_unauthenticated_ssl_peer(void) {
tsi_peer peer;
tsi_peer rpeer;
- grpc_auth_context *ctx;
+ grpc_auth_context* ctx;
GPR_ASSERT(tsi_construct_peer(1, &peer) == TSI_OK);
GPR_ASSERT(tsi_construct_string_peer_property_from_cstring(
TSI_CERTIFICATE_TYPE_PEER_PROPERTY, TSI_X509_CERTIFICATE_TYPE,
@@ -101,12 +101,12 @@ static void test_unauthenticated_ssl_peer(void) {
GRPC_AUTH_CONTEXT_UNREF(ctx, "test");
}
-static int check_identity(const grpc_auth_context *ctx,
- const char *expected_property_name,
- const char **expected_identities,
+static int check_identity(const grpc_auth_context* ctx,
+ const char* expected_property_name,
+ const char** expected_identities,
size_t num_identities) {
grpc_auth_property_iterator it;
- const grpc_auth_property *prop;
+ const grpc_auth_property* prop;
size_t i;
GPR_ASSERT(grpc_auth_context_peer_is_authenticated(ctx));
it = grpc_auth_context_peer_identity(ctx);
@@ -131,11 +131,11 @@ static int check_identity(const grpc_auth_context *ctx,
return 1;
}
-static int check_x509_cn(const grpc_auth_context *ctx,
- const char *expected_cn) {
+static int check_x509_cn(const grpc_auth_context* ctx,
+ const char* expected_cn) {
grpc_auth_property_iterator it = grpc_auth_context_find_properties_by_name(
ctx, GRPC_X509_CN_PROPERTY_NAME);
- const grpc_auth_property *prop = grpc_auth_property_iterator_next(&it);
+ const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it);
if (prop == NULL) {
gpr_log(GPR_ERROR, "CN property not found.");
return 0;
@@ -151,11 +151,11 @@ static int check_x509_cn(const grpc_auth_context *ctx,
return 1;
}
-static int check_x509_pem_cert(const grpc_auth_context *ctx,
- const char *expected_pem_cert) {
+static int check_x509_pem_cert(const grpc_auth_context* ctx,
+ const char* expected_pem_cert) {
grpc_auth_property_iterator it = grpc_auth_context_find_properties_by_name(
ctx, GRPC_X509_PEM_CERT_PROPERTY_NAME);
- const grpc_auth_property *prop = grpc_auth_property_iterator_next(&it);
+ const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it);
if (prop == NULL) {
gpr_log(GPR_ERROR, "Pem certificate property not found.");
return 0;
@@ -175,9 +175,9 @@ static int check_x509_pem_cert(const grpc_auth_context *ctx,
static void test_cn_only_ssl_peer_to_auth_context(void) {
tsi_peer peer;
tsi_peer rpeer;
- grpc_auth_context *ctx;
- const char *expected_cn = "cn1";
- const char *expected_pem_cert = "pem_cert1";
+ grpc_auth_context* ctx;
+ const char* expected_cn = "cn1";
+ const char* expected_pem_cert = "pem_cert1";
GPR_ASSERT(tsi_construct_peer(3, &peer) == TSI_OK);
GPR_ASSERT(tsi_construct_string_peer_property_from_cstring(
TSI_CERTIFICATE_TYPE_PEER_PROPERTY, TSI_X509_CERTIFICATE_TYPE,
@@ -207,10 +207,10 @@ static void test_cn_only_ssl_peer_to_auth_context(void) {
static void test_cn_and_one_san_ssl_peer_to_auth_context(void) {
tsi_peer peer;
tsi_peer rpeer;
- grpc_auth_context *ctx;
- const char *expected_cn = "cn1";
- const char *expected_san = "san1";
- const char *expected_pem_cert = "pem_cert1";
+ grpc_auth_context* ctx;
+ const char* expected_cn = "cn1";
+ const char* expected_san = "san1";
+ const char* expected_pem_cert = "pem_cert1";
GPR_ASSERT(tsi_construct_peer(4, &peer) == TSI_OK);
GPR_ASSERT(tsi_construct_string_peer_property_from_cstring(
TSI_CERTIFICATE_TYPE_PEER_PROPERTY, TSI_X509_CERTIFICATE_TYPE,
@@ -244,10 +244,10 @@ static void test_cn_and_one_san_ssl_peer_to_auth_context(void) {
static void test_cn_and_multiple_sans_ssl_peer_to_auth_context(void) {
tsi_peer peer;
tsi_peer rpeer;
- grpc_auth_context *ctx;
- const char *expected_cn = "cn1";
- const char *expected_sans[] = {"san1", "san2", "san3"};
- const char *expected_pem_cert = "pem_cert1";
+ grpc_auth_context* ctx;
+ const char* expected_cn = "cn1";
+ const char* expected_sans[] = {"san1", "san2", "san3"};
+ const char* expected_pem_cert = "pem_cert1";
size_t i;
GPR_ASSERT(tsi_construct_peer(3 + GPR_ARRAY_SIZE(expected_sans), &peer) ==
TSI_OK);
@@ -286,10 +286,10 @@ static void test_cn_and_multiple_sans_and_others_ssl_peer_to_auth_context(
void) {
tsi_peer peer;
tsi_peer rpeer;
- grpc_auth_context *ctx;
- const char *expected_cn = "cn1";
- const char *expected_pem_cert = "pem_cert1";
- const char *expected_sans[] = {"san1", "san2", "san3"};
+ grpc_auth_context* ctx;
+ const char* expected_cn = "cn1";
+ const char* expected_pem_cert = "pem_cert1";
+ const char* expected_sans[] = {"san1", "san2", "san3"};
size_t i;
GPR_ASSERT(tsi_construct_peer(5 + GPR_ARRAY_SIZE(expected_sans), &peer) ==
TSI_OK);
@@ -328,24 +328,24 @@ static void test_cn_and_multiple_sans_and_others_ssl_peer_to_auth_context(
GRPC_AUTH_CONTEXT_UNREF(ctx, "test");
}
-static const char *roots_for_override_api = "roots for override api";
+static const char* roots_for_override_api = "roots for override api";
static grpc_ssl_roots_override_result override_roots_success(
- char **pem_root_certs) {
+ char** pem_root_certs) {
*pem_root_certs = gpr_strdup(roots_for_override_api);
return GRPC_SSL_ROOTS_OVERRIDE_OK;
}
static grpc_ssl_roots_override_result override_roots_permanent_failure(
- char **pem_root_certs) {
+ char** pem_root_certs) {
return GRPC_SSL_ROOTS_OVERRIDE_FAIL_PERMANENTLY;
}
static void test_default_ssl_roots(void) {
- const char *roots_for_env_var = "roots for env var";
+ const char* roots_for_env_var = "roots for env var";
- char *roots_env_var_file_path;
- FILE *roots_env_var_file =
+ char* roots_env_var_file_path;
+ FILE* roots_env_var_file =
gpr_tmpfile("test_roots_for_env_var", &roots_env_var_file_path);
fwrite(roots_for_env_var, 1, strlen(roots_for_env_var), roots_env_var_file);
fclose(roots_env_var_file);
@@ -355,7 +355,7 @@ static void test_default_ssl_roots(void) {
gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, "");
grpc_set_ssl_roots_override_callback(override_roots_success);
grpc_slice roots = grpc_get_default_ssl_roots_for_testing();
- char *roots_contents = grpc_slice_to_c_string(roots);
+ char* roots_contents = grpc_slice_to_c_string(roots);
grpc_slice_unref(roots);
GPR_ASSERT(strcmp(roots_contents, roots_for_override_api) == 0);
gpr_free(roots_contents);
@@ -389,7 +389,7 @@ static void test_default_ssl_roots(void) {
gpr_free(roots_env_var_file_path);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
diff --git a/test/core/security/ssl_credentials_test.c b/test/core/security/ssl_credentials_test.c
index 3c838faa60..76ee32b001 100644
--- a/test/core/security/ssl_credentials_test.c
+++ b/test/core/security/ssl_credentials_test.c
@@ -34,13 +34,13 @@ static void test_convert_grpc_to_tsi_cert_pairs() {
const size_t num_pairs = 3;
{
- tsi_ssl_pem_key_cert_pair *tsi_pairs =
+ tsi_ssl_pem_key_cert_pair* tsi_pairs =
grpc_convert_grpc_to_tsi_cert_pairs(grpc_pairs, 0);
GPR_ASSERT(tsi_pairs == NULL);
}
{
- tsi_ssl_pem_key_cert_pair *tsi_pairs =
+ tsi_ssl_pem_key_cert_pair* tsi_pairs =
grpc_convert_grpc_to_tsi_cert_pairs(grpc_pairs, num_pairs);
GPR_ASSERT(tsi_pairs != NULL);
@@ -55,7 +55,7 @@ static void test_convert_grpc_to_tsi_cert_pairs() {
}
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
diff --git a/test/core/security/ssl_server_fuzzer.c b/test/core/security/ssl_server_fuzzer.c
index f9b754b8f2..7d6b3409b3 100644
--- a/test/core/security/ssl_server_fuzzer.c
+++ b/test/core/security/ssl_server_fuzzer.c
@@ -34,38 +34,38 @@ bool leak_check = false;
static void discard_write(grpc_slice slice) {}
-static void dont_log(gpr_log_func_args *args) {}
+static void dont_log(gpr_log_func_args* args) {}
struct handshake_state {
bool done_callback_called;
};
-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;
+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;
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) {
+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();
grpc_init();
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_resource_quota *resource_quota =
+ grpc_resource_quota* resource_quota =
grpc_resource_quota_create("ssl_server_fuzzer");
- grpc_endpoint *mock_endpoint =
+ grpc_endpoint* mock_endpoint =
grpc_mock_endpoint_create(discard_write, resource_quota);
grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
grpc_mock_endpoint_put_read(
&exec_ctx, mock_endpoint,
- grpc_slice_from_copied_buffer((const char *)data, size));
+ grpc_slice_from_copied_buffer((const char*)data, size));
// Load key pair and establish server SSL credentials.
grpc_ssl_pem_key_cert_pair pem_key_cert_pair;
@@ -73,14 +73,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
ca_slice = grpc_slice_from_static_string(test_root_cert);
cert_slice = grpc_slice_from_static_string(test_server1_cert);
key_slice = grpc_slice_from_static_string(test_server1_key);
- const char *ca_cert = (const char *)GRPC_SLICE_START_PTR(ca_slice);
- pem_key_cert_pair.private_key = (const char *)GRPC_SLICE_START_PTR(key_slice);
- pem_key_cert_pair.cert_chain = (const char *)GRPC_SLICE_START_PTR(cert_slice);
- grpc_server_credentials *creds = grpc_ssl_server_credentials_create(
+ const char* ca_cert = (const char*)GRPC_SLICE_START_PTR(ca_slice);
+ pem_key_cert_pair.private_key = (const char*)GRPC_SLICE_START_PTR(key_slice);
+ pem_key_cert_pair.cert_chain = (const char*)GRPC_SLICE_START_PTR(cert_slice);
+ grpc_server_credentials* creds = grpc_ssl_server_credentials_create(
ca_cert, &pem_key_cert_pair, 1, 0, NULL);
// Create security connector
- grpc_server_security_connector *sc = NULL;
+ grpc_server_security_connector* sc = NULL;
grpc_security_status status =
grpc_server_credentials_create_security_connector(&exec_ctx, creds, &sc);
GPR_ASSERT(status == GRPC_SECURITY_OK);
@@ -88,7 +88,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
struct handshake_state state;
state.done_callback_called = false;
- grpc_handshake_manager *handshake_mgr = grpc_handshake_manager_create();
+ grpc_handshake_manager* handshake_mgr = grpc_handshake_manager_create();
grpc_server_security_connector_add_handshakers(&exec_ctx, sc, handshake_mgr);
grpc_handshake_manager_do_handshake(
&exec_ctx, handshake_mgr, mock_endpoint, NULL /* channel_args */,
diff --git a/test/core/security/verify_jwt.c b/test/core/security/verify_jwt.c
index cec6fb94b4..08adb6e463 100644
--- a/test/core/security/verify_jwt.c
+++ b/test/core/security/verify_jwt.c
@@ -30,31 +30,31 @@
#include "src/core/lib/security/credentials/jwt/jwt_verifier.h"
typedef struct {
- grpc_pollset *pollset;
- gpr_mu *mu;
+ grpc_pollset* pollset;
+ gpr_mu* mu;
int is_done;
int success;
} synchronizer;
-static void print_usage_and_exit(gpr_cmdline *cl, const char *argv0) {
- char *usage = gpr_cmdline_usage_string(cl, argv0);
+static void print_usage_and_exit(gpr_cmdline* cl, const char* argv0) {
+ char* usage = gpr_cmdline_usage_string(cl, argv0);
fprintf(stderr, "%s", usage);
gpr_free(usage);
gpr_cmdline_destroy(cl);
exit(1);
}
-static void on_jwt_verification_done(grpc_exec_ctx *exec_ctx, void *user_data,
+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;
+ grpc_jwt_claims* claims) {
+ synchronizer* sync = user_data;
sync->success = (status == GRPC_JWT_VERIFIER_OK);
if (sync->success) {
- char *claims_str;
+ char* claims_str;
GPR_ASSERT(claims != NULL);
claims_str =
- grpc_json_dump_to_string((grpc_json *)grpc_jwt_claims_json(claims), 2);
+ grpc_json_dump_to_string((grpc_json*)grpc_jwt_claims_json(claims), 2);
printf("Claims: \n\n%s\n", claims_str);
gpr_free(claims_str);
grpc_jwt_claims_destroy(exec_ctx, claims);
@@ -71,12 +71,12 @@ static void on_jwt_verification_done(grpc_exec_ctx *exec_ctx, void *user_data,
gpr_mu_unlock(sync->mu);
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
synchronizer sync;
- grpc_jwt_verifier *verifier;
- gpr_cmdline *cl;
- char *jwt = NULL;
- char *aud = NULL;
+ grpc_jwt_verifier* verifier;
+ gpr_cmdline* cl;
+ char* jwt = NULL;
+ char* aud = NULL;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_init();
@@ -101,7 +101,7 @@ int main(int argc, char **argv) {
gpr_mu_lock(sync.mu);
while (!sync.is_done) {
- grpc_pollset_worker *worker = NULL;
+ grpc_pollset_worker* worker = NULL;
if (!GRPC_LOG_IF_ERROR("pollset_work",
grpc_pollset_work(&exec_ctx, sync.pollset, &worker,
GRPC_MILLIS_INF_FUTURE)))