|
|
|
@ -55,16 +55,18 @@ class TestTlsCredentialReload : public TlsCredentialReloadInterface { |
|
|
|
|
GPR_ASSERT(arg != nullptr); |
|
|
|
|
struct TlsKeyMaterialsConfig::PemKeyCertPair pair3 = {"private_key3", |
|
|
|
|
"cert_chain3"}; |
|
|
|
|
std::shared_ptr<TlsKeyMaterialsConfig> key_materials_config = |
|
|
|
|
arg->key_materials_config(); |
|
|
|
|
GPR_ASSERT(key_materials_config != nullptr); |
|
|
|
|
std::vector<TlsKeyMaterialsConfig::PemKeyCertPair> pair_list = |
|
|
|
|
key_materials_config->pem_key_cert_pair_list(); |
|
|
|
|
//std::shared_ptr<TlsKeyMaterialsConfig> key_materials_config =
|
|
|
|
|
// arg->key_materials_config();
|
|
|
|
|
//GPR_ASSERT(key_materials_config != nullptr);
|
|
|
|
|
//std::vector<TlsKeyMaterialsConfig::PemKeyCertPair> pair_list =
|
|
|
|
|
// key_materials_config->pem_key_cert_pair_list();
|
|
|
|
|
pair_list.push_back(pair3); |
|
|
|
|
pair_list[0].private_key = "private_key01"; |
|
|
|
|
pair_list[0].cert_chain = "cert_chain01"; |
|
|
|
|
key_materials_config->set_key_materials("new_pem_root_certs", pair_list); |
|
|
|
|
arg->set_key_materials_config(key_materials_config); |
|
|
|
|
//pair_list[0].private_key = "private_key01";
|
|
|
|
|
//pair_list[0].cert_chain = "cert_chain01";
|
|
|
|
|
//key_materials_config->set_key_materials("new_pem_root_certs", pair_list);
|
|
|
|
|
//arg->set_key_materials_config(key_materials_config);
|
|
|
|
|
arg->set_pem_root_certs("new_pem_root_certs"); |
|
|
|
|
arg->add_pem_key_cert_pair(pair3); |
|
|
|
|
arg->set_status(GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW); |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
@ -302,6 +304,7 @@ TEST_F(CredentialsTest, TlsKeyMaterialsConfigCppToC) { |
|
|
|
|
gpr_free(c_config); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
TEST_F(CredentialsTest, TlsKeyMaterialsCtoCpp) { |
|
|
|
|
grpc_tls_key_materials_config c_config; |
|
|
|
|
grpc::string test_private_key = "private_key"; |
|
|
|
@ -328,6 +331,7 @@ TEST_F(CredentialsTest, TlsKeyMaterialsCtoCpp) { |
|
|
|
|
EXPECT_STREQ("private_key", cpp_pair_list[0].private_key.c_str()); |
|
|
|
|
EXPECT_STREQ("cert_chain", cpp_pair_list[0].cert_chain.c_str()); |
|
|
|
|
} |
|
|
|
|
**/ |
|
|
|
|
|
|
|
|
|
typedef class ::grpc_impl::experimental::TlsCredentialReloadArg |
|
|
|
|
TlsCredentialReloadArg; |
|
|
|
@ -344,7 +348,7 @@ TEST_F(CredentialsTest, TlsCredentialReloadArgCallback) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(CredentialsTest, TlsCredentialReloadConfigSchedule) { |
|
|
|
|
std::unique_ptr<TestTlsCredentialReload> test_credential_reload( |
|
|
|
|
std::shared_ptr<TestTlsCredentialReload> test_credential_reload( |
|
|
|
|
new TestTlsCredentialReload()); |
|
|
|
|
TlsCredentialReloadConfig config(std::move(test_credential_reload)); |
|
|
|
|
grpc_tls_credential_reload_arg c_arg; |
|
|
|
@ -368,9 +372,9 @@ TEST_F(CredentialsTest, TlsCredentialReloadConfigSchedule) { |
|
|
|
|
int schedule_output = config.Schedule(&arg); |
|
|
|
|
EXPECT_EQ(schedule_output, 0); |
|
|
|
|
EXPECT_EQ(arg.cb_user_data(), nullptr); |
|
|
|
|
EXPECT_STREQ(arg.key_materials_config()->pem_root_certs().c_str(), |
|
|
|
|
EXPECT_STREQ(c_arg.key_materials_config->pem_root_certs().get(), |
|
|
|
|
"new_pem_root_certs"); |
|
|
|
|
pair_list = arg.key_materials_config()->pem_key_cert_pair_list(); |
|
|
|
|
pair_list = c_arg.key_materials_config->pem_key_cert_pair_list(); |
|
|
|
|
EXPECT_EQ(static_cast<int>(pair_list.size()), 3); |
|
|
|
|
EXPECT_STREQ(pair_list[0].private_key.c_str(), "private_key01"); |
|
|
|
|
EXPECT_STREQ(pair_list[0].cert_chain.c_str(), "cert_chain01"); |
|
|
|
@ -389,7 +393,7 @@ TEST_F(CredentialsTest, TlsCredentialReloadConfigSchedule) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(CredentialsTest, TlsCredentialReloadConfigCppToC) { |
|
|
|
|
std::unique_ptr<TestTlsCredentialReload> test_credential_reload( |
|
|
|
|
std::shared_ptr<TestTlsCredentialReload> test_credential_reload( |
|
|
|
|
new TestTlsCredentialReload()); |
|
|
|
|
TlsCredentialReloadConfig config(std::move(test_credential_reload)); |
|
|
|
|
grpc_tls_credential_reload_arg c_arg; |
|
|
|
@ -478,7 +482,7 @@ TEST_F(CredentialsTest, TlsServerAuthorizationCheckArgCallback) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(CredentialsTest, TlsServerAuthorizationCheckConfigSchedule) { |
|
|
|
|
std::unique_ptr<TestTlsServerAuthorizationCheck> |
|
|
|
|
std::shared_ptr<TestTlsServerAuthorizationCheck> |
|
|
|
|
test_server_authorization_check(new TestTlsServerAuthorizationCheck()); |
|
|
|
|
TlsServerAuthorizationCheckConfig config( |
|
|
|
|
std::move(test_server_authorization_check)); |
|
|
|
@ -515,7 +519,7 @@ TEST_F(CredentialsTest, TlsServerAuthorizationCheckConfigSchedule) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(CredentialsTest, TlsServerAuthorizationCheckConfigCppToC) { |
|
|
|
|
std::unique_ptr<TestTlsServerAuthorizationCheck> |
|
|
|
|
std::shared_ptr<TestTlsServerAuthorizationCheck> |
|
|
|
|
test_server_authorization_check(new TestTlsServerAuthorizationCheck()); |
|
|
|
|
TlsServerAuthorizationCheckConfig config( |
|
|
|
|
std::move(test_server_authorization_check)); |
|
|
|
@ -559,12 +563,12 @@ TEST_F(CredentialsTest, TlsCredentialsOptionsCppToC) { |
|
|
|
|
std::vector<TlsKeyMaterialsConfig::PemKeyCertPair> pair_list = {pair}; |
|
|
|
|
key_materials_config->set_key_materials("pem_root_certs", pair_list); |
|
|
|
|
|
|
|
|
|
std::unique_ptr<TestTlsCredentialReload> test_credential_reload( |
|
|
|
|
std::shared_ptr<TestTlsCredentialReload> test_credential_reload( |
|
|
|
|
new TestTlsCredentialReload()); |
|
|
|
|
std::shared_ptr<TlsCredentialReloadConfig> credential_reload_config( |
|
|
|
|
new TlsCredentialReloadConfig(std::move(test_credential_reload))); |
|
|
|
|
|
|
|
|
|
std::unique_ptr<TestTlsServerAuthorizationCheck> |
|
|
|
|
std::shared_ptr<TestTlsServerAuthorizationCheck> |
|
|
|
|
test_server_authorization_check(new TestTlsServerAuthorizationCheck()); |
|
|
|
|
std::shared_ptr<TlsServerAuthorizationCheckConfig> |
|
|
|
|
server_authorization_check_config(new TlsServerAuthorizationCheckConfig( |
|
|
|
@ -656,12 +660,12 @@ TEST_F(CredentialsTest, TlsCredentialsOptionsCppToC) { |
|
|
|
|
|
|
|
|
|
// This test demonstrates how the SPIFFE credentials will be used.
|
|
|
|
|
TEST_F(CredentialsTest, LoadSpiffeChannelCredentials) { |
|
|
|
|
std::unique_ptr<TestTlsCredentialReload> test_credential_reload( |
|
|
|
|
std::shared_ptr<TestTlsCredentialReload> test_credential_reload( |
|
|
|
|
new TestTlsCredentialReload()); |
|
|
|
|
std::shared_ptr<TlsCredentialReloadConfig> credential_reload_config( |
|
|
|
|
new TlsCredentialReloadConfig(std::move(test_credential_reload))); |
|
|
|
|
|
|
|
|
|
std::unique_ptr<TestTlsServerAuthorizationCheck> |
|
|
|
|
std::shared_ptr<TestTlsServerAuthorizationCheck> |
|
|
|
|
test_server_authorization_check(new TestTlsServerAuthorizationCheck()); |
|
|
|
|
std::shared_ptr<TlsServerAuthorizationCheckConfig> |
|
|
|
|
server_authorization_check_config(new TlsServerAuthorizationCheckConfig( |
|
|
|
|