X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/dc872e42c8649f5b3fd59861e5c56c89d9fc1cbb..0db1679a3d38bcb6bc0e5f380d07defefff1aabd:/t/relativity.t diff --git a/t/relativity.t b/t/relativity.t index 5922ec9fa..84672fecd 100755 --- a/t/relativity.t +++ b/t/relativity.t @@ -99,6 +99,19 @@ sub check_cgi_mode_bits { is($mode & 07777, 0754); } +sub check_generated_content { + my $cgiurl_regex = shift; + ok(-e "t/tmp/out/a/b/c/index.html"); + $content = readfile("t/tmp/out/a/b/c/index.html"); + # no on static HTML + unlike($content, qr{A: a}); + like($content, qr{
  • B: b
  • }); + like($content, qr{
  • E: e
  • }); +} + ####################################################################### # site 1: a perfectly ordinary ikiwiki @@ -109,17 +122,8 @@ write_setup_file( ); thoroughly_rebuild(); check_cgi_mode_bits(); - -ok(-e "t/tmp/out/a/b/c/index.html"); -$content = readfile("t/tmp/out/a/b/c/index.html"); -# no on static HTML -unlike($content, qr{]+href="/cgi-bin/ikiwiki.cgi\?do=prefs"}); -# cross-links between static pages are relative -like($content, qr{
  • A: a
  • }); -like($content, qr{
  • B: b
  • }); -like($content, qr{
  • E: e
  • }); +check_generated_content(qr{]+href="/cgi-bin/ikiwiki.cgi\?do=prefs"}); run(["./t/tmp/ikiwiki.cgi"], \undef, \$content, init => sub { $ENV{REQUEST_METHOD} = 'GET'; @@ -187,17 +191,8 @@ write_setup_file( ); thoroughly_rebuild(); check_cgi_mode_bits(); - -ok(-e "t/tmp/out/a/b/c/index.html"); -$content = readfile("t/tmp/out/a/b/c/index.html"); -# no on static HTML -unlike($content, qr{]+href="/cgi-bin/ikiwiki.cgi\?do=prefs"}); -# cross-links between static pages are relative -like($content, qr{
  • A: a
  • }); -like($content, qr{
  • B: b
  • }); -like($content, qr{
  • E: e
  • }); +check_generated_content(qr{]+href="/cgi-bin/ikiwiki.cgi\?do=prefs"}); run(["./t/tmp/ikiwiki.cgi"], \undef, \$content, init => sub { $ENV{REQUEST_METHOD} = 'GET'; @@ -268,18 +263,9 @@ write_setup_file( ); thoroughly_rebuild(); check_cgi_mode_bits(); - -ok(-e "t/tmp/out/a/b/c/index.html"); -$content = readfile("t/tmp/out/a/b/c/index.html"); -# no on static HTML -unlike($content, qr{]+href="(?:http:)?//cgi.example.com/ikiwiki.cgi\?do=prefs"}); -# cross-links between static pages are still relative -like($content, qr{
  • A: a
  • }); -like($content, qr{
  • B: b
  • }); -like($content, qr{
  • E: e
  • }); +check_generated_content(qr{]+href="(?:http:)?//cgi.example.com/ikiwiki.cgi\?do=prefs"}); run(["./t/tmp/ikiwiki.cgi"], \undef, \$content, init => sub { $ENV{REQUEST_METHOD} = 'GET'; @@ -336,18 +322,9 @@ write_setup_file( ); thoroughly_rebuild(); check_cgi_mode_bits(); - -ok(-e "t/tmp/out/a/b/c/index.html"); -$content = readfile("t/tmp/out/a/b/c/index.html"); -# no on static HTML -unlike($content, qr{]+href="(?:http:)?//cgi.example.com/ikiwiki.cgi\?do=prefs"}); -# cross-links between static pages are still relative -like($content, qr{
  • A: a
  • }); -like($content, qr{
  • B: b
  • }); -like($content, qr{
  • E: e
  • }); +check_generated_content(qr{]+href="(?:http:)?//cgi.example.com/ikiwiki.cgi\?do=prefs"}); run(["./t/tmp/ikiwiki.cgi"], \undef, \$content, init => sub { $ENV{REQUEST_METHOD} = 'GET'; @@ -408,17 +385,8 @@ write_setup_file( ); thoroughly_rebuild(); check_cgi_mode_bits(); - -ok(-e "t/tmp/out/a/b/c/index.html"); -$content = readfile("t/tmp/out/a/b/c/index.html"); -# no on static HTML -unlike($content, qr{]+href="/cgi-bin/ikiwiki.cgi\?do=prefs"}); -# cross-links between static pages are relative -like($content, qr{
  • A: a
  • }); -like($content, qr{
  • B: b
  • }); -like($content, qr{
  • E: e
  • }); +check_generated_content(qr{]+href="/cgi-bin/ikiwiki.cgi\?do=prefs"}); # when accessed via HTTPS, links are secure run(["./t/tmp/ikiwiki.cgi"], \undef, \$content, init => sub { @@ -496,17 +464,8 @@ write_setup_file( ); thoroughly_rebuild(); check_cgi_mode_bits(); - -ok(-e "t/tmp/out/a/b/c/index.html"); -$content = readfile("t/tmp/out/a/b/c/index.html"); -# no on static HTML -unlike($content, qr{]+href="https://example.com/cgi-bin/ikiwiki.cgi\?do=prefs"}); -# cross-links between static pages are relative -like($content, qr{
  • A: a
  • }); -like($content, qr{
  • B: b
  • }); -like($content, qr{
  • E: e
  • }); +check_generated_content(qr{]+href="https://example.com/cgi-bin/ikiwiki.cgi\?do=prefs"}); # when accessed via HTTPS, links are secure (to avoid mixed-content) run(["./t/tmp/ikiwiki.cgi"], \undef, \$content, init => sub { @@ -581,17 +540,8 @@ write_setup_file( ); thoroughly_rebuild(); check_cgi_mode_bits(); - -ok(-e "t/tmp/out/a/b/c/index.html"); -$content = readfile("t/tmp/out/a/b/c/index.html"); -# no on static HTML -unlike($content, qr{]+href="https://example.com/cgi-bin/ikiwiki.cgi\?do=prefs"}); -# cross-links between static pages are relative -like($content, qr{
  • A: a
  • }); -like($content, qr{
  • B: b
  • }); -like($content, qr{
  • E: e
  • }); +check_generated_content(qr{]+href="https://example.com/cgi-bin/ikiwiki.cgi\?do=prefs"}); # when accessed via HTTPS, links are secure (to avoid mixed-content) run(["./t/tmp/ikiwiki.cgi"], \undef, \$content, init => sub { @@ -673,17 +623,8 @@ write_setup_file( ); thoroughly_rebuild(); check_cgi_mode_bits(); - -ok(-e "t/tmp/out/a/b/c/index.html"); -$content = readfile("t/tmp/out/a/b/c/index.html"); -# no on static HTML -unlike($content, qr{]+href="(?:file://)?/\$LIB/ikiwiki-w3m.cgi/ikiwiki.cgi\?do=prefs"}); -# cross-links between static pages are still relative -like($content, qr{
  • A: a
  • }); -like($content, qr{
  • B: b
  • }); -like($content, qr{
  • E: e
  • }); +check_generated_content(qr{]+href="(?:file://)?/\$LIB/ikiwiki-w3m.cgi/ikiwiki.cgi\?do=prefs"}); run(["./t/tmp/ikiwiki.cgi"], \undef, \$content, init => sub { $ENV{REQUEST_METHOD} = 'GET'; @@ -705,17 +646,8 @@ write_setup_file( ); thoroughly_rebuild(); check_cgi_mode_bits(); - -ok(-e "t/tmp/out/a/b/c/index.html"); -$content = readfile("t/tmp/out/a/b/c/index.html"); -# no on static HTML -unlike($content, qr{]+href="(?:file://)?/\$LIB/ikiwiki-w3m.cgi/ikiwiki.cgi\?do=prefs"}); -# cross-links between static pages are still relative -like($content, qr{
  • A: a
  • }); -like($content, qr{
  • B: b
  • }); -like($content, qr{
  • E: e
  • }); +check_generated_content(qr{]+href="(?:file://)?/\$LIB/ikiwiki-w3m.cgi/ikiwiki.cgi\?do=prefs"}); run(["./t/tmp/ikiwiki.cgi"], \undef, \$content, init => sub { $ENV{REQUEST_METHOD} = 'GET'; @@ -740,17 +672,8 @@ write_setup_file( ); thoroughly_rebuild(); check_cgi_mode_bits(); - -ok(-e "t/tmp/out/a/b/c/index.html"); -$content = readfile("t/tmp/out/a/b/c/index.html"); -# no on static HTML -unlike($content, qr{]+href="/cgi-bin/ikiwiki.cgi\?do=prefs"}); -# cross-links between static pages are relative -like($content, qr{
  • A: a
  • }); -like($content, qr{
  • B: b
  • }); -like($content, qr{
  • E: e
  • }); +check_generated_content(qr{]+href="/cgi-bin/ikiwiki.cgi\?do=prefs"}); # because we are behind a reverse-proxy we must assume that # we're being accessed by the configured cgiurl