summaryrefslogtreecommitdiffstats
path: root/reg-tests/http-rules
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-03 05:11:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-03 05:11:10 +0000
commitcff6d757e3ba609c08ef2aaa00f07e53551e5bf6 (patch)
tree08c4fc3255483ad397d712edb4214ded49149fd9 /reg-tests/http-rules
parentAdding upstream version 2.9.7. (diff)
downloadhaproxy-cff6d757e3ba609c08ef2aaa00f07e53551e5bf6.tar.xz
haproxy-cff6d757e3ba609c08ef2aaa00f07e53551e5bf6.zip
Adding upstream version 3.0.0.upstream/3.0.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'reg-tests/http-rules')
-rw-r--r--reg-tests/http-rules/acl_cli_spaces.vtc2
-rw-r--r--reg-tests/http-rules/http-err-fail.vtc84
-rw-r--r--reg-tests/http-rules/map_ordering.map2
-rw-r--r--reg-tests/http-rules/map_ordering.vtc18
4 files changed, 102 insertions, 4 deletions
diff --git a/reg-tests/http-rules/acl_cli_spaces.vtc b/reg-tests/http-rules/acl_cli_spaces.vtc
index a554977..334133d 100644
--- a/reg-tests/http-rules/acl_cli_spaces.vtc
+++ b/reg-tests/http-rules/acl_cli_spaces.vtc
@@ -10,8 +10,6 @@ server s1 {
haproxy h1 -W -S -conf {
defaults
mode http
- log global
- option httplog
timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
diff --git a/reg-tests/http-rules/http-err-fail.vtc b/reg-tests/http-rules/http-err-fail.vtc
new file mode 100644
index 0000000..6d8f9ea
--- /dev/null
+++ b/reg-tests/http-rules/http-err-fail.vtc
@@ -0,0 +1,84 @@
+varnishtest "test for http-err-codes/http-fail-codes redefinitions"
+
+feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(3.0-dev1)'"
+feature ignore_unknown_macro
+
+server s2 {
+ rxreq
+ txresp -status 220
+} -start
+
+server s3 {
+ rxreq
+ txresp -status 300
+} -start
+
+server s4 {
+ rxreq
+ txresp -status 400
+} -start
+
+server s5 {
+ rxreq
+ txresp -status 555
+} -start
+
+
+haproxy h1 -conf {
+ global
+ http-err-codes 220 +300-499 -300-399 # only 220, 400-499 remain
+ http-fail-codes -550-580 +555,599,556-566
+
+ defaults
+ mode http
+ timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
+ timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
+ timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
+ option socket-stats
+
+ frontend fe
+ bind "fd@${fe}"
+ http-request track-sc0 path
+ http-after-response add-header x-table err=%[sc0_http_err_cnt],fail=%[sc0_http_fail_cnt]
+ stick-table type string size 100 store http_err_cnt,http_fail_cnt
+ default_backend be
+
+ backend be
+ use-server s2 if { path -m beg /2 }
+ use-server s3 if { path -m beg /3 }
+ use-server s4 if { path -m beg /4 }
+ use-server s5 if { path -m beg /5 }
+
+ server s2 ${s2_addr}:${s2_port}
+ server s3 ${s3_addr}:${s3_port}
+ server s4 ${s4_addr}:${s4_port}
+ server s5 ${s5_addr}:${s5_port}
+} -start
+
+client c2 -connect ${h1_fe_sock} {
+ txreq -url "/2"
+ rxresp
+ expect resp.status == 220
+ expect resp.http.x-table ~ "err=1,fail=0"
+} -run
+
+client c3 -connect ${h1_fe_sock} {
+ txreq -url "/3"
+ rxresp
+ expect resp.status == 300
+ expect resp.http.x-table ~ "err=0,fail=0"
+} -run
+
+client c4 -connect ${h1_fe_sock} {
+ txreq -url "/4"
+ rxresp
+ expect resp.status == 400
+ expect resp.http.x-table ~ "err=1,fail=0"
+} -run
+
+client c5 -connect ${h1_fe_sock} {
+ txreq -url "/5"
+ rxresp
+ expect resp.status == 555
+ expect resp.http.x-table ~ "err=0,fail=1"
+} -run
diff --git a/reg-tests/http-rules/map_ordering.map b/reg-tests/http-rules/map_ordering.map
index dcd9529..dc9ac71 100644
--- a/reg-tests/http-rules/map_ordering.map
+++ b/reg-tests/http-rules/map_ordering.map
@@ -2,3 +2,5 @@
first.domain.tld first
domain.tld domain
second.domain.tld second
+# This entry is used to test duplicate behavior (ie: tree-based match)
+first.domain.tld first_dup
diff --git a/reg-tests/http-rules/map_ordering.vtc b/reg-tests/http-rules/map_ordering.vtc
index 40da465..923d19f 100644
--- a/reg-tests/http-rules/map_ordering.vtc
+++ b/reg-tests/http-rules/map_ordering.vtc
@@ -1,4 +1,4 @@
-varnishtest "Test list-based matching types ordering"
+varnishtest "Ensure mapfile ordering is preserved when loading the file"
feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.5-dev0)'"
feature ignore_unknown_macro
@@ -14,9 +14,13 @@ haproxy h1 -conf {
# check list ordering using map_dom (list-based match)
http-request return hdr dom %[req.hdr(Host),lower,map_dom(${testdir}/map_ordering.map)] if { url_beg /dom }
+
+ # check tree ordering using map_str (tree-based match) and duplicated keys
+ http-request return hdr str %[req.hdr(Host),lower,map_str(${testdir}/map_ordering.map)] if { url_beg /str }
+
} -start
-# Check map ordering
+# Check map ordering for list-based matching types
client c1 -connect ${h1_fe1_sock} {
# first.domain.tld is above domain.tld so it should match first
txreq -url "/dom" -hdr "Host: first.domain.tld"
@@ -30,3 +34,13 @@ client c1 -connect ${h1_fe1_sock} {
expect resp.status == 200
expect resp.http.dom == "domain"
} -run
+
+# Check map ordering for tree-based matching types (check that the matching
+# key is the first one seen in the file)
+client c2 -connect ${h1_fe1_sock} {
+ # first.domain.tld is first mapped to "first" in the mapfile
+ txreq -url "/str" -hdr "Host: first.domain.tld"
+ rxresp
+ expect resp.status == 200
+ expect resp.http.str == "first"
+} -run