6 use RT::Test tests => 13;
8 my $r = $HTML::Mason::Commands::r = bless {}, 'R';
9 my $m = $HTML::Mason::Commands::m = bless {}, 'M';
12 CanonicalizeRedirectURLs => 0,
13 WebDomain => 'localhost',
17 is( RT->Config->Get('WebBaseURL'), 'http://localhost' );
18 is( RT->Config->Get('WebURL'), 'http://localhost/' );
21 'http://localhost/Ticket/', 'http://localhost/Ticket/',
22 { SERVER_NAME => 'localhost', SERVER_PORT => 80 },
25 '/Ticket/', 'http://localhost/Ticket/',
26 { SERVER_NAME => 'localhost', SERVER_PORT => 80 },
29 'http://localhost/Ticket/', 'http://example.com/Ticket/',
30 { SERVER_NAME => 'example.com', SERVER_PORT => 80 },
34 CanonicalizeRedirectURLs => 0,
35 WebDomain => 'localhost',
39 is( RT->Config->Get('WebBaseURL'), 'https://localhost' );
40 is( RT->Config->Get('WebURL'), 'https://localhost/' );
43 'https://localhost/Ticket/', 'https://localhost/Ticket/',
44 { SERVER_NAME => 'localhost', SERVER_PORT => 443, HTTPS => 'on' },
47 '/Ticket/', 'https://localhost/Ticket/',
48 { SERVER_NAME => 'localhost', SERVER_PORT => 443, HTTPS => 'on' },
51 'https://localhost/Ticket/', 'http://localhost/Ticket/',
52 { SERVER_NAME => 'localhost', SERVER_PORT => 80 },
55 '/Ticket/', 'http://localhost/Ticket/',
56 { SERVER_NAME => 'localhost', SERVER_PORT => 80 },
59 'https://localhost/Ticket/', 'http://example.com/Ticket/',
60 { SERVER_NAME => 'example.com', SERVER_PORT => 80 },
63 'https://localhost/Ticket/', 'https://example.com/Ticket/',
64 { SERVER_NAME => 'example.com', SERVER_PORT => 443, HTTPS => 'on' },
69 while ( my ($k, $v) = each %values ) {
70 RT->Config->Set( $k => $v );
73 unless ( $values{'WebBaseURL'} ) {
74 my $port = RT->Config->Get('WebPort');
77 ($port == 443? 'https': 'http') .'://'
78 . RT->Config->Get('WebDomain')
79 . ($port != 80 && $port != 443? ":$port" : '')
82 unless ( $values{'WebURL'} ) {
84 WebURL => RT->Config->Get('WebBaseURL') . RT->Config->Get('WebPath') . "/"
90 my ($to, $expected, $env, $details) = @_;
93 while ( my ($k, $v) = each %{ $env || {} } ) {
96 RT::Interface::Web::Redirect( $to );
97 is($m->redirect, $expected, $details || "correct for '$to'");
104 sub redirect { $_[0]{'last'} = $_[1] if @_ > 1; return $_[0]{'last'} }