- my $res = cgi_run("/test/m/blahblah\@example.com.txt");
- like($res->{body}, qr/Message-Id: <blahblah\@example\.com>/,
- "mid.txt hit");
-
- my $pfx = cgi_run("/prefixed/test/m/blahblah\@example.com.txt");
- is_deeply($pfx, $res, "we do not have to be a top-level URL");
-
- $res = cgi_run("/test/m/blahblah\@example.con.txt");
- like($res->{head}, qr/Status: 404 Not Found/, "mid.txt miss");
-
- $res = cgi_run("/test/m/blahblah\@example.com.html");
- like($res->{body}, qr/\A<html>/, "mid.html hit");
- like($res->{head}, qr/Status: 200 OK/, "200 response");
- $res = cgi_run("/test/m/blahblah\@example.con.html");
- like($res->{head}, qr/Status: 404 Not Found/, "mid.html miss");
-
- $res = cgi_run("/test/f/blahblah\@example.com.html");
- like($res->{body}, qr/\A<html>/, "mid.html hit");
- like($res->{head}, qr/Status: 200 OK/, "200 response");
- $res = cgi_run("/test/f/blahblah\@example.con.html");
- like($res->{head}, qr/Status: 404 Not Found/, "mid.html miss");
+ my $path = "/test/blahblah\@example.com/t.mbox.gz";
+ my $res = cgi_run($path);
+ like($res->{head}, qr/^Status: 501 /, "search not-yet-enabled");
+ my $cmd = ['-index', $ibx->{inboxdir}, '--max-size=2k'];
+ print $cfgfh "\tindexlevel = basic\n" or BAIL_OUT $!;
+ $cfgfh->flush or BAIL_OUT $!;
+ my $opt = { 2 => \(my $err) };
+ my $indexed = run_script($cmd, undef, $opt);
+ if ($indexed) {
+ $res = cgi_run($path);
+ like($res->{head}, qr/^Status: 200 /, "search returned mbox");
+ my $in = $res->{body};
+ my $out;
+ gunzip(\$in => \$out);
+ like($out, qr/^From /m, "From lines in mbox");
+ $res = cgi_run('/test/toobig@example.com/');
+ like($res->{head}, qr/^Status: 300 /,
+ 'did not index or return >max-size message');
+ like($err, qr/skipping [a-f0-9]{40,}/,
+ 'warned about skipping large OID');
+ } else {
+ like($res->{head}, qr/^Status: 501 /, "search not available");
+ skip('DBD::SQLite not available', 7); # (4 - 1) above, 4 below
+ }
+ require_mods('XML::TreePP', 4);
+ $path = "/test/blahblah\@example.com/t.atom";
+ $res = cgi_run($path);
+ like($res->{head}, qr/^Status: 200 /, "atom returned 200");
+ like($res->{head}, qr!^Content-Type: application/atom\+xml!m,
+ "search returned atom");
+ my $t = XML::TreePP->new->parse($res->{body});
+ is(scalar @{$t->{feed}->{entry}}, 3, "parsed three entries");
+ like($t->{feed}->{-xmlns}, qr/\bAtom\b/,
+ 'looks like an an Atom feed');