blob: 4db79a5faa269ef6523e6f9d9afa1719f7be2e49 [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 Lallemand5bb21b12020-06-18 18:56:44 +02004#REQUIRE_VERSION=2.0
William Lallemand398c5f32020-06-18 18:52:18 +02005
6server s1 {
7 rxreq
8 expect req.method == "GET"
9 txresp
10} -repeat 2 -start
11
William Lallemand5bb21b12020-06-18 18:56:44 +020012haproxy h1 -W -S -conf {
William Lallemand398c5f32020-06-18 18:52:18 +020013 defaults
14 mode http
William Lallemand398c5f32020-06-18 18:52:18 +020015 log global
16 option httplog
Willy Tarreaudb522b52020-09-02 07:26:08 +020017 timeout connect 1s
18 timeout client 1s
19 timeout server 1s
William Lallemand398c5f32020-06-18 18:52:18 +020020
21 frontend fe1
22 bind "fd@${fe1}"
23
24 http-request deny if { req.hdr(user-agent) -i -m str -f ${testdir}/agents.acl }
25
26 default_backend be1
27
28 backend be1
29 server s1 ${s1_addr}:${s1_port}
30
31} -start
32
33client c1 -connect ${h1_fe1_sock} {
34 txreq -hdr "User-Agent: Mon User Agent"
35 rxresp
36 expect resp.status == 200
37} -run
38
39haproxy h1 -cli {
40 send "add acl ${testdir}/agents.acl Mon\\ User\\ Agent\\;"
41 expect ~ .*
42
43 send "show acl ${testdir}/agents.acl"
44 expect ~ ".*Mon User Agent.*"
45}
46
47client c1 -connect ${h1_fe1_sock} {
48 txreq -hdr "User-Agent: Mon User Agent;"
49 rxresp
50 expect resp.status == 403
51} -run
William Lallemand5bb21b12020-06-18 18:56:44 +020052
53
54haproxy h1 -cli {
55 send "del acl ${testdir}/agents.acl Mon\\ User\\ Agent\\;"
56 expect ~ .*
57
58 send "show acl ${testdir}/agents.acl"
59 expect ~ .*
60}
61
62client c1 -connect ${h1_fe1_sock} {
63 txreq -hdr "User-Agent: Mon User Agent;"
64 rxresp
65 expect resp.status == 200
66} -run
67
68
69# Try it with the master CLI
70haproxy h1 -mcli {
71 send "@1 add acl ${testdir}/agents.acl Mon\\ User\\ Agent\\;;@1 show acl ${testdir}/agents.acl"
72 expect ~ ".*Mon User Agent;.*"
73}
74
75client c1 -connect ${h1_fe1_sock} {
76 txreq -hdr "User-Agent: Mon User Agent;"
77 rxresp
78 expect resp.status == 403
79} -run