10 plan(skip_all => "CGI not available")
16 plan(skip_all => "IPC::Run not available")
26 # We check for English error messages
32 my $installed = $ENV{INSTALLED_TESTS};
36 @command = qw(ikiwiki --plugin inline);
39 ok(! system("make -s ikiwiki.out"));
40 @command = ("perl", "-I".getcwd."/blib/lib", './ikiwiki.out',
41 '--underlaydir='.getcwd.'/underlays/basewiki',
42 '--set', 'underlaydirbase='.getcwd.'/underlays',
43 '--templatedir='.getcwd.'/templates');
50 writefile($name, $dir, $content);
51 ok(utime(333333333, 333333333, "$dir/$name"));
54 sub write_setup_file {
57 wikiname => 'this is the name of my wiki',
58 srcdir => getcwd.'/t/tmp/in',
59 destdir => getcwd.'/t/tmp/out',
60 url => 'http://example.com',
61 cgiurl => 'http://example.com/cgi-bin/ikiwiki.cgi',
62 cgi_wrapper => getcwd.'/t/tmp/ikiwiki.cgi',
63 cgi_wrappermode => '0751',
64 add_plugins => [qw(aggregate)],
65 disable_plugins => [qw(emailauth openid passwordauth)],
66 aggregate_webtrigger => 1,
68 if ($params{without_paranoia}) {
69 $setup{libdirs} = [getcwd.'/t/noparanoia'];
72 $setup{ENV} = { 'PERL5LIB' => getcwd.'/blib/lib' };
74 writefile("test.setup", "t/tmp",
75 "# IkiWiki::Setup::Yaml - YAML formatted setup file\n" .
79 sub thoroughly_rebuild {
80 ok(unlink("t/tmp/ikiwiki.cgi") || $!{ENOENT});
81 ok(! system(@command, qw(--setup t/tmp/test.setup --rebuild --wrappers)));
87 my $method = $args{method} || 'GET';
88 my $environ = $args{environ} || {};
89 my $params = $args{params} || { do => 'prefs' };
92 SCRIPT_NAME => '/cgi-bin/ikiwiki.cgi',
93 HTTP_HOST => 'example.com',
96 my $cgi = CGI->new($args{params});
97 my $query_string = $cgi->query_string();
100 if ($method eq 'POST') {
101 $defaults{REQUEST_METHOD} = 'POST';
103 $defaults{CONTENT_LENGTH} = length $in;
105 $defaults{REQUEST_METHOD} = 'GET';
106 $defaults{QUERY_STRING} = $query_string;
113 run(["./t/tmp/ikiwiki.cgi"], \$in, \$out, init => sub {
115 $ENV{$_} = $envvars{$_}
119 return decode_utf8($out);
125 ok(! system(qw(rm -rf t/tmp)));
126 ok(! system(qw(mkdir t/tmp)));
128 write_old_file('aggregator.mdwn', 't/tmp/in',
129 '[[!aggregate name="ssrf" url="file://'.getcwd.'/t/secret.rss"]]'
130 .'[[!inline pages="internal(aggregator/*)"]]');
133 thoroughly_rebuild();
138 do => 'aggregate_webtrigger',
141 unlike($content, qr{creating new page});
142 unlike($content, qr{Secrets});
143 ok(! -e 't/tmp/in/.ikiwiki/transient/aggregator/ssrf');
144 ok(! -e 't/tmp/in/.ikiwiki/transient/aggregator/ssrf/Secrets_go_here._aggregated');
146 thoroughly_rebuild();
147 $content = readfile('t/tmp/out/aggregator/index.html');
148 unlike($content, qr{Secrets});
150 diag('Trying test again with LWPx::ParanoidAgent disabled');
152 write_setup_file(without_paranoia => 1);
153 thoroughly_rebuild();
158 do => 'aggregate_webtrigger',
161 unlike($content, qr{creating new page});
162 unlike($content, qr{Secrets});
163 ok(! -e 't/tmp/in/.ikiwiki/transient/aggregator/ssrf');
164 ok(! -e 't/tmp/in/.ikiwiki/transient/aggregator/ssrf/Secrets_go_here._aggregated');
166 thoroughly_rebuild();
167 $content = readfile('t/tmp/out/aggregator/index.html');
168 unlike($content, qr{Secrets});