You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by wk...@apache.org on 2021/01/21 22:06:06 UTC
[trafficserver] branch master updated: Small fix to regex_remap PR
# 7347. (#7437)
This is an automated email from the ASF dual-hosted git repository.
wkaras 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 04e6b33 Small fix to regex_remap PR # 7347. (#7437)
04e6b33 is described below
commit 04e6b3348d48f3dbcfa54825cbcdc7848e5d43a6
Author: Walt Karas <wk...@verizonmedia.com>
AuthorDate: Thu Jan 21 16:05:52 2021 -0600
Small fix to regex_remap PR # 7347. (#7437)
---
plugins/regex_remap/regex_remap.cc | 2 +-
.../pluginTest/regex_remap/gold/regex_remap_redirect.gold | 2 ++
tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py | 12 +++++++-----
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/plugins/regex_remap/regex_remap.cc b/plugins/regex_remap/regex_remap.cc
index 76aaa0a..b640d33 100644
--- a/plugins/regex_remap/regex_remap.cc
+++ b/plugins/regex_remap/regex_remap.cc
@@ -929,7 +929,7 @@ TSRemapDoRemap(void *ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
const SrcUrl src_url([=]() -> SrcUrl {
SrcUrl u;
- if (ri->pristine_url) {
+ if (!ri->pristine_url) {
u.bufp = rri->requestBufp;
u.loc = rri->requestUrl;
u.bad = false;
diff --git a/tests/gold_tests/pluginTest/regex_remap/gold/regex_remap_redirect.gold b/tests/gold_tests/pluginTest/regex_remap/gold/regex_remap_redirect.gold
new file mode 100644
index 0000000..de8c55e
--- /dev/null
+++ b/tests/gold_tests/pluginTest/regex_remap/gold/regex_remap_redirect.gold
@@ -0,0 +1,2 @@
+HTTP/1.1 301 Redirect
+Location: http://localhost:SERVER_PORT/alpha/bravo/?action=newsfed;param0001=00003E;param0002=00004E;param0003=00005E
diff --git a/tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py b/tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py
index b85e57f..30355dd 100644
--- a/tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py
+++ b/tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py
@@ -56,14 +56,13 @@ curl_and_args = 'curl -s -D - -v --proxy localhost:{} '.format(ts.Variables.port
ts.Disk.File(regex_remap_conf_path, typename="ats:config").AddLines([
"# regex_remap configuration\n"
"^/alpha/bravo/[?]((?!action=(newsfeed|calendar|contacts|notepad)).)*$ http://example.one @status=301\n"
- "^/charlie http://example.one @status=301\n"
])
ts.Disk.remap_config.AddLine(
"map http://example.one/ http://localhost:{}/ @plugin=regex_remap.so @pparam=regex_remap.conf\n".format(server.Variables.Port)
)
ts.Disk.remap_config.AddLine(
- "map http://example.two/charlie http://localhost:{}/delta ".format(server.Variables.Port) +
+ "map http://example.two/ http://localhost:{}/ ".format(server.Variables.Port) +
"@plugin=regex_remap.so @pparam=regex_remap.conf @pparam=pristine\n"
)
@@ -83,15 +82,18 @@ tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.stdout = "gold/regex_remap_smoke.gold"
tr.StillRunningAfter = ts
+# 1 Test - Match and redirect
tr = Test.AddTestRun("pristine test")
tr.Processes.Default.Command = (
- curl_and_args + '--header "uuid: {}" http://example.two/charlie'.format(creq["headers"]["fields"][1][1])
+ curl_and_args +
+ "'http://example.two/alpha/bravo/?action=newsfed;param0001=00003E;param0002=00004E;param0003=00005E'" +
+ f" | grep -e '^HTTP/' -e '^Location' | sed 's/{server.Variables.Port}/SERVER_PORT/'"
)
tr.Processes.Default.ReturnCode = 0
-tr.Processes.Default.Streams.stdout = "gold/regex_remap_smoke.gold"
+tr.Processes.Default.Streams.stdout = "gold/regex_remap_redirect.gold"
tr.StillRunningAfter = ts
-# Crash test.
+# 2 Test - Crash test.
tr = Test.AddTestRun("crash test")
creq = replay_txns[1]['client-request']
tr.Processes.Default.Command = curl_and_args + \