diff --git a/CMakeLists.txt b/CMakeLists.txt index c7db2d856ab..d84462bd725 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7397,6 +7397,7 @@ target_include_directories(aws_request_signer_test target_link_libraries(aws_request_signer_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) @@ -15807,6 +15808,7 @@ target_include_directories(grpc_tls_certificate_distributor_test target_link_libraries(grpc_tls_certificate_distributor_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) @@ -15858,6 +15860,7 @@ target_include_directories(grpc_tls_certificate_provider_test target_link_libraries(grpc_tls_certificate_provider_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) @@ -31284,6 +31287,7 @@ target_include_directories(tls_security_connector_test target_link_libraries(tls_security_connector_test ${_gRPC_ALLTARGETS_LIBRARIES} gtest + absl::check grpc_test_util ) diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index e8e69293969..731c17d651a 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -5775,6 +5775,7 @@ targets: - test/core/util/tracer_util.cc deps: - gtest + - absl/log:check - grpc_test_util - name: backend_metrics_lb_policy_test gtest: true @@ -10697,6 +10698,7 @@ targets: - test/core/util/tracer_util.cc deps: - gtest + - absl/log:check - grpc_test_util - name: grpc_tls_certificate_provider_test gtest: true @@ -10727,6 +10729,7 @@ targets: - test/core/util/tracer_util.cc deps: - gtest + - absl/log:check - grpc_test_util - name: grpc_tls_certificate_verifier_test gtest: true @@ -19560,6 +19563,7 @@ targets: - test/core/util/tracer_util.cc deps: - gtest + - absl/log:check - grpc_test_util - name: too_many_pings_test gtest: true diff --git a/test/core/security/BUILD b/test/core/security/BUILD index 58c2c6d63f5..8c40aa5fc50 100644 --- a/test/core/security/BUILD +++ b/test/core/security/BUILD @@ -23,6 +23,7 @@ grpc_fuzzer( name = "alts_credentials_fuzzer", srcs = ["alts_credentials_fuzzer.cc"], corpus = "corpus/alts_credentials_corpus", + external_deps = ["absl/log:check"], language = "C++", tags = ["no_windows"], deps = [ @@ -42,6 +43,7 @@ grpc_fuzzer( "//src/core/tsi/test_creds:server1.key", "//src/core/tsi/test_creds:server1.pem", ], + external_deps = ["absl/log:check"], language = "C++", tags = ["no_windows"], deps = [ @@ -112,7 +114,10 @@ grpc_cc_test( grpc_cc_test( name = "aws_request_signer_test", srcs = ["aws_request_signer_test.cc"], - external_deps = ["gtest"], + external_deps = [ + "absl/log:check", + "gtest", + ], language = "C++", deps = [ "//:gpr", @@ -250,6 +255,7 @@ grpc_cc_binary( grpc_cc_binary( name = "fetch_oauth2", srcs = ["fetch_oauth2.cc"], + external_deps = ["absl/log:check"], language = "C++", deps = [ ":oauth2_utils", @@ -264,6 +270,7 @@ grpc_cc_binary( grpc_cc_binary( name = "verify_jwt", srcs = ["verify_jwt.cc"], + external_deps = ["absl/log:check"], language = "C++", deps = [ "//:gpr", @@ -339,6 +346,7 @@ grpc_cc_test( "//src/core/tsi/test_creds:server1.pem", ], external_deps = [ + "absl/log:check", "gtest", ], language = "C++", @@ -389,7 +397,10 @@ grpc_cc_test( grpc_cc_test( name = "grpc_tls_certificate_distributor_test", srcs = ["grpc_tls_certificate_distributor_test.cc"], - external_deps = ["gtest"], + external_deps = [ + "absl/log:check", + "gtest", + ], language = "C++", deps = [ "//:gpr", @@ -412,7 +423,10 @@ grpc_cc_test( "//src/core/tsi/test_creds:server1.key", "//src/core/tsi/test_creds:server1.pem", ], - external_deps = ["gtest"], + external_deps = [ + "absl/log:check", + "gtest", + ], language = "C++", deps = [ "//:gpr", diff --git a/test/core/security/alts_credentials_fuzzer.cc b/test/core/security/alts_credentials_fuzzer.cc index 1d47a506061..a145ee0f0b0 100644 --- a/test/core/security/alts_credentials_fuzzer.cc +++ b/test/core/security/alts_credentials_fuzzer.cc @@ -18,6 +18,8 @@ #include +#include "absl/log/check.h" + #include #include #include @@ -82,9 +84,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_channel_credentials* cred = grpc_alts_credentials_create_customized( options, handshaker_service_url, enable_untrusted_alts); if (!enable_untrusted_alts && !is_on_gcp) { - GPR_ASSERT(cred == nullptr); + CHECK_EQ(cred, nullptr); } else { - GPR_ASSERT(cred != nullptr); + CHECK_NE(cred, nullptr); } grpc_channel_credentials_release(cred); grpc_alts_credentials_options_destroy(options); @@ -96,9 +98,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_alts_server_credentials_create_customized( options, handshaker_service_url, enable_untrusted_alts); if (!enable_untrusted_alts && !is_on_gcp) { - GPR_ASSERT(cred == nullptr); + CHECK_EQ(cred, nullptr); } else { - GPR_ASSERT(cred != nullptr); + CHECK_NE(cred, nullptr); } grpc_server_credentials_release(cred); grpc_alts_credentials_options_destroy(options); diff --git a/test/core/security/aws_request_signer_test.cc b/test/core/security/aws_request_signer_test.cc index 94f535d3b2d..c877fd5ae47 100644 --- a/test/core/security/aws_request_signer_test.cc +++ b/test/core/security/aws_request_signer_test.cc @@ -18,6 +18,8 @@ #include +#include "absl/log/check.h" + #include #include "test/core/util/test_config.h" @@ -247,9 +249,8 @@ TEST(GrpcAwsRequestSignerTest, InvalidUrl) { "token", "POST", "invalid_url", "us-east-1", "", {}, &error); std::string actual_error_description; - GPR_ASSERT(grpc_error_get_str(error, - grpc_core::StatusStrProperty::kDescription, - &actual_error_description)); + CHECK(grpc_error_get_str(error, grpc_core::StatusStrProperty::kDescription, + &actual_error_description)); EXPECT_EQ(actual_error_description, "Invalid Aws request url."); } @@ -260,9 +261,8 @@ TEST(GrpcAwsRequestSignerTest, DuplicateRequestDate) { "us-east-1", "", {{"date", kBotoTestDate}, {"x-amz-date", kAmzTestDate}}, &error); std::string actual_error_description; - GPR_ASSERT(grpc_error_get_str(error, - grpc_core::StatusStrProperty::kDescription, - &actual_error_description)); + CHECK(grpc_error_get_str(error, grpc_core::StatusStrProperty::kDescription, + &actual_error_description)); EXPECT_EQ(actual_error_description, "Only one of {date, x-amz-date} can be specified, not both."); } diff --git a/test/core/security/fetch_oauth2.cc b/test/core/security/fetch_oauth2.cc index c60c85bbf7f..8dd9c9731ad 100644 --- a/test/core/security/fetch_oauth2.cc +++ b/test/core/security/fetch_oauth2.cc @@ -19,6 +19,8 @@ #include #include +#include "absl/log/check.h" + #include #include #include @@ -137,7 +139,7 @@ int main(int argc, char** argv) { "Missing --gce, --json_sts_options, or --json_refresh_token option."); exit(1); } - GPR_ASSERT(creds != nullptr); + CHECK_NE(creds, nullptr); token = grpc_test_fetch_oauth2_token_with_credentials(creds); if (token != nullptr) { diff --git a/test/core/security/grpc_tls_certificate_distributor_test.cc b/test/core/security/grpc_tls_certificate_distributor_test.cc index 8fa6187eaf9..4b4259e9191 100644 --- a/test/core/security/grpc_tls_certificate_distributor_test.cc +++ b/test/core/security/grpc_tls_certificate_distributor_test.cc @@ -24,6 +24,8 @@ #include #include +#include "absl/log/check.h" + #include #include #include @@ -133,17 +135,17 @@ class GrpcTlsCertificateDistributorTest : public ::testing::Test { void OnError(grpc_error_handle root_cert_error, grpc_error_handle identity_cert_error) override { - GPR_ASSERT(!root_cert_error.ok() || !identity_cert_error.ok()); + CHECK(!root_cert_error.ok() || !identity_cert_error.ok()); std::string root_error_str; std::string identity_error_str; if (!root_cert_error.ok()) { - GPR_ASSERT(grpc_error_get_str( + CHECK(grpc_error_get_str( root_cert_error, StatusStrProperty::kDescription, &root_error_str)); } if (!identity_cert_error.ok()) { - GPR_ASSERT(grpc_error_get_str(identity_cert_error, - StatusStrProperty::kDescription, - &identity_error_str)); + CHECK(grpc_error_get_str(identity_cert_error, + StatusStrProperty::kDescription, + &identity_error_str)); } state_->error_queue.emplace_back(std::move(root_error_str), std::move(identity_error_str)); diff --git a/test/core/security/grpc_tls_certificate_provider_test.cc b/test/core/security/grpc_tls_certificate_provider_test.cc index 29e9ca0960d..af5491a48e4 100644 --- a/test/core/security/grpc_tls_certificate_provider_test.cc +++ b/test/core/security/grpc_tls_certificate_provider_test.cc @@ -22,6 +22,8 @@ #include #include +#include "absl/log/check.h" + #include #include #include @@ -134,17 +136,17 @@ class GrpcTlsCertificateProviderTest : public ::testing::Test { void OnError(grpc_error_handle root_cert_error, grpc_error_handle identity_cert_error) override { MutexLock lock(&state_->mu); - GPR_ASSERT(!root_cert_error.ok() || !identity_cert_error.ok()); + CHECK(!root_cert_error.ok() || !identity_cert_error.ok()); std::string root_error_str; std::string identity_error_str; if (!root_cert_error.ok()) { - GPR_ASSERT(grpc_error_get_str( + CHECK(grpc_error_get_str( root_cert_error, StatusStrProperty::kDescription, &root_error_str)); } if (!identity_cert_error.ok()) { - GPR_ASSERT(grpc_error_get_str(identity_cert_error, - StatusStrProperty::kDescription, - &identity_error_str)); + CHECK(grpc_error_get_str(identity_cert_error, + StatusStrProperty::kDescription, + &identity_error_str)); } state_->error_queue.emplace_back(std::move(root_error_str), std::move(identity_error_str)); diff --git a/test/core/security/print_google_default_creds_token.cc b/test/core/security/print_google_default_creds_token.cc index 66ea4a904c0..134d3e57d45 100644 --- a/test/core/security/print_google_default_creds_token.cc +++ b/test/core/security/print_google_default_creds_token.cc @@ -19,6 +19,8 @@ #include #include +#include "absl/log/check.h" + #include #include #include @@ -51,7 +53,7 @@ static void on_metadata_response(void* arg, grpc_error_handle error) { fflush(stderr); } else { char* token; - GPR_ASSERT(sync->md_array.size == 1); + CHECK_EQ(sync->md_array.size, 1u); token = grpc_slice_to_c_string(GRPC_MDVALUE(sync->md_array.md[0])); printf("\nGot token: %s\n\n", token); gpr_free(token); diff --git a/test/core/security/ssl_server_fuzzer.cc b/test/core/security/ssl_server_fuzzer.cc index e657550f376..ea4e82123e6 100644 --- a/test/core/security/ssl_server_fuzzer.cc +++ b/test/core/security/ssl_server_fuzzer.cc @@ -15,6 +15,7 @@ // limitations under the License. // // +#include "absl/log/check.h" #include #include @@ -54,10 +55,10 @@ static void on_handshake_done(void* arg, grpc_error_handle error) { static_cast(arg); struct handshake_state* state = static_cast(args->user_data); - GPR_ASSERT(state->done_callback_called == false); + CHECK(state->done_callback_called == false); state->done_callback_called = true; // The fuzzer should not pass the handshake. - GPR_ASSERT(!error.ok()); + CHECK(!error.ok()); } extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { @@ -86,7 +87,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { // Create security connector grpc_core::RefCountedPtr sc = creds->create_security_connector(grpc_core::ChannelArgs()); - GPR_ASSERT(sc != nullptr); + CHECK(sc != nullptr); grpc_core::Timestamp deadline = grpc_core::Duration::Seconds(1) + grpc_core::Timestamp::Now(); @@ -110,7 +111,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { GRPC_ERROR_CREATE("Explicit close")); grpc_core::ExecCtx::Get()->Flush(); } - GPR_ASSERT(state.done_callback_called); + CHECK(state.done_callback_called); sc.reset(DEBUG_LOCATION, "test"); grpc_server_credentials_release(creds); diff --git a/test/core/security/tls_security_connector_test.cc b/test/core/security/tls_security_connector_test.cc index 264eb8103db..41ca123eba0 100644 --- a/test/core/security/tls_security_connector_test.cc +++ b/test/core/security/tls_security_connector_test.cc @@ -24,6 +24,8 @@ #include #include +#include "absl/log/check.h" + #include #include #include @@ -82,7 +84,7 @@ class TlsSecurityConnectorTest : public ::testing::Test { static std::string GetErrorMsg(grpc_error_handle error) { std::string error_str; - GPR_ASSERT( + CHECK( grpc_error_get_str(error, StatusStrProperty::kDescription, &error_str)); return error_str; } @@ -368,13 +370,13 @@ TEST_F(TlsSecurityConnectorTest, EXPECT_NE(tls_connector->ClientHandshakerFactoryForTesting(), nullptr); // Construct a basic TSI Peer. tsi_peer peer; - GPR_ASSERT(tsi_construct_peer(2, &peer) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, - "h2", strlen("h2"), - &peer.properties[0]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", - &peer.properties[1]) == TSI_OK); + CHECK(tsi_construct_peer(2, &peer) == TSI_OK); + CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", + strlen("h2"), + &peer.properties[0]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", + &peer.properties[1]) == TSI_OK); RefCountedPtr auth_context; ExecCtx exec_ctx; grpc_closure* on_peer_checked = GRPC_CLOSURE_CREATE( @@ -404,13 +406,13 @@ TEST_F(TlsSecurityConnectorTest, EXPECT_NE(tls_connector->ClientHandshakerFactoryForTesting(), nullptr); // Construct a basic TSI Peer. tsi_peer peer; - GPR_ASSERT(tsi_construct_peer(2, &peer) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, - "h2", strlen("h2"), - &peer.properties[0]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", - &peer.properties[1]) == TSI_OK); + CHECK(tsi_construct_peer(2, &peer) == TSI_OK); + CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", + strlen("h2"), + &peer.properties[0]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", + &peer.properties[1]) == TSI_OK); RefCountedPtr auth_context; const char* expected_error_msg = "Custom verification check failed with error: UNAUTHENTICATED: " @@ -557,13 +559,13 @@ TEST_F(TlsSecurityConnectorTest, EXPECT_NE(tls_connector->ClientHandshakerFactoryForTesting(), nullptr); // Construct a basic TSI Peer. tsi_peer peer; - GPR_ASSERT(tsi_construct_peer(2, &peer) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, - "h2", strlen("h2"), - &peer.properties[0]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", - &peer.properties[1]) == TSI_OK); + CHECK(tsi_construct_peer(2, &peer) == TSI_OK); + CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", + strlen("h2"), + &peer.properties[0]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", + &peer.properties[1]) == TSI_OK); RefCountedPtr auth_context; ExecCtx exec_ctx; grpc_closure* on_peer_checked = GRPC_CLOSURE_CREATE( @@ -593,13 +595,13 @@ TEST_F(TlsSecurityConnectorTest, EXPECT_NE(tls_connector->ClientHandshakerFactoryForTesting(), nullptr); // Construct a basic TSI Peer. tsi_peer peer; - GPR_ASSERT(tsi_construct_peer(2, &peer) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, - "h2", strlen("h2"), - &peer.properties[0]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", - &peer.properties[1]) == TSI_OK); + CHECK(tsi_construct_peer(2, &peer) == TSI_OK); + CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", + strlen("h2"), + &peer.properties[0]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", + &peer.properties[1]) == TSI_OK); RefCountedPtr auth_context; const char* expected_error_msg = "Custom verification check failed with error: UNAUTHENTICATED: " @@ -631,29 +633,29 @@ TEST_F(TlsSecurityConnectorTest, EXPECT_NE(tls_connector->ClientHandshakerFactoryForTesting(), nullptr); // Construct a full TSI Peer. tsi_peer peer; - GPR_ASSERT(tsi_construct_peer(7, &peer) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, - "h2", strlen("h2"), - &peer.properties[0]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", - &peer.properties[1]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_PEM_CERT_PROPERTY, "pem_cert", &peer.properties[2]) == - TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_SECURITY_LEVEL_PEER_PROPERTY, - tsi_security_level_to_string(TSI_PRIVACY_AND_INTEGRITY), - &peer.properties[3]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_PEM_CERT_CHAIN_PROPERTY, "pem_cert_chain", - &peer.properties[4]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "foo.bar.com", - &peer.properties[5]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "foo.baz.com", - &peer.properties[6]) == TSI_OK); + CHECK(tsi_construct_peer(7, &peer) == TSI_OK); + CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", + strlen("h2"), + &peer.properties[0]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", + &peer.properties[1]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_PEM_CERT_PROPERTY, "pem_cert", &peer.properties[2]) == + TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_SECURITY_LEVEL_PEER_PROPERTY, + tsi_security_level_to_string(TSI_PRIVACY_AND_INTEGRITY), + &peer.properties[3]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_PEM_CERT_CHAIN_PROPERTY, "pem_cert_chain", + &peer.properties[4]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "foo.bar.com", + &peer.properties[5]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "foo.baz.com", + &peer.properties[6]) == TSI_OK); RefCountedPtr auth_context; ExecCtx exec_ctx; grpc_closure* on_peer_checked = GRPC_CLOSURE_CREATE( @@ -679,29 +681,29 @@ TEST_F(TlsSecurityConnectorTest, EXPECT_NE(tls_connector->ClientHandshakerFactoryForTesting(), nullptr); // Construct a full TSI Peer. tsi_peer peer; - GPR_ASSERT(tsi_construct_peer(7, &peer) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, - "h2", strlen("h2"), - &peer.properties[0]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.com", - &peer.properties[1]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_PEM_CERT_PROPERTY, "pem_cert", &peer.properties[2]) == - TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_SECURITY_LEVEL_PEER_PROPERTY, - tsi_security_level_to_string(TSI_PRIVACY_AND_INTEGRITY), - &peer.properties[3]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_PEM_CERT_CHAIN_PROPERTY, "pem_cert_chain", - &peer.properties[4]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "*.com", - &peer.properties[5]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "foo.baz.com", - &peer.properties[6]) == TSI_OK); + CHECK(tsi_construct_peer(7, &peer) == TSI_OK); + CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", + strlen("h2"), + &peer.properties[0]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.com", + &peer.properties[1]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_PEM_CERT_PROPERTY, "pem_cert", &peer.properties[2]) == + TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_SECURITY_LEVEL_PEER_PROPERTY, + tsi_security_level_to_string(TSI_PRIVACY_AND_INTEGRITY), + &peer.properties[3]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_PEM_CERT_CHAIN_PROPERTY, "pem_cert_chain", + &peer.properties[4]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "*.com", + &peer.properties[5]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, "foo.baz.com", + &peer.properties[6]) == TSI_OK); RefCountedPtr auth_context; const char* expected_error_msg = "Custom verification check failed with error: UNAUTHENTICATED: Hostname " @@ -988,13 +990,13 @@ TEST_F(TlsSecurityConnectorTest, auto connector = credentials->create_security_connector(ChannelArgs()); // Construct a basic TSI Peer. tsi_peer peer; - GPR_ASSERT(tsi_construct_peer(2, &peer) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, - "h2", strlen("h2"), - &peer.properties[0]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", - &peer.properties[1]) == TSI_OK); + CHECK(tsi_construct_peer(2, &peer) == TSI_OK); + CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", + strlen("h2"), + &peer.properties[0]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", + &peer.properties[1]) == TSI_OK); RefCountedPtr auth_context; ExecCtx exec_ctx; grpc_closure* on_peer_checked = GRPC_CLOSURE_CREATE( @@ -1019,13 +1021,13 @@ TEST_F(TlsSecurityConnectorTest, auto connector = credentials->create_security_connector(ChannelArgs()); // Construct a basic TSI Peer. tsi_peer peer; - GPR_ASSERT(tsi_construct_peer(2, &peer) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, - "h2", strlen("h2"), - &peer.properties[0]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", - &peer.properties[1]) == TSI_OK); + CHECK(tsi_construct_peer(2, &peer) == TSI_OK); + CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", + strlen("h2"), + &peer.properties[0]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", + &peer.properties[1]) == TSI_OK); RefCountedPtr auth_context; const char* expected_error_msg = "Custom verification check failed with error: UNAUTHENTICATED: " @@ -1054,13 +1056,13 @@ TEST_F(TlsSecurityConnectorTest, auto connector = credentials->create_security_connector(ChannelArgs()); // Construct a basic TSI Peer. tsi_peer peer; - GPR_ASSERT(tsi_construct_peer(2, &peer) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, - "h2", strlen("h2"), - &peer.properties[0]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", - &peer.properties[1]) == TSI_OK); + CHECK(tsi_construct_peer(2, &peer) == TSI_OK); + CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", + strlen("h2"), + &peer.properties[0]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", + &peer.properties[1]) == TSI_OK); RefCountedPtr auth_context; ExecCtx exec_ctx; grpc_closure* on_peer_checked = GRPC_CLOSURE_CREATE( @@ -1087,13 +1089,13 @@ TEST_F(TlsSecurityConnectorTest, auto connector = credentials->create_security_connector(ChannelArgs()); // Construct a basic TSI Peer. tsi_peer peer; - GPR_ASSERT(tsi_construct_peer(2, &peer) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, - "h2", strlen("h2"), - &peer.properties[0]) == TSI_OK); - GPR_ASSERT(tsi_construct_string_peer_property_from_cstring( - TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", - &peer.properties[1]) == TSI_OK); + CHECK(tsi_construct_peer(2, &peer) == TSI_OK); + CHECK(tsi_construct_string_peer_property(TSI_SSL_ALPN_SELECTED_PROTOCOL, "h2", + strlen("h2"), + &peer.properties[0]) == TSI_OK); + CHECK(tsi_construct_string_peer_property_from_cstring( + TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY, "foo.bar.com", + &peer.properties[1]) == TSI_OK); RefCountedPtr auth_context; const char* expected_error_msg = "Custom verification check failed with error: UNAUTHENTICATED: " diff --git a/test/core/security/verify_jwt.cc b/test/core/security/verify_jwt.cc index 9b64fc8e124..c9178d230f1 100644 --- a/test/core/security/verify_jwt.cc +++ b/test/core/security/verify_jwt.cc @@ -19,6 +19,8 @@ #include #include +#include "absl/log/check.h" + #include #include #include @@ -55,13 +57,13 @@ static void on_jwt_verification_done(void* user_data, sync->success = (status == GRPC_JWT_VERIFIER_OK); if (sync->success) { - GPR_ASSERT(claims != nullptr); + CHECK_NE(claims, nullptr); std::string claims_str = grpc_core::JsonDump(*grpc_jwt_claims_json(claims), /*indent=*/2); printf("Claims: \n\n%s\n", claims_str.c_str()); grpc_jwt_claims_destroy(claims); } else { - GPR_ASSERT(claims == nullptr); + CHECK_EQ(claims, nullptr); fprintf(stderr, "Verification failed with error %s\n", grpc_jwt_verifier_status_to_string(status)); fflush(stderr);