Skip to content

Commit 90aada7

Browse files
yuval-ksoloio-bulldozer[bot]
authored andcommitted
test failing extractor config; add break to switch (#23)
* test failing extractor config; add break to switch
1 parent 2d3466c commit 90aada7

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

source/extensions/filters/http/transformation/inja_transformer.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,15 @@ InjaTransformer::InjaTransformer(
135135
throw EnvoyException(
136136
fmt::format("Failed to parse body template {}", e.what()));
137137
}
138+
break;
138139
}
139140
case envoy::api::v2::filter::http::TransformationTemplate::
140141
kMergeExtractorsToBody: {
141142
merged_extractors_to_body_ = true;
143+
break;
142144
}
143145
case envoy::api::v2::filter::http::TransformationTemplate::kPassthrough:
146+
break;
144147
case envoy::api::v2::filter::http::TransformationTemplate::
145148
BODY_TRANSFORMATION_NOT_SET: {
146149
break;

test/extensions/filters/http/transformation/inja_transformer_test.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,19 @@ TEST(ExtractorUtil, ExtractIdFromHeader) {
113113
EXPECT_EQ("123", res);
114114
}
115115

116+
TEST(ExtractorUtil, ExtractorFail) {
117+
Http::TestHeaderMapImpl headers{{":method", "GET"},
118+
{":authority", "www.solo.io"},
119+
{":path", "/users/123"}};
120+
envoy::api::v2::filter::http::Extraction extractor;
121+
extractor.set_header(":path");
122+
extractor.set_regex("ILLEGAL REGEX \\ \\ \\ \\ a\\ \\a\\ a\\ \\d+)");
123+
extractor.set_subgroup(1);
124+
EXPECT_THROW_WITH_MESSAGE(Extractor a(extractor), EnvoyException,
125+
"Invalid regex 'ILLEGAL REGEX \\ \\ \\ \\ a\\ "
126+
"\\a\\ a\\ \\d+)': regex_error");
127+
}
128+
116129
TEST(Transformer, transform) {
117130
Http::TestHeaderMapImpl headers{{":method", "GET"},
118131
{":authority", "www.solo.io"},

0 commit comments

Comments
 (0)