From b1d9c8f62775841b4fe105726e94be6a0e50af6d Mon Sep 17 00:00:00 2001 From: nfuden Date: Mon, 13 Jan 2025 10:54:28 -0500 Subject: [PATCH] show bad test --- .../transformation_filter_test.cc | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/test/extensions/filters/http/transformation/transformation_filter_test.cc b/test/extensions/filters/http/transformation/transformation_filter_test.cc index 7964757c..b0538c45 100644 --- a/test/extensions/filters/http/transformation/transformation_filter_test.cc +++ b/test/extensions/filters/http/transformation/transformation_filter_test.cc @@ -410,6 +410,7 @@ TEST_F(TransformationFilterTest, TransformsResponseOnHeadersNoHost) { EXPECT_EQ(0U, config_->stats().response_header_transformations_.value()); } + TEST_F(TransformationFilterTest, TransformLocalResponse) { Http::TestRequestHeaderMapImpl request_headers{ {"content-type", "test"}, {":method", "GET"}, {":path", "/"}}; @@ -525,6 +526,43 @@ TEST_F(TransformationFilterTest, StagedFilterRequestConfig) { EXPECT_EQ(request_headers.get_("x-foo"), "stage1"); } +TEST_F(TransformationFilterTest, SameStageExtractAndUse) { + Http::TestRequestHeaderMapImpl request_headers{ + {"content-type", "test"}, {":method", "GET"}, {":path", "/abc/123"}}; + listener_config_.set_stage(1); + const std::string match_string = R"EOF( + transformations: + - stage: 1 + request_match: + match: + prefix: / + request_transformation: + transformation_template: + advanced_templates: true + passthrough: {} + extractors: + ext1: + header: ":path" + regex: "^/(.*)/(.*)" + subgroup: 1 + ext2: + header: ":path" + regex: "^/(.*)/(.*)" + subgroup: 2 + headers: + ":path": {text: "/{{extraction(\"ext1\")}}/somethingreallyreallylongsowecanevictmemoryorsomething"} + "x-foo": {text: "{{extraction(\"ext2\")}}"} + )EOF"; + TestUtility::loadFromYaml(match_string, route_config_); + + initFilter(); + auto res = filter_->decodeHeaders(request_headers, true); + EXPECT_EQ(Http::FilterHeadersStatus::Continue, res); + EXPECT_EQ(request_headers.get_(":path"), "/abc/somethingreallyreallylongsowecanevictmemoryorsomething"); + // enforces that we dont care that hte source has changed + EXPECT_EQ(request_headers.get_("x-foo"), "123"); +} + TEST_F(TransformationFilterTest, RequestMatchInOrder) { Http::TestRequestHeaderMapImpl request_headers{ {"content-type", "test"}, {":method", "GET"}, {":path", "/foo"}}; @@ -995,4 +1033,4 @@ TEST_F(TransformationFilterTest, MatcherOnRouteConfigTypedStruct) { } // namespace Transformation } // namespace HttpFilters } // namespace Extensions -} // namespace Envoy +} // namespace Envoy \ No newline at end of file