|
|
|
@ -303,7 +303,8 @@ TEST_F(XdsFaultInjectionFilterTest, ModifyChannelArgs) { |
|
|
|
|
TEST_F(XdsFaultInjectionFilterTest, GenerateServiceConfigTopLevelConfig) { |
|
|
|
|
XdsHttpFilterImpl::FilterConfig config; |
|
|
|
|
config.config = Json::Object{{"foo", "bar"}}; |
|
|
|
|
auto service_config = filter_->GenerateServiceConfig(config, nullptr); |
|
|
|
|
auto service_config = |
|
|
|
|
filter_->GenerateServiceConfig(config, nullptr, /*filter_name=*/""); |
|
|
|
|
ASSERT_TRUE(service_config.ok()) << service_config.status(); |
|
|
|
|
EXPECT_EQ(service_config->service_config_field_name, "faultInjectionPolicy"); |
|
|
|
|
EXPECT_EQ(service_config->element, "{\"foo\":\"bar\"}"); |
|
|
|
@ -314,8 +315,8 @@ TEST_F(XdsFaultInjectionFilterTest, GenerateServiceConfigOverrideConfig) { |
|
|
|
|
top_config.config = Json::Object{{"foo", "bar"}}; |
|
|
|
|
XdsHttpFilterImpl::FilterConfig override_config; |
|
|
|
|
override_config.config = Json::Object{{"baz", "quux"}}; |
|
|
|
|
auto service_config = |
|
|
|
|
filter_->GenerateServiceConfig(top_config, &override_config); |
|
|
|
|
auto service_config = filter_->GenerateServiceConfig( |
|
|
|
|
top_config, &override_config, /*filter_name=*/""); |
|
|
|
|
ASSERT_TRUE(service_config.ok()) << service_config.status(); |
|
|
|
|
EXPECT_EQ(service_config->service_config_field_name, "faultInjectionPolicy"); |
|
|
|
|
EXPECT_EQ(service_config->element, "{\"baz\":\"quux\"}"); |
|
|
|
@ -591,6 +592,17 @@ TEST_F(XdsRbacFilterTest, GenerateFilterConfigOverrideUnparseable) { |
|
|
|
|
<< status; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(XdsRbacFilterTest, GenerateServiceConfig) { |
|
|
|
|
XdsHttpFilterImpl::FilterConfig hcm_config = {filter_->ConfigProtoName(), |
|
|
|
|
Json::Object{{"name", "foo"}}}; |
|
|
|
|
auto config = filter_->GenerateServiceConfig(hcm_config, nullptr, "rbac"); |
|
|
|
|
ASSERT_TRUE(config.ok()) << config.status(); |
|
|
|
|
EXPECT_EQ(config->service_config_field_name, "rbacPolicy"); |
|
|
|
|
EXPECT_EQ( |
|
|
|
|
config->element, |
|
|
|
|
JsonDump(Json(Json::Object{{"name", "foo"}, {"filter_name", "rbac"}}))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// For the RBAC filter, the override config is a superset of the
|
|
|
|
|
// top-level config, so we test all of the common fields as input for
|
|
|
|
|
// both GenerateFilterConfig() and GenerateFilterConfigOverride().
|
|
|
|
@ -1125,7 +1137,8 @@ TEST_F(XdsStatefulSessionFilterTest, OverrideConfigDisabled) { |
|
|
|
|
TEST_F(XdsStatefulSessionFilterTest, GenerateServiceConfigNoOverride) { |
|
|
|
|
XdsHttpFilterImpl::FilterConfig hcm_config = {filter_->ConfigProtoName(), |
|
|
|
|
Json::Object{{"name", "foo"}}}; |
|
|
|
|
auto config = filter_->GenerateServiceConfig(hcm_config, nullptr); |
|
|
|
|
auto config = |
|
|
|
|
filter_->GenerateServiceConfig(hcm_config, nullptr, /*filter_name=*/""); |
|
|
|
|
ASSERT_TRUE(config.ok()) << config.status(); |
|
|
|
|
EXPECT_EQ(config->service_config_field_name, "stateful_session"); |
|
|
|
|
EXPECT_EQ(config->element, JsonDump(Json(Json::Object{{"name", "foo"}}))); |
|
|
|
@ -1136,7 +1149,8 @@ TEST_F(XdsStatefulSessionFilterTest, GenerateServiceConfigWithOverride) { |
|
|
|
|
Json::Object{{"name", "foo"}}}; |
|
|
|
|
XdsHttpFilterImpl::FilterConfig override_config = { |
|
|
|
|
filter_->OverrideConfigProtoName(), Json::Object{{"name", "bar"}}}; |
|
|
|
|
auto config = filter_->GenerateServiceConfig(hcm_config, &override_config); |
|
|
|
|
auto config = filter_->GenerateServiceConfig(hcm_config, &override_config, |
|
|
|
|
/*filter_name=*/""); |
|
|
|
|
ASSERT_TRUE(config.ok()) << config.status(); |
|
|
|
|
EXPECT_EQ(config->service_config_field_name, "stateful_session"); |
|
|
|
|
EXPECT_EQ(config->element, JsonDump(Json(Json::Object{{"name", "bar"}}))); |
|
|
|
|