use strict; use warnings FATAL => 'all'; use Apache::Test; use Apache::TestRequest; use Apache::TestUtil; use Apache::TestConfig (); use constant WINFU => Apache::TestConfig::WINFU(); ## ## mod_alias test ## ## redirect codes for Redirect testing ## my %redirect = ( perm => '301', perm2 => '301', temp => '302', temp2 => '302', seeother => '303', gone => '410', forbid => '403' ); ## RedirectMatch testing ## my %rm_body = ( p => '301', t => '302' ); my %rm_rc = ( s => '303', g => '410', f => '403' ); #XXX: find something that'll on other platforms (/bin/sh aint it) my $script_tests = WINFU ? 0 : 4 + have_min_apache_version("2.4.19"); my $tests = 12 + have_min_apache_version("2.4.19") * 10 + (keys %redirect) + (keys %rm_body) * (1 + have_min_apache_version("2.4.19")) * 10 + (keys %rm_rc) * (1 + have_min_apache_version("2.4.19")) * 10 + $script_tests; #LWP required to follow redirects plan tests => $tests, need need_module('alias'), need_lwp; ## simple alias ## t_debug "verifying simple aliases"; ok t_cmp((GET_RC "/alias/"), 200, "/alias/"); ## alias to a non-existant area ## ok t_cmp((GET_RC "/bogu/"), 404, "/bogu/"); t_debug "verifying alias match with /ali[0-9]."; for (my $i=0 ; $i <= 9 ; $i++) { ok t_cmp((GET_BODY "/ali$i"), $i, "/ali$i"); } if (have_min_apache_version("2.4.19")) { t_debug "verifying expression alias match with /expr/ali[0-9]."; for (my $i=0 ; $i <= 9 ; $i++) { ok t_cmp((GET_BODY "/expr/ali$i"), $i, "/ali$i"); } } my ($actual, $expected); foreach (sort keys %redirect) { ## make LWP not follow the redirect since we ## are just interested in the return code. local $Apache::TestRequest::RedirectOK = 0; $expected = $redirect{$_}; $actual = GET_RC "/$_"; ok t_cmp($actual, $expected, "/$_"); } print "verifying body of perm and temp redirect match\n"; foreach (sort keys %rm_body) { for (my $i=0 ; $i <= 9 ; $i++) { $expected = $i; $actual = GET_BODY "/$_$i"; ok t_cmp($actual, $expected, "/$_$i"); } } if (have_min_apache_version("2.4.19")) { print "verifying body of perm and temp redirect match with expression support\n"; foreach (sort keys %rm_body) { for (my $i=0 ; $i <= 9 ; $i++) { $expected = $i; $actual = GET_BODY "/expr/$_$i"; ok t_cmp($actual, $expected, "/$_$i"); } } } print "verifying return code of seeother and gone redirect match\n"; foreach (keys %rm_rc) { ## make LWP not follow the redirect since we ## are just interested in the return code. local $Apache::TestRequest::RedirectOK = 0; $expected = $rm_rc{$_}; for (my $i=0 ; $i <= 9 ; $i++) { $actual = GET_RC "$_$i"; ok t_cmp($actual, $expected, "$_$i"); } } if (have_min_apache_version("2.4.19")) { print "verifying return code of seeother and gone redirect match with expression support\n"; foreach (keys %rm_rc) { ## make LWP not follow the redirect since we ## are just interested in the return code. local $Apache::TestRequest::RedirectOK = 0; $expected = $rm_rc{$_}; for (my $i=0 ; $i <= 9 ; $i++) { $actual = GET_RC "/expr/$_$i"; ok t_cmp($actual, $expected, "$_$i"); } } } ## create a little cgi to test ScriptAlias and ScriptAliasMatch ## my $string = "this is a shell script cgi."; my $cgi =<{t_logs}/mod_cgi.log");