xds_bootstrap_test.cc
Go to the documentation of this file.
1 //
2 // Copyright 2019 gRPC authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
18 
19 #include <regex>
20 
21 #include <gmock/gmock.h>
22 #include <gtest/gtest.h>
23 
24 #include "absl/strings/numbers.h"
25 #include "absl/strings/str_format.h"
26 
27 #include <grpc/grpc.h>
28 #include <grpc/slice.h>
29 
31 #include "src/core/lib/gpr/env.h"
34 
35 namespace grpc_core {
36 namespace testing {
37 namespace {
38 
39 TEST(XdsBootstrapTest, Basic) {
40  gpr_setenv("GRPC_EXPERIMENTAL_XDS_FEDERATION", "true");
41  const char* json_str =
42  "{"
43  " \"xds_servers\": ["
44  " {"
45  " \"server_uri\": \"fake:///lb\","
46  " \"channel_creds\": ["
47  " {"
48  " \"type\": \"fake\","
49  " \"ignore\": 0"
50  " }"
51  " ],"
52  " \"ignore\": 0"
53  " },"
54  " {"
55  " \"server_uri\": \"ignored\","
56  " \"channel_creds\": ["
57  " {"
58  " \"type\": \"ignored\","
59  " \"ignore\": 0"
60  " },"
61  " {"
62  " \"type\": \"fake\""
63  " }"
64  " ],"
65  " \"ignore\": 0"
66  " }"
67  " ],"
68  " \"authorities\": {"
69  " \"xds.example.com\": {"
70  " \"client_listener_resource_name_template\": "
71  "\"xdstp://xds.example.com/envoy.config.listener.v3.Listener/grpc/server/"
72  "%s\","
73  " \"xds_servers\": ["
74  " {"
75  " \"server_uri\": \"fake:///xds_server\","
76  " \"channel_creds\": ["
77  " {"
78  " \"type\": \"fake\""
79  " }"
80  " ],"
81  " \"server_features\": [\"xds_v3\"]"
82  " }"
83  " ]"
84  " },"
85  " \"xds.example2.com\": {"
86  " \"client_listener_resource_name_template\": "
87  "\"xdstp://xds.example2.com/envoy.config.listener.v3.Listener/grpc/"
88  "server/%s\","
89  " \"xds_servers\": ["
90  " {"
91  " \"server_uri\": \"fake:///xds_server2\","
92  " \"channel_creds\": ["
93  " {"
94  " \"type\": \"fake\""
95  " }"
96  " ],"
97  " \"server_features\": [\"xds_v3\"]"
98  " }"
99  " ]"
100  " }"
101  " },"
102  " \"node\": {"
103  " \"id\": \"foo\","
104  " \"cluster\": \"bar\","
105  " \"locality\": {"
106  " \"region\": \"milky_way\","
107  " \"zone\": \"sol_system\","
108  " \"sub_zone\": \"earth\","
109  " \"ignore\": {}"
110  " },"
111  " \"metadata\": {"
112  " \"foo\": 1,"
113  " \"bar\": 2"
114  " },"
115  " \"ignore\": \"whee\""
116  " },"
117  " \"server_listener_resource_name_template\": \"example/resource\","
118  " \"ignore\": {}"
119  "}";
121  Json json = Json::Parse(json_str, &error);
123  XdsBootstrap bootstrap(std::move(json), &error);
125  EXPECT_EQ(bootstrap.server().server_uri, "fake:///lb");
126  EXPECT_EQ(bootstrap.server().channel_creds_type, "fake");
127  EXPECT_EQ(bootstrap.server().channel_creds_config.type(),
129  EXPECT_EQ(bootstrap.authorities().size(), 2);
130  const XdsBootstrap::Authority* authority1 =
131  bootstrap.LookupAuthority("xds.example.com");
132  ASSERT_NE(authority1, nullptr);
133  EXPECT_EQ(authority1->client_listener_resource_name_template,
134  "xdstp://xds.example.com/envoy.config.listener.v3.Listener/grpc/"
135  "server/%s");
136  EXPECT_EQ(authority1->xds_servers.size(), 1);
137  EXPECT_EQ(authority1->xds_servers[0].server_uri, "fake:///xds_server");
138  EXPECT_EQ(authority1->xds_servers[0].channel_creds_type, "fake");
139  EXPECT_EQ(authority1->xds_servers[0].channel_creds_config.type(),
141  const XdsBootstrap::Authority* authority2 =
142  bootstrap.LookupAuthority("xds.example2.com");
143  ASSERT_NE(authority2, nullptr);
144  EXPECT_EQ(authority2->client_listener_resource_name_template,
145  "xdstp://xds.example2.com/envoy.config.listener.v3.Listener/grpc/"
146  "server/%s");
147  EXPECT_EQ(authority2->xds_servers.size(), 1);
148  EXPECT_EQ(authority2->xds_servers[0].server_uri, "fake:///xds_server2");
149  EXPECT_EQ(authority2->xds_servers[0].channel_creds_type, "fake");
150  EXPECT_EQ(authority2->xds_servers[0].channel_creds_config.type(),
152  ASSERT_NE(bootstrap.node(), nullptr);
153  EXPECT_EQ(bootstrap.node()->id, "foo");
154  EXPECT_EQ(bootstrap.node()->cluster, "bar");
155  EXPECT_EQ(bootstrap.node()->locality_region, "milky_way");
156  EXPECT_EQ(bootstrap.node()->locality_zone, "sol_system");
157  EXPECT_EQ(bootstrap.node()->locality_sub_zone, "earth");
158  ASSERT_EQ(bootstrap.node()->metadata.type(), Json::Type::OBJECT);
159  EXPECT_THAT(bootstrap.node()->metadata.object_value(),
161  ::testing::Pair(
162  ::testing::Eq("bar"),
163  ::testing::AllOf(
166  ::testing::Pair(
167  ::testing::Eq("foo"),
168  ::testing::AllOf(
171  EXPECT_EQ(bootstrap.server_listener_resource_name_template(),
172  "example/resource");
173  gpr_unsetenv("GRPC_EXPERIMENTAL_XDS_FEDERATION");
174 }
175 
176 TEST(XdsBootstrapTest, ValidWithoutNode) {
177  const char* json_str =
178  "{"
179  " \"xds_servers\": ["
180  " {"
181  " \"server_uri\": \"fake:///lb\","
182  " \"channel_creds\": [{\"type\": \"fake\"}]"
183  " }"
184  " ]"
185  "}";
187  Json json = Json::Parse(json_str, &error);
189  XdsBootstrap bootstrap(std::move(json), &error);
191  EXPECT_EQ(bootstrap.server().server_uri, "fake:///lb");
192  EXPECT_EQ(bootstrap.server().channel_creds_type, "fake");
193  EXPECT_EQ(bootstrap.node(), nullptr);
194 }
195 
196 TEST(XdsBootstrapTest, InsecureCreds) {
197  const char* json_str =
198  "{"
199  " \"xds_servers\": ["
200  " {"
201  " \"server_uri\": \"fake:///lb\","
202  " \"channel_creds\": [{\"type\": \"insecure\"}]"
203  " }"
204  " ]"
205  "}";
207  Json json = Json::Parse(json_str, &error);
209  XdsBootstrap bootstrap(std::move(json), &error);
211  EXPECT_EQ(bootstrap.server().server_uri, "fake:///lb");
212  EXPECT_EQ(bootstrap.server().channel_creds_type, "insecure");
213  EXPECT_EQ(bootstrap.node(), nullptr);
214 }
215 
216 TEST(XdsBootstrapTest, GoogleDefaultCreds) {
217  // Generate call creds file needed by GoogleDefaultCreds.
218  const char token_str[] =
219  "{ \"client_id\": \"32555999999.apps.googleusercontent.com\","
220  " \"client_secret\": \"EmssLNjJy1332hD4KFsecret\","
221  " \"refresh_token\": \"1/Blahblasj424jladJDSGNf-u4Sua3HDA2ngjd42\","
222  " \"type\": \"authorized_user\"}";
223  char* creds_file_name;
224  FILE* creds_file = gpr_tmpfile("xds_bootstrap_test", &creds_file_name);
225  ASSERT_NE(creds_file_name, nullptr);
226  ASSERT_NE(creds_file, nullptr);
227  ASSERT_EQ(fwrite(token_str, 1, sizeof(token_str), creds_file),
228  sizeof(token_str));
232  // Now run test.
233  const char* json_str =
234  "{"
235  " \"xds_servers\": ["
236  " {"
237  " \"server_uri\": \"fake:///lb\","
238  " \"channel_creds\": [{\"type\": \"google_default\"}]"
239  " }"
240  " ]"
241  "}";
243  Json json = Json::Parse(json_str, &error);
245  XdsBootstrap bootstrap(std::move(json), &error);
247  EXPECT_EQ(bootstrap.server().server_uri, "fake:///lb");
248  EXPECT_EQ(bootstrap.server().channel_creds_type, "google_default");
249  EXPECT_EQ(bootstrap.node(), nullptr);
250 }
251 
252 TEST(XdsBootstrapTest, MissingChannelCreds) {
253  const char* json_str =
254  "{"
255  " \"xds_servers\": ["
256  " {"
257  " \"server_uri\": \"fake:///lb\""
258  " }"
259  " ]"
260  "}";
262  Json json = Json::Parse(json_str, &error);
264  XdsBootstrap bootstrap(std::move(json), &error);
265  EXPECT_THAT(
267  ::testing::ContainsRegex("field:channel_creds error:does not exist."));
269 }
270 
271 TEST(XdsBootstrapTest, NoKnownChannelCreds) {
272  const char* json_str =
273  "{"
274  " \"xds_servers\": ["
275  " {"
276  " \"server_uri\": \"fake:///lb\","
277  " \"channel_creds\": [{\"type\": \"unknown\"}]"
278  " }"
279  " ]"
280  "}";
282  Json json = Json::Parse(json_str, &error);
284  XdsBootstrap bootstrap(std::move(json), &error);
287  "no known creds type found in \"channel_creds\""));
289 }
290 
291 TEST(XdsBootstrapTest, MissingXdsServers) {
293  Json json = Json::Parse("{}", &error);
295  XdsBootstrap bootstrap(std::move(json), &error);
297  ::testing::ContainsRegex("\"xds_servers\" field not present"));
299 }
300 
301 TEST(XdsBootstrapTest, TopFieldsWrongTypes) {
302  const char* json_str =
303  "{"
304  " \"xds_servers\":1,"
305  " \"node\":1,"
306  " \"server_listener_resource_name_template\":1,"
307  " \"certificate_providers\":1"
308  "}";
310  Json json = Json::Parse(json_str, &error);
312  XdsBootstrap bootstrap(std::move(json), &error);
314  ::testing::ContainsRegex("\"xds_servers\" field is not an array.*"
315  "\"node\" field is not an object.*"
316  "\"server_listener_resource_name_"
317  "template\" field is not a string.*"));
320  "\"certificate_providers\" field is not an object"));
322 }
323 
324 TEST(XdsBootstrapTest, XdsServerMissingServerUri) {
325  const char* json_str =
326  "{"
327  " \"xds_servers\":[{}]"
328  "}";
330  Json json = Json::Parse(json_str, &error);
332  XdsBootstrap bootstrap(std::move(json), &error);
333  EXPECT_THAT(
335  ::testing::ContainsRegex("errors parsing \"xds_servers\" array.*"
336  "errors parsing index 0.*"
337  "errors parsing xds server.*"
338  "field:server_uri error:does not exist."));
340 }
341 
342 TEST(XdsBootstrapTest, XdsServerUriAndCredsWrongTypes) {
343  const char* json_str =
344  "{"
345  " \"xds_servers\":["
346  " {"
347  " \"server_uri\":1,"
348  " \"channel_creds\":1"
349  " }"
350  " ]"
351  "}";
353  Json json = Json::Parse(json_str, &error);
355  XdsBootstrap bootstrap(std::move(json), &error);
358  "errors parsing \"xds_servers\" array.*"
359  "errors parsing index 0.*"
360  "errors parsing xds server.*"
361  "field:server_uri error:type should be STRING.*"
362  "field:channel_creds error:type should be ARRAY"));
364 }
365 
366 TEST(XdsBootstrapTest, ChannelCredsFieldsWrongTypes) {
367  const char* json_str =
368  "{"
369  " \"xds_servers\":["
370  " {"
371  " \"server_uri\":\"foo\","
372  " \"channel_creds\":["
373  " {"
374  " \"type\":0,"
375  " \"config\":1"
376  " }"
377  " ]"
378  " }"
379  " ]"
380  "}";
382  Json json = Json::Parse(json_str, &error);
384  XdsBootstrap bootstrap(std::move(json), &error);
385  EXPECT_THAT(
387  ::testing::ContainsRegex("errors parsing \"xds_servers\" array.*"
388  "errors parsing index 0.*"
389  "errors parsing xds server.*"
390  "errors parsing \"channel_creds\" array.*"
391  "errors parsing index 0.*"
392  "field:type error:type should be STRING.*"
393  "field:config error:type should be OBJECT"));
395 }
396 
397 TEST(XdsBootstrapTest, NodeFieldsWrongTypes) {
398  const char* json_str =
399  "{"
400  " \"node\":{"
401  " \"id\":0,"
402  " \"cluster\":0,"
403  " \"locality\":0,"
404  " \"metadata\":0"
405  " }"
406  "}";
408  Json json = Json::Parse(json_str, &error);
410  XdsBootstrap bootstrap(std::move(json), &error);
412  ::testing::ContainsRegex("errors parsing \"node\" object.*"
413  "\"id\" field is not a string.*"
414  "\"cluster\" field is not a string.*"
415  "\"locality\" field is not an object.*"
416  "\"metadata\" field is not an object"));
418 }
419 
420 TEST(XdsBootstrapTest, LocalityFieldsWrongType) {
421  const char* json_str =
422  "{"
423  " \"node\":{"
424  " \"locality\":{"
425  " \"region\":0,"
426  " \"zone\":0,"
427  " \"sub_zone\":0"
428  " }"
429  " }"
430  "}";
432  Json json = Json::Parse(json_str, &error);
434  XdsBootstrap bootstrap(std::move(json), &error);
436  ::testing::ContainsRegex("errors parsing \"node\" object.*"
437  "errors parsing \"locality\" object.*"
438  "\"region\" field is not a string.*"
439  "\"zone\" field is not a string.*"
440  "\"sub_zone\" field is not a string"));
442 }
443 
444 TEST(XdsBootstrapTest, CertificateProvidersElementWrongType) {
445  const char* json_str =
446  "{"
447  " \"xds_servers\": ["
448  " {"
449  " \"server_uri\": \"fake:///lb\","
450  " \"channel_creds\": [{\"type\": \"fake\"}]"
451  " }"
452  " ],"
453  " \"certificate_providers\": {"
454  " \"plugin\":1"
455  " }"
456  "}";
458  Json json = Json::Parse(json_str, &error);
460  XdsBootstrap bootstrap(std::move(json), &error);
463  "errors parsing \"certificate_providers\" object.*"
464  "element \"plugin\" is not an object"));
466 }
467 
468 TEST(XdsBootstrapTest, CertificateProvidersPluginNameWrongType) {
469  const char* json_str =
470  "{"
471  " \"xds_servers\": ["
472  " {"
473  " \"server_uri\": \"fake:///lb\","
474  " \"channel_creds\": [{\"type\": \"fake\"}]"
475  " }"
476  " ],"
477  " \"certificate_providers\": {"
478  " \"plugin\": {"
479  " \"plugin_name\":1"
480  " }"
481  " }"
482  "}";
484  Json json = Json::Parse(json_str, &error);
486  XdsBootstrap bootstrap(std::move(json), &error);
489  "errors parsing \"certificate_providers\" object.*"
490  "errors parsing element \"plugin\".*"
491  "\"plugin_name\" field is not a string"));
493 }
494 
495 TEST(XdsBootstrapTest, CertificateProvidersUnrecognizedPluginName) {
496  const char* json_str =
497  "{"
498  " \"xds_servers\": ["
499  " {"
500  " \"server_uri\": \"fake:///lb\","
501  " \"channel_creds\": [{\"type\": \"fake\"}]"
502  " }"
503  " ],"
504  " \"certificate_providers\": {"
505  " \"plugin\": {"
506  " \"plugin_name\":\"unknown\""
507  " }"
508  " }"
509  "}";
511  Json json = Json::Parse(json_str, &error);
513  XdsBootstrap bootstrap(std::move(json), &error);
516  "errors parsing \"certificate_providers\" object.*"
517  "errors parsing element \"plugin\".*"
518  "Unrecognized plugin name: unknown"));
520 }
521 
522 TEST(XdsBootstrapTest, AuthorityXdsServerInvalidResourceTemplate) {
523  gpr_setenv("GRPC_EXPERIMENTAL_XDS_FEDERATION", "true");
524  const char* json_str =
525  "{"
526  " \"xds_servers\": ["
527  " {"
528  " \"server_uri\": \"fake:///lb\","
529  " \"channel_creds\": [{\"type\": \"fake\"}]"
530  " }"
531  " ],"
532  " \"authorities\": {"
533  " \"xds.example.com\": {"
534  " \"client_listener_resource_name_template\": "
535  "\"xds://xds.example.com/envoy.config.listener.v3.Listener/grpc/server/"
536  "%s\","
537  " \"xds_servers\": ["
538  " {"
539  " \"server_uri\": \"fake:///xds_server\","
540  " \"channel_creds\": ["
541  " {"
542  " \"type\": \"fake\""
543  " }"
544  " ],"
545  " \"server_features\": [\"xds_v3\"]"
546  " }"
547  " ]"
548  " }"
549  " }"
550  "}";
552  Json json = Json::Parse(json_str, &error);
554  XdsBootstrap bootstrap(std::move(json), &error);
557  "errors parsing \"authorities\".*"
558  "errors parsing authority xds.example.com.*"
559  "field must begin with \"xdstp://xds.example.com/\""));
561  gpr_unsetenv("GRPC_EXPERIMENTAL_XDS_FEDERATION");
562 }
563 
564 TEST(XdsBootstrapTest, AuthorityXdsServerMissingServerUri) {
565  gpr_setenv("GRPC_EXPERIMENTAL_XDS_FEDERATION", "true");
566  const char* json_str =
567  "{"
568  " \"xds_servers\": ["
569  " {"
570  " \"server_uri\": \"fake:///lb\","
571  " \"channel_creds\": [{\"type\": \"fake\"}]"
572  " }"
573  " ],"
574  " \"authorities\": {"
575  " \"xds.example.com\": {"
576  " \"client_listener_resource_name_template\": "
577  "\"xdstp://xds.example.com/envoy.config.listener.v3.Listener/grpc/server/"
578  "%s\","
579  " \"xds_servers\":[{}]"
580  " }"
581  " }"
582  "}";
584  Json json = Json::Parse(json_str, &error);
586  XdsBootstrap bootstrap(std::move(json), &error);
587  EXPECT_THAT(
589  ::testing::ContainsRegex("errors parsing \"authorities\".*"
590  "errors parsing authority xds.example.com.*"
591  "errors parsing \"xds_servers\" array.*"
592  "errors parsing index 0.*"
593  "errors parsing xds server.*"
594  "field:server_uri error:does not exist."));
596  gpr_unsetenv("GRPC_EXPERIMENTAL_XDS_FEDERATION");
597 }
598 
599 class FakeCertificateProviderFactory : public CertificateProviderFactory {
600  public:
602  public:
603  explicit Config(int value) : value_(value) {}
604 
605  int value() const { return value_; }
606 
607  const char* name() const override { return "fake"; }
608 
609  std::string ToString() const override {
610  return absl::StrFormat(
611  "{\n"
612  " value=%d"
613  "}",
614  value_);
615  }
616 
617  private:
618  int value_;
619  };
620 
621  const char* name() const override { return "fake"; }
622 
623  RefCountedPtr<CertificateProviderFactory::Config>
624  CreateCertificateProviderConfig(const Json& config_json,
625  grpc_error_handle* error) override {
626  std::vector<grpc_error_handle> error_list;
627  EXPECT_EQ(config_json.type(), Json::Type::OBJECT);
628  auto it = config_json.object_value().find("value");
629  if (it == config_json.object_value().end()) {
630  return MakeRefCounted<FakeCertificateProviderFactory::Config>(0);
631  } else if (it->second.type() != Json::Type::NUMBER) {
633  "field:config field:value not of type number");
634  } else {
635  int value = 0;
636  EXPECT_TRUE(absl::SimpleAtoi(it->second.string_value(), &value));
637  return MakeRefCounted<FakeCertificateProviderFactory::Config>(value);
638  }
639  return nullptr;
640  }
641 
642  RefCountedPtr<grpc_tls_certificate_provider> CreateCertificateProvider(
643  RefCountedPtr<CertificateProviderFactory::Config> /*config*/) override {
644  return nullptr;
645  }
646 };
647 
648 TEST(XdsBootstrapTest, CertificateProvidersFakePluginParsingError) {
649  const char* json_str =
650  "{"
651  " \"xds_servers\": ["
652  " {"
653  " \"server_uri\": \"fake:///lb\","
654  " \"channel_creds\": [{\"type\": \"fake\"}]"
655  " }"
656  " ],"
657  " \"certificate_providers\": {"
658  " \"fake_plugin\": {"
659  " \"plugin_name\": \"fake\","
660  " \"config\": {"
661  " \"value\": \"10\""
662  " }"
663  " }"
664  " }"
665  "}";
667  Json json = Json::Parse(json_str, &error);
669  XdsBootstrap bootstrap(std::move(json), &error);
672  "errors parsing \"certificate_providers\" object.*"
673  "errors parsing element \"fake_plugin\".*"
674  "field:config field:value not of type number"));
676 }
677 
678 TEST(XdsBootstrapTest, CertificateProvidersFakePluginParsingSuccess) {
679  const char* json_str =
680  "{"
681  " \"xds_servers\": ["
682  " {"
683  " \"server_uri\": \"fake:///lb\","
684  " \"channel_creds\": [{\"type\": \"fake\"}]"
685  " }"
686  " ],"
687  " \"certificate_providers\": {"
688  " \"fake_plugin\": {"
689  " \"plugin_name\": \"fake\","
690  " \"config\": {"
691  " \"value\": 10"
692  " }"
693  " }"
694  " }"
695  "}";
697  Json json = Json::Parse(json_str, &error);
699  XdsBootstrap bootstrap(std::move(json), &error);
701  const CertificateProviderStore::PluginDefinition& fake_plugin =
702  bootstrap.certificate_providers().at("fake_plugin");
703  ASSERT_EQ(fake_plugin.plugin_name, "fake");
704  ASSERT_STREQ(fake_plugin.config->name(), "fake");
705  ASSERT_EQ(static_cast<RefCountedPtr<FakeCertificateProviderFactory::Config>>(
706  fake_plugin.config)
707  ->value(),
708  10);
709 }
710 
711 TEST(XdsBootstrapTest, CertificateProvidersFakePluginEmptyConfig) {
712  const char* json_str =
713  "{"
714  " \"xds_servers\": ["
715  " {"
716  " \"server_uri\": \"fake:///lb\","
717  " \"channel_creds\": [{\"type\": \"fake\"}]"
718  " }"
719  " ],"
720  " \"certificate_providers\": {"
721  " \"fake_plugin\": {"
722  " \"plugin_name\": \"fake\""
723  " }"
724  " }"
725  "}";
727  Json json = Json::Parse(json_str, &error);
729  XdsBootstrap bootstrap(std::move(json), &error);
731  const CertificateProviderStore::PluginDefinition& fake_plugin =
732  bootstrap.certificate_providers().at("fake_plugin");
733  ASSERT_EQ(fake_plugin.plugin_name, "fake");
734  ASSERT_STREQ(fake_plugin.config->name(), "fake");
735  ASSERT_EQ(static_cast<RefCountedPtr<FakeCertificateProviderFactory::Config>>(
736  fake_plugin.config)
737  ->value(),
738  0);
739 }
740 
741 TEST(XdsBootstrapTest, XdsServerToJsonAndParse) {
742  gpr_setenv("GRPC_EXPERIMENTAL_XDS_FEDERATION", "true");
743  const char* json_str =
744  " {"
745  " \"server_uri\": \"fake:///lb\","
746  " \"channel_creds\": ["
747  " {"
748  " \"type\": \"fake\","
749  " \"ignore\": 0"
750  " }"
751  " ],"
752  " \"ignore\": 0"
753  " }";
755  Json json = Json::Parse(json_str, &error);
757  XdsBootstrap::XdsServer xds_server =
760  Json::Object output = xds_server.ToJson();
761  XdsBootstrap::XdsServer output_xds_server =
764  gpr_unsetenv("GRPC_EXPERIMENTAL_XDS_FEDERATION");
765 }
766 
767 } // namespace
768 } // namespace testing
769 } // namespace grpc_core
770 
771 int main(int argc, char** argv) {
772  ::testing::InitGoogleTest(&argc, argv);
773  grpc::testing::TestEnvironment env(&argc, argv);
774  grpc_init();
776  absl::make_unique<grpc_core::testing::FakeCertificateProviderFactory>());
777  int ret = RUN_ALL_TESTS();
778  grpc_shutdown();
779  return ret;
780 }
testing
Definition: aws_request_signer_test.cc:25
ASSERT_NE
#define ASSERT_NE(val1, val2)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2060
testing::ContainsRegex
PolymorphicMatcher< internal::MatchesRegexMatcher > ContainsRegex(const internal::RE *regex)
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:8835
regen-readme.it
it
Definition: regen-readme.py:15
GRPC_ERROR_NONE
#define GRPC_ERROR_NONE
Definition: error.h:234
grpc_core::CertificateProviderRegistry::RegisterCertificateProviderFactory
static void RegisterCertificateProviderFactory(std::unique_ptr< CertificateProviderFactory > factory)
Definition: certificate_provider_registry.cc:85
grpc_core::Json::type
Type type() const
Definition: src/core/lib/json/json.h:174
generate.env
env
Definition: generate.py:37
absl::StrFormat
ABSL_MUST_USE_RESULT std::string StrFormat(const FormatSpec< Args... > &format, const Args &... args)
Definition: abseil-cpp/absl/strings/str_format.h:338
EXPECT_THAT
#define EXPECT_THAT(value, matcher)
grpc_core::Json::Type::OBJECT
@ OBJECT
slice.h
ASSERT_STREQ
#define ASSERT_STREQ(s1, s2)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2104
grpc_core
Definition: call_metric_recorder.h:31
gpr_free
GPRAPI void gpr_free(void *ptr)
Definition: alloc.cc:51
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
error
grpc_error_handle error
Definition: retry_filter.cc:499
value_
int value_
Definition: xds_bootstrap_test.cc:618
gpr_tmpfile
FILE * gpr_tmpfile(const char *prefix, char **tmp_filename)
setup.name
name
Definition: setup.py:542
env.h
grpc::creds_file
FILE * creds_file
Definition: cpp/client/credentials_test.cc:244
EXPECT_EQ
#define EXPECT_EQ(a, b)
Definition: iomgr/time_averaged_stats_test.cc:27
testing::ElementsAre
internal::ElementsAreMatcher< ::testing::tuple<> > ElementsAre()
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:13040
testing::Property
PolymorphicMatcher< internal::PropertyMatcher< Class, PropertyType > > Property(PropertyType(Class::*property)() const, const PropertyMatcher &matcher)
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:8732
absl::SimpleAtoi
ABSL_NAMESPACE_BEGIN ABSL_MUST_USE_RESULT bool SimpleAtoi(absl::string_view str, int_type *out)
Definition: abseil-cpp/absl/strings/numbers.h:271
grpc::creds_file_name
char * creds_file_name
Definition: cpp/client/credentials_test.cc:242
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
ToString
std::string ToString(const grpc::string_ref &r)
Definition: string_ref_helper.cc:24
Json
JSON (JavaScript Object Notation).
Definition: third_party/bloaty/third_party/protobuf/conformance/third_party/jsoncpp/json.h:227
gmock_output_test.output
output
Definition: bloaty/third_party/googletest/googlemock/test/gmock_output_test.py:175
xds_bootstrap.h
grpc.h
testing::Eq
internal::EqMatcher< T > Eq(T x)
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:8561
tmpfile.h
grpc_core::Json::Type::NUMBER
@ NUMBER
RUN_ALL_TESTS
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2471
testing::Pair
internal::PairMatcher< FirstMatcher, SecondMatcher > Pair(FirstMatcher first_matcher, SecondMatcher second_matcher)
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:9152
GRPC_ERROR_CREATE_FROM_STATIC_STRING
#define GRPC_ERROR_CREATE_FROM_STATIC_STRING(desc)
Definition: error.h:291
GRPC_GOOGLE_CREDENTIALS_ENV_VAR
#define GRPC_GOOGLE_CREDENTIALS_ENV_VAR
Definition: grpc_security_constants.h:63
grpc_core::Json::Parse
static Json Parse(absl::string_view json_str, grpc_error_handle *error)
Definition: json_reader.cc:899
test_config.h
value
const char * value
Definition: hpack_parser_table.cc:165
main
int main(int argc, char **argv)
Definition: xds_bootstrap_test.cc:771
grpc_core::Json::Object
std::map< std::string, Json > Object
Definition: src/core/lib/json/json.h:54
testing::InitGoogleTest
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
Definition: bloaty/third_party/googletest/googletest/src/gtest.cc:6106
benchmark.FILE
FILE
Definition: benchmark.py:21
grpc_error_std_string
std::string grpc_error_std_string(grpc_error_handle error)
Definition: error.cc:944
grpc::fclose
fclose(creds_file)
ret
UniquePtr< SSL_SESSION > ret
Definition: ssl_x509.cc:1029
grpc_core::Json::Type::JSON_NULL
@ JSON_NULL
grpc::testing::TestEnvironment
Definition: test/core/util/test_config.h:54
certificate_provider_registry.h
grpc_core::Json::string_value
const std::string & string_value() const
Definition: src/core/lib/json/json.h:175
ASSERT_TRUE
#define ASSERT_TRUE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1973
GRPC_ERROR_UNREF
#define GRPC_ERROR_UNREF(err)
Definition: error.h:262
grpc_core::testing::TEST
TEST(ServiceConfigParserTest, DoubleRegistration)
Definition: service_config_test.cc:448
EXPECT_TRUE
#define EXPECT_TRUE(condition)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:1967
check_redundant_namespace_qualifiers.Config
Config
Definition: check_redundant_namespace_qualifiers.py:142
testing::AllOf
internal::AllOfResult2< M1, M2 >::type AllOf(M1 m1, M2 m2)
Definition: cares/cares/test/gmock-1.8.0/gmock/gmock.h:13472
grpc_init
GRPCAPI void grpc_init(void)
Definition: init.cc:146
grpc_error
Definition: error_internal.h:42
gpr_unsetenv
void gpr_unsetenv(const char *name)
grpc_shutdown
GRPCAPI void grpc_shutdown(void)
Definition: init.cc:209
grpc_core::XdsBootstrap::XdsServer::Parse
static XdsServer Parse(const Json &json, grpc_error_handle *error)
Definition: xds_bootstrap.cc:115
ASSERT_EQ
#define ASSERT_EQ(val1, val2)
Definition: bloaty/third_party/googletest/googletest/include/gtest/gtest.h:2056
gpr_setenv
void gpr_setenv(const char *name, const char *value)
GRPC_ERROR_IS_NONE
#define GRPC_ERROR_IS_NONE(err)
Definition: error.h:241


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:55