1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
use strict;
use warnings FATAL => 'all';
use Apache::Test;
use Apache::TestRequest;
use Apache::TestUtil;
my $havecgi = have_cgi();
my $pathinfo = "/foo/bar";
##
## mode path, filerc, filebody, cgirc, cgibody
##
my %tests = (
default => [ "", "404","Not Found", "200","_${pathinfo}_" ],
on => [ "/on", "200","_${pathinfo}_","200","_${pathinfo}_" ],
off => [ "/off","404","Not Found", "404","Not Found" ]
);
my @files = ("", "/index.shtml");
push @files, "/test.sh" if ($havecgi);
my $numtests = ((scalar keys %tests) * (scalar @files) * 4);
plan tests => $numtests, need need_apache(2), need_module('include'), need_lwp;
my $loc = "/apache/acceptpathinfo";
foreach my $mode (keys %tests) {
foreach my $file (@files) {
foreach my $pinf ("","$pathinfo") {
my ($expectedrc, $expectedbody);
if ($pinf eq "") {
$expectedrc = "200";
$expectedbody = "_\\(none\\)_";
}
else {
if ($file eq "") {
$expectedrc = "404";
$expectedbody = "Not Found";
}
elsif ($file eq "/index.shtml") {
$expectedrc = $tests{$mode}[1];
$expectedbody = $tests{$mode}[2];
}
else {
$expectedrc = $tests{$mode}[3];
$expectedbody = $tests{$mode}[4];
}
}
my $req = $loc.$tests{$mode}[0].$file.$pinf;
my $resp = GET $req;
ok t_cmp($resp->code,
$expectedrc,
"AcceptPathInfo $mode return code for $req"
);
my $actual = super_chomp($resp->content);
ok t_cmp($actual,
qr/$expectedbody/,
"AcceptPathInfo $mode body for $req"
);
}
}
}
sub super_chomp {
my ($body) = shift;
## super chomp - all leading and trailing \n (and \r for win32)
$body =~ s/^[\n\r]*//;
$body =~ s/[\n\r]*$//;
## and all the rest change to spaces
$body =~ s/\n/ /g;
$body =~ s/\r//g; #rip out all remaining \r's
$body;
}
|