From f169b4b28e320303f825286ebd12765bb6a25e39 Mon Sep 17 00:00:00 2001 From: Matthew Stevenson Date: Fri, 9 Aug 2019 09:37:27 -0700 Subject: [PATCH] Update CredentialReloadArg unit test --- test/cpp/client/credentials_test.cc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/test/cpp/client/credentials_test.cc b/test/cpp/client/credentials_test.cc index 994d3a0fa8e..30e6dd1ca97 100644 --- a/test/cpp/client/credentials_test.cc +++ b/test/cpp/client/credentials_test.cc @@ -246,20 +246,26 @@ typedef void (*grpcpp_tls_on_credential_reload_done_cb)( TEST_F(CredentialsTest, TlsCredentialReloadArgCppToC) { TlsCredentialReloadArg arg; - // Only sync credential reload supported currently, - // so we use a nullptr call back function. arg.set_cb(static_cast(nullptr)); arg.set_cb_user_data(nullptr); - arg.set_key_materials_config( - static_cast<::std::shared_ptr>(nullptr)); + ::std::shared_ptr key_materials_config; + struct TlsKeyMaterialsConfig::PemKeyCertPair pair1 = {"private_key1", + "cert_chain1"}; + struct TlsKeyMaterialsConfig::PemKeyCertPair pair2 = {"private_key2", "cert_chain2"}; + ::std::vector pair_list = {pair1, pair2}; + key_materials_config->set_key_materials("pem_root_certs", pair_list); + arg.set_key_materials_config(key_materials_config); arg.set_status(GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW); arg.set_error_details("error_details"); grpc_tls_credential_reload_arg* c_arg = arg.c_credential_reload_arg(); EXPECT_EQ(c_arg->cb, static_cast(nullptr)); EXPECT_EQ(c_arg->cb_user_data, nullptr); - EXPECT_EQ(c_arg->key_materials_config, - static_cast<::std::shared_ptr>(nullptr)); + EXPECT_EQ(c_arg->key_materials_config->pem_root_certs(), "pem_root_certs"); + EXPECT_EQ(c_arg->key_materials_config->pem_key_cert_pair_list()[0].private_key(), "private_key1"); + EXPECT_EQ(c_arg->key_materials_config->pem_key_cert_pair_list()[1].private_key(), "private_key2"); + EXPECT_EQ(c_arg->key_materials_config->pem_key_cert_pair_list()[0].cert_chain(), "cert_chain1"); + EXPECT_EQ(c_arg->key_materials_config->pem_key_cert_pair_list()[1].cert_chain(), "cert_chain2"); EXPECT_EQ(c_arg->status, GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW); EXPECT_STREQ(c_arg->error_details, "error_details"); }