Fail xDS bootstrap parsing for unrecognized certificate provider plugins (#26628)

reviewable/pr26614/r3
Yash Tibrewal 4 years ago committed by GitHub
parent 25a849baf3
commit b8575847e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/core/ext/xds/xds_bootstrap.cc
  2. 31
      test/core/xds/xds_bootstrap_test.cc

@ -403,7 +403,10 @@ grpc_error_handle XdsBootstrap::ParseCertificateProvider(
CertificateProviderFactory* factory =
CertificateProviderRegistry::LookupCertificateProviderFactory(
plugin_name);
if (factory != nullptr) {
if (factory == nullptr) {
error_list.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
absl::StrCat("Unrecognized plugin name: ", plugin_name).c_str()));
} else {
RefCountedPtr<CertificateProviderFactory::Config> config;
it = certificate_provider_json->mutable_object()->find("config");
if (it != certificate_provider_json->mutable_object()->end()) {

@ -469,6 +469,37 @@ TEST_P(XdsBootstrapTest, CertificateProvidersPluginNameWrongType) {
GRPC_ERROR_UNREF(error);
}
TEST_P(XdsBootstrapTest, CertificateProvidersUnrecognizedPluginName) {
const char* json_str =
"{"
" \"xds_servers\": ["
" {"
" \"server_uri\": \"fake:///lb\","
" \"channel_creds\": [{\"type\": \"fake\"}]"
" }"
" ],"
" \"certificate_providers\": {"
" \"plugin\": {"
" \"plugin_name\":\"unknown\""
" }"
" }"
"}";
grpc_error_handle error = GRPC_ERROR_NONE;
Json json = Json::Parse(json_str, &error);
ASSERT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error);
XdsBootstrap bootstrap(std::move(json), &error);
if (GetParam().parse_xds_certificate_providers()) {
EXPECT_THAT(grpc_error_std_string(error),
::testing::ContainsRegex(
"errors parsing \"certificate_providers\" object.*"
"errors parsing element \"plugin\".*"
"Unrecognized plugin name: unknown"));
} else {
EXPECT_EQ(error, GRPC_ERROR_NONE) << grpc_error_std_string(error);
}
GRPC_ERROR_UNREF(error);
}
class FakeCertificateProviderFactory : public CertificateProviderFactory {
public:
class Config : public CertificateProviderFactory::Config {

Loading…
Cancel
Save