use_ok("IkiWiki");
}
+my $PERL5LIB = 'blib/lib:blib/arch';
my $pwd = getcwd();
# Black-box (ish) test for relative linking between CGI and static content
add_plugins:
- anonok
anonok_pagespec: "*"
+ENV: { 'PERL5LIB': '$PERL5LIB' }
EOF
);
add_plugins:
- anonok
anonok_pagespec: "*"
+ENV: { 'PERL5LIB': '$PERL5LIB' }
EOF
);
$ENV{HTTPS} = 'on';
});
%bits = parse_cgi_content($content);
-TODO: {
-local $TODO = "avoid mixed content";
like($bits{basehref}, qr{^https://static.example.com/$});
like($bits{stylehref}, qr{^(?:(?:https:)?//static.example.com)?/style.css$});
like($bits{tophref}, qr{^(?:https:)?//static.example.com/$});
like($bits{cgihref}, qr{^(?:(?:https:)?//cgi.example.com)?/ikiwiki.cgi$});
-}
# when accessed via a different hostname, links to the CGI (only) should
# stay on that host?
$ENV{SERVER_PORT} = '80';
$ENV{SCRIPT_NAME} = '/ikiwiki.cgi';
$ENV{HTTP_HOST} = 'staging.example.net';
- $ENV{HTTPS} = 'on';
$ENV{CONTENT_LENGTH} = length $in;
});
-like($bits{basehref}, qr{^http://static.example.com/$});
-like($bits{stylehref}, qr{^(?:(?:http:)?//static.example.com)?/style.css$});
-like($bits{tophref}, qr{^(?:http:)?//static.example.com/$});
+%bits = parse_cgi_content($content);
+like($bits{basehref}, qr{^http://static.example.com/a/b/c/$});
+like($bits{stylehref}, qr{^(?:(?:http:)?//static.example.com|\.\./\.\./\.\.)/style.css$});
+like($bits{tophref}, qr{^(?:(?:http:)?//static.example.com|\.\./\.\./\.\.)/$});
TODO: {
local $TODO = "use self-referential CGI URL?";
like($bits{cgihref}, qr{^(?:(?:http:)?//staging.example.net)?/ikiwiki.cgi$});
add_plugins:
- anonok
anonok_pagespec: "*"
+ENV: { 'PERL5LIB': '$PERL5LIB' }
EOF
);
add_plugins:
- anonok
anonok_pagespec: "*"
+ENV: { 'PERL5LIB': '$PERL5LIB' }
EOF
);
$ENV{HTTPS} = 'on';
});
%bits = parse_cgi_content($content);
-TODO: {
-local $TODO = "avoid mixed content";
is($bits{basehref}, "https://example.com/wiki/");
like($bits{stylehref}, qr{^(?:(?:https:)?//example.com)?/wiki/style.css$});
like($bits{tophref}, qr{^(?:/wiki|\.)/$});
-}
like($bits{cgihref}, qr{^(?:(?:https:)?//example.com)?/cgi-bin/ikiwiki.cgi$});
# when not accessed via HTTPS, ???
$ENV{HTTPS} = 'on';
});
%bits = parse_cgi_content($content);
+# because the static and dynamic stuff is on the same server, we assume that
+# both are also on the staging server
+like($bits{basehref}, qr{^https://staging.example.net/wiki/$});
+like($bits{stylehref}, qr{^(?:(?:https:)?//staging.example.net)?/wiki/style.css$});
+like($bits{tophref}, qr{^(?:(?:(?:https:)?//staging.example.net)?/wiki|\.)/$});
TODO: {
-local $TODO = "avoid mixed content";
-like($bits{basehref}, qr{^https://example.com/wiki/$});
-like($bits{stylehref}, qr{^(?:(?:https:)?//example.com)?/wiki/style.css$});
-like($bits{tophref}, qr{^(?:(?:(?:https:)?//example.com)?/wiki|\.)/$});
+local $TODO = "this should really point back to itself but currently points to example.com";
like($bits{cgihref}, qr{^(?:(?:https:)?//staging.example.net)?/cgi-bin/ikiwiki.cgi$});
}
$ENV{HTTPS} = 'on';
});
%bits = parse_cgi_content($content);
-TODO: {
-local $TODO = "avoid mixed content";
is($bits{basehref}, "https://example.com/wiki/a/b/c/");
like($bits{stylehref}, qr{^(?:(?:https:)?//example.com)?/wiki/style.css$});
-}
like($bits{tophref}, qr{^(?:/wiki|\.\./\.\./\.\.)/$});
like($bits{cgihref}, qr{^(?:(?:https:)?//example.com)?/cgi-bin/ikiwiki.cgi$});
add_plugins:
- anonok
anonok_pagespec: "*"
+ENV: { 'PERL5LIB': '$PERL5LIB' }
EOF
);
%bits = parse_cgi_content($content);
like($bits{tophref}, qr{^(?:\Q$pwd\E/t/tmp/out|\.)/$});
like($bits{cgihref}, qr{^(?:file://)?/\$LIB/ikiwiki-w3m.cgi/ikiwiki.cgi$});
-TODO: {
-local $TODO = "should be file:///";
like($bits{basehref}, qr{^(?:(?:file:)?//)?\Q$pwd\E/t/tmp/out/$});
like($bits{stylehref}, qr{^(?:(?:(?:file:)?//)?\Q$pwd\E/t/tmp/out|\.)/style.css$});
-}
#######################################################################
# site 6: we're behind a reverse-proxy
- anonok
anonok_pagespec: "*"
reverse_proxy: 1
+ENV: { 'PERL5LIB': '$PERL5LIB' }
EOF
);