blob: 55919ea40aa5d2f71603c208bc7408e07aced3e2 [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
15 ${no-htx} option http-use-htx
16 log global
17 option httplog
Willy Tarreaudb522b52020-09-02 07:26:08 +020018 timeout connect 1s
19 timeout client 1s
20 timeout server 1s
William Lallemand398c5f32020-06-18 18:52:18 +020021
22 frontend fe1
23 bind "fd@${fe1}"
24
25 http-request deny if { req.hdr(user-agent) -i -m str -f ${testdir}/agents.acl }
26
27 default_backend be1
28
29 backend be1
30 server s1 ${s1_addr}:${s1_port}
31
32} -start
33
34client c1 -connect ${h1_fe1_sock} {
35 txreq -hdr "User-Agent: Mon User Agent"
36 rxresp
37 expect resp.status == 200
38} -run
39
40haproxy h1 -cli {
41 send "add acl ${testdir}/agents.acl Mon\\ User\\ Agent\\;"
42 expect ~ .*
43
44 send "show acl ${testdir}/agents.acl"
45 expect ~ ".*Mon User Agent.*"
46}
47
48client c1 -connect ${h1_fe1_sock} {
49 txreq -hdr "User-Agent: Mon User Agent;"
50 rxresp
51 expect resp.status == 403
52} -run
William Lallemand5bb21b12020-06-18 18:56:44 +020053
54
55haproxy h1 -cli {
56 send "del acl ${testdir}/agents.acl Mon\\ User\\ Agent\\;"
57 expect ~ .*
58
59 send "show acl ${testdir}/agents.acl"
60 expect ~ .*
61}
62
63client c1 -connect ${h1_fe1_sock} {
64 txreq -hdr "User-Agent: Mon User Agent;"
65 rxresp
66 expect resp.status == 200
67} -run
68
69
70# Try it with the master CLI
71haproxy h1 -mcli {
72 send "@1 add acl ${testdir}/agents.acl Mon\\ User\\ Agent\\;;@1 show acl ${testdir}/agents.acl"
73 expect ~ ".*Mon User Agent;.*"
74}
75
76client c1 -connect ${h1_fe1_sock} {
77 txreq -hdr "User-Agent: Mon User Agent;"
78 rxresp
79 expect resp.status == 403
80} -run