blob: a5549774863db7e8c8475b09b8ff1fa935686696 [file] [log] [blame]
William Lallemand5bb21b12020-06-18 18:56:44 +02001varnishtest "haproxy ACL, CLI and mCLI spaces"
William Lallemand398c5f32020-06-18 18:52:18 +02002feature ignore_unknown_macro
3
William Lallemand398c5f32020-06-18 18:52:18 +02004server s1 {
5 rxreq
6 expect req.method == "GET"
7 txresp
8} -repeat 2 -start
9
William Lallemand5bb21b12020-06-18 18:56:44 +020010haproxy h1 -W -S -conf {
William Lallemand398c5f32020-06-18 18:52:18 +020011 defaults
12 mode http
William Lallemand398c5f32020-06-18 18:52:18 +020013 log global
14 option httplog
Willy Tarreauf6739232021-11-18 17:46:22 +010015 timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
16 timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
17 timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
William Lallemand398c5f32020-06-18 18:52:18 +020018
19 frontend fe1
20 bind "fd@${fe1}"
21
22 http-request deny if { req.hdr(user-agent) -i -m str -f ${testdir}/agents.acl }
23
24 default_backend be1
25
26 backend be1
27 server s1 ${s1_addr}:${s1_port}
28
29} -start
30
31client c1 -connect ${h1_fe1_sock} {
32 txreq -hdr "User-Agent: Mon User Agent"
33 rxresp
34 expect resp.status == 200
35} -run
36
37haproxy h1 -cli {
38 send "add acl ${testdir}/agents.acl Mon\\ User\\ Agent\\;"
39 expect ~ .*
40
41 send "show acl ${testdir}/agents.acl"
42 expect ~ ".*Mon User Agent.*"
43}
44
45client c1 -connect ${h1_fe1_sock} {
46 txreq -hdr "User-Agent: Mon User Agent;"
47 rxresp
48 expect resp.status == 403
49} -run
William Lallemand5bb21b12020-06-18 18:56:44 +020050
51
52haproxy h1 -cli {
53 send "del acl ${testdir}/agents.acl Mon\\ User\\ Agent\\;"
54 expect ~ .*
55
56 send "show acl ${testdir}/agents.acl"
57 expect ~ .*
58}
59
60client c1 -connect ${h1_fe1_sock} {
61 txreq -hdr "User-Agent: Mon User Agent;"
62 rxresp
63 expect resp.status == 200
64} -run
65
66
67# Try it with the master CLI
68haproxy h1 -mcli {
69 send "@1 add acl ${testdir}/agents.acl Mon\\ User\\ Agent\\;;@1 show acl ${testdir}/agents.acl"
70 expect ~ ".*Mon User Agent;.*"
71}
72
73client c1 -connect ${h1_fe1_sock} {
74 txreq -hdr "User-Agent: Mon User Agent;"
75 rxresp
76 expect resp.status == 403
77} -run