App-Phoebe

 view release on metacpan or  search on metacpan

t/spaces.t  view on Meta::CPAN

# redirect of reserved word
$page = query_gemini("$base/alex/do");
is($page, "31 $base/alex\r\n", "Redirect reserved word");

# upload

my $titan = "titan://$host:$port";

my $haiku = <<EOT;
Outside children shout
Everybody is running
Recess is the best
EOT

$page = query_gemini("$titan/alex/raw/Haiku;size=63;mime=text/plain;token=hello", $haiku);
like($page, qr/^30 $base\/alex\/page\/Haiku\r$/, "Titan Haiku");

$page = query_gemini("$base/alex/page/Haiku");
like($page, qr/^20 text\/gemini; charset=UTF-8\r\n# Haiku\n$haiku/, "Haiku saved");

$page = query_gemini("$base/page/Haiku");
like($page, qr/^This page does not yet exist/m, "Haiku page is empty in the main space");

ok(-f "$dir/alex/page/Haiku.gmi", "alex/page/Haiku.gmi exists");
ok(-f "$dir/alex/changes.log", "alex/changes.log exists");
ok(-f "$dir/alex/index", "alex/index exists");

$page = query_gemini("$base/alex/do/match?Haiku");
like($page, qr/^=> $base\/alex\/page\/Haiku Haiku/m, "Haiku found by name match");

$page = query_gemini("$base/alex/do/search?Schroeder");
like($page, qr/Search term not found/, "Alex not found in the alex space");
$page = query_gemini("$base/alex/do/search?Everybody");
like($page, qr/^=> $base\/alex\/page\/Haiku Haiku/m, "Haiku found in the alex space");

$page = query_gemini("$base/do/search?Schroeder");
like($page, qr/^=> $base\/page\/Alex Alex/m, "Alex found in the main space");

$page = query_gemini("$base/alex/history/Haiku");
like($page, qr/^=> $base\/alex\/page\/Haiku Haiku \(current\)/m, "Current version of Haiku found in the alex space history");

$page = query_gemini("$base/alex/do/changes");
like($page, qr/^=> $base\/alex\/page\/Haiku Haiku/m, "Haiku found in the alex space changes");

$page = query_gemini("$base/alex/do/rss");
like($page, qr/<link>$base\/alex\/page\/Haiku<\/link>/, "Haiku found in the alex space RSS feed");

$page = query_gemini("$base/alex/do/atom");
like($page, qr/<link href="$base\/alex\/page\/Haiku"\/>/, "Haiku found in the alex space Atom feed");

$page = query_gemini("$base/do/all/changes");
like($page, qr/^=> $base\/page\/Alex Alex/m, "Alex found in unified changes");
like($page, qr/^=> $base\/alex\/page\/Haiku/m, "Haiku found in unified changes");

$page = query_gemini("$base/do/spaces");
like($page, qr/^=> $base\/alex\/ alex/m, "Space alex found");

# add a special token to the alex space via config file

open(my $config, ">", "$dir/config"); # overwrite
say $config 'package App::Phoebe;';
say $config 'use Modern::Perl;';
say $config 'our ($server);';
say $config '$server->{wiki_space_token}->{alex} = ["*secret*"];';
say $config '$server->{wiki_token} = [];';
close($config);
is(kill('HUP', $pid), 1, "Restarted server");
sleep 1;

$haiku = <<EOT;
Rattling keys and quiet
Fingers hover in the air
Outside, a full moon
EOT

$page = query_gemini("$titan/alex/raw/Haiku;size=70;mime=text/plain;token=hello", $haiku);
# in this situation the client simply returns undef!?
# like($page, /^59 Your token is the wrong token\r$/, "Can no longer save");
$page = query_gemini("$base/alex/page/Haiku");
like($page, qr/Outside children shout/, "Save with old token failed");

$page = query_gemini("$titan/alex/raw/Haiku;size=70;mime=text/plain;token=*secret*", $haiku);
like($page, qr/^30 $base\/alex\/page\/Haiku\r$/, "Titan Haiku");

done_testing();



( run in 0.664 second using v1.01-cache-2.11-cpan-364913b4093 )