]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REGTEST: add tests for acl() sample fetch
authorPatrick Hemmer <patrick.hemmer@gmail.com>
Tue, 1 Aug 2023 14:31:01 +0000 (10:31 -0400)
committerWilly Tarreau <w@1wt.eu>
Mon, 6 May 2024 16:41:57 +0000 (18:41 +0200)
This adds reg tests for the recently added acl() sample fetch

reg-tests/sample_fetches/acl.vtc [new file with mode: 0644]

diff --git a/reg-tests/sample_fetches/acl.vtc b/reg-tests/sample_fetches/acl.vtc
new file mode 100644 (file)
index 0000000..8f4f8fb
--- /dev/null
@@ -0,0 +1,32 @@
+varnishtest "Test acl() sample fetch"
+feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.9-dev2)'"
+
+feature ignore_unknown_macro
+
+haproxy h1 -conf {
+    defaults
+        mode http
+        timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
+        timeout client  "${HAPROXY_TEST_TIMEOUT-5s}"
+        timeout server  "${HAPROXY_TEST_TIMEOUT-5s}"
+
+    frontend fe1
+        bind "fd@${fe1}"
+
+        acl ACL1 always_true
+        acl ACL2 acl(ACL1)
+        acl ACL3 acl(!ACL2)
+        acl ACL4 acl(ACL2,!ACL3)
+
+        http-request return status 200 hdr x-acl "ACL1=%[acl(ACL1)] ACL2=%[acl(ACL2)] ACL3=%[acl(ACL3)] ACL4=%[acl(ACL4)]"
+} -start
+
+client c1 -connect ${h1_fe1_sock} {
+    txreq -req GET -url /
+    rxresp
+    expect resp.status == 200
+    expect resp.http.x-acl ~ "ACL1=1"
+    expect resp.http.x-acl ~ "ACL2=1"
+    expect resp.http.x-acl ~ "ACL3=0"
+    expect resp.http.x-acl ~ "ACL4=1"
+} -run