Note for other redirect test
[catagits/Catalyst-Runtime.git] / t / aggregate / live_engine_response_redirect.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use FindBin;
7 use lib "$FindBin::Bin/../lib";
8
9 use Test::More tests => 26;
10 use Catalyst::Test 'TestApp';
11
12 # XXX: these fail on remote servers due to LWP max_redirect 0 bug:
13 # http://rt.cpan.org/Ticket/Display.html?id=40260
14 {
15     ok( my $response = request('http://localhost/engine/response/redirect/one'), 'Request' );
16     ok( $response->is_redirect, 'Response Redirection 3xx' );
17     is( $response->code, 302, 'Response Code' );
18     is( $response->header('X-Catalyst-Action'), 'engine/response/redirect/one', 'Test Action' );
19     is( $response->header('Location'), '/test/writing/is/boring', 'Response Header Location' );
20     ok( $response->header('Content-Length'), '302 Redirect contains Content-Length' );
21     ok( $response->content, '302 Redirect contains a response body' );
22 }
23
24 {
25     ok( my $response = request('http://localhost/engine/response/redirect/two'), 'Request' );
26     ok( $response->is_redirect, 'Response Redirection 3xx' );
27     is( $response->code, 302, 'Response Code' );
28     is( $response->header('X-Catalyst-Action'), 'engine/response/redirect/two', 'Test Action' );
29     is( $response->header('Location'), 'http://www.google.com/', 'Response Header Location' );
30 }
31
32 {
33     ok( my $response = request('http://localhost/engine/response/redirect/three'), 'Request' );
34     ok( $response->is_redirect, 'Response Redirection 3xx' );
35     is( $response->code, 301, 'Response Code' );
36     is( $response->header('X-Catalyst-Action'), 'engine/response/redirect/three', 'Test Action' );
37     is( $response->header('Location'), 'http://www.google.com/', 'Response Header Location' );
38     ok( $response->header('Content-Length'), '301 Redirect contains Content-Length' );
39     ok( $response->content, '301 Redirect contains a response body' );
40 }
41
42 {
43     ok( my $response = request('http://localhost/engine/response/redirect/four'), 'Request' );
44     ok( $response->is_redirect, 'Response Redirection 3xx' );
45     is( $response->code, 307, 'Response Code' );
46     is( $response->header('X-Catalyst-Action'), 'engine/response/redirect/four', 'Test Action' );
47     is( $response->header('Location'), 'http://www.google.com/', 'Response Header Location' );
48     ok( $response->header('Content-Length'), '307 Redirect contains Content-Length' );
49     ok( $response->content, '307 Redirect contains a response body' );
50 }