aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/security
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-11-10 14:14:17 -0800
committerGravatar Craig Tiller <ctiller@google.com>2017-11-10 14:14:17 -0800
commit4ac2b8e585cbf7064f9bdde4eabaf8ff42801142 (patch)
tree5379629b43d287972916a87637a26251c1b0de5f /test/core/security
parente77b3c36d1b3e2033abd19d553748b678c22253f (diff)
Enable clang-tidy as a sanity check, fix up all known failures
Diffstat (limited to 'test/core/security')
-rw-r--r--test/core/security/auth_context_test.cc32
-rw-r--r--test/core/security/create_jwt.cc18
-rw-r--r--test/core/security/credentials_test.cc198
-rw-r--r--test/core/security/fetch_oauth2.cc28
-rw-r--r--test/core/security/json_token_test.cc98
-rw-r--r--test/core/security/jwt_verifier_test.cc120
-rw-r--r--test/core/security/oauth2_utils.cc10
-rw-r--r--test/core/security/print_google_default_creds_token.cc8
-rw-r--r--test/core/security/secure_endpoint_test.cc20
-rw-r--r--test/core/security/security_connector_test.cc24
-rw-r--r--test/core/security/ssl_credentials_test.cc4
-rw-r--r--test/core/security/ssl_server_fuzzer.cc8
-rw-r--r--test/core/security/verify_jwt.cc16
13 files changed, 292 insertions, 292 deletions
diff --git a/test/core/security/auth_context_test.cc b/test/core/security/auth_context_test.cc
index 3ab9190689..d8e41326c0 100644
--- a/test/core/security/auth_context_test.cc
+++ b/test/core/security/auth_context_test.cc
@@ -25,31 +25,31 @@
#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(nullptr);
grpc_auth_property_iterator it;
gpr_log(GPR_INFO, "test_empty_context");
- GPR_ASSERT(ctx != NULL);
- GPR_ASSERT(grpc_auth_context_peer_identity_property_name(ctx) == NULL);
+ GPR_ASSERT(ctx != nullptr);
+ GPR_ASSERT(grpc_auth_context_peer_identity_property_name(ctx) == nullptr);
it = grpc_auth_context_peer_identity(ctx);
- GPR_ASSERT(grpc_auth_property_iterator_next(&it) == NULL);
+ GPR_ASSERT(grpc_auth_property_iterator_next(&it) == nullptr);
it = grpc_auth_context_property_iterator(ctx);
- GPR_ASSERT(grpc_auth_property_iterator_next(&it) == NULL);
+ GPR_ASSERT(grpc_auth_property_iterator_next(&it) == nullptr);
it = grpc_auth_context_find_properties_by_name(ctx, "foo");
- GPR_ASSERT(grpc_auth_property_iterator_next(&it) == NULL);
+ GPR_ASSERT(grpc_auth_property_iterator_next(&it) == nullptr);
GPR_ASSERT(grpc_auth_context_set_peer_identity_property_name(ctx, "bar") ==
0);
- GPR_ASSERT(grpc_auth_context_peer_identity_property_name(ctx) == NULL);
+ GPR_ASSERT(grpc_auth_context_peer_identity_property_name(ctx) == nullptr);
GRPC_AUTH_CONTEXT_UNREF(ctx, "test");
}
static void test_simple_context(void) {
- grpc_auth_context* ctx = grpc_auth_context_create(NULL);
+ grpc_auth_context* ctx = grpc_auth_context_create(nullptr);
grpc_auth_property_iterator it;
size_t i;
gpr_log(GPR_INFO, "test_simple_context");
- GPR_ASSERT(ctx != NULL);
+ GPR_ASSERT(ctx != nullptr);
grpc_auth_context_add_cstring_property(ctx, "name", "chapi");
grpc_auth_context_add_cstring_property(ctx, "name", "chapo");
grpc_auth_context_add_cstring_property(ctx, "foo", "bar");
@@ -64,25 +64,25 @@ static void test_simple_context(void) {
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);
+ GPR_ASSERT(grpc_auth_property_iterator_next(&it) == nullptr);
it = grpc_auth_context_find_properties_by_name(ctx, "foo");
GPR_ASSERT(grpc_auth_property_iterator_next(&it) ==
&ctx->properties.array[2]);
- GPR_ASSERT(grpc_auth_property_iterator_next(&it) == NULL);
+ GPR_ASSERT(grpc_auth_property_iterator_next(&it) == nullptr);
it = grpc_auth_context_peer_identity(ctx);
GPR_ASSERT(grpc_auth_property_iterator_next(&it) ==
&ctx->properties.array[0]);
GPR_ASSERT(grpc_auth_property_iterator_next(&it) ==
&ctx->properties.array[1]);
- GPR_ASSERT(grpc_auth_property_iterator_next(&it) == NULL);
+ GPR_ASSERT(grpc_auth_property_iterator_next(&it) == nullptr);
GRPC_AUTH_CONTEXT_UNREF(ctx, "test");
}
static void test_chained_context(void) {
- grpc_auth_context* chained = grpc_auth_context_create(NULL);
+ grpc_auth_context* chained = grpc_auth_context_create(nullptr);
grpc_auth_context* ctx = grpc_auth_context_create(chained);
grpc_auth_property_iterator it;
size_t i;
@@ -108,14 +108,14 @@ static void test_chained_context(void) {
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);
+ GPR_ASSERT(grpc_auth_property_iterator_next(&it) == nullptr);
it = grpc_auth_context_find_properties_by_name(ctx, "foo");
GPR_ASSERT(grpc_auth_property_iterator_next(&it) ==
&ctx->properties.array[2]);
GPR_ASSERT(grpc_auth_property_iterator_next(&it) ==
&chained->properties.array[1]);
- GPR_ASSERT(grpc_auth_property_iterator_next(&it) == NULL);
+ GPR_ASSERT(grpc_auth_property_iterator_next(&it) == nullptr);
it = grpc_auth_context_peer_identity(ctx);
GPR_ASSERT(grpc_auth_property_iterator_next(&it) ==
@@ -124,7 +124,7 @@ static void test_chained_context(void) {
&ctx->properties.array[1]);
GPR_ASSERT(grpc_auth_property_iterator_next(&it) ==
&chained->properties.array[0]);
- GPR_ASSERT(grpc_auth_property_iterator_next(&it) == NULL);
+ GPR_ASSERT(grpc_auth_property_iterator_next(&it) == nullptr);
GRPC_AUTH_CONTEXT_UNREF(ctx, "test");
}
diff --git a/test/core/security/create_jwt.cc b/test/core/security/create_jwt.cc
index 95f3615074..867a8ba575 100644
--- a/test/core/security/create_jwt.cc
+++ b/test/core/security/create_jwt.cc
@@ -42,10 +42,10 @@ void create_jwt(const char* json_key_file_path, const char* service_url,
exit(1);
}
jwt = grpc_jwt_encode_and_sign(
- &key, service_url == NULL ? GRPC_JWT_OAUTH2_AUDIENCE : service_url,
+ &key, service_url == nullptr ? GRPC_JWT_OAUTH2_AUDIENCE : service_url,
grpc_max_auth_token_lifetime(), scope);
grpc_auth_json_key_destruct(&key);
- if (jwt == NULL) {
+ if (jwt == nullptr) {
fprintf(stderr, "Could not create JWT.\n");
exit(1);
}
@@ -54,9 +54,9 @@ void create_jwt(const char* json_key_file_path, const char* service_url,
}
int main(int argc, char** argv) {
- const char* scope = NULL;
- const char* json_key_file_path = NULL;
- const char* service_url = NULL;
+ const char* scope = nullptr;
+ const char* json_key_file_path = nullptr;
+ const char* service_url = nullptr;
grpc_init();
gpr_cmdline* cl = gpr_cmdline_create("create_jwt");
gpr_cmdline_add_string(cl, "json_key", "File path of the json key.",
@@ -70,17 +70,17 @@ int main(int argc, char** argv) {
&service_url);
gpr_cmdline_parse(cl, argc, argv);
- if (json_key_file_path == NULL) {
+ if (json_key_file_path == nullptr) {
fprintf(stderr, "Missing --json_key option.\n");
exit(1);
}
- if (scope != NULL) {
- if (service_url != NULL) {
+ if (scope != nullptr) {
+ if (service_url != nullptr) {
fprintf(stderr,
"Options --scope and --service_url are mutually exclusive.\n");
exit(1);
}
- } else if (service_url == NULL) {
+ } else if (service_url == nullptr) {
fprintf(stderr, "Need one of --service_url or --scope options.\n");
exit(1);
}
diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc
index 9b575c4bc5..f9d6e444f3 100644
--- a/test/core/security/credentials_test.cc
+++ b/test/core/security/credentials_test.cc
@@ -151,7 +151,7 @@ static void test_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));
- GPR_ASSERT(md_array.md == NULL);
+ GPR_ASSERT(md_array.md == nullptr);
GPR_ASSERT(md_array.size == 0);
grpc_credentials_mdelem_array_destroy(&exec_ctx, &md_array);
grpc_exec_ctx_finish(&exec_ctx);
@@ -403,9 +403,9 @@ static void test_google_iam_creds(void) {
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
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,
- NULL};
+ nullptr);
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, nullptr,
+ nullptr};
run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
grpc_call_credentials_unref(&exec_ctx, creds);
grpc_exec_ctx_finish(&exec_ctx);
@@ -417,9 +417,9 @@ static void test_access_token_creds(void) {
request_metadata_state* state =
make_request_metadata_state(GRPC_ERROR_NONE, emd, GPR_ARRAY_SIZE(emd));
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};
+ grpc_access_token_credentials_create("blah", nullptr);
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, nullptr,
+ nullptr};
GPR_ASSERT(strcmp(creds->type, GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == 0);
run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
grpc_call_credentials_unref(&exec_ctx, creds);
@@ -432,7 +432,7 @@ static grpc_security_status check_channel_oauth2_create_security_connector(
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(call_creds != nullptr);
GPR_ASSERT(strcmp(call_creds->type, GRPC_CALL_CREDENTIALS_TYPE_OAUTH2) == 0);
return GRPC_SECURITY_OK;
}
@@ -441,18 +441,18 @@ static void test_channel_oauth2_composite_creds(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_channel_args* new_args;
grpc_channel_credentials_vtable vtable = {
- NULL, check_channel_oauth2_create_security_connector, NULL};
+ nullptr, check_channel_oauth2_create_security_connector, nullptr};
grpc_channel_credentials* channel_creds =
grpc_mock_channel_credentials_create(&vtable);
grpc_call_credentials* oauth2_creds =
- grpc_access_token_credentials_create("blah", NULL);
+ grpc_access_token_credentials_create("blah", nullptr);
grpc_channel_credentials* channel_oauth2_creds =
grpc_composite_channel_credentials_create(channel_creds, oauth2_creds,
- NULL);
+ nullptr);
grpc_channel_credentials_release(channel_creds);
grpc_call_credentials_release(oauth2_creds);
GPR_ASSERT(grpc_channel_credentials_create_security_connector(
- &exec_ctx, channel_oauth2_creds, NULL, NULL, NULL,
+ &exec_ctx, channel_oauth2_creds, nullptr, nullptr, nullptr,
&new_args) == GRPC_SECURITY_OK);
grpc_channel_credentials_release(channel_oauth2_creds);
grpc_exec_ctx_finish(&exec_ctx);
@@ -468,16 +468,16 @@ static void test_oauth2_google_iam_composite_creds(void) {
test_google_iam_authority_selector}};
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_auth_metadata_context auth_md_ctx = {test_service_url, test_method, nullptr,
+ nullptr};
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(
test_google_iam_authorization_token, test_google_iam_authority_selector,
- NULL);
+ nullptr);
grpc_call_credentials* composite_creds =
grpc_composite_call_credentials_create(oauth2_creds, google_iam_creds,
- NULL);
+ nullptr);
grpc_call_credentials_unref(&exec_ctx, oauth2_creds);
grpc_call_credentials_unref(&exec_ctx, google_iam_creds);
GPR_ASSERT(
@@ -502,7 +502,7 @@ check_channel_oauth2_google_iam_create_security_connector(
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(call_creds != nullptr);
GPR_ASSERT(strcmp(call_creds->type, GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE) ==
0);
creds_array = grpc_composite_call_credentials_get_credentials(call_creds);
@@ -517,27 +517,27 @@ 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_credentials_vtable vtable = {
- NULL, check_channel_oauth2_google_iam_create_security_connector, NULL};
+ nullptr, check_channel_oauth2_google_iam_create_security_connector, nullptr};
grpc_channel_credentials* channel_creds =
grpc_mock_channel_credentials_create(&vtable);
grpc_call_credentials* oauth2_creds =
- grpc_access_token_credentials_create("blah", NULL);
+ grpc_access_token_credentials_create("blah", nullptr);
grpc_channel_credentials* channel_oauth2_creds =
grpc_composite_channel_credentials_create(channel_creds, oauth2_creds,
- NULL);
+ nullptr);
grpc_call_credentials* google_iam_creds = grpc_google_iam_credentials_create(
test_google_iam_authorization_token, test_google_iam_authority_selector,
- NULL);
+ nullptr);
grpc_channel_credentials* channel_oauth2_iam_creds =
grpc_composite_channel_credentials_create(channel_oauth2_creds,
- google_iam_creds, NULL);
+ google_iam_creds, nullptr);
grpc_channel_credentials_release(channel_creds);
grpc_call_credentials_release(oauth2_creds);
grpc_channel_credentials_release(channel_oauth2_creds);
grpc_call_credentials_release(google_iam_creds);
GPR_ASSERT(grpc_channel_credentials_create_security_connector(
- &exec_ctx, channel_oauth2_iam_creds, NULL, NULL, NULL,
+ &exec_ctx, channel_oauth2_iam_creds, nullptr, nullptr, nullptr,
&new_args) == GRPC_SECURITY_OK);
grpc_channel_credentials_release(channel_oauth2_iam_creds);
@@ -581,7 +581,7 @@ 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) {
- GPR_ASSERT("HTTP POST should not be called" == NULL);
+ GPR_ASSERT("HTTP POST should not be called" == nullptr);
return 1;
}
@@ -590,7 +590,7 @@ static int httpcli_get_should_not_be_called(grpc_exec_ctx* exec_ctx,
grpc_millis deadline,
grpc_closure* on_done,
grpc_httpcli_response* response) {
- GPR_ASSERT("HTTP GET should not be called" == NULL);
+ GPR_ASSERT("HTTP GET should not be called" == nullptr);
return 1;
}
@@ -599,9 +599,9 @@ static void test_compute_engine_creds_success(void) {
expected_md emd[] = {
{"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}};
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};
+ grpc_google_compute_engine_credentials_create(nullptr);
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, nullptr,
+ nullptr};
/* First request: http get should be called. */
request_metadata_state* state =
@@ -620,7 +620,7 @@ static void test_compute_engine_creds_success(void) {
grpc_exec_ctx_flush(&exec_ctx);
grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_httpcli_set_override(NULL, NULL);
+ grpc_httpcli_set_override(nullptr, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -629,24 +629,24 @@ static void test_compute_engine_creds_failure(void) {
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};
+ nullptr, 0);
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, nullptr,
+ nullptr};
grpc_call_credentials* creds =
- grpc_google_compute_engine_credentials_create(NULL);
+ grpc_google_compute_engine_credentials_create(nullptr);
grpc_httpcli_set_override(compute_engine_httpcli_get_failure_override,
httpcli_post_should_not_be_called);
run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_httpcli_set_override(NULL, NULL);
+ grpc_httpcli_set_override(nullptr, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
static void validate_refresh_token_http_request(
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;
- GPR_ASSERT(body != NULL);
+ char* expected_body = nullptr;
+ GPR_ASSERT(body != nullptr);
GPR_ASSERT(body_size != 0);
gpr_asprintf(&expected_body, GRPC_REFRESH_TOKEN_POST_BODY_FORMAT_STRING,
"32555999999.apps.googleusercontent.com",
@@ -689,10 +689,10 @@ static void test_refresh_token_creds_success(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
expected_md emd[] = {
{"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}};
- grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
- NULL};
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, nullptr,
+ nullptr};
grpc_call_credentials* creds = grpc_google_refresh_token_credentials_create(
- test_refresh_token_str, NULL);
+ test_refresh_token_str, nullptr);
/* First request: http get should be called. */
request_metadata_state* state =
@@ -711,7 +711,7 @@ static void test_refresh_token_creds_success(void) {
grpc_exec_ctx_flush(&exec_ctx);
grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_httpcli_set_override(NULL, NULL);
+ grpc_httpcli_set_override(nullptr, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -720,16 +720,16 @@ static void test_refresh_token_creds_failure(void) {
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};
+ nullptr, 0);
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, nullptr,
+ nullptr};
grpc_call_credentials* creds = grpc_google_refresh_token_credentials_create(
- test_refresh_token_str, NULL);
+ test_refresh_token_str, nullptr);
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
refresh_token_httpcli_post_failure);
run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_httpcli_set_override(NULL, NULL);
+ grpc_httpcli_set_override(nullptr, nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -737,22 +737,22 @@ static void validate_jwt_encode_and_sign_params(
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);
+ GPR_ASSERT(json_key->private_key != nullptr);
GPR_ASSERT(RSA_check_key(json_key->private_key));
- GPR_ASSERT(json_key->type != NULL &&
+ GPR_ASSERT(json_key->type != nullptr &&
strcmp(json_key->type, "service_account") == 0);
- GPR_ASSERT(json_key->private_key_id != NULL &&
+ GPR_ASSERT(json_key->private_key_id != nullptr &&
strcmp(json_key->private_key_id,
"e6b5137873db8d2ef81e06a47289e6434ec8a165") == 0);
- GPR_ASSERT(json_key->client_id != NULL &&
+ GPR_ASSERT(json_key->client_id != nullptr &&
strcmp(json_key->client_id,
"777-abaslkan11hlb6nmim3bpspl31ud.apps."
"googleusercontent.com") == 0);
- GPR_ASSERT(json_key->client_email != NULL &&
+ GPR_ASSERT(json_key->client_email != nullptr &&
strcmp(json_key->client_email,
"777-abaslkan11hlb6nmim3bpspl31ud@developer."
"gserviceaccount.com") == 0);
- if (scope != NULL) GPR_ASSERT(strcmp(scope, test_scope) == 0);
+ if (scope != nullptr) GPR_ASSERT(strcmp(scope, test_scope) == 0);
GPR_ASSERT(!gpr_time_cmp(token_lifetime, grpc_max_auth_token_lifetime()));
}
@@ -769,19 +769,19 @@ static char* encode_and_sign_jwt_failure(const grpc_auth_json_key* json_key,
gpr_timespec token_lifetime,
const char* scope) {
validate_jwt_encode_and_sign_params(json_key, scope, token_lifetime);
- return NULL;
+ return nullptr;
}
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;
+ GPR_ASSERT("grpc_jwt_encode_and_sign should not be called" == nullptr);
+ return nullptr;
}
static grpc_service_account_jwt_access_credentials* creds_as_jwt(
grpc_call_credentials* creds) {
- GPR_ASSERT(creds != NULL);
+ GPR_ASSERT(creds != nullptr);
GPR_ASSERT(strcmp(creds->type, GRPC_CALL_CREDENTIALS_TYPE_JWT) == 0);
return (grpc_service_account_jwt_access_credentials*)creds;
}
@@ -792,7 +792,7 @@ static void test_jwt_creds_lifetime(void) {
// Max lifetime.
grpc_call_credentials* jwt_creds =
grpc_service_account_jwt_access_credentials_create(
- json_key_string, grpc_max_auth_token_lifetime(), NULL);
+ json_key_string, grpc_max_auth_token_lifetime(), nullptr);
GPR_ASSERT(gpr_time_cmp(creds_as_jwt(jwt_creds)->jwt_lifetime,
grpc_max_auth_token_lifetime()) == 0);
grpc_call_credentials_release(jwt_creds);
@@ -801,7 +801,7 @@ static void test_jwt_creds_lifetime(void) {
gpr_timespec token_lifetime = {10, 0, GPR_TIMESPAN};
GPR_ASSERT(gpr_time_cmp(grpc_max_auth_token_lifetime(), token_lifetime) > 0);
jwt_creds = grpc_service_account_jwt_access_credentials_create(
- json_key_string, token_lifetime, NULL);
+ json_key_string, token_lifetime, nullptr);
GPR_ASSERT(
gpr_time_cmp(creds_as_jwt(jwt_creds)->jwt_lifetime, token_lifetime) == 0);
grpc_call_credentials_release(jwt_creds);
@@ -810,7 +810,7 @@ static void test_jwt_creds_lifetime(void) {
gpr_timespec add_to_max = {10, 0, GPR_TIMESPAN};
token_lifetime = gpr_time_add(grpc_max_auth_token_lifetime(), add_to_max);
jwt_creds = grpc_service_account_jwt_access_credentials_create(
- json_key_string, token_lifetime, NULL);
+ json_key_string, token_lifetime, nullptr);
GPR_ASSERT(gpr_time_cmp(creds_as_jwt(jwt_creds)->jwt_lifetime,
grpc_max_auth_token_lifetime()) == 0);
grpc_call_credentials_release(jwt_creds);
@@ -821,14 +821,14 @@ static void test_jwt_creds_lifetime(void) {
static void test_jwt_creds_success(void) {
char* json_key_string = test_json_key_str();
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
- NULL};
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, nullptr,
+ nullptr};
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_service_account_jwt_access_credentials_create(
- json_key_string, grpc_max_auth_token_lifetime(), NULL);
+ json_key_string, grpc_max_auth_token_lifetime(), nullptr);
/* First request: jwt_encode_and_sign should be called. */
request_metadata_state* state =
@@ -857,27 +857,27 @@ static void test_jwt_creds_success(void) {
grpc_call_credentials_unref(&exec_ctx, creds);
gpr_free(json_key_string);
gpr_free(expected_md_value);
- grpc_jwt_encode_and_sign_set_override(NULL);
+ grpc_jwt_encode_and_sign_set_override(nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
static void test_jwt_creds_signing_failure(void) {
char* json_key_string = test_json_key_str();
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
- NULL};
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, nullptr,
+ nullptr};
request_metadata_state* state = make_request_metadata_state(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Could not generate JWT."), NULL, 0);
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Could not generate JWT."), nullptr, 0);
grpc_call_credentials* creds =
grpc_service_account_jwt_access_credentials_create(
- json_key_string, grpc_max_auth_token_lifetime(), NULL);
+ json_key_string, grpc_max_auth_token_lifetime(), nullptr);
grpc_jwt_encode_and_sign_set_override(encode_and_sign_jwt_failure);
run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, state);
gpr_free(json_key_string);
grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_jwt_encode_and_sign_set_override(NULL);
+ grpc_jwt_encode_and_sign_set_override(nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -886,8 +886,8 @@ static void set_google_default_creds_env_var_with_file_contents(
size_t contents_len = strlen(contents);
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(creds_file_name != nullptr);
+ GPR_ASSERT(creds_file != nullptr);
GPR_ASSERT(fwrite(contents, 1, contents_len, creds_file) == contents_len);
fclose(creds_file);
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, creds_file_name);
@@ -905,7 +905,7 @@ static void test_google_default_creds_auth_key(void) {
gpr_free(json_key);
creds = (grpc_composite_channel_credentials*)
grpc_google_default_credentials_create();
- GPR_ASSERT(creds != NULL);
+ GPR_ASSERT(creds != nullptr);
jwt = (grpc_service_account_jwt_access_credentials*)creds->call_creds;
GPR_ASSERT(
strcmp(jwt->key.client_id,
@@ -925,7 +925,7 @@ static void test_google_default_creds_refresh_token(void) {
"refresh_token_google_default_creds", test_refresh_token_str);
creds = (grpc_composite_channel_credentials*)
grpc_google_default_credentials_create();
- GPR_ASSERT(creds != NULL);
+ GPR_ASSERT(creds != nullptr);
refresh = (grpc_google_refresh_token_credentials*)creds->call_creds;
GPR_ASSERT(strcmp(refresh->refresh_token.client_id,
"32555999999.apps.googleusercontent.com") == 0);
@@ -951,7 +951,7 @@ 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 nullptr; }
static void test_google_default_creds_gce(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
@@ -959,8 +959,8 @@ static void test_google_default_creds_gce(void) {
{"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}};
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_auth_metadata_context auth_md_ctx = {test_service_url, test_method, nullptr,
+ nullptr};
grpc_flush_cached_google_default_credentials();
gpr_setenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR, ""); /* Reset. */
grpc_override_well_known_credentials_path_getter(
@@ -975,8 +975,8 @@ static void test_google_default_creds_gce(void) {
grpc_google_default_credentials_create();
/* Verify that the default creds actually embeds a GCE creds. */
- GPR_ASSERT(creds != NULL);
- GPR_ASSERT(creds->call_creds != NULL);
+ GPR_ASSERT(creds != nullptr);
+ GPR_ASSERT(creds->call_creds != nullptr);
grpc_httpcli_set_override(compute_engine_httpcli_get_success_override,
httpcli_post_should_not_be_called);
run_request_metadata_test(&exec_ctx, creds->call_creds, auth_md_ctx, state);
@@ -994,8 +994,8 @@ static void test_google_default_creds_gce(void) {
/* Cleanup. */
grpc_channel_credentials_unref(&exec_ctx, cached_creds);
grpc_channel_credentials_unref(&exec_ctx, &creds->base);
- grpc_httpcli_set_override(NULL, NULL);
- grpc_override_well_known_credentials_path_getter(NULL);
+ grpc_httpcli_set_override(nullptr, nullptr);
+ grpc_override_well_known_credentials_path_getter(nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -1021,16 +1021,16 @@ static void test_no_google_default_creds(void) {
grpc_httpcli_set_override(
default_creds_gce_detection_httpcli_get_failure_override,
httpcli_post_should_not_be_called);
- GPR_ASSERT(grpc_google_default_credentials_create() == NULL);
+ GPR_ASSERT(grpc_google_default_credentials_create() == nullptr);
/* Try a cached one. GCE detection should not occur anymore. */
grpc_httpcli_set_override(httpcli_get_should_not_be_called,
httpcli_post_should_not_be_called);
- GPR_ASSERT(grpc_google_default_credentials_create() == NULL);
+ GPR_ASSERT(grpc_google_default_credentials_create() == nullptr);
/* Cleanup. */
- grpc_httpcli_set_override(NULL, NULL);
- grpc_override_well_known_credentials_path_getter(NULL);
+ grpc_httpcli_set_override(nullptr, nullptr);
+ grpc_override_well_known_credentials_path_getter(nullptr);
}
typedef enum {
@@ -1049,8 +1049,8 @@ static int plugin_get_metadata_success(
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(context.channel_auth_context == nullptr);
+ GPR_ASSERT(context.reserved == nullptr);
GPR_ASSERT(GPR_ARRAY_SIZE(plugin_md) <
GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX);
plugin_state* s = (plugin_state*)state;
@@ -1074,8 +1074,8 @@ static int plugin_get_metadata_failure(
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(context.channel_auth_context == nullptr);
+ GPR_ASSERT(context.reserved == nullptr);
plugin_state* s = (plugin_state*)state;
*s = PLUGIN_GET_METADATA_CALLED_STATE;
*status = GRPC_STATUS_UNAUTHENTICATED;
@@ -1092,8 +1092,8 @@ static void test_metadata_plugin_success(void) {
plugin_state state = PLUGIN_INITIAL_STATE;
grpc_metadata_credentials_plugin plugin;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
- NULL};
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, nullptr,
+ nullptr};
request_metadata_state* md_state = make_request_metadata_state(
GRPC_ERROR_NONE, plugin_md, GPR_ARRAY_SIZE(plugin_md));
@@ -1102,7 +1102,7 @@ static void test_metadata_plugin_success(void) {
plugin.destroy = plugin_destroy;
grpc_call_credentials* creds =
- grpc_metadata_credentials_create_from_plugin(plugin, NULL);
+ grpc_metadata_credentials_create_from_plugin(plugin, nullptr);
GPR_ASSERT(state == PLUGIN_INITIAL_STATE);
run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, md_state);
GPR_ASSERT(state == PLUGIN_GET_METADATA_CALLED_STATE);
@@ -1115,14 +1115,14 @@ static void test_metadata_plugin_failure(void) {
plugin_state state = PLUGIN_INITIAL_STATE;
grpc_metadata_credentials_plugin plugin;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, NULL,
- NULL};
+ grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, nullptr,
+ nullptr};
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(
- GRPC_ERROR_CREATE_FROM_COPIED_STRING(expected_error), NULL, 0);
+ GRPC_ERROR_CREATE_FROM_COPIED_STRING(expected_error), nullptr, 0);
gpr_free(expected_error);
plugin.state = &state;
@@ -1130,7 +1130,7 @@ static void test_metadata_plugin_failure(void) {
plugin.destroy = plugin_destroy;
grpc_call_credentials* creds =
- grpc_metadata_credentials_create_from_plugin(plugin, NULL);
+ grpc_metadata_credentials_create_from_plugin(plugin, nullptr);
GPR_ASSERT(state == PLUGIN_INITIAL_STATE);
run_request_metadata_test(&exec_ctx, creds, auth_md_ctx, md_state);
GPR_ASSERT(state == PLUGIN_GET_METADATA_CALLED_STATE);
@@ -1143,12 +1143,12 @@ static void test_get_well_known_google_credentials_file_path(void) {
char* path;
char* home = gpr_getenv("HOME");
path = grpc_get_well_known_google_credentials_file_path();
- GPR_ASSERT(path != NULL);
+ GPR_ASSERT(path != nullptr);
gpr_free(path);
#if defined(GPR_POSIX_ENV) || defined(GPR_LINUX_ENV)
unsetenv("HOME");
path = grpc_get_well_known_google_credentials_file_path();
- GPR_ASSERT(path == NULL);
+ GPR_ASSERT(path == nullptr);
gpr_setenv("HOME", home);
gpr_free(path);
#endif /* GPR_POSIX_ENV || GPR_LINUX_ENV */
@@ -1168,10 +1168,10 @@ static void test_channel_creds_duplicate_without_call_creds(void) {
grpc_channel_credentials_unref(&exec_ctx, dup);
grpc_call_credentials* call_creds =
- grpc_access_token_credentials_create("blah", NULL);
+ grpc_access_token_credentials_create("blah", nullptr);
grpc_channel_credentials* composite_creds =
grpc_composite_channel_credentials_create(channel_creds, call_creds,
- NULL);
+ nullptr);
grpc_call_credentials_unref(&exec_ctx, call_creds);
dup = grpc_channel_credentials_duplicate_without_call_credentials(
composite_creds);
@@ -1234,7 +1234,7 @@ static void test_auth_metadata_context(void) {
grpc_slice_from_copied_string(test_cases[i].call_method);
grpc_auth_metadata_context auth_md_context;
memset(&auth_md_context, 0, sizeof(auth_md_context));
- grpc_auth_metadata_context_build(url_scheme, call_host, call_method, NULL,
+ grpc_auth_metadata_context_build(url_scheme, call_host, call_method, nullptr,
&auth_md_context);
if (strcmp(auth_md_context.service_url,
test_cases[i].desired_service_url) != 0) {
@@ -1248,7 +1248,7 @@ static void test_auth_metadata_context(void) {
test_cases[i].desired_method_name, auth_md_context.method_name);
GPR_ASSERT(false);
}
- GPR_ASSERT(auth_md_context.channel_auth_context == NULL);
+ GPR_ASSERT(auth_md_context.channel_auth_context == nullptr);
grpc_slice_unref(call_host);
grpc_slice_unref(call_method);
grpc_auth_metadata_context_reset(&auth_md_context);
diff --git a/test/core/security/fetch_oauth2.cc b/test/core/security/fetch_oauth2.cc
index fa8036e581..69c470641a 100644
--- a/test/core/security/fetch_oauth2.cc
+++ b/test/core/security/fetch_oauth2.cc
@@ -38,16 +38,16 @@ static grpc_call_credentials* create_refresh_token_creds(
"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), nullptr);
}
int main(int argc, char** argv) {
- grpc_call_credentials* creds = NULL;
- char* json_key_file_path = NULL;
- const char* json_refresh_token_file_path = NULL;
- char* token = NULL;
+ grpc_call_credentials* creds = nullptr;
+ char* json_key_file_path = nullptr;
+ const char* json_refresh_token_file_path = nullptr;
+ char* token = nullptr;
int use_gce = 0;
- char* scope = NULL;
+ char* scope = nullptr;
gpr_cmdline* cl = gpr_cmdline_create("fetch_oauth2");
gpr_cmdline_add_string(cl, "json_refresh_token",
"File path of the json refresh token.",
@@ -60,26 +60,26 @@ int main(int argc, char** argv) {
grpc_init();
- if (json_key_file_path != NULL && json_refresh_token_file_path != NULL) {
+ if (json_key_file_path != nullptr && json_refresh_token_file_path != nullptr) {
gpr_log(GPR_ERROR,
"--json_key and --json_refresh_token are mutually exclusive.");
exit(1);
}
if (use_gce) {
- if (json_key_file_path != NULL || scope != NULL) {
+ if (json_key_file_path != nullptr || scope != nullptr) {
gpr_log(GPR_INFO,
"Ignoring json key and scope to get a token from the GCE "
"metadata server.");
}
- creds = grpc_google_compute_engine_credentials_create(NULL);
- if (creds == NULL) {
+ creds = grpc_google_compute_engine_credentials_create(nullptr);
+ if (creds == nullptr) {
gpr_log(GPR_ERROR, "Could not create gce credentials.");
exit(1);
}
- } else if (json_refresh_token_file_path != NULL) {
+ } else if (json_refresh_token_file_path != nullptr) {
creds = create_refresh_token_creds(json_refresh_token_file_path);
- if (creds == NULL) {
+ if (creds == nullptr) {
gpr_log(GPR_ERROR,
"Could not create refresh token creds. %s does probably not "
"contain a valid json refresh token.",
@@ -90,10 +90,10 @@ int main(int argc, char** argv) {
gpr_log(GPR_ERROR, "Missing --gce or --json_refresh_token option.");
exit(1);
}
- GPR_ASSERT(creds != NULL);
+ GPR_ASSERT(creds != nullptr);
token = grpc_test_fetch_oauth2_token_with_credentials(creds);
- if (token != NULL) {
+ if (token != nullptr) {
printf("Got token: %s.\n", token);
gpr_free(token);
}
diff --git a/test/core/security/json_token_test.cc b/test/core/security/json_token_test.cc
index a06e1d05ce..0dee341169 100644
--- a/test/core/security/json_token_test.cc
+++ b/test/core/security/json_token_test.cc
@@ -78,7 +78,7 @@ 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;
+ const char* part3 = bad_part3 != nullptr ? 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 = static_cast<char*>(gpr_malloc(result_len + 1));
@@ -92,24 +92,24 @@ 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(nullptr);
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));
- GPR_ASSERT(json_key.type != NULL &&
+ GPR_ASSERT(json_key.type != nullptr &&
strcmp(json_key.type, "service_account") == 0);
- GPR_ASSERT(json_key.private_key_id != NULL &&
+ GPR_ASSERT(json_key.private_key_id != nullptr &&
strcmp(json_key.private_key_id,
"e6b5137873db8d2ef81e06a47289e6434ec8a165") == 0);
- GPR_ASSERT(json_key.client_id != NULL &&
+ GPR_ASSERT(json_key.client_id != nullptr &&
strcmp(json_key.client_id,
"777-abaslkan11hlb6nmim3bpspl31ud.apps."
"googleusercontent.com") == 0);
- GPR_ASSERT(json_key.client_email != NULL &&
+ GPR_ASSERT(json_key.client_email != nullptr &&
strcmp(json_key.client_email,
"777-abaslkan11hlb6nmim3bpspl31ud@developer."
"gserviceaccount.com") == 0);
- GPR_ASSERT(json_key.private_key != NULL);
+ GPR_ASSERT(json_key.private_key != nullptr);
gpr_free(json_string);
grpc_auth_json_key_destruct(&json_key);
}
@@ -230,9 +230,9 @@ static grpc_json* parse_json_part_from_jwt(const char* str, size_t len,
static void check_jwt_header(grpc_json* header) {
grpc_json* ptr;
- grpc_json* alg = NULL;
- grpc_json* typ = NULL;
- grpc_json* kid = NULL;
+ grpc_json* alg = nullptr;
+ grpc_json* typ = nullptr;
+ grpc_json* kid = nullptr;
for (ptr = header->child; ptr; ptr = ptr->next) {
if (strcmp(ptr->key, "alg") == 0) {
@@ -243,15 +243,15 @@ static void check_jwt_header(grpc_json* header) {
kid = ptr;
}
}
- GPR_ASSERT(alg != NULL);
+ GPR_ASSERT(alg != nullptr);
GPR_ASSERT(alg->type == GRPC_JSON_STRING);
GPR_ASSERT(strcmp(alg->value, "RS256") == 0);
- GPR_ASSERT(typ != NULL);
+ GPR_ASSERT(typ != nullptr);
GPR_ASSERT(typ->type == GRPC_JSON_STRING);
GPR_ASSERT(strcmp(typ->value, "JWT") == 0);
- GPR_ASSERT(kid != NULL);
+ GPR_ASSERT(kid != nullptr);
GPR_ASSERT(kid->type == GRPC_JSON_STRING);
GPR_ASSERT(strcmp(kid->value, "e6b5137873db8d2ef81e06a47289e6434ec8a165") ==
0);
@@ -262,12 +262,12 @@ static void check_jwt_claim(grpc_json* claim, const char* expected_audience,
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* iss = nullptr;
+ grpc_json* scope = nullptr;
+ grpc_json* aud = nullptr;
+ grpc_json* exp = nullptr;
+ grpc_json* iat = nullptr;
+ grpc_json* sub = nullptr;
grpc_json* ptr;
for (ptr = claim->child; ptr; ptr = ptr->next) {
@@ -286,7 +286,7 @@ static void check_jwt_claim(grpc_json* claim, const char* expected_audience,
}
}
- GPR_ASSERT(iss != NULL);
+ GPR_ASSERT(iss != nullptr);
GPR_ASSERT(iss->type == GRPC_JSON_STRING);
GPR_ASSERT(
strcmp(
@@ -294,30 +294,30 @@ static void check_jwt_claim(grpc_json* claim, const char* expected_audience,
"777-abaslkan11hlb6nmim3bpspl31ud@developer.gserviceaccount.com") ==
0);
- if (expected_scope != NULL) {
- GPR_ASSERT(scope != NULL);
- GPR_ASSERT(sub == NULL);
+ if (expected_scope != nullptr) {
+ GPR_ASSERT(scope != nullptr);
+ GPR_ASSERT(sub == nullptr);
GPR_ASSERT(scope->type == GRPC_JSON_STRING);
GPR_ASSERT(strcmp(scope->value, expected_scope) == 0);
} else {
/* Claims without scope must have a sub. */
- GPR_ASSERT(scope == NULL);
- GPR_ASSERT(sub != NULL);
+ GPR_ASSERT(scope == nullptr);
+ GPR_ASSERT(sub != nullptr);
GPR_ASSERT(sub->type == GRPC_JSON_STRING);
GPR_ASSERT(strcmp(iss->value, sub->value) == 0);
}
- GPR_ASSERT(aud != NULL);
+ GPR_ASSERT(aud != nullptr);
GPR_ASSERT(aud->type == GRPC_JSON_STRING);
GPR_ASSERT(strcmp(aud->value, expected_audience) == 0);
- GPR_ASSERT(exp != NULL);
+ GPR_ASSERT(exp != nullptr);
GPR_ASSERT(exp->type == GRPC_JSON_NUMBER);
- expiration.tv_sec = strtol(exp->value, NULL, 10);
+ expiration.tv_sec = strtol(exp->value, nullptr, 10);
- GPR_ASSERT(iat != NULL);
+ GPR_ASSERT(iat != nullptr);
GPR_ASSERT(iat->type == GRPC_JSON_NUMBER);
- issue_time.tv_sec = strtol(iat->value, NULL, 10);
+ issue_time.tv_sec = strtol(iat->value, nullptr, 10);
parsed_lifetime = gpr_time_sub(expiration, issue_time);
GPR_ASSERT(parsed_lifetime.tv_sec == grpc_max_auth_token_lifetime().tv_sec);
@@ -335,19 +335,19 @@ static void check_jwt_signature(const char* b64_signature, RSA* rsa_key,
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(sig));
GPR_ASSERT(GRPC_SLICE_LENGTH(sig) == 128);
- GPR_ASSERT(md_ctx != NULL);
- GPR_ASSERT(key != NULL);
+ GPR_ASSERT(md_ctx != nullptr);
+ GPR_ASSERT(key != nullptr);
EVP_PKEY_set1_RSA(key, rsa_key);
- GPR_ASSERT(EVP_DigestVerifyInit(md_ctx, NULL, EVP_sha256(), NULL, key) == 1);
+ GPR_ASSERT(EVP_DigestVerifyInit(md_ctx, nullptr, EVP_sha256(), nullptr, key) == 1);
GPR_ASSERT(EVP_DigestVerifyUpdate(md_ctx, signed_data, signed_data_size) ==
1);
GPR_ASSERT(EVP_DigestVerifyFinal(md_ctx, GRPC_SLICE_START_PTR(sig),
GRPC_SLICE_LENGTH(sig)) == 1);
grpc_slice_unref_internal(&exec_ctx, sig);
- if (key != NULL) EVP_PKEY_free(key);
- if (md_ctx != NULL) EVP_MD_CTX_destroy(md_ctx);
+ if (key != nullptr) EVP_PKEY_free(key);
+ if (md_ctx != nullptr) EVP_MD_CTX_destroy(md_ctx);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -360,7 +360,7 @@ static char* service_account_creds_jwt_encode_and_sign(
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);
+ grpc_max_auth_token_lifetime(), nullptr);
}
static void service_account_creds_check_jwt_claim(grpc_json* claim) {
@@ -368,15 +368,15 @@ static void service_account_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);
+ check_jwt_claim(claim, test_service_url, nullptr);
}
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* json_string = test_json_key_str(nullptr);
+ grpc_json* parsed_header = nullptr;
+ grpc_json* parsed_claim = nullptr;
char* scratchpad;
grpc_auth_json_key json_key =
grpc_auth_json_key_create_from_string(json_string);
@@ -384,27 +384,27 @@ static void test_jwt_encode_and_sign(
size_t offset = 0;
char* jwt = jwt_encode_and_sign_func(&json_key);
const char* dot = strchr(jwt, '.');
- GPR_ASSERT(dot != NULL);
+ GPR_ASSERT(dot != nullptr);
parsed_header =
parse_json_part_from_jwt(jwt, (size_t)(dot - jwt), &scratchpad);
- GPR_ASSERT(parsed_header != NULL);
+ GPR_ASSERT(parsed_header != nullptr);
check_jwt_header(parsed_header);
offset = (size_t)(dot - jwt) + 1;
grpc_json_destroy(parsed_header);
gpr_free(scratchpad);
dot = strchr(jwt + offset, '.');
- GPR_ASSERT(dot != NULL);
+ GPR_ASSERT(dot != nullptr);
parsed_claim = parse_json_part_from_jwt(
jwt + offset, (size_t)(dot - (jwt + offset)), &scratchpad);
- GPR_ASSERT(parsed_claim != NULL);
+ GPR_ASSERT(parsed_claim != nullptr);
check_jwt_claim_func(parsed_claim);
offset = (size_t)(dot - jwt) + 1;
grpc_json_destroy(parsed_claim);
gpr_free(scratchpad);
dot = strchr(jwt + offset, '.');
- GPR_ASSERT(dot == NULL); /* no more part. */
+ GPR_ASSERT(dot == nullptr); /* no more part. */
b64_signature = jwt + offset;
check_jwt_signature(b64_signature, json_key.private_key, jwt, offset - 1);
@@ -427,15 +427,15 @@ static void test_parse_refresh_token_success(void) {
grpc_auth_refresh_token refresh_token =
grpc_auth_refresh_token_create_from_string(test_refresh_token_str);
GPR_ASSERT(grpc_auth_refresh_token_is_valid(&refresh_token));
- GPR_ASSERT(refresh_token.type != NULL &&
+ GPR_ASSERT(refresh_token.type != nullptr &&
(strcmp(refresh_token.type, "authorized_user") == 0));
- GPR_ASSERT(refresh_token.client_id != NULL &&
+ GPR_ASSERT(refresh_token.client_id != nullptr &&
(strcmp(refresh_token.client_id,
"32555999999.apps.googleusercontent.com") == 0));
GPR_ASSERT(
- refresh_token.client_secret != NULL &&
+ refresh_token.client_secret != nullptr &&
(strcmp(refresh_token.client_secret, "EmssLNjJy1332hD4KFsecret") == 0));
- GPR_ASSERT(refresh_token.refresh_token != NULL &&
+ GPR_ASSERT(refresh_token.refresh_token != nullptr &&
(strcmp(refresh_token.refresh_token,
"1/Blahblasj424jladJDSGNf-u4Sua3HDA2ngjd42") == 0));
grpc_auth_refresh_token_destruct(&refresh_token);
diff --git a/test/core/security/jwt_verifier_test.cc b/test/core/security/jwt_verifier_test.cc
index 6858b36141..df0ebe5607 100644
--- a/test/core/security/jwt_verifier_test.cc
+++ b/test/core/security/jwt_verifier_test.cc
@@ -173,13 +173,13 @@ typedef struct {
static void test_jwt_issuer_email_domain(void) {
const char* d = grpc_jwt_issuer_email_domain("https://foo.com");
- GPR_ASSERT(d == NULL);
+ GPR_ASSERT(d == nullptr);
d = grpc_jwt_issuer_email_domain("foo.com");
- GPR_ASSERT(d == NULL);
+ GPR_ASSERT(d == nullptr);
d = grpc_jwt_issuer_email_domain("");
- GPR_ASSERT(d == NULL);
+ GPR_ASSERT(d == nullptr);
d = grpc_jwt_issuer_email_domain("@");
- GPR_ASSERT(d == NULL);
+ GPR_ASSERT(d == nullptr);
d = grpc_jwt_issuer_email_domain("bar@foo");
GPR_ASSERT(strcmp(d, "foo") == 0);
d = grpc_jwt_issuer_email_domain("bar@foo.com");
@@ -196,11 +196,11 @@ static void test_jwt_issuer_email_domain(void) {
d = grpc_jwt_issuer_email_domain("@foo");
GPR_ASSERT(strcmp(d, "foo") == 0);
d = grpc_jwt_issuer_email_domain("bar@.");
- GPR_ASSERT(d != NULL);
+ GPR_ASSERT(d != nullptr);
d = grpc_jwt_issuer_email_domain("bar@..");
- GPR_ASSERT(d != NULL);
+ GPR_ASSERT(d != nullptr);
d = grpc_jwt_issuer_email_domain("bar@...");
- GPR_ASSERT(d != NULL);
+ GPR_ASSERT(d != nullptr);
}
static void test_claims_success(void) {
@@ -208,10 +208,10 @@ static void test_claims_success(void) {
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));
- GPR_ASSERT(json != NULL);
+ GPR_ASSERT(json != nullptr);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
- GPR_ASSERT(claims != NULL);
+ GPR_ASSERT(claims != nullptr);
GPR_ASSERT(grpc_jwt_claims_json(claims) == json);
GPR_ASSERT(strcmp(grpc_jwt_claims_audience(claims), "https://foo.com") == 0);
GPR_ASSERT(strcmp(grpc_jwt_claims_issuer(claims), "blah.foo.com") == 0);
@@ -231,10 +231,10 @@ static void test_expired_claims_failure(void) {
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};
- GPR_ASSERT(json != NULL);
+ GPR_ASSERT(json != nullptr);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
- GPR_ASSERT(claims != NULL);
+ GPR_ASSERT(claims != nullptr);
GPR_ASSERT(grpc_jwt_claims_json(claims) == json);
GPR_ASSERT(strcmp(grpc_jwt_claims_audience(claims), "https://foo.com") == 0);
GPR_ASSERT(strcmp(grpc_jwt_claims_issuer(claims), "blah.foo.com") == 0);
@@ -255,7 +255,7 @@ static void test_invalid_claims_failure(void) {
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);
+ GPR_ASSERT(grpc_jwt_claims_from_json(&exec_ctx, json, s) == nullptr);
grpc_exec_ctx_finish(&exec_ctx);
}
@@ -264,10 +264,10 @@ static void test_bad_audience_claims_failure(void) {
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));
- GPR_ASSERT(json != NULL);
+ GPR_ASSERT(json != nullptr);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
- GPR_ASSERT(claims != NULL);
+ GPR_ASSERT(claims != nullptr);
GPR_ASSERT(grpc_jwt_claims_check(claims, "https://bar.com") ==
GRPC_JWT_VERIFIER_BAD_AUDIENCE);
grpc_jwt_claims_destroy(&exec_ctx, claims);
@@ -279,10 +279,10 @@ static void test_bad_subject_claims_failure(void) {
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));
- GPR_ASSERT(json != NULL);
+ GPR_ASSERT(json != nullptr);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
claims = grpc_jwt_claims_from_json(&exec_ctx, json, s);
- GPR_ASSERT(claims != NULL);
+ GPR_ASSERT(claims != nullptr);
GPR_ASSERT(grpc_jwt_claims_check(claims, "https://foo.com") ==
GRPC_JWT_VERIFIER_BAD_SUBJECT);
grpc_jwt_claims_destroy(&exec_ctx, claims);
@@ -326,7 +326,7 @@ 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) {
- GPR_ASSERT("HTTP POST should not be called" == NULL);
+ GPR_ASSERT("HTTP POST should not be called" == nullptr);
return 1;
}
@@ -349,7 +349,7 @@ static void on_verification_success(grpc_exec_ctx* exec_ctx, void* user_data,
grpc_jwt_verifier_status status,
grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_OK);
- GPR_ASSERT(claims != NULL);
+ GPR_ASSERT(claims != nullptr);
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);
@@ -357,8 +357,8 @@ static void on_verification_success(grpc_exec_ctx* exec_ctx, void* user_data,
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;
+ grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
+ char* jwt = nullptr;
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);
@@ -366,15 +366,15 @@ static void test_jwt_verifier_google_email_issuer_success(void) {
grpc_httpcli_set_override(httpcli_get_google_keys_for_email,
httpcli_post_should_not_be_called);
jwt = grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime,
- NULL);
+ nullptr);
grpc_auth_json_key_destruct(&key);
- GPR_ASSERT(jwt != NULL);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience,
+ GPR_ASSERT(jwt != nullptr);
+ grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, jwt, expected_audience,
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);
+ grpc_httpcli_set_override(nullptr, nullptr);
}
static int httpcli_get_custom_keys_for_email(
@@ -392,7 +392,7 @@ 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* jwt = nullptr;
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);
@@ -400,15 +400,15 @@ static void test_jwt_verifier_custom_email_issuer_success(void) {
grpc_httpcli_set_override(httpcli_get_custom_keys_for_email,
httpcli_post_should_not_be_called);
jwt = grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime,
- NULL);
+ nullptr);
grpc_auth_json_key_destruct(&key);
- GPR_ASSERT(jwt != NULL);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience,
+ GPR_ASSERT(jwt != nullptr);
+ grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, jwt, expected_audience,
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);
+ grpc_httpcli_set_override(nullptr, nullptr);
}
static int httpcli_get_jwk_set(grpc_exec_ctx* exec_ctx,
@@ -440,8 +440,8 @@ 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;
+ grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
+ char* jwt = nullptr;
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);
@@ -449,15 +449,15 @@ static void test_jwt_verifier_url_issuer_success(void) {
grpc_httpcli_set_override(httpcli_get_openid_config,
httpcli_post_should_not_be_called);
jwt = grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime,
- NULL);
+ nullptr);
grpc_auth_json_key_destruct(&key);
- GPR_ASSERT(jwt != NULL);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience,
+ GPR_ASSERT(jwt != nullptr);
+ grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, jwt, expected_audience,
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);
+ grpc_httpcli_set_override(nullptr, nullptr);
}
static void on_verification_key_retrieval_error(grpc_exec_ctx* exec_ctx,
@@ -465,7 +465,7 @@ static void on_verification_key_retrieval_error(grpc_exec_ctx* exec_ctx,
grpc_jwt_verifier_status status,
grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR);
- GPR_ASSERT(claims == NULL);
+ GPR_ASSERT(claims == nullptr);
GPR_ASSERT(user_data == (void*)expected_user_data);
}
@@ -481,8 +481,8 @@ 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;
+ grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
+ char* jwt = nullptr;
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);
@@ -490,22 +490,22 @@ static void test_jwt_verifier_url_issuer_bad_config(void) {
grpc_httpcli_set_override(httpcli_get_bad_json,
httpcli_post_should_not_be_called);
jwt = grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime,
- NULL);
+ nullptr);
grpc_auth_json_key_destruct(&key);
- GPR_ASSERT(jwt != NULL);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience,
+ GPR_ASSERT(jwt != nullptr);
+ grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, jwt, expected_audience,
on_verification_key_retrieval_error,
(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);
+ grpc_httpcli_set_override(nullptr, nullptr);
}
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;
+ grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
+ char* jwt = nullptr;
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);
@@ -513,16 +513,16 @@ static void test_jwt_verifier_bad_json_key(void) {
grpc_httpcli_set_override(httpcli_get_bad_json,
httpcli_post_should_not_be_called);
jwt = grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime,
- NULL);
+ nullptr);
grpc_auth_json_key_destruct(&key);
- GPR_ASSERT(jwt != NULL);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience,
+ GPR_ASSERT(jwt != nullptr);
+ grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, jwt, expected_audience,
on_verification_key_retrieval_error,
(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);
+ grpc_httpcli_set_override(nullptr, nullptr);
}
static void corrupt_jwt_sig(char* jwt) {
@@ -530,7 +530,7 @@ static void corrupt_jwt_sig(char* jwt) {
char* bad_b64_sig;
uint8_t* sig_bytes;
char* last_dot = strrchr(jwt, '.');
- GPR_ASSERT(last_dot != NULL);
+ GPR_ASSERT(last_dot != nullptr);
{
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
sig = grpc_base64_decode(&exec_ctx, last_dot + 1, 1);
@@ -551,14 +551,14 @@ static void on_verification_bad_signature(grpc_exec_ctx* exec_ctx,
grpc_jwt_verifier_status status,
grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_BAD_SIGNATURE);
- GPR_ASSERT(claims == NULL);
+ GPR_ASSERT(claims == nullptr);
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;
+ grpc_jwt_verifier* verifier = grpc_jwt_verifier_create(nullptr, 0);
+ char* jwt = nullptr;
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);
@@ -566,17 +566,17 @@ static void test_jwt_verifier_bad_signature(void) {
grpc_httpcli_set_override(httpcli_get_openid_config,
httpcli_post_should_not_be_called);
jwt = grpc_jwt_encode_and_sign(&key, expected_audience, expected_lifetime,
- NULL);
+ nullptr);
grpc_auth_json_key_destruct(&key);
corrupt_jwt_sig(jwt);
- GPR_ASSERT(jwt != NULL);
- grpc_jwt_verifier_verify(&exec_ctx, verifier, NULL, jwt, expected_audience,
+ GPR_ASSERT(jwt != nullptr);
+ grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, jwt, expected_audience,
on_verification_bad_signature,
(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);
+ grpc_httpcli_set_override(nullptr, nullptr);
}
static int httpcli_get_should_not_be_called(grpc_exec_ctx* exec_ctx,
@@ -592,21 +592,21 @@ static void on_verification_bad_format(grpc_exec_ctx* exec_ctx, void* user_data,
grpc_jwt_verifier_status status,
grpc_jwt_claims* claims) {
GPR_ASSERT(status == GRPC_JWT_VERIFIER_BAD_FORMAT);
- GPR_ASSERT(claims == NULL);
+ GPR_ASSERT(claims == nullptr);
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(nullptr, 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",
+ grpc_jwt_verifier_verify(&exec_ctx, verifier, nullptr, "bad jwt",
expected_audience, on_verification_bad_format,
(void*)expected_user_data);
grpc_jwt_verifier_destroy(&exec_ctx, verifier);
grpc_exec_ctx_finish(&exec_ctx);
- grpc_httpcli_set_override(NULL, NULL);
+ grpc_httpcli_set_override(nullptr, nullptr);
}
/* find verification key: bad jks, cannot find key in jks */
diff --git a/test/core/security/oauth2_utils.cc b/test/core/security/oauth2_utils.cc
index fda3d96e18..602041eecc 100644
--- a/test/core/security/oauth2_utils.cc
+++ b/test/core/security/oauth2_utils.cc
@@ -42,7 +42,7 @@ typedef struct {
static void on_oauth2_response(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) {
oauth2_request* request = (oauth2_request*)arg;
- char* token = NULL;
+ char* token = nullptr;
grpc_slice token_slice;
if (error != GRPC_ERROR_NONE) {
gpr_log(GPR_ERROR, "Fetching token failed: %s", grpc_error_string(error));
@@ -61,7 +61,7 @@ static void on_oauth2_response(grpc_exec_ctx* exec_ctx, void* arg,
GRPC_LOG_IF_ERROR(
"pollset_kick",
grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&request->pops),
- NULL));
+ nullptr));
gpr_mu_unlock(request->mu);
}
@@ -74,14 +74,14 @@ char* grpc_test_fetch_oauth2_token_with_credentials(
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_auth_metadata_context null_ctx = {"", "", nullptr, nullptr};
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;
- GRPC_CLOSURE_INIT(&do_nothing_closure, do_nothing, NULL,
+ GRPC_CLOSURE_INIT(&do_nothing_closure, do_nothing, nullptr,
grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&request.closure, on_oauth2_response, &request,
@@ -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 = nullptr;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx,
diff --git a/test/core/security/print_google_default_creds_token.cc b/test/core/security/print_google_default_creds_token.cc
index a57180b57d..f4acf023bd 100644
--- a/test/core/security/print_google_default_creds_token.cc
+++ b/test/core/security/print_google_default_creds_token.cc
@@ -58,7 +58,7 @@ static void on_metadata_response(grpc_exec_ctx* exec_ctx, void* arg,
GRPC_LOG_IF_ERROR(
"pollset_kick",
grpc_pollset_kick(exec_ctx, grpc_polling_entity_pollset(&sync->pops),
- NULL));
+ nullptr));
gpr_mu_unlock(sync->mu);
}
@@ -66,7 +66,7 @@ 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;
+ grpc_channel_credentials* creds = nullptr;
const char* service_url = "https://test.foo.google.com/Foo";
grpc_auth_metadata_context context;
gpr_cmdline* cl = gpr_cmdline_create("print_google_default_creds_token");
@@ -81,7 +81,7 @@ int main(int argc, char** argv) {
grpc_init();
creds = grpc_google_default_credentials_create();
- if (creds == NULL) {
+ if (creds == nullptr) {
fprintf(stderr, "\nCould not find default credentials.\n\n");
result = 1;
goto end;
@@ -107,7 +107,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 = nullptr;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx,
diff --git a/test/core/security/secure_endpoint_test.cc b/test/core/security/secure_endpoint_test.cc
index 11d1e5fcf4..2d4c6b1b88 100644
--- a/test/core/security/secure_endpoint_test.cc
+++ b/test/core/security/secure_endpoint_test.cc
@@ -40,15 +40,15 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
bool use_zero_copy_protector) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
tsi_frame_protector* fake_read_protector =
- tsi_create_fake_frame_protector(NULL);
+ tsi_create_fake_frame_protector(nullptr);
tsi_frame_protector* fake_write_protector =
- tsi_create_fake_frame_protector(NULL);
+ tsi_create_fake_frame_protector(nullptr);
tsi_zero_copy_grpc_protector* fake_read_zero_copy_protector =
- use_zero_copy_protector ? tsi_create_fake_zero_copy_grpc_protector(NULL)
- : NULL;
+ use_zero_copy_protector ? tsi_create_fake_zero_copy_grpc_protector(nullptr)
+ : nullptr;
tsi_zero_copy_grpc_protector* fake_write_zero_copy_protector =
- use_zero_copy_protector ? tsi_create_fake_zero_copy_grpc_protector(NULL)
- : NULL;
+ use_zero_copy_protector ? tsi_create_fake_zero_copy_grpc_protector(nullptr)
+ : nullptr;
grpc_endpoint_test_fixture f;
grpc_endpoint_pair tcp;
@@ -64,7 +64,7 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
if (leftover_nslices == 0) {
f.client_ep = grpc_secure_endpoint_create(fake_read_protector,
fake_read_zero_copy_protector,
- tcp.client, NULL, 0);
+ tcp.client, nullptr, 0);
} else {
unsigned i;
tsi_result result;
@@ -114,21 +114,21 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
f.server_ep = grpc_secure_endpoint_create(fake_write_protector,
fake_write_zero_copy_protector,
- tcp.server, NULL, 0);
+ tcp.server, nullptr, 0);
grpc_exec_ctx_finish(&exec_ctx);
return f;
}
static grpc_endpoint_test_fixture
secure_endpoint_create_fixture_tcp_socketpair_noleftover(size_t slice_size) {
- return secure_endpoint_create_fixture_tcp_socketpair(slice_size, NULL, 0,
+ return secure_endpoint_create_fixture_tcp_socketpair(slice_size, nullptr, 0,
false);
}
static grpc_endpoint_test_fixture
secure_endpoint_create_fixture_tcp_socketpair_noleftover_zero_copy(
size_t slice_size) {
- return secure_endpoint_create_fixture_tcp_socketpair(slice_size, NULL, 0,
+ return secure_endpoint_create_fixture_tcp_socketpair(slice_size, nullptr, 0,
true);
}
diff --git a/test/core/security/security_connector_test.cc b/test/core/security/security_connector_test.cc
index a0c1e93532..9a68e176db 100644
--- a/test/core/security/security_connector_test.cc
+++ b/test/core/security/security_connector_test.cc
@@ -39,13 +39,13 @@ 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);
- if (prop == NULL) return 0;
+ if (prop == nullptr) return 0;
if (strncmp(prop->value, GRPC_SSL_TRANSPORT_SECURITY_TYPE,
prop->value_length) != 0) {
return 0;
}
/* Check that we have only one property with this name. */
- if (grpc_auth_property_iterator_next(&it) != NULL) return 0;
+ if (grpc_auth_property_iterator_next(&it) != nullptr) return 0;
return 1;
}
@@ -89,7 +89,7 @@ static void test_unauthenticated_ssl_peer(void) {
TSI_CERTIFICATE_TYPE_PEER_PROPERTY, TSI_X509_CERTIFICATE_TYPE,
&peer.properties[0]) == TSI_OK);
ctx = tsi_ssl_peer_to_auth_context(&peer);
- GPR_ASSERT(ctx != NULL);
+ GPR_ASSERT(ctx != nullptr);
GPR_ASSERT(!grpc_auth_context_peer_is_authenticated(ctx));
GPR_ASSERT(check_transport_security_type(ctx));
@@ -112,7 +112,7 @@ static int check_identity(const grpc_auth_context* ctx,
it = grpc_auth_context_peer_identity(ctx);
for (i = 0; i < num_identities; i++) {
prop = grpc_auth_property_iterator_next(&it);
- if (prop == NULL) {
+ if (prop == nullptr) {
gpr_log(GPR_ERROR, "Expected identity value %s not found.",
expected_identities[i]);
return 0;
@@ -136,7 +136,7 @@ static int check_x509_cn(const grpc_auth_context* ctx,
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);
- if (prop == NULL) {
+ if (prop == nullptr) {
gpr_log(GPR_ERROR, "CN property not found.");
return 0;
}
@@ -144,7 +144,7 @@ static int check_x509_cn(const grpc_auth_context* ctx,
gpr_log(GPR_ERROR, "Expected CN %s and got %s", expected_cn, prop->value);
return 0;
}
- if (grpc_auth_property_iterator_next(&it) != NULL) {
+ if (grpc_auth_property_iterator_next(&it) != nullptr) {
gpr_log(GPR_ERROR, "Expected only one property for CN.");
return 0;
}
@@ -156,7 +156,7 @@ static int check_x509_pem_cert(const grpc_auth_context* ctx,
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);
- if (prop == NULL) {
+ if (prop == nullptr) {
gpr_log(GPR_ERROR, "Pem certificate property not found.");
return 0;
}
@@ -165,7 +165,7 @@ static int check_x509_pem_cert(const grpc_auth_context* ctx,
prop->value);
return 0;
}
- if (grpc_auth_property_iterator_next(&it) != NULL) {
+ if (grpc_auth_property_iterator_next(&it) != nullptr) {
gpr_log(GPR_ERROR, "Expected only one property for pem cert.");
return 0;
}
@@ -189,7 +189,7 @@ static void test_cn_only_ssl_peer_to_auth_context(void) {
TSI_X509_PEM_CERT_PROPERTY, expected_pem_cert,
&peer.properties[2]) == TSI_OK);
ctx = tsi_ssl_peer_to_auth_context(&peer);
- GPR_ASSERT(ctx != NULL);
+ GPR_ASSERT(ctx != nullptr);
GPR_ASSERT(grpc_auth_context_peer_is_authenticated(ctx));
GPR_ASSERT(check_identity(ctx, GRPC_X509_CN_PROPERTY_NAME, &expected_cn, 1));
GPR_ASSERT(check_transport_security_type(ctx));
@@ -225,7 +225,7 @@ static void test_cn_and_one_san_ssl_peer_to_auth_context(void) {
TSI_X509_PEM_CERT_PROPERTY, expected_pem_cert,
&peer.properties[3]) == TSI_OK);
ctx = tsi_ssl_peer_to_auth_context(&peer);
- GPR_ASSERT(ctx != NULL);
+ GPR_ASSERT(ctx != nullptr);
GPR_ASSERT(grpc_auth_context_peer_is_authenticated(ctx));
GPR_ASSERT(
check_identity(ctx, GRPC_X509_SAN_PROPERTY_NAME, &expected_san, 1));
@@ -266,7 +266,7 @@ static void test_cn_and_multiple_sans_ssl_peer_to_auth_context(void) {
expected_sans[i], &peer.properties[3 + i]) == TSI_OK);
}
ctx = tsi_ssl_peer_to_auth_context(&peer);
- GPR_ASSERT(ctx != NULL);
+ GPR_ASSERT(ctx != nullptr);
GPR_ASSERT(grpc_auth_context_peer_is_authenticated(ctx));
GPR_ASSERT(check_identity(ctx, GRPC_X509_SAN_PROPERTY_NAME, expected_sans,
GPR_ARRAY_SIZE(expected_sans)));
@@ -312,7 +312,7 @@ static void test_cn_and_multiple_sans_and_others_ssl_peer_to_auth_context(
expected_sans[i], &peer.properties[5 + i]) == TSI_OK);
}
ctx = tsi_ssl_peer_to_auth_context(&peer);
- GPR_ASSERT(ctx != NULL);
+ GPR_ASSERT(ctx != nullptr);
GPR_ASSERT(grpc_auth_context_peer_is_authenticated(ctx));
GPR_ASSERT(check_identity(ctx, GRPC_X509_SAN_PROPERTY_NAME, expected_sans,
GPR_ARRAY_SIZE(expected_sans)));
diff --git a/test/core/security/ssl_credentials_test.cc b/test/core/security/ssl_credentials_test.cc
index 76ee32b001..9edcf42d3a 100644
--- a/test/core/security/ssl_credentials_test.cc
+++ b/test/core/security/ssl_credentials_test.cc
@@ -36,14 +36,14 @@ static void test_convert_grpc_to_tsi_cert_pairs() {
{
tsi_ssl_pem_key_cert_pair* tsi_pairs =
grpc_convert_grpc_to_tsi_cert_pairs(grpc_pairs, 0);
- GPR_ASSERT(tsi_pairs == NULL);
+ GPR_ASSERT(tsi_pairs == nullptr);
}
{
tsi_ssl_pem_key_cert_pair* tsi_pairs =
grpc_convert_grpc_to_tsi_cert_pairs(grpc_pairs, num_pairs);
- GPR_ASSERT(tsi_pairs != NULL);
+ GPR_ASSERT(tsi_pairs != nullptr);
for (size_t i = 0; i < num_pairs; i++) {
GPR_ASSERT(strncmp(grpc_pairs[i].private_key, tsi_pairs[i].private_key,
strlen(grpc_pairs[i].private_key)) == 0);
diff --git a/test/core/security/ssl_server_fuzzer.cc b/test/core/security/ssl_server_fuzzer.cc
index 5c5153b505..bbb2f6013e 100644
--- a/test/core/security/ssl_server_fuzzer.cc
+++ b/test/core/security/ssl_server_fuzzer.cc
@@ -78,10 +78,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
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);
+ ca_cert, &pem_key_cert_pair, 1, 0, nullptr);
// Create security connector
- grpc_server_security_connector* sc = NULL;
+ grpc_server_security_connector* sc = nullptr;
grpc_security_status status =
grpc_server_credentials_create_security_connector(&exec_ctx, creds, &sc);
GPR_ASSERT(status == GRPC_SECURITY_OK);
@@ -92,8 +92,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
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 */,
- deadline, NULL /* acceptor */, on_handshake_done, &state);
+ &exec_ctx, handshake_mgr, mock_endpoint, nullptr /* channel_args */,
+ deadline, nullptr /* acceptor */, on_handshake_done, &state);
grpc_exec_ctx_flush(&exec_ctx);
// If the given string happens to be part of the correct client hello, the
diff --git a/test/core/security/verify_jwt.cc b/test/core/security/verify_jwt.cc
index e0e22d16f9..787d58bc37 100644
--- a/test/core/security/verify_jwt.cc
+++ b/test/core/security/verify_jwt.cc
@@ -52,14 +52,14 @@ static void on_jwt_verification_done(grpc_exec_ctx* exec_ctx, void* user_data,
sync->success = (status == GRPC_JWT_VERIFIER_OK);
if (sync->success) {
char* claims_str;
- GPR_ASSERT(claims != NULL);
+ GPR_ASSERT(claims != nullptr);
claims_str =
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);
} else {
- GPR_ASSERT(claims == NULL);
+ GPR_ASSERT(claims == nullptr);
fprintf(stderr, "Verification failed with error %s\n",
grpc_jwt_verifier_status_to_string(status));
}
@@ -67,7 +67,7 @@ static void on_jwt_verification_done(grpc_exec_ctx* exec_ctx, void* user_data,
gpr_mu_lock(sync->mu);
sync->is_done = 1;
GRPC_LOG_IF_ERROR("pollset_kick",
- grpc_pollset_kick(exec_ctx, sync->pollset, NULL));
+ grpc_pollset_kick(exec_ctx, sync->pollset, nullptr));
gpr_mu_unlock(sync->mu);
}
@@ -75,8 +75,8 @@ int main(int argc, char** argv) {
synchronizer sync;
grpc_jwt_verifier* verifier;
gpr_cmdline* cl;
- const char* jwt = NULL;
- const char* aud = NULL;
+ const char* jwt = nullptr;
+ const char* aud = nullptr;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_init();
@@ -84,11 +84,11 @@ int main(int argc, char** argv) {
gpr_cmdline_add_string(cl, "jwt", "JSON web token to verify", &jwt);
gpr_cmdline_add_string(cl, "aud", "Audience for the JWT", &aud);
gpr_cmdline_parse(cl, argc, argv);
- if (jwt == NULL || aud == NULL) {
+ if (jwt == nullptr || aud == nullptr) {
print_usage_and_exit(cl, argv[0]);
}
- verifier = grpc_jwt_verifier_create(NULL, 0);
+ verifier = grpc_jwt_verifier_create(nullptr, 0);
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 = nullptr;
if (!GRPC_LOG_IF_ERROR("pollset_work",
grpc_pollset_work(&exec_ctx, sync.pollset, &worker,
GRPC_MILLIS_INF_FUTURE)))