X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/823268e5c78be454f0da5013c1bfa7e5d936902d..d712389ae3e8351c1416aa81d4b85586cf98f002:/t/relativity.t diff --git a/t/relativity.t b/t/relativity.t index ca1664f3c..675efc903 100755 --- a/t/relativity.t +++ b/t/relativity.t @@ -18,6 +18,7 @@ BEGIN { use_ok("IkiWiki"); } +my $PERL5LIB = 'blib/lib:blib/arch'; my $pwd = getcwd(); # Black-box (ish) test for relative linking between CGI and static content @@ -80,6 +81,7 @@ cgi_wrappermode: 0754 add_plugins: - anonok anonok_pagespec: "*" +ENV: { 'PERL5LIB': '$PERL5LIB' } EOF ); @@ -177,6 +179,7 @@ cgi_wrappermode: 0754 add_plugins: - anonok anonok_pagespec: "*" +ENV: { 'PERL5LIB': '$PERL5LIB' } EOF ); @@ -224,13 +227,10 @@ run(["./t/tmp/ikiwiki.cgi"], \undef, \$content, init => sub { $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? @@ -240,12 +240,12 @@ run(["./t/tmp/ikiwiki.cgi"], \$in, \$content, init => sub { $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$}); @@ -268,6 +268,7 @@ cgi_wrappermode: 0754 add_plugins: - anonok anonok_pagespec: "*" +ENV: { 'PERL5LIB': '$PERL5LIB' } EOF ); @@ -372,6 +373,7 @@ cgi_wrappermode: 0754 add_plugins: - anonok anonok_pagespec: "*" +ENV: { 'PERL5LIB': '$PERL5LIB' } EOF ); @@ -405,12 +407,9 @@ run(["./t/tmp/ikiwiki.cgi"], \undef, \$content, init => sub { $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, ??? @@ -437,11 +436,13 @@ run(["./t/tmp/ikiwiki.cgi"], \undef, \$content, init => sub { $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$}); } @@ -456,11 +457,8 @@ run(["./t/tmp/ikiwiki.cgi"], \$in, \$content, init => sub { $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$}); @@ -483,6 +481,7 @@ cgi_wrappermode: 0754 add_plugins: - anonok anonok_pagespec: "*" +ENV: { 'PERL5LIB': '$PERL5LIB' } EOF ); @@ -515,11 +514,8 @@ run(["./t/tmp/ikiwiki.cgi"], \undef, \$content, init => sub { %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 @@ -539,6 +535,7 @@ add_plugins: - anonok anonok_pagespec: "*" reverse_proxy: 1 +ENV: { 'PERL5LIB': '$PERL5LIB' } EOF );