diff --git a/test/common/router/header_formatter_test.cc b/test/common/router/header_formatter_test.cc index 7f5f47b9dba6..f0e7ecd10f89 100644 --- a/test/common/router/header_formatter_test.cc +++ b/test/common/router/header_formatter_test.cc @@ -34,9 +34,10 @@ namespace Envoy { namespace Router { namespace { -static envoy::config::route::v3::Route parseRouteFromV2Yaml(const std::string& yaml) { +static envoy::config::route::v3::Route parseRouteFromV3Yaml(const std::string& yaml, + bool avoid_boosting = true) { envoy::config::route::v3::Route route; - TestUtility::loadFromYaml(yaml, route); + TestUtility::loadFromYaml(yaml, route, false, avoid_boosting); return route; } @@ -931,7 +932,7 @@ match: { prefix: "/new_endpoint" } )EOF"; HeaderParserPtr req_header_parser = - HeaderParser::configure(parseRouteFromV2Yaml(ymal).request_headers_to_add()); + HeaderParser::configure(parseRouteFromV3Yaml(ymal).request_headers_to_add()); Http::TestRequestHeaderMapImpl header_map{{":method", "POST"}}; NiceMock stream_info; req_header_parser->evaluateHeaders(header_map, stream_info); @@ -953,7 +954,7 @@ match: { prefix: "/new_endpoint" } )EOF"; HeaderParserPtr req_header_parser = - HeaderParser::configure(parseRouteFromV2Yaml(ymal).request_headers_to_add()); + HeaderParser::configure(parseRouteFromV3Yaml(ymal).request_headers_to_add()); Http::TestRequestHeaderMapImpl header_map{{":method", "POST"}}; std::shared_ptr> host( new NiceMock()); @@ -979,7 +980,7 @@ match: { prefix: "/new_endpoint" } )EOF"; HeaderParserPtr req_header_parser = - HeaderParser::configure(parseRouteFromV2Yaml(ymal).request_headers_to_add()); + HeaderParser::configure(parseRouteFromV3Yaml(ymal).request_headers_to_add()); Http::TestRequestHeaderMapImpl header_map{{":method", "POST"}}; NiceMock stream_info; req_header_parser->evaluateHeaders(header_map, stream_info); @@ -1023,7 +1024,7 @@ match: { prefix: "/new_endpoint" } request_headers_to_remove: ["x-nope"] )EOF"; - const auto route = parseRouteFromV2Yaml(yaml); + const auto route = parseRouteFromV3Yaml(yaml); HeaderParserPtr req_header_parser = HeaderParser::configure(route.request_headers_to_add(), route.request_headers_to_remove()); Http::TestRequestHeaderMapImpl header_map{ @@ -1118,7 +1119,7 @@ match: { prefix: "/new_endpoint" } )EOF"; // Disable append mode. - envoy::config::route::v3::Route route = parseRouteFromV2Yaml(ymal); + envoy::config::route::v3::Route route = parseRouteFromV3Yaml(ymal); route.mutable_request_headers_to_add(0)->mutable_append()->set_value(false); route.mutable_request_headers_to_add(1)->mutable_append()->set_value(false); route.mutable_request_headers_to_add(2)->mutable_append()->set_value(false); @@ -1211,7 +1212,7 @@ match: { prefix: "/new_endpoint" } response_headers_to_remove: ["x-nope"] )EOF"; - const auto route = parseRouteFromV2Yaml(yaml); + const auto route = parseRouteFromV3Yaml(yaml); HeaderParserPtr resp_header_parser = HeaderParser::configure(route.response_headers_to_add(), route.response_headers_to_remove()); Http::TestRequestHeaderMapImpl header_map{ @@ -1262,7 +1263,7 @@ match: { prefix: "/new_endpoint" } request_headers_to_remove: ["x-foo-header"] )EOF"; - const auto route = parseRouteFromV2Yaml(yaml); + const auto route = parseRouteFromV3Yaml(yaml); HeaderParserPtr req_header_parser = HeaderParser::configure(route.request_headers_to_add(), route.request_headers_to_remove()); Http::TestRequestHeaderMapImpl header_map{{"x-foo-header", "foo"}}; @@ -1284,7 +1285,7 @@ match: { prefix: "/new_endpoint" } response_headers_to_remove: ["x-foo-header"] )EOF"; - const auto route = parseRouteFromV2Yaml(yaml); + const auto route = parseRouteFromV3Yaml(yaml); HeaderParserPtr resp_header_parser = HeaderParser::configure(route.response_headers_to_add(), route.response_headers_to_remove()); Http::TestResponseHeaderMapImpl header_map{{"x-foo-header", "foo"}}; diff --git a/test/common/router/rds_impl_test.cc b/test/common/router/rds_impl_test.cc index 73342acededd..2116ae2a90b9 100644 --- a/test/common/router/rds_impl_test.cc +++ b/test/common/router/rds_impl_test.cc @@ -358,9 +358,9 @@ class RouteConfigProviderManagerImplTest : public RdsTestBase { }; envoy::config::route::v3::RouteConfiguration -parseRouteConfigurationFromV2Yaml(const std::string& yaml) { +parseRouteConfigurationFromV3Yaml(const std::string& yaml, bool avoid_boosting = true) { envoy::config::route::v3::RouteConfiguration route_config; - TestUtility::loadFromYaml(yaml, route_config, true); + TestUtility::loadFromYaml(yaml, route_config, true, avoid_boosting); return route_config; } @@ -394,7 +394,7 @@ name: foo // Only static route. RouteConfigProviderPtr static_config = route_config_provider_manager_->createStaticRouteConfigProvider( - parseRouteConfigurationFromV2Yaml(config_yaml), server_factory_context_, + parseRouteConfigurationFromV3Yaml(config_yaml), server_factory_context_, validation_visitor_); message_ptr = server_factory_context_.admin_.config_tracker_.config_tracker_callbacks_["routes"](); @@ -403,7 +403,7 @@ name: foo TestUtility::loadFromYaml(R"EOF( static_route_configs: - route_config: - "@type": type.googleapis.com/envoy.api.v2.RouteConfiguration + "@type": type.googleapis.com/envoy.config.route.v3.RouteConfiguration name: foo virtual_hosts: - name: bar @@ -430,7 +430,7 @@ name: foo "version_info": "1", "resources": [ { - "@type": "type.googleapis.com/envoy.api.v2.RouteConfiguration", + "@type": "type.googleapis.com/envoy.config.route.v3.RouteConfiguration", "name": "foo_route_config", "virtual_hosts": null } @@ -451,7 +451,7 @@ name: foo TestUtility::loadFromYaml(R"EOF( static_route_configs: - route_config: - "@type": type.googleapis.com/envoy.api.v2.RouteConfiguration + "@type": type.googleapis.com/envoy.config.route.v3.RouteConfiguration name: foo virtual_hosts: - name: bar @@ -465,7 +465,7 @@ name: foo dynamic_route_configs: - version_info: "1" route_config: - "@type": type.googleapis.com/envoy.api.v2.RouteConfiguration + "@type": type.googleapis.com/envoy.config.route.v3.RouteConfiguration name: foo_route_config virtual_hosts: last_updated: @@ -484,7 +484,7 @@ TEST_F(RouteConfigProviderManagerImplTest, Basic) { EXPECT_FALSE(provider_->configInfo().has_value()); - const auto route_config = parseRouteConfigurationFromV2Yaml(R"EOF( + const auto route_config = parseRouteConfigurationFromV3Yaml(R"EOF( name: foo_route_config virtual_hosts: - name: bar @@ -565,7 +565,7 @@ TEST_F(RouteConfigProviderManagerImplTest, SameProviderOnTwoInitManager) { EXPECT_EQ(Init::Manager::State::Initializing, real_init_manager.state()); { - const auto route_config = parseRouteConfigurationFromV2Yaml(R"EOF( + const auto route_config = parseRouteConfigurationFromV3Yaml(R"EOF( name: foo_route_config virtual_hosts: - name: bar diff --git a/test/common/router/router_ratelimit_test.cc b/test/common/router/router_ratelimit_test.cc index ee3d16403792..2d0ff4988ae2 100644 --- a/test/common/router/router_ratelimit_test.cc +++ b/test/common/router/router_ratelimit_test.cc @@ -28,15 +28,16 @@ namespace Envoy { namespace Router { namespace { -envoy::config::route::v3::RateLimit parseRateLimitFromV2Yaml(const std::string& yaml_string) { +envoy::config::route::v3::RateLimit parseRateLimitFromV3Yaml(const std::string& yaml_string, + bool avoid_boosting = true) { envoy::config::route::v3::RateLimit rate_limit; - TestUtility::loadFromYaml(yaml_string, rate_limit); + TestUtility::loadFromYaml(yaml_string, rate_limit, false, avoid_boosting); TestUtility::validate(rate_limit); return rate_limit; } TEST(BadRateLimitConfiguration, MissingActions) { - EXPECT_THROW_WITH_REGEX(parseRateLimitFromV2Yaml("{}"), EnvoyException, + EXPECT_THROW_WITH_REGEX(parseRateLimitFromV3Yaml("{}"), EnvoyException, "value must contain at least"); } @@ -46,7 +47,7 @@ TEST(BadRateLimitConfiguration, ActionsMissingRequiredFields) { - request_headers: {} )EOF"; - EXPECT_THROW_WITH_REGEX(parseRateLimitFromV2Yaml(yaml_one), EnvoyException, + EXPECT_THROW_WITH_REGEX(parseRateLimitFromV3Yaml(yaml_one), EnvoyException, "value length must be at least"); const std::string yaml_two = R"EOF( @@ -55,7 +56,7 @@ TEST(BadRateLimitConfiguration, ActionsMissingRequiredFields) { header_name: test )EOF"; - EXPECT_THROW_WITH_REGEX(parseRateLimitFromV2Yaml(yaml_two), EnvoyException, + EXPECT_THROW_WITH_REGEX(parseRateLimitFromV3Yaml(yaml_two), EnvoyException, "value length must be at least"); const std::string yaml_three = R"EOF( @@ -64,7 +65,7 @@ TEST(BadRateLimitConfiguration, ActionsMissingRequiredFields) { descriptor_key: test )EOF"; - EXPECT_THROW_WITH_REGEX(parseRateLimitFromV2Yaml(yaml_three), EnvoyException, + EXPECT_THROW_WITH_REGEX(parseRateLimitFromV3Yaml(yaml_three), EnvoyException, "value length must be at least"); } @@ -268,7 +269,7 @@ TEST_F(RateLimitConfiguration, Stages) { class RateLimitPolicyEntryTest : public testing::Test { public: void setupTest(const std::string& yaml) { - rate_limit_entry_ = std::make_unique(parseRateLimitFromV2Yaml(yaml)); + rate_limit_entry_ = std::make_unique(parseRateLimitFromV3Yaml(yaml)); descriptors_.clear(); }