blob: 7d9f18c3dc175f447979bb7fdbae74e7202a849d [file] [log] [blame]
Christopher Faulet4e22d212020-01-20 13:49:48 +01001varnishtest "Test the errorfiles directive"
2#REQUIRE_VERSION=2.2
3
4# This config tests the errorfiles directive.
5
6feature ignore_unknown_macro
7
8
9haproxy h1 -conf {
10 http-errors errors-1
11 errorfile 400 ${testdir}/errors/400-1.http
12 errorfile 403 ${testdir}/errors/403-1.http
13 errorfile 404 ${testdir}/errors/404-1.http
14 errorfile 500 ${testdir}/errors/500-1.http
15
16 http-errors errors-2
17 errorfile 400 ${testdir}/errors/400-2.http
18 errorfile 403 ${testdir}/errors/403-2.http
19 errorfile 404 ${testdir}/errors/404-2.http
20
21 http-errors errors-3
22 errorfile 400 ${testdir}/errors/400-3.http
23 errorfile 404 ${testdir}/errors/404-3.http
24
25 defaults
26 mode http
27 timeout connect 1s
28 timeout client 1s
29 timeout server 1s
30 errorfiles errors-2
31 errorfile 400 ${testdir}/errors/400.http
32 errorfile 404 ${testdir}/errors/404.http
33
34 frontend fe1
35 bind "fd@${fe1}"
36 http-request deny deny_status 400 if { path /400 }
37 http-request deny deny_status 403 if { path /403 }
38 http-request deny deny_status 404 if { path /404 }
39 http-request deny deny_status 500 if { path /500 }
40
41 frontend fe2
42 bind "fd@${fe2}"
43 errorfiles errors-1
44 errorfile 500 ${testdir}/errors/500.http
45 http-request deny deny_status 400 if { path /400 }
46 http-request deny deny_status 403 if { path /403 }
47 http-request deny deny_status 404 if { path /404 }
48 http-request deny deny_status 500 if { path /500 }
49
50 frontend fe3
51 bind "fd@${fe3}"
52 errorfile 500 ${testdir}/errors/500.http
53 errorfiles errors-1 500
54 errorfiles errors-3 400
55 http-request deny deny_status 400 if { path /400 }
56 http-request deny deny_status 403 if { path /403 }
57 http-request deny deny_status 404 if { path /404 }
58 http-request deny deny_status 500 if { path /500 }
59} -start
60
61client c1r1 -connect ${h1_fe1_sock} {
62 txreq -req GET -url /400
63 rxresp
64 expect resp.status == 400
65 expect resp.http.x-err-type == "default"
66} -run
67client c1r2 -connect ${h1_fe1_sock} {
68 txreq -req GET -url /403
69 rxresp
70 expect resp.status == 403
71 expect resp.http.x-err-type == "errors-2"
72} -run
73client c1r3 -connect ${h1_fe1_sock} {
74 txreq -req GET -url /404
75 rxresp
76 expect resp.status == 404
77 expect resp.http.x-err-type == "default"
78} -run
79client c1r4 -connect ${h1_fe1_sock} {
80 txreq -req GET -url /500
81 rxresp
82 expect resp.status == 500
83 expect resp.http.x-err-type == <undef>
84} -run
85
86client c2r1 -connect ${h1_fe2_sock} {
87 txreq -req GET -url /400
88 rxresp
89 expect resp.status == 400
90 expect resp.http.x-err-type == "errors-1"
91} -run
92client c2r2 -connect ${h1_fe2_sock} {
93 txreq -req GET -url /403
94 rxresp
95 expect resp.status == 403
96 expect resp.http.x-err-type == "errors-1"
97} -run
98client c2r3 -connect ${h1_fe2_sock} {
99 txreq -req GET -url /404
100 rxresp
101 expect resp.status == 404
102 expect resp.http.x-err-type == "errors-1"
103} -run
104client c2r4 -connect ${h1_fe2_sock} {
105 txreq -req GET -url /500
106 rxresp
107 expect resp.status == 500
108 expect resp.http.x-err-type == "default"
109} -run
110
111client c3r1 -connect ${h1_fe3_sock} {
112 txreq -req GET -url /400
113 rxresp
114 expect resp.status == 400
115 expect resp.http.x-err-type == "errors-3"
116} -run
117client c3r2 -connect ${h1_fe3_sock} {
118 txreq -req GET -url /403
119 rxresp
120 expect resp.status == 403
121 expect resp.http.x-err-type == "errors-2"
122} -run
123client c3r3 -connect ${h1_fe3_sock} {
124 txreq -req GET -url /404
125 rxresp
126 expect resp.status == 404
127 expect resp.http.x-err-type == "default"
128} -run
129client c3r4 -connect ${h1_fe3_sock} {
130 txreq -req GET -url /500
131 rxresp
132 expect resp.status == 500
133 expect resp.http.x-err-type == "errors-1"
134} -run