Skip to content

Commit 11a0bb7

Browse files
authored
HRW: Adds some more regex tests, in prep for PCRE2 migration (#12577)
1 parent 90dd505 commit 11a0bb7

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
``
2+
> GET http://www.example.com/from_9/``
3+
> Host: www.example.com``
4+
> User-Agent: curl/``
5+
> X-Test1: Foobar``
6+
``
7+
< HTTP/1.1 200 OK
8+
< Date: ``
9+
``
10+
< X-Match: yes
11+
< X-Match-2: yes
12+
``
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
``
2+
> GET http://www.example.com/from_9/``
3+
> Host: www.example.com``
4+
> User-Agent: curl/``
5+
``
6+
< HTTP/1.1 200 OK
7+
< Date: ``
8+
``
9+
< X-Match-2: yes
10+
``

tests/gold_tests/pluginTest/header_rewrite/header_rewrite_bundle.test.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@
8282
"from": f"{url_base}_8/",
8383
"to": f"{origin_base}_8/",
8484
"plugins": [("header_rewrite", [f"{mgr.run_dir}/implicit_hook.conf"])]
85+
}, {
86+
"from": f"{url_base}_9/",
87+
"to": f"{origin_base}_9/",
88+
"plugins": [("header_rewrite", [f"{mgr.run_dir}/regex_tests.conf"])]
8589
}
8690
]
8791

@@ -168,6 +172,11 @@
168172
"timestamp": "1469733493.993",
169173
"body": ""
170174
}, def_resp),
175+
({
176+
"headers": "GET /to_9/ HTTP/1.1\r\nHost: www.example.com\r\n\r\n",
177+
"timestamp": "1469733493.993",
178+
"body": ""
179+
}, def_resp),
171180
]
172181
mgr.add_server_responses(origin_rules)
173182

@@ -265,6 +274,21 @@
265274
"curl": f'{curl_proxy} "http://{url_base}_8/" -H "X-Client-Foo: fOoBar"',
266275
"gold": "gold/implicit_hook_prefix.gold",
267276
},
277+
{
278+
"desc": "Regex test - no additional headers (expect X-Match-2 only)",
279+
"curl": f'{curl_proxy} "http://{url_base}_9/"',
280+
"gold": "gold/regex_match2_only.gold",
281+
},
282+
{
283+
"desc": "Regex test - X-Test1: Foobar (expect X-Match and X-Match-2)",
284+
"curl": f'{curl_proxy} "http://{url_base}_9/" -H "X-Test1: Foobar"',
285+
"gold": "gold/regex_both_match.gold",
286+
},
287+
{
288+
"desc": "Regex test - X-Test1: none (expect X-Match-2 only)",
289+
"curl": f'{curl_proxy} "http://{url_base}_9/" -H "X-Test1: none"',
290+
"gold": "gold/regex_match2_only.gold",
291+
},
268292
]
269293

270294
mgr.execute_tests(test_runs)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
cond %{SEND_RESPONSE_HDR_HOOK} [AND]
19+
cond %{CLIENT-HEADER:X-Test1} /^[Ff]o+[bB]ar/
20+
set-header X-Match "yes"
21+
22+
cond %{SEND_RESPONSE_HDR_HOOK} [AND]
23+
cond %{CLIENT-HEADER:X-We-Set} /^fie[0-9]+fum$/ [NOCASE]
24+
set-header X-Match-2 "yes"
25+
26+
cond %{REMAP_PSEUDO_HOOK} [AND]
27+
cond %{CLIENT-URL:PATH} /^from/
28+
set-header X-We-Set "FIe123fuM"

0 commit comments

Comments
 (0)