Skip to content

Commit cd44517

Browse files
committed
Update redirect tests
Includes tests when proxy is not from root (see #571) Removes tests for ftp as the protocol behing a http proxy - it was silly and ReverseProxy middleware doesn't support it.
1 parent 26317cc commit cd44517

File tree

1 file changed

+6
-27
lines changed

1 file changed

+6
-27
lines changed

t/redirect.t

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,9 @@ subtest 'redirect behind a proxy' => sub {
144144
$cb->(
145145
GET '/test2/bounce',
146146
'X-FORWARDED-HOST' => 'nice.host.name',
147+
'X-Forwarded-Script-Name' => '/myapp',
147148
)->headers->header('Location'),
148-
'http://nice.host.name/test2',
149+
'http://nice.host.name/myapp/test2',
149150
'behind a proxy, host() is read from X_FORWARDED_HOST',
150151
);
151152
}
@@ -156,32 +157,22 @@ subtest 'redirect behind a proxy' => sub {
156157
GET '/test2/bounce',
157158
'X-FORWARDED-HOST' => 'nice.host.name',
158159
'FORWARDED-PROTO' => 'https',
160+
'Request-Base' => '/myapp',
159161
)->headers->header('Location'),
160-
'https://nice.host.name/test2',
162+
'https://nice.host.name/myapp/test2',
161163
'... and the scheme is read from HTTP_FORWARDED_PROTO',
162164
);
163165
}
164166

165-
{
166-
is(
167-
$cb->(
168-
GET '/test2/bounce',
169-
'X-FORWARDED-HOST' => 'nice.host.name',
170-
'X-FORWARDED-PROTOCOL' => 'ftp', # stupid, but why not?
171-
)->headers->header('Location'),
172-
'ftp://nice.host.name/test2',
173-
'... or from X_FORWARDED_PROTOCOL',
174-
);
175-
}
176-
177167
{
178168
is(
179169
$cb->(
180170
GET '/test2/bounce',
181171
'X-FORWARDED-HOST' => 'nice.host.name',
182172
'X-FORWARDED-PROTO' => 'https',
173+
'X-Forwarded-Script-Name' => '/myapp',
183174
)->headers->header('Location'),
184-
'https://nice.host.name/test2',
175+
'https://nice.host.name/myapp/test2',
185176
'... or from X_FORWARDED_PROTO',
186177
);
187178
}
@@ -226,18 +217,6 @@ subtest 'redirect behind multiple proxies' => sub {
226217
'... and the scheme is read from HTTP_FORWARDED_PROTO',
227218
);
228219
}
229-
230-
{
231-
is(
232-
$cb->(
233-
GET '/test2/bounce',
234-
'X-FORWARDED-HOST' => "proxy1.example, proxy2.example",
235-
'X-FORWARDED-PROTOCOL' => 'ftp', # stupid, but why not?
236-
)->headers->header('Location'),
237-
'ftp://proxy1.example/test2',
238-
'... or from X_FORWARDED_PROTOCOL',
239-
);
240-
}
241220
};
242221
};
243222

0 commit comments

Comments
 (0)