blob: a72776c079e3e0766209915f5847225ec8439c75 [file] [log] [blame]
Christopher Faulete41b4972021-10-13 18:06:55 +02001varnishtest "Test declaration of HTTP rules in default sections"
2
3#REQUIRE_VERSION=2.5
4
5feature ignore_unknown_macro
6
7server s1 {
8 rxreq
9 expect req.http.x-frontend == "fe"
10 expect req.http.x-backend == "be"
11 expect req.http.x-test1-frt == "def_front"
12 expect req.http.x-test1-bck == "def_back"
13 txresp
14} -start
15
16server s2 {
17 rxreq
18 txresp
19} -start
20
21haproxy h1 -conf {
22 defaults common
23 mode http
24 timeout connect 1s
25 timeout client 1s
26 timeout server 1s
27
28 defaults def_front from common
29 http-request set-header x-frontend "%[fe_name]"
30 http-request set-var(txn.test1) "str(def_front)"
31 http-response set-header x-frontend "%[fe_name]"
32 http-response set-var(txn.test2) "str(def_front)"
33 http-after-response set-var(txn.test3) "str(def_front)"
34
35 defaults def_back from common
36 http-request set-header x-backend "%[be_name]"
37 http-request set-var(txn.test1) "str(def_back)"
38 http-response set-header x-backend "%[be_name]"
39 http-response set-var(txn.test2) "str(def_back)"
40 http-after-response set-var(txn.test3) "str(def_back)"
41
42 frontend fe from def_front
43 bind "fd@${feh1}"
44
45 http-request set-header x-test1-frt "%[var(txn.test1)]"
46 http-response set-header x-test2-frt "%[var(txn.test2)]"
47 http-after-response set-header x-test3-frt "%[var(txn.test3)]"
48
49 default_backend be
50
51 backend be from def_back
52 http-request set-header x-test1-bck "%[var(txn.test1)]"
53 http-response set-header x-test2-bck "%[var(txn.test2)]"
54 http-after-response set-header x-test3-bck "%[var(txn.test3)]"
55
56 server s1 ${s1_addr}:${s1_port}
57
58} -start
59
60
61haproxy h2 -conf {
62 defaults common
63 mode http
64 timeout connect 1s
65 timeout client 1s
66 timeout server 1s
67
68 defaults def_front from common
69 http-request allow
70 http-response allow
71 http-after-response allow
72
73 defaults def_back from common
74 http-request allow
75 http-response allow
76 http-after-response allow
77
78 frontend fe from def_front
79 bind "fd@${feh2}"
80
81 http-request deny status 403
82 http-response deny status 502
83 http-after-response set-status 502
84
85 default_backend be
86
87 backend be from def_back
88 http-request deny status 403
89 http-response deny status 502
90 http-after-response set-status 502
91
92 server s2 ${s2_addr}:${s2_port}
93
94} -start
95
96client c1 -connect ${h1_feh1_sock} {
97 txreq -req GET -url /
98 rxresp
99 expect resp.status == 200
100 expect resp.http.x-frontend == "fe"
101 expect resp.http.x-backend == "be"
102 expect resp.http.x-test2-bck == "def_back"
103 expect resp.http.x-test2-frt == "def_front"
104 expect resp.http.x-test3-bck == "def_back"
105 expect resp.http.x-test3-frt == "def_front"
106} -run
107
108client c2 -connect ${h2_feh2_sock} {
109 txreq -req GET -url /
110 rxresp
111 expect resp.status == 200
112} -run