From c9cf025fadfe043f0f2f679e10d1207d8a158bb6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 17:01:31 +0200 Subject: Adding debian version 2.4.57-2. Signed-off-by: Daniel Baumann --- debian/perl-framework/t/modules/alias.t | 240 ++++++++++++++++++++++++++++++++ 1 file changed, 240 insertions(+) create mode 100644 debian/perl-framework/t/modules/alias.t (limited to 'debian/perl-framework/t/modules/alias.t') diff --git a/debian/perl-framework/t/modules/alias.t b/debian/perl-framework/t/modules/alias.t new file mode 100644 index 0000000..957fccc --- /dev/null +++ b/debian/perl-framework/t/modules/alias.t @@ -0,0 +1,240 @@ +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' +); + + +my %relative_redirects = ( + "/redirect_relative/default" => "^http", # URL should be absolute + "/redirect_relative/on" => "^/out-on", # URL should be relative + "/redirect_relative/off" => "^http", # URL should be absolute + "/redirect_relative/off/fail" => undef, # 500 due to invalid URL +); + +#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; + +if (have_min_apache_version("2.5.1")) { + $tests += (keys %relative_redirects)*2; +} + +#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"); + + +if (have_min_apache_version("2.5.1")) { + my ($path, $regex); + while (($path, $regex) = each (%relative_redirects)) { + local $Apache::TestRequest::RedirectOK = 0; + my $r; + $r = GET($path); + if (defined($regex)) { + ok t_cmp($r->code, "302"); + ok t_cmp($r->header("Location"), qr/$regex/, "failure on $path"); + } + else { + ok t_cmp($r->code, "500"); + ok t_cmp($r->header("Location"), undef, "failure on $path"); + } + } +} + -- cgit v1.2.3