[xds_client_fuzzer] fail bootstrap parsing if xds_servers is empty (#33119)

b/269022924
pull/33127/head
Mark D. Roth 2 years ago committed by GitHub
parent a1e72482e4
commit 59dbdfeea2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      src/core/ext/xds/xds_bootstrap_grpc.cc
  2. 13
      test/core/xds/xds_bootstrap_test.cc
  3. 10
      test/core/xds/xds_client_corpora/bootstrap_xds_servers_empty

@ -259,6 +259,13 @@ const JsonLoaderInterface* GrpcXdsBootstrap::JsonLoader(const JsonArgs&) {
void GrpcXdsBootstrap::JsonPostLoad(const Json& /*json*/,
const JsonArgs& /*args*/,
ValidationErrors* errors) {
// Verify that there is at least one server present.
{
ValidationErrors::ScopedField field(errors, ".xds_servers");
if (servers_.empty() && !errors->FieldHasErrors()) {
errors->AddError("must be non-empty");
}
}
// Verify that each authority has the right prefix in the
// client_listener_resource_name_template field.
{

@ -314,6 +314,19 @@ TEST(XdsBootstrapTest, MissingXdsServers) {
<< bootstrap.status();
}
TEST(XdsBootstrapTest, EmptyXdsServers) {
const char* json_str =
"{"
" \"xds_servers\": ["
" ]"
"}";
auto bootstrap = GrpcXdsBootstrap::Create(json_str);
EXPECT_EQ(
bootstrap.status().message(),
"errors validating JSON: [field:xds_servers error:must be non-empty]")
<< bootstrap.status();
}
TEST(XdsBootstrapTest, TopFieldsWrongTypes) {
const char* json_str =
"{"

@ -0,0 +1,10 @@
bootstrap: "{\"xds_servers\": []}"
actions {
start_watch {
resource_type {
listener {
}
}
resource_name: "\003"
}
}
Loading…
Cancel
Save