X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/bb8f15e2a7e55bef6c2e44a0b4a530add030befc..cd9297322a9e909b908320aa8824a7b524396e2f:/t/relativity.t diff --git a/t/relativity.t b/t/relativity.t index 7e1e7049f..c562dccb7 100755 --- a/t/relativity.t +++ b/t/relativity.t @@ -14,7 +14,6 @@ use IkiWiki; use Cwd qw(getcwd); use Errno qw(ENOENT); -my $PERL5LIB = 'blib/lib:blib/arch'; my $pwd = getcwd(); # Black-box (ish) test for relative linking between CGI and static content @@ -60,30 +59,48 @@ write_old_file("a/b/c.mdwn", write_old_file("a/d.mdwn", "D"); write_old_file("a/d/e.mdwn", "E"); -####################################################################### -# site 1: a perfectly ordinary ikiwiki +sub write_setup_file { + my (%args) = @_; + my $urlline = defined $args{url} ? "url: $args{url}" : ""; + my $w3mmodeline = defined $args{w3mmode} ? "w3mmode: $args{w3mmode}" : ""; + my $reverseproxyline = defined $args{reverse_proxy} ? "reverse_proxy: $args{reverse_proxy}" : ""; -writefile("test.setup", "t/tmp", < 0, + url => "http://example.com/wiki/", + cgiurl => "http://example.com/cgi-bin/ikiwiki.cgi", +); +thoroughly_rebuild(); # CGI wrapper should be exactly the requested mode my (undef, undef, $mode, undef, undef, @@ -161,27 +178,12 @@ like($bits{cgihref}, qr{^(?:(?:http:)?//example.com)?/cgi-bin/ikiwiki.cgi$}); # in html5, the is allowed to be relative, and we take full # advantage of that -writefile("test.setup", "t/tmp", < 1, + url => "http://example.com/wiki/", + cgiurl => "http://example.com/cgi-bin/ikiwiki.cgi", ); - -ok(unlink("t/tmp/ikiwiki.cgi") || $!{ENOENT}); -ok(! system("./ikiwiki.out --setup t/tmp/test.setup --rebuild --wrappers")); +thoroughly_rebuild(); # CGI wrapper should be exactly the requested mode (undef, undef, $mode, undef, undef, @@ -262,27 +264,12 @@ is($bits{cgihref}, "/cgi-bin/ikiwiki.cgi"); ####################################################################### # site 2: static content and CGI are on different servers -writefile("test.setup", "t/tmp", < 0, + url => "http://static.example.com/", + cgiurl => "http://cgi.example.com/ikiwiki.cgi", ); - -ok(unlink("t/tmp/ikiwiki.cgi")); -ok(! system("./ikiwiki.out --setup t/tmp/test.setup --rebuild --wrappers")); +thoroughly_rebuild(); # CGI wrapper should be exactly the requested mode (undef, undef, $mode, undef, undef, @@ -350,27 +337,12 @@ local $TODO = "use self-referential CGI URL?"; like($bits{cgihref}, qr{^(?:(?:http:)?//staging.example.net)?/ikiwiki.cgi$}); } -writefile("test.setup", "t/tmp", < 1, + url => "http://static.example.com/", + cgiurl => "http://cgi.example.com/ikiwiki.cgi", ); - -ok(unlink("t/tmp/ikiwiki.cgi")); -ok(! system("./ikiwiki.out --setup t/tmp/test.setup --rebuild --wrappers")); +thoroughly_rebuild(); # CGI wrapper should be exactly the requested mode (undef, undef, $mode, undef, undef, @@ -442,27 +414,12 @@ is($bits{cgihref}, "//staging.example.net/ikiwiki.cgi"); ####################################################################### # site 3: we specifically want everything to be secure -writefile("test.setup", "t/tmp", < 0, + url => "https://example.com/wiki/", + cgiurl => "https://example.com/cgi-bin/ikiwiki.cgi", ); - -ok(unlink("t/tmp/ikiwiki.cgi")); -ok(! system("./ikiwiki.out --setup t/tmp/test.setup --rebuild --wrappers")); +thoroughly_rebuild(); # CGI wrapper should be exactly the requested mode (undef, undef, $mode, undef, undef, @@ -550,27 +507,12 @@ like($bits{cgihref}, qr{^(?:(?:https:)?//example.com)?/cgi-bin/ikiwiki.cgi$}); ####################################################################### # site 4 (NetBSD wiki): CGI is secure, static content doesn't have to be -writefile("test.setup", "t/tmp", < 0, + url => "http://example.com/wiki/", + cgiurl => "https://example.com/cgi-bin/ikiwiki.cgi", ); - -ok(unlink("t/tmp/ikiwiki.cgi")); -ok(! system("./ikiwiki.out --setup t/tmp/test.setup --rebuild --wrappers")); +thoroughly_rebuild(); # CGI wrapper should be exactly the requested mode (undef, undef, $mode, undef, undef, @@ -655,27 +597,12 @@ 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$}); -writefile("test.setup", "t/tmp", < 1, + url => "http://example.com/wiki/", + cgiurl => "https://example.com/cgi-bin/ikiwiki.cgi", ); - -ok(unlink("t/tmp/ikiwiki.cgi")); -ok(! system("./ikiwiki.out --setup t/tmp/test.setup --rebuild --wrappers")); +thoroughly_rebuild(); # CGI wrapper should be exactly the requested mode (undef, undef, $mode, undef, undef, @@ -766,26 +693,13 @@ like($bits{cgihref}, qr{^(?:(?:https:)?//example.com)?/cgi-bin/ikiwiki.cgi$}); ####################################################################### # site 5: w3mmode, as documented in [[w3mmode]] -writefile("test.setup", "t/tmp", < 0, + url => undef, + cgiurl => "ikiwiki.cgi", + w3mmode => 1, ); - -ok(unlink("t/tmp/ikiwiki.cgi")); -ok(! system("./ikiwiki.out --setup t/tmp/test.setup --rebuild --wrappers")); +thoroughly_rebuild(); # CGI wrapper should be exactly the requested mode (undef, undef, $mode, undef, undef, @@ -816,26 +730,13 @@ like($bits{cgihref}, qr{^(?:file://)?/\$LIB/ikiwiki-w3m.cgi/ikiwiki.cgi$}); like($bits{basehref}, qr{^(?:(?:file:)?//)?\Q$pwd\E/t/tmp/out/$}); like($bits{stylehref}, qr{^(?:(?:(?:file:)?//)?\Q$pwd\E/t/tmp/out|\.)/style.css$}); -writefile("test.setup", "t/tmp", < 1, + url => undef, + cgiurl => "ikiwiki.cgi", + w3mmode => 1, ); - -ok(unlink("t/tmp/ikiwiki.cgi")); -ok(! system("./ikiwiki.out --setup t/tmp/test.setup --rebuild --wrappers")); +thoroughly_rebuild(); # CGI wrapper should be exactly the requested mode (undef, undef, $mode, undef, undef, @@ -869,28 +770,13 @@ like($bits{stylehref}, qr{^(?:(?:(?:file:)?//)?\Q$pwd\E/t/tmp/out|\.)/style.css$ ####################################################################### # site 6: we're behind a reverse-proxy -writefile("test.setup", "t/tmp", < 0, + url => "https://example.com/wiki/", + cgiurl => "https://example.com/cgi-bin/ikiwiki.cgi", + reverse_proxy => 1, ); - -ok(unlink("t/tmp/ikiwiki.cgi")); -ok(! system("./ikiwiki.out --setup t/tmp/test.setup --rebuild --wrappers")); +thoroughly_rebuild(); # CGI wrapper should be exactly the requested mode (undef, undef, $mode, undef, undef,