This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 11a0bb7cf8 HRW: Adds some more regex tests, in prep for PCRE2
migration (#12577)
11a0bb7cf8 is described below
commit 11a0bb7cf8337d96e5b742bf40be69b5bd06e00a
Author: Leif Hedstrom <[email protected]>
AuthorDate: Thu Oct 16 15:23:52 2025 -0600
HRW: Adds some more regex tests, in prep for PCRE2 migration (#12577)
---
.../header_rewrite/gold/regex_both_match.gold | 12 ++++++++++
.../header_rewrite/gold/regex_match2_only.gold | 10 ++++++++
.../header_rewrite/header_rewrite_bundle.test.py | 24 +++++++++++++++++++
.../header_rewrite/rules/regex_tests.conf | 28 ++++++++++++++++++++++
4 files changed, 74 insertions(+)
diff --git
a/tests/gold_tests/pluginTest/header_rewrite/gold/regex_both_match.gold
b/tests/gold_tests/pluginTest/header_rewrite/gold/regex_both_match.gold
new file mode 100644
index 0000000000..ef3b257006
--- /dev/null
+++ b/tests/gold_tests/pluginTest/header_rewrite/gold/regex_both_match.gold
@@ -0,0 +1,12 @@
+``
+> GET http://www.example.com/from_9/``
+> Host: www.example.com``
+> User-Agent: curl/``
+> X-Test1: Foobar``
+``
+< HTTP/1.1 200 OK
+< Date: ``
+``
+< X-Match: yes
+< X-Match-2: yes
+``
diff --git
a/tests/gold_tests/pluginTest/header_rewrite/gold/regex_match2_only.gold
b/tests/gold_tests/pluginTest/header_rewrite/gold/regex_match2_only.gold
new file mode 100644
index 0000000000..06217cd6cb
--- /dev/null
+++ b/tests/gold_tests/pluginTest/header_rewrite/gold/regex_match2_only.gold
@@ -0,0 +1,10 @@
+``
+> GET http://www.example.com/from_9/``
+> Host: www.example.com``
+> User-Agent: curl/``
+``
+< HTTP/1.1 200 OK
+< Date: ``
+``
+< X-Match-2: yes
+``
diff --git
a/tests/gold_tests/pluginTest/header_rewrite/header_rewrite_bundle.test.py
b/tests/gold_tests/pluginTest/header_rewrite/header_rewrite_bundle.test.py
index 4e7d0fbd49..71e87518f3 100644
--- a/tests/gold_tests/pluginTest/header_rewrite/header_rewrite_bundle.test.py
+++ b/tests/gold_tests/pluginTest/header_rewrite/header_rewrite_bundle.test.py
@@ -82,6 +82,10 @@ remap_rules = [
"from": f"{url_base}_8/",
"to": f"{origin_base}_8/",
"plugins": [("header_rewrite", [f"{mgr.run_dir}/implicit_hook.conf"])]
+ }, {
+ "from": f"{url_base}_9/",
+ "to": f"{origin_base}_9/",
+ "plugins": [("header_rewrite", [f"{mgr.run_dir}/regex_tests.conf"])]
}
]
@@ -168,6 +172,11 @@ origin_rules = [
"timestamp": "1469733493.993",
"body": ""
}, def_resp),
+ ({
+ "headers": "GET /to_9/ HTTP/1.1\r\nHost: www.example.com\r\n\r\n",
+ "timestamp": "1469733493.993",
+ "body": ""
+ }, def_resp),
]
mgr.add_server_responses(origin_rules)
@@ -265,6 +274,21 @@ test_runs = [
"curl": f'{curl_proxy} "http://{url_base}_8/" -H "X-Client-Foo:
fOoBar"',
"gold": "gold/implicit_hook_prefix.gold",
},
+ {
+ "desc": "Regex test - no additional headers (expect X-Match-2 only)",
+ "curl": f'{curl_proxy} "http://{url_base}_9/"',
+ "gold": "gold/regex_match2_only.gold",
+ },
+ {
+ "desc": "Regex test - X-Test1: Foobar (expect X-Match and X-Match-2)",
+ "curl": f'{curl_proxy} "http://{url_base}_9/" -H "X-Test1: Foobar"',
+ "gold": "gold/regex_both_match.gold",
+ },
+ {
+ "desc": "Regex test - X-Test1: none (expect X-Match-2 only)",
+ "curl": f'{curl_proxy} "http://{url_base}_9/" -H "X-Test1: none"',
+ "gold": "gold/regex_match2_only.gold",
+ },
]
mgr.execute_tests(test_runs)
diff --git a/tests/gold_tests/pluginTest/header_rewrite/rules/regex_tests.conf
b/tests/gold_tests/pluginTest/header_rewrite/rules/regex_tests.conf
new file mode 100644
index 0000000000..2869b36530
--- /dev/null
+++ b/tests/gold_tests/pluginTest/header_rewrite/rules/regex_tests.conf
@@ -0,0 +1,28 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+cond %{SEND_RESPONSE_HDR_HOOK} [AND]
+cond %{CLIENT-HEADER:X-Test1} /^[Ff]o+[bB]ar/
+ set-header X-Match "yes"
+
+cond %{SEND_RESPONSE_HDR_HOOK} [AND]
+cond %{CLIENT-HEADER:X-We-Set} /^fie[0-9]+fum$/ [NOCASE]
+ set-header X-Match-2 "yes"
+
+cond %{REMAP_PSEUDO_HOOK} [AND]
+cond %{CLIENT-URL:PATH} /^from/
+ set-header X-We-Set "FIe123fuM"