blob: 6ea32d284fbd8cb82d8720036863c0f8383991f1 [file] [log] [blame]
Christopher Faulet63f95ed2022-07-05 14:50:17 +02001varnishtest "H1 authority validation and host normalizarion based on the scheme (rfc3982 6.3.2) or the method (connect)"
2
3#REQUIRE_VERSION=2.4
4feature ignore_unknown_macro
5
6syslog S1 -level info {
7 # C1
8 recv
9 expect ~ "^.* uri: GET http://toto:poue@hostname/c1 HTTP/1.1; host: {hostname}$"
10
11 # C2
12 recv
13 expect ~ "^.* uri: GET http://hostname:8080/c2 HTTP/1.1; host: {hostname:8080}$"
14
15 # C3
16 recv
17 expect ~ "^.* uri: GET https://hostname/c3 HTTP/1.1; host: {hostname}$"
18
19 # C4
20 recv
21 expect ~ "^.* uri: GET https://hostname:80/c4 HTTP/1.1; host: {hostname:80}$"
22
23 # C5
24 recv
25 expect ~ "^.* uri: CONNECT hostname:80 HTTP/1.1; host: {hostname}$"
26 recv
27 expect ~ "^.* uri: CONNECT hostname:80 HTTP/1.1; host: {hostname}$"
28
29 # C6
30 recv
31 expect ~ "^.* uri: CONNECT hostname:443 HTTP/1.1; host: {hostname}$"
32 recv
33 expect ~ "^.* uri: CONNECT hostname:443 HTTP/1.1; host: {hostname}$"
34
35 recv
36 expect ~ "^.* uri: CONNECT hostname:8443 HTTP/1.1; host: {hostname:8443}$"
37} -start
38
39haproxy h1 -conf {
40 defaults
41 mode http
42 timeout connect 1s
43 timeout client 1s
44 timeout server 1s
45
46 frontend fe
47 bind "fd@${fe}"
48
49 http-request capture req.hdr(host) len 512
50 log-format "uri: %r; host: %hr"
51 log ${S1_addr}:${S1_port} len 2048 local0 debug err
52
53 http-request return status 200
54} -start
55
56# default port 80 with http scheme => should be normalized
57# Be sure userinfo are skipped
58client c1 -connect ${h1_fe_sock} {
59 txreq \
60 -req "GET" \
61 -url "http://toto:poue@hostname:80/c1" \
62 -hdr "host: hostname:80"
63
64 rxresp
65 expect resp.status == 200
66} -run
67
68# port 8080 with http scheme => no normalization
69client c2 -connect ${h1_fe_sock} {
70 txreq \
71 -req "GET" \
72 -url "http://hostname:8080/c2" \
73 -hdr "host: hostname:8080"
74
75 rxresp
76 expect resp.status == 200
77} -run
78
79# default port 443 with https scheme => should be normalized
80client c3 -connect ${h1_fe_sock} {
81 txreq \
82 -req "GET" \
83 -url "https://hostname:443/c3" \
84 -hdr "host: hostname:443"
85
86 rxresp
87 expect resp.status == 200
88} -run
89
90# port 80 with https scheme => no normalization
91client c4 -connect ${h1_fe_sock} {
92 txreq \
93 -req "GET" \
94 -url "https://hostname:80/c4" \
95 -hdr "host: hostname:80"
96
97 rxresp
98 expect resp.status == 200
99} -run
100
101# CONNECT on port 80 => should be normalized
102client c5 -connect ${h1_fe_sock} {
103 txreq \
104 -req "CONNECT" \
105 -url "hostname:80" \
106 -hdr "host: hostname:80"
107
108 rxresp
109 expect resp.status == 200
110} -run
111client c5 -connect ${h1_fe_sock} {
112
113 txreq \
114 -req "CONNECT" \
115 -url "hostname:80" \
116 -hdr "host: hostname"
117
118 rxresp
119 expect resp.status == 200
120} -run
121
122# CONNECT on port 443 => should be normalized
123client c6 -connect ${h1_fe_sock} {
124 txreq \
125 -req "CONNECT" \
126 -url "hostname:443" \
127 -hdr "host: hostname:443"
128
129 rxresp
130 expect resp.status == 200
131} -run
132client c6 -connect ${h1_fe_sock} {
133 txreq \
134 -req "CONNECT" \
135 -url "hostname:443" \
136 -hdr "host: hostname"
137
138 rxresp
139 expect resp.status == 200
140} -run
141
142# CONNECT on port non-default port => no normalization
143client c7 -connect ${h1_fe_sock} {
144 txreq \
145 -req "CONNECT" \
146 -url "hostname:8443" \
147 -hdr "host: hostname:8443"
148
149 rxresp
150 expect resp.status == 200
151} -run
152
153# host miss-match => error
154client c8 -connect ${h1_fe_sock} {
155 txreq \
156 -req "GET" \
157 -url "http://hostname1/" \
158 -hdr "host: hostname2"
159
160 rxresp
161 expect resp.status == 400
162} -run
163
164# port miss-match => error
165client c9 -connect ${h1_fe_sock} {
166 txreq \
167 -req "GET" \
168 -url "http://hostname:80/" \
169 -hdr "host: hostname:81"
170
171 rxresp
172 expect resp.status == 400
173} -run
174
175# no host port with a non-default port in abs-uri => error
176client c10 -connect ${h1_fe_sock} {
177 txreq \
178 -req "GET" \
179 -url "http://hostname:8080/" \
180 -hdr "host: hostname"
181
182 rxresp
183 expect resp.status == 400
184} -run
185
186# non-default host port with a default in abs-uri => error
187client c11 -connect ${h1_fe_sock} {
188 txreq \
189 -req "GET" \
190 -url "http://hostname/" \
191 -hdr "host: hostname:81"
192
193 rxresp
194 expect resp.status == 400
195} -run
196
197# miss-match between host headers => error
198client c12 -connect ${h1_fe_sock} {
199 txreq \
200 -req "GET" \
201 -url "http://hostname1/" \
202 -hdr "host: hostname1" \
203 -hdr "host: hostname2"
204
205 rxresp
206 expect resp.status == 400
207} -run
208
209# miss-match between host headers but with a normalization => error
210client c13 -connect ${h1_fe_sock} {
211 txreq \
212 -req "GET" \
213 -url "http://hostname1/" \
214 -hdr "host: hostname1:80" \
215 -hdr "host: hostname1"
216
217 rxresp
218 expect resp.status == 400
219} -run
220
221# CONNECT authoriy without port => error
222client c14 -connect ${h1_fe_sock} {
223 txreq \
224 -req "CONNECT" \
225 -url "hostname" \
226 -hdr "host: hostname"
227
228 rxresp
229 expect resp.status == 400
230} -run
231
232# host miss-match with CONNECT => error
233client c15 -connect ${h1_fe_sock} {
234 txreq \
235 -req "CONNECT" \
236 -url "hostname1:80" \
237 -hdr "host: hostname2:80"
238
239 rxresp
240 expect resp.status == 400
241} -run
242
243# port miss-match with CONNECT => error
244client c16 -connect ${h1_fe_sock} {
245 txreq \
246 -req "CONNECT" \
247 -url "hostname:80" \
248 -hdr "host: hostname:443"
249
250 rxresp
251 expect resp.status == 400
252} -run
253
254# no host port with non-default port in CONNECT authority => error
255client c17 -connect ${h1_fe_sock} {
256 txreq \
257 -req "CONNECT" \
258 -url "hostname:8080" \
259 -hdr "host: hostname"
260
261 rxresp
262 expect resp.status == 400
263} -run
264
265# no authority => error
266client c18 -connect ${h1_fe_sock} {
267 txreq \
268 -req "CONNECT" \
269 -url "/" \
270 -hdr "host: hostname"
271
272 rxresp
273 expect resp.status == 400
274} -run
275
276syslog S1 -wait