2021-04-15 19:45:58 +00:00
|
|
|
varnishtest "normalize-uri tests"
|
|
|
|
#REQUIRE_VERSION=2.4
|
|
|
|
|
|
|
|
# This reg-test tests the http-request normalize-uri action.
|
|
|
|
|
|
|
|
feature ignore_unknown_macro
|
|
|
|
|
|
|
|
server s1 {
|
|
|
|
rxreq
|
|
|
|
txresp
|
2021-04-15 19:45:59 +00:00
|
|
|
} -repeat 21 -start
|
2021-04-15 19:45:58 +00:00
|
|
|
|
|
|
|
haproxy h1 -conf {
|
|
|
|
defaults
|
|
|
|
mode http
|
|
|
|
timeout connect 1s
|
|
|
|
timeout client 1s
|
|
|
|
timeout server 1s
|
|
|
|
|
|
|
|
frontend fe_merge_slashes
|
|
|
|
bind "fd@${fe_merge_slashes}"
|
|
|
|
|
|
|
|
http-request set-var(txn.before) url
|
|
|
|
http-request normalize-uri merge-slashes
|
|
|
|
http-request set-var(txn.after) url
|
|
|
|
|
|
|
|
http-response add-header before %[var(txn.before)]
|
|
|
|
http-response add-header after %[var(txn.after)]
|
|
|
|
|
|
|
|
default_backend be
|
|
|
|
|
2021-04-15 19:45:59 +00:00
|
|
|
frontend fe_dotdot
|
|
|
|
bind "fd@${fe_dotdot}"
|
|
|
|
|
|
|
|
http-request set-var(txn.before) url
|
|
|
|
http-request normalize-uri dotdot
|
|
|
|
http-request set-var(txn.after) url
|
|
|
|
|
2021-04-15 19:46:00 +00:00
|
|
|
http-request set-uri %[var(txn.before)]
|
|
|
|
http-request normalize-uri dotdot full
|
|
|
|
http-request set-var(txn.after_full) url
|
|
|
|
|
2021-04-15 19:45:59 +00:00
|
|
|
http-response add-header before %[var(txn.before)]
|
|
|
|
http-response add-header after %[var(txn.after)]
|
2021-04-15 19:46:00 +00:00
|
|
|
http-response add-header after-full %[var(txn.after_full)]
|
2021-04-15 19:45:59 +00:00
|
|
|
|
|
|
|
default_backend be
|
|
|
|
|
2021-04-15 19:45:58 +00:00
|
|
|
backend be
|
|
|
|
server s1 ${s1_addr}:${s1_port}
|
|
|
|
|
|
|
|
} -start
|
|
|
|
|
|
|
|
client c1 -connect ${h1_fe_merge_slashes_sock} {
|
|
|
|
txreq -url "/foo/bar"
|
|
|
|
rxresp
|
|
|
|
expect resp.http.before == "/foo/bar"
|
|
|
|
expect resp.http.after == "/foo/bar"
|
|
|
|
|
|
|
|
txreq -url "/foo//bar"
|
|
|
|
rxresp
|
|
|
|
expect resp.http.before == "/foo//bar"
|
|
|
|
expect resp.http.after == "/foo/bar"
|
|
|
|
|
|
|
|
txreq -url "/foo///bar"
|
|
|
|
rxresp
|
|
|
|
expect resp.http.before == "/foo///bar"
|
|
|
|
expect resp.http.after == "/foo/bar"
|
|
|
|
|
|
|
|
txreq -url "///foo///bar"
|
|
|
|
rxresp
|
|
|
|
expect resp.http.before == "///foo///bar"
|
|
|
|
expect resp.http.after == "/foo/bar"
|
|
|
|
|
|
|
|
txreq -url "///foo/bar"
|
|
|
|
rxresp
|
|
|
|
expect resp.http.before == "///foo/bar"
|
|
|
|
expect resp.http.after == "/foo/bar"
|
|
|
|
|
|
|
|
txreq -url "///foo///bar///"
|
|
|
|
rxresp
|
|
|
|
expect resp.http.before == "///foo///bar///"
|
|
|
|
expect resp.http.after == "/foo/bar/"
|
|
|
|
|
|
|
|
txreq -url "///"
|
|
|
|
rxresp
|
|
|
|
expect resp.http.before == "///"
|
|
|
|
expect resp.http.after == "/"
|
|
|
|
|
|
|
|
txreq -url "/foo?bar=///"
|
|
|
|
rxresp
|
|
|
|
expect resp.http.before == "/foo?bar=///"
|
|
|
|
expect resp.http.after == "/foo?bar=///"
|
|
|
|
|
|
|
|
txreq -url "//foo?bar=///"
|
|
|
|
rxresp
|
|
|
|
expect resp.http.before == "//foo?bar=///"
|
|
|
|
expect resp.http.after == "/foo?bar=///"
|
|
|
|
|
|
|
|
txreq -req OPTIONS -url "*"
|
|
|
|
rxresp
|
|
|
|
expect resp.http.before == "*"
|
|
|
|
expect resp.http.after == "*"
|
|
|
|
} -run
|
2021-04-15 19:45:59 +00:00
|
|
|
|
|
|
|
client c2 -connect ${h1_fe_dotdot_sock} {
|
|
|
|
txreq -url "/foo/bar"
|
|
|
|
rxresp
|
|
|
|
expect resp.http.before == "/foo/bar"
|
|
|
|
expect resp.http.after == "/foo/bar"
|
2021-04-15 19:46:00 +00:00
|
|
|
expect resp.http.after-full == "/foo/bar"
|
2021-04-15 19:45:59 +00:00
|
|
|
|
|
|
|
txreq -url "/foo/.."
|
|
|
|
rxresp
|
|
|
|
expect resp.http.before == "/foo/.."
|
|
|
|
expect resp.http.after == "/"
|
2021-04-15 19:46:00 +00:00
|
|
|
expect resp.http.after-full == "/"
|
2021-04-15 19:45:59 +00:00
|
|
|
|
|
|
|
txreq -url "/foo/../"
|
|
|
|
rxresp
|
|
|
|
expect resp.http.before == "/foo/../"
|
|
|
|
expect resp.http.after == "/"
|
2021-04-15 19:46:00 +00:00
|
|
|
expect resp.http.after-full == "/"
|
2021-04-15 19:45:59 +00:00
|
|
|
|
|
|
|
txreq -url "/foo/bar/../"
|
|
|
|
rxresp
|
|
|
|
expect resp.http.before == "/foo/bar/../"
|
|
|
|
expect resp.http.after == "/foo/"
|
2021-04-15 19:46:00 +00:00
|
|
|
expect resp.http.after-full == "/foo/"
|
2021-04-15 19:45:59 +00:00
|
|
|
|
|
|
|
txreq -url "/foo/../bar"
|
|
|
|
rxresp
|
|
|
|
expect resp.http.before == "/foo/../bar"
|
|
|
|
expect resp.http.after == "/bar"
|
2021-04-15 19:46:00 +00:00
|
|
|
expect resp.http.after-full == "/bar"
|
2021-04-15 19:45:59 +00:00
|
|
|
|
|
|
|
txreq -url "/foo/../bar/"
|
|
|
|
rxresp
|
|
|
|
expect resp.http.before == "/foo/../bar/"
|
|
|
|
expect resp.http.after == "/bar/"
|
2021-04-15 19:46:00 +00:00
|
|
|
expect resp.http.after-full == "/bar/"
|
2021-04-15 19:45:59 +00:00
|
|
|
|
|
|
|
txreq -url "/foo/../../bar/"
|
|
|
|
rxresp
|
|
|
|
expect resp.http.before == "/foo/../../bar/"
|
|
|
|
expect resp.http.after == "/../bar/"
|
2021-04-15 19:46:00 +00:00
|
|
|
expect resp.http.after-full == "/bar/"
|
2021-04-15 19:45:59 +00:00
|
|
|
|
|
|
|
txreq -url "/foo//../../bar/"
|
|
|
|
rxresp
|
|
|
|
expect resp.http.before == "/foo//../../bar/"
|
|
|
|
expect resp.http.after == "/bar/"
|
2021-04-15 19:46:00 +00:00
|
|
|
expect resp.http.after-full == "/bar/"
|
2021-04-15 19:45:59 +00:00
|
|
|
|
|
|
|
txreq -url "/foo/?bar=/foo/../"
|
|
|
|
rxresp
|
|
|
|
expect resp.http.before == "/foo/?bar=/foo/../"
|
|
|
|
expect resp.http.after == "/foo/?bar=/foo/../"
|
2021-04-15 19:46:00 +00:00
|
|
|
expect resp.http.after-full == "/foo/?bar=/foo/../"
|
2021-04-15 19:45:59 +00:00
|
|
|
|
|
|
|
txreq -url "/foo/../?bar=/foo/../"
|
|
|
|
rxresp
|
|
|
|
expect resp.http.before == "/foo/../?bar=/foo/../"
|
|
|
|
expect resp.http.after == "/?bar=/foo/../"
|
2021-04-15 19:46:00 +00:00
|
|
|
expect resp.http.after-full == "/?bar=/foo/../"
|
2021-04-15 19:45:59 +00:00
|
|
|
|
|
|
|
txreq -req OPTIONS -url "*"
|
|
|
|
rxresp
|
|
|
|
expect resp.http.before == "*"
|
|
|
|
expect resp.http.after == "*"
|
2021-04-15 19:46:00 +00:00
|
|
|
expect resp.http.after-full == "*"
|
2021-04-15 19:45:59 +00:00
|
|
|
} -run
|