diff --git a/source/extensions/filters/http/header_to_metadata/header_to_metadata_filter.cc b/source/extensions/filters/http/header_to_metadata/header_to_metadata_filter.cc index e80d7845cb41..b61e5ecf92c0 100644 --- a/source/extensions/filters/http/header_to_metadata/header_to_metadata_filter.cc +++ b/source/extensions/filters/http/header_to_metadata/header_to_metadata_filter.cc @@ -150,7 +150,7 @@ void HeaderToMetadataFilter::setEncoderFilterCallbacks( encoder_callbacks_ = &callbacks; } -bool HeaderToMetadataFilter::addMetadata(StructMap& map, const std::string& meta_namespace, +bool HeaderToMetadataFilter::addMetadata(StructMap& struct_map, const std::string& meta_namespace, const std::string& key, std::string value, ValueType type, ValueEncode encode) const { ProtobufWkt::Value val; @@ -196,15 +196,8 @@ bool HeaderToMetadataFilter::addMetadata(StructMap& map, const std::string& meta } } - // Have we seen this namespace before? - auto namespace_iter = map.find(meta_namespace); - if (namespace_iter == map.end()) { - map[meta_namespace] = ProtobufWkt::Struct(); - namespace_iter = map.find(meta_namespace); - } - - auto& keyval = namespace_iter->second; - (*keyval.mutable_fields())[key] = val; + auto& keyval = struct_map[meta_namespace]; + (*keyval.mutable_fields())[key] = std::move(val); return true; } diff --git a/source/extensions/filters/network/thrift_proxy/filters/header_to_metadata/header_to_metadata_filter.cc b/source/extensions/filters/network/thrift_proxy/filters/header_to_metadata/header_to_metadata_filter.cc index 143a715a8d1a..686547a795ec 100644 --- a/source/extensions/filters/network/thrift_proxy/filters/header_to_metadata/header_to_metadata_filter.cc +++ b/source/extensions/filters/network/thrift_proxy/filters/header_to_metadata/header_to_metadata_filter.cc @@ -39,7 +39,7 @@ Rule::Rule(const ProtoRule& rule) : rule_(rule) { } if (rule.has_on_missing() && rule.on_missing().value().empty()) { - throw EnvoyException("Cannot specify on_missing rule without non-empty value"); + throw EnvoyException("Cannot specify on_missing rule with empty value"); } if (rule.has_on_present() && rule.on_present().has_regex_value_rewrite()) { @@ -72,7 +72,7 @@ const std::string& HeaderToMetadataFilter::decideNamespace(const std::string& ns return nspace.empty() ? headerToMetadata : nspace; } -bool HeaderToMetadataFilter::addMetadata(StructMap& map, const std::string& meta_namespace, +bool HeaderToMetadataFilter::addMetadata(StructMap& struct_map, const std::string& meta_namespace, const std::string& key, std::string value, ValueType type, ValueEncode encode) const { ProtobufWkt::Value val; @@ -122,15 +122,8 @@ bool HeaderToMetadataFilter::addMetadata(StructMap& map, const std::string& meta } } - // Have we seen this namespace before? - auto namespace_iter = map.find(meta_namespace); - if (namespace_iter == map.end()) { - map[meta_namespace] = ProtobufWkt::Struct(); - namespace_iter = map.find(meta_namespace); - } - - auto& keyval = namespace_iter->second; - (*keyval.mutable_fields())[key] = val; + auto& keyval = struct_map[meta_namespace]; + (*keyval.mutable_fields())[key] = std::move(val); return true; } diff --git a/source/extensions/filters/network/thrift_proxy/filters/payload_to_metadata/payload_to_metadata_filter.cc b/source/extensions/filters/network/thrift_proxy/filters/payload_to_metadata/payload_to_metadata_filter.cc index 5e258043ca3c..d92b30b2e915 100644 --- a/source/extensions/filters/network/thrift_proxy/filters/payload_to_metadata/payload_to_metadata_filter.cc +++ b/source/extensions/filters/network/thrift_proxy/filters/payload_to_metadata/payload_to_metadata_filter.cc @@ -244,15 +244,8 @@ bool PayloadToMetadataFilter::addMetadata(const std::string& meta_namespace, con } } - // Have we seen this namespace before? - auto namespace_iter = structs_by_namespace_.find(meta_namespace); - if (namespace_iter == structs_by_namespace_.end()) { - structs_by_namespace_[meta_namespace] = ProtobufWkt::Struct(); - namespace_iter = structs_by_namespace_.find(meta_namespace); - } - - auto& keyval = namespace_iter->second; - (*keyval.mutable_fields())[key] = val; + auto& keyval = structs_by_namespace_[meta_namespace]; + (*keyval.mutable_fields())[key] = std::move(val); return true; } diff --git a/source/extensions/filters/network/thrift_proxy/filters/payload_to_metadata/payload_to_metadata_filter.h b/source/extensions/filters/network/thrift_proxy/filters/payload_to_metadata/payload_to_metadata_filter.h index 9fbad3b3b5af..9f900cc0d22f 100644 --- a/source/extensions/filters/network/thrift_proxy/filters/payload_to_metadata/payload_to_metadata_filter.h +++ b/source/extensions/filters/network/thrift_proxy/filters/payload_to_metadata/payload_to_metadata_filter.h @@ -159,10 +159,6 @@ class PayloadToMetadataFilter : public MetadataHandler, void handleOnMissing() override; private: - static TransportPtr createTransport(TransportType transport) { - return NamedTransportConfigFactory::getFactory(transport).createTransport(); - } - static ProtocolPtr createProtocol(ProtocolType protocol) { return NamedProtocolConfigFactory::getFactory(protocol).createProtocol(); } diff --git a/test/extensions/filters/http/header_to_metadata/header_to_metadata_filter_test.cc b/test/extensions/filters/http/header_to_metadata/header_to_metadata_filter_test.cc index baf05d45aa1c..5b16b93a6add 100644 --- a/test/extensions/filters/http/header_to_metadata/header_to_metadata_filter_test.cc +++ b/test/extensions/filters/http/header_to_metadata/header_to_metadata_filter_test.cc @@ -93,7 +93,7 @@ class HeaderToMetadataTest : public testing::Test { TEST_F(HeaderToMetadataTest, BasicRequestTest) { initializeFilter(request_config_yaml); Http::TestRequestHeaderMapImpl incoming_headers{{"X-VERSION", "0xdeadbeef"}}; - std::map expected = {{"version", "0xdeadbeef"}}; + const std::map expected = {{"version", "0xdeadbeef"}}; EXPECT_CALL(decoder_callbacks_, streamInfo()).WillRepeatedly(ReturnRef(req_info_)); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -111,7 +111,7 @@ TEST_F(HeaderToMetadataTest, BasicRequestTest) { TEST_F(HeaderToMetadataTest, BasicRequestDoubleHeadersTest) { initializeFilter(request_config_yaml); Http::TestRequestHeaderMapImpl incoming_headers{{"X-VERSION", "foo"}, {"X-VERSION", "bar"}}; - std::map expected = {{"version", "foo,bar"}}; + const std::map expected = {{"version", "foo,bar"}}; EXPECT_CALL(decoder_callbacks_, streamInfo()).WillRepeatedly(ReturnRef(req_info_)); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -129,7 +129,7 @@ TEST_F(HeaderToMetadataTest, PerRouteOverride) { // Global config is empty. initializeFilter("{}"); Http::TestRequestHeaderMapImpl incoming_headers{{"X-VERSION", "0xdeadbeef"}}; - std::map expected = {{"version", "0xdeadbeef"}}; + const std::map expected = {{"version", "0xdeadbeef"}}; // Setup per route config. envoy::extensions::filters::http::header_to_metadata::v3::Config config_proto; @@ -154,7 +154,7 @@ TEST_F(HeaderToMetadataTest, ConfigIsCached) { // Global config is empty. initializeFilter("{}"); Http::TestRequestHeaderMapImpl incoming_headers{{"X-VERSION", "0xdeadbeef"}}; - std::map expected = {{"version", "0xdeadbeef"}}; + const std::map expected = {{"version", "0xdeadbeef"}}; // Setup per route config. envoy::extensions::filters::http::header_to_metadata::v3::Config config_proto; @@ -173,7 +173,7 @@ TEST_F(HeaderToMetadataTest, ConfigIsCached) { TEST_F(HeaderToMetadataTest, DefaultEndpointsTest) { initializeFilter(request_config_yaml); Http::TestRequestHeaderMapImpl incoming_headers{{"X-FOO", "bar"}}; - std::map expected = {{"default", "true"}}; + const std::map expected = {{"default", "true"}}; EXPECT_CALL(decoder_callbacks_, streamInfo()).WillRepeatedly(ReturnRef(req_info_)); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -194,7 +194,7 @@ TEST_F(HeaderToMetadataTest, HeaderRemovedTest) { )EOF"; initializeFilter(response_config_yaml); Http::TestResponseHeaderMapImpl incoming_headers{{"x-authenticated", "1"}}; - std::map expected = {{"auth", "1"}}; + const std::map expected = {{"auth", "1"}}; Http::TestResponseHeaderMapImpl empty_headers; EXPECT_CALL(encoder_callbacks_, streamInfo()).WillRepeatedly(ReturnRef(req_info_)); @@ -250,7 +250,7 @@ TEST_F(HeaderToMetadataTest, StringTypeInBase64UrlTest) { std::string data = "Non-ascii-characters"; const auto encoded = Base64::encode(data.c_str(), data.size()); Http::TestResponseHeaderMapImpl incoming_headers{{"x-authenticated", encoded}}; - std::map expected = {{"auth", data}}; + const std::map expected = {{"auth", data}}; Http::TestResponseHeaderMapImpl empty_headers; EXPECT_CALL(encoder_callbacks_, streamInfo()).WillRepeatedly(ReturnRef(req_info_)); @@ -381,7 +381,8 @@ TEST_F(HeaderToMetadataTest, MultipleHeadersMatch) { {"X-PYTHON-VERSION", "3.7"}, {"X-IGNORE", "nothing"}, }; - std::map expected = {{"version", "v4.0"}, {"python_version", "3.7"}}; + const std::map expected = {{"version", "v4.0"}, + {"python_version", "3.7"}}; EXPECT_CALL(decoder_callbacks_, streamInfo()).WillRepeatedly(ReturnRef(req_info_)); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -428,7 +429,7 @@ TEST_F(HeaderToMetadataTest, IgnoreHeaderValueUseConstant) { )EOF"; initializeFilter(response_config_yaml); Http::TestResponseHeaderMapImpl incoming_headers{{"x-something", "thing"}}; - std::map expected = {{"something", "else"}}; + const std::map expected = {{"something", "else"}}; Http::TestResponseHeaderMapImpl empty_headers; EXPECT_CALL(encoder_callbacks_, streamInfo()).WillRepeatedly(ReturnRef(req_info_)); @@ -546,7 +547,7 @@ TEST_F(HeaderToMetadataTest, RegexSubstitution) { // Match with additional path elements. { Http::TestRequestHeaderMapImpl headers{{":path", "/cluster-prod-001/x/y"}}; - std::map expected = {{"cluster", "cluster-prod-001"}}; + const std::map expected = {{"cluster", "cluster-prod-001"}}; EXPECT_CALL(decoder_callbacks_, streamInfo()).WillRepeatedly(ReturnRef(req_info_)); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -556,7 +557,7 @@ TEST_F(HeaderToMetadataTest, RegexSubstitution) { // Match with no additional path elements. { Http::TestRequestHeaderMapImpl headers{{":path", "/cluster-prod-001"}}; - std::map expected = {{"cluster", "cluster-prod-001"}}; + const std::map expected = {{"cluster", "cluster-prod-001"}}; EXPECT_CALL(decoder_callbacks_, streamInfo()).WillRepeatedly(ReturnRef(req_info_)); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -566,7 +567,7 @@ TEST_F(HeaderToMetadataTest, RegexSubstitution) { // No match. { Http::TestRequestHeaderMapImpl headers{{":path", "/foo"}}; - std::map expected = {{"cluster", "/foo"}}; + const std::map expected = {{"cluster", "/foo"}}; EXPECT_CALL(decoder_callbacks_, streamInfo()).WillRepeatedly(ReturnRef(req_info_)); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -576,7 +577,7 @@ TEST_F(HeaderToMetadataTest, RegexSubstitution) { // No match with additional path elements. { Http::TestRequestHeaderMapImpl headers{{":path", "/foo/bar?x=2"}}; - std::map expected = {{"cluster", "/foo/bar?x=2"}}; + const std::map expected = {{"cluster", "/foo/bar?x=2"}}; EXPECT_CALL(decoder_callbacks_, streamInfo()).WillRepeatedly(ReturnRef(req_info_)); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -670,7 +671,7 @@ TEST_F(HeaderToMetadataTest, CookieValueUsed) { )EOF"; initializeFilter(response_config_yaml); Http::TestResponseHeaderMapImpl incoming_headers{{"cookie", "bar=foo"}}; - std::map expected = {{"bar", "foo"}}; + const std::map expected = {{"bar", "foo"}}; EXPECT_CALL(encoder_callbacks_, streamInfo()).WillRepeatedly(ReturnRef(req_info_)); EXPECT_CALL(req_info_, @@ -693,7 +694,7 @@ TEST_F(HeaderToMetadataTest, IgnoreCookieValueUseConstant) { )EOF"; initializeFilter(response_config_yaml); Http::TestResponseHeaderMapImpl incoming_headers{{"cookie", "meh=foo"}}; - std::map expected = {{"meh", "some_value"}}; + const std::map expected = {{"meh", "some_value"}}; EXPECT_CALL(encoder_callbacks_, streamInfo()).WillRepeatedly(ReturnRef(req_info_)); EXPECT_CALL(req_info_, @@ -716,7 +717,7 @@ TEST_F(HeaderToMetadataTest, NoCookieValue) { )EOF"; initializeFilter(config); Http::TestRequestHeaderMapImpl headers{{"cookie", ""}}; - std::map expected = {{"foo", "some_value"}}; + const std::map expected = {{"foo", "some_value"}}; EXPECT_CALL(decoder_callbacks_, streamInfo()).WillRepeatedly(ReturnRef(req_info_)); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -744,7 +745,7 @@ TEST_F(HeaderToMetadataTest, CookieRegexSubstitution) { // match. { Http::TestRequestHeaderMapImpl headers{{"cookie", "foo=cluster-prod-001"}}; - std::map expected = {{"cluster", "cluster-prod-001 matched"}}; + const std::map expected = {{"cluster", "cluster-prod-001 matched"}}; EXPECT_CALL(decoder_callbacks_, streamInfo()).WillRepeatedly(ReturnRef(req_info_)); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -754,7 +755,7 @@ TEST_F(HeaderToMetadataTest, CookieRegexSubstitution) { // No match. { Http::TestRequestHeaderMapImpl headers{{"cookie", "foo=cluster"}}; - std::map expected = {{"cluster", "cluster"}}; + const std::map expected = {{"cluster", "cluster"}}; EXPECT_CALL(decoder_callbacks_, streamInfo()).WillRepeatedly(ReturnRef(req_info_)); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); diff --git a/test/extensions/filters/network/thrift_proxy/filters/header_to_metadata/config_test.cc b/test/extensions/filters/network/thrift_proxy/filters/header_to_metadata/config_test.cc index e3dadf9eedf2..bee231135f99 100644 --- a/test/extensions/filters/network/thrift_proxy/filters/header_to_metadata/config_test.cc +++ b/test/extensions/filters/network/thrift_proxy/filters/header_to_metadata/config_test.cc @@ -118,7 +118,7 @@ TEST(HeaderToMetadataFilterConfigTest, OnHeaderMissingEmptyValue) { type: STRING )EOF"; - testForbiddenConfig(yaml, "Cannot specify on_missing rule without non-empty value"); + testForbiddenConfig(yaml, "Cannot specify on_missing rule with empty value"); } } // namespace HeaderToMetadataFilter diff --git a/test/extensions/filters/network/thrift_proxy/filters/header_to_metadata/header_to_metadata_filter_test.cc b/test/extensions/filters/network/thrift_proxy/filters/header_to_metadata/header_to_metadata_filter_test.cc index 33f13f377773..1d0b1b0b718a 100644 --- a/test/extensions/filters/network/thrift_proxy/filters/header_to_metadata/header_to_metadata_filter_test.cc +++ b/test/extensions/filters/network/thrift_proxy/filters/header_to_metadata/header_to_metadata_filter_test.cc @@ -74,7 +74,7 @@ TEST_F(HeaderToMetadataTest, BasicRequestTest) { key: version )EOF"; initializeFilter(request_config_yaml); - std::map expected = {{"version", "0xdeadbeef"}}; + const std::map expected = {{"version", "0xdeadbeef"}}; EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); auto metadata = std::make_shared(); @@ -92,7 +92,7 @@ TEST_F(HeaderToMetadataTest, DefaultNamespaceTest) { key: version )EOF"; initializeFilter(request_config_yaml); - std::map expected = {{"version", "0xdeadbeef"}}; + const std::map expected = {{"version", "0xdeadbeef"}}; EXPECT_CALL(req_info_, setDynamicMetadata("envoy.filters.thrift.header_to_metadata", MapEq(expected))); @@ -113,7 +113,7 @@ TEST_F(HeaderToMetadataTest, ReplaceValueTest) { value: world )EOF"; initializeFilter(request_config_yaml); - std::map expected = {{"replace", "world"}}; + const std::map expected = {{"replace", "world"}}; EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); auto metadata = std::make_shared(); @@ -137,7 +137,7 @@ TEST_F(HeaderToMetadataTest, SubstituteValueTest) { substitution: "\\1" )EOF"; initializeFilter(request_config_yaml); - std::map expected = {{"subbed", "world"}}; + const std::map expected = {{"subbed", "world"}}; EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); auto metadata = std::make_shared(); @@ -161,7 +161,7 @@ TEST_F(HeaderToMetadataTest, NoMatchSubstituteValueTest) { substitution: "\\1" )EOF"; initializeFilter(request_config_yaml); - std::map expected = {{"subbed", "does not match"}}; + const std::map expected = {{"subbed", "does not match"}}; EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); auto metadata = std::make_shared(); @@ -257,7 +257,7 @@ TEST_F(HeaderToMetadataTest, StringTypeInBase64UrlTest) { )EOF"; initializeFilter(request_config_yaml); std::string data = "Non-ascii-characters"; - std::map expected = {{"base64_key", data}}; + const std::map expected = {{"base64_key", data}}; EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); const auto encoded = Base64::encode(data.c_str(), data.size()); @@ -366,7 +366,7 @@ TEST_F(HeaderToMetadataTest, SetMissingValueTest) { value: hi )EOF"; initializeFilter(request_config_yaml); - std::map expected = {{"set", "hi"}}; + const std::map expected = {{"set", "hi"}}; EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); auto metadata = std::make_shared(); @@ -413,7 +413,7 @@ TEST_F(HeaderToMetadataTest, RemoveHeaderTest) { value: world )EOF"; initializeFilter(request_config_yaml); - std::map expected = {{"remove", "hello"}, {"keep", "world"}}; + const std::map expected = {{"remove", "hello"}, {"keep", "world"}}; EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); auto metadata = std::make_shared(); @@ -486,7 +486,7 @@ TEST_F(HeaderToMetadataTest, MultipleRulesTest) { value: world )EOF"; initializeFilter(request_config_yaml); - std::map expected = {{"set", "hello"}, {"replace", "world"}}; + const std::map expected = {{"set", "hello"}, {"replace", "world"}}; EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); auto metadata = std::make_shared(); diff --git a/test/extensions/filters/network/thrift_proxy/filters/payload_to_metadata/payload_to_metadata_filter_test.cc b/test/extensions/filters/network/thrift_proxy/filters/payload_to_metadata/payload_to_metadata_filter_test.cc index 726b702db253..d11472c0036d 100644 --- a/test/extensions/filters/network/thrift_proxy/filters/payload_to_metadata/payload_to_metadata_filter_test.cc +++ b/test/extensions/filters/network/thrift_proxy/filters/payload_to_metadata/payload_to_metadata_filter_test.cc @@ -265,7 +265,7 @@ TEST_F(PayloadToMetadataTest, MatchFirstLayerString) { value: unknown )EOF"; - std::map expected = {{"present", "two"}}; + const std::map expected = {{"present", "two"}}; initializeFilter(request_config_yaml); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -294,7 +294,7 @@ TEST_F(PayloadToMetadataTest, MatchSecondLayerString) { value: unknown )EOF"; - std::map expected = {{"present", "seven"}}; + const std::map expected = {{"present", "seven"}}; initializeFilter(request_config_yaml); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -320,7 +320,7 @@ TEST_F(PayloadToMetadataTest, MatchFirstLayerNumber) { value: unknown )EOF"; - std::map expected = {{"present", "1"}}; + const std::map expected = {{"present", "1"}}; initializeFilter(request_config_yaml); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -349,7 +349,7 @@ TEST_F(PayloadToMetadataTest, MatchSecondLayerBool) { value: unknown )EOF"; - std::map expected = {{"present", "1"}}; + const std::map expected = {{"present", "1"}}; initializeFilter(request_config_yaml); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -378,7 +378,7 @@ TEST_F(PayloadToMetadataTest, MatchSecondLayerByte) { value: unknown )EOF"; - std::map expected = {{"present", "2"}}; + const std::map expected = {{"present", "2"}}; initializeFilter(request_config_yaml); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -407,7 +407,7 @@ TEST_F(PayloadToMetadataTest, MatchSecondLayerDouble) { value: unknown )EOF"; - std::map expected = {{"present", "3.000000"}}; + const std::map expected = {{"present", "3.000000"}}; initializeFilter(request_config_yaml); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -436,7 +436,7 @@ TEST_F(PayloadToMetadataTest, MatchSecondLayerInt16) { value: unknown )EOF"; - std::map expected = {{"present", "4"}}; + const std::map expected = {{"present", "4"}}; initializeFilter(request_config_yaml); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -465,7 +465,7 @@ TEST_F(PayloadToMetadataTest, MatchSecondLayerInt32) { value: unknown )EOF"; - std::map expected = {{"present", "5"}}; + const std::map expected = {{"present", "5"}}; initializeFilter(request_config_yaml); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -494,7 +494,7 @@ TEST_F(PayloadToMetadataTest, MatchSecondLayerInt64) { value: unknown )EOF"; - std::map expected = {{"present", "6"}}; + const std::map expected = {{"present", "6"}}; initializeFilter(request_config_yaml); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -520,7 +520,7 @@ TEST_F(PayloadToMetadataTest, EmptyMethodName) { value: unknown )EOF"; - std::map expected = {{"present", "two"}}; + const std::map expected = {{"present", "two"}}; initializeFilter(request_config_yaml); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -568,7 +568,7 @@ TEST_F(PayloadToMetadataTest, DefaultNamespaceTest) { value: unknown )EOF"; initializeFilter(request_config_yaml); - std::map expected = {{"present", "two"}}; + const std::map expected = {{"present", "two"}}; EXPECT_CALL(req_info_, setDynamicMetadata("envoy.filters.thrift.payload_to_metadata", MapEq(expected))); EXPECT_CALL(decoder_callbacks_, streamInfo()).WillRepeatedly(ReturnRef(req_info_)); @@ -594,7 +594,7 @@ TEST_F(PayloadToMetadataTest, ReplaceValueTest) { value: unknown )EOF"; - std::map expected = {{"present", "bar"}}; + const std::map expected = {{"present", "bar"}}; initializeFilter(request_config_yaml); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -625,7 +625,7 @@ TEST_F(PayloadToMetadataTest, SubstituteValueTest) { value: unknown )EOF"; - std::map expected = {{"present", "two cents"}}; + const std::map expected = {{"present", "two cents"}}; initializeFilter(request_config_yaml); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -657,7 +657,7 @@ TEST_F(PayloadToMetadataTest, NoMatchSubstituteValueTest) { )EOF"; const std::string value = "do not match"; - std::map expected = {{"present", value}}; + const std::map expected = {{"present", value}}; initializeFilter(request_config_yaml); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -826,7 +826,7 @@ TEST_F(PayloadToMetadataTest, MissingValueInFirstLayer) { key: missing value: unknown )EOF"; - std::map expected = {{"missing", "unknown"}}; + const std::map expected = {{"missing", "unknown"}}; initializeFilter(request_config_yaml); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -855,7 +855,7 @@ TEST_F(PayloadToMetadataTest, MissingValueInSecondLayer) { key: missing value: unknown )EOF"; - std::map expected = {{"missing", "unknown"}}; + const std::map expected = {{"missing", "unknown"}}; initializeFilter(request_config_yaml); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -887,7 +887,7 @@ TEST_F(PayloadToMetadataTest, MissingValueInThirdLayer) { key: missing value: unknown )EOF"; - std::map expected = {{"missing", "unknown"}}; + const std::map expected = {{"missing", "unknown"}}; initializeFilter(request_config_yaml); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -913,7 +913,7 @@ TEST_F(PayloadToMetadataTest, FieldSelectorPointsToStruct) { key: missing value: unknown )EOF"; - std::map expected = {{"missing", "unknown"}}; + const std::map expected = {{"missing", "unknown"}}; initializeFilter(request_config_yaml); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -942,7 +942,7 @@ TEST_F(PayloadToMetadataTest, FieldSelectorPointsToMap) { key: missing value: unknown )EOF"; - std::map expected = {{"missing", "unknown"}}; + const std::map expected = {{"missing", "unknown"}}; initializeFilter(request_config_yaml); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -971,7 +971,7 @@ TEST_F(PayloadToMetadataTest, PointToNonExistSecondLayer) { key: missing value: unknown )EOF"; - std::map expected = {{"missing", "unknown"}}; + const std::map expected = {{"missing", "unknown"}}; initializeFilter(request_config_yaml); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -1117,7 +1117,7 @@ TEST_F(PayloadToMetadataTest, MultipleRulesTest) { key: seven )EOF"; - std::map expected = { + const std::map expected = { {"present", "two"}, {"six", "6"}, {"seven", "seven"}}; initializeFilter(request_config_yaml); @@ -1174,7 +1174,7 @@ TEST_F(PayloadToMetadataTest, MultipleRulesInSamePath) { key: method_not_match_again )EOF"; - std::map expected = { + const std::map expected = { {"present", "two"}, {"present2", "two"}, {"six", "6"}}; initializeFilter(request_config_yaml); @@ -1204,7 +1204,7 @@ TEST_F(PayloadToMetadataTest, MultipleRulesInSamePathFirstRuleUnmatched) { key: present2 )EOF"; - std::map expected = {{"present2", "two"}}; + const std::map expected = {{"present2", "two"}}; initializeFilter(request_config_yaml); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected))); @@ -1249,7 +1249,7 @@ TEST_F(PayloadToMetadataTest, MultipleRulesOnMultiStruct) { key: baz )EOF"; - std::map expected = {{"baz", "qux"}}; + const std::map expected = {{"baz", "qux"}}; initializeFilter(request_config_yaml); EXPECT_CALL(req_info_, setDynamicMetadata("envoy.lb", MapEq(expected)));