Update CredentialReloadArg unit test

pull/19778/head
Matthew Stevenson 5 years ago
parent 1d32c79ee7
commit f169b4b28e
  1. 18
      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<grpcpp_tls_on_credential_reload_done_cb>(nullptr));
arg.set_cb_user_data(nullptr);
arg.set_key_materials_config(
static_cast<::std::shared_ptr<TlsKeyMaterialsConfig>>(nullptr));
::std::shared_ptr<TlsKeyMaterialsConfig> key_materials_config;
struct TlsKeyMaterialsConfig::PemKeyCertPair pair1 = {"private_key1",
"cert_chain1"};
struct TlsKeyMaterialsConfig::PemKeyCertPair pair2 = {"private_key2", "cert_chain2"};
::std::vector<TlsKeyMaterialsConfig::PemKeyCertPair> 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<grpc_tls_on_credential_reload_done_cb>(nullptr));
EXPECT_EQ(c_arg->cb_user_data, nullptr);
EXPECT_EQ(c_arg->key_materials_config,
static_cast<::std::shared_ptr<TlsKeyMaterialsConfig>>(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");
}

Loading…
Cancel
Save