Christopher Faulet | a5afb0b | 2020-01-20 13:49:48 +0100 | [diff] [blame] | 1 | varnishtest "Test the errorfiles directive" |
| 2 | #REQUIRE_VERSION=2.2 |
| 3 | |
| 4 | # This config tests the errorfiles directive. |
| 5 | |
| 6 | feature ignore_unknown_macro |
| 7 | |
| 8 | |
| 9 | haproxy 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 |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame] | 27 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 28 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 29 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
Christopher Faulet | a5afb0b | 2020-01-20 13:49:48 +0100 | [diff] [blame] | 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 } |
Christopher Faulet | 9467f18 | 2020-06-30 09:32:01 +0200 | [diff] [blame] | 37 | http-request deny if { path /403 } |
Christopher Faulet | a5afb0b | 2020-01-20 13:49:48 +0100 | [diff] [blame] | 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 } |
Christopher Faulet | 9467f18 | 2020-06-30 09:32:01 +0200 | [diff] [blame] | 46 | http-request deny if { path /403 } |
Christopher Faulet | a5afb0b | 2020-01-20 13:49:48 +0100 | [diff] [blame] | 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 } |
Christopher Faulet | 9467f18 | 2020-06-30 09:32:01 +0200 | [diff] [blame] | 56 | http-request deny if { path /403 } |
Christopher Faulet | a5afb0b | 2020-01-20 13:49:48 +0100 | [diff] [blame] | 57 | http-request deny deny_status 404 if { path /404 } |
| 58 | http-request deny deny_status 500 if { path /500 } |
| 59 | } -start |
| 60 | |
| 61 | client 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 |
| 67 | client 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 |
| 73 | client 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 |
| 79 | client 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 | |
| 86 | client 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 |
| 92 | client 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 |
| 98 | client 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 |
| 104 | client 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 | |
| 111 | client 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 |
| 117 | client 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 |
| 123 | client 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 |
| 129 | client 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 |