Skip to content

Commit

Permalink
Update redirect tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
veryrusty committed May 22, 2014
1 parent 26317cc commit cd44517
Showing 1 changed file with 6 additions and 27 deletions.
33 changes: 6 additions & 27 deletions t/redirect.t
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ subtest 'redirect behind a proxy' => sub {
$cb->(
GET '/test2/bounce',
'X-FORWARDED-HOST' => 'nice.host.name',
'X-Forwarded-Script-Name' => '/myapp',
)->headers->header('Location'),
'http://nice.host.name/test2',
'http://nice.host.name/myapp/test2',
'behind a proxy, host() is read from X_FORWARDED_HOST',
);
}
Expand All @@ -156,32 +157,22 @@ subtest 'redirect behind a proxy' => sub {
GET '/test2/bounce',
'X-FORWARDED-HOST' => 'nice.host.name',
'FORWARDED-PROTO' => 'https',
'Request-Base' => '/myapp',
)->headers->header('Location'),
'https://nice.host.name/test2',
'https://nice.host.name/myapp/test2',
'... and the scheme is read from HTTP_FORWARDED_PROTO',
);
}

{
is(
$cb->(
GET '/test2/bounce',
'X-FORWARDED-HOST' => 'nice.host.name',
'X-FORWARDED-PROTOCOL' => 'ftp', # stupid, but why not?
)->headers->header('Location'),
'ftp://nice.host.name/test2',
'... or from X_FORWARDED_PROTOCOL',
);
}

{
is(
$cb->(
GET '/test2/bounce',
'X-FORWARDED-HOST' => 'nice.host.name',
'X-FORWARDED-PROTO' => 'https',
'X-Forwarded-Script-Name' => '/myapp',
)->headers->header('Location'),
'https://nice.host.name/test2',
'https://nice.host.name/myapp/test2',
'... or from X_FORWARDED_PROTO',
);
}
Expand Down Expand Up @@ -226,18 +217,6 @@ subtest 'redirect behind multiple proxies' => sub {
'... and the scheme is read from HTTP_FORWARDED_PROTO',
);
}

{
is(
$cb->(
GET '/test2/bounce',
'X-FORWARDED-HOST' => "proxy1.example, proxy2.example",
'X-FORWARDED-PROTOCOL' => 'ftp', # stupid, but why not?
)->headers->header('Location'),
'ftp://proxy1.example/test2',
'... or from X_FORWARDED_PROTOCOL',
);
}
};
};

Expand Down

0 comments on commit cd44517

Please sign in to comment.