- my %umap = (
- 'm' => '',
- 'f' => '',
- 't' => 't/',
- );
- while (my ($t, $e) = each %umap) {
- test_psgi($app, sub {
- my ($cb) = @_;
- my $res = $cb->(GET($pfx . "/$t/blah\@example.com.html"));
- is(301, $res->code, "redirect for old $t .html link");
- my $location = $res->header('Location');
- like($location,
- qr!/blah\@example\.com/$e(?:#u)?\z!,
- ".html redirected to new location");
- });
- }
- foreach my $sfx (qw(mbox mbox.gz)) {
- test_psgi($app, sub {
- my ($cb) = @_;
- my $res = $cb->(GET($pfx . "/t/blah\@example.com.$sfx"));
- is(301, $res->code, 'redirect for old thread link');
- my $location = $res->header('Location');
- like($location,
- qr!/blah\@example\.com/t\.mbox(?:\.gz)?\z!,
- "$sfx redirected to /mbox.gz");
- });
- }
+test_psgi($app, sub {
+ my ($cb) = @_;
+ my $path = '/blah@example.com/';
+ my $res = $cb->(GET($pfx . $path));
+ is(200, $res->code, "success for $path");
+ my $html = $res->content;
+ like($html, qr!<title>hihi - Me</title>!, 'HTML returned');
+ like($html, qr!<a\nhref="raw"!s, 'raw link present');
+ like($html, qr!> quoted text!s, 'quoted text inline');
+
+ $path .= 'f/';
+ $res = $cb->(GET($pfx . $path));
+ is(301, $res->code, "redirect for $path");
+ my $location = $res->header('Location');
+ like($location, qr!/blah\@example\.com/\z!,
+ '/$MESSAGE_ID/f/ redirected to /$MESSAGE_ID/');
+
+ $res = $cb->(GET($pfx . '/multipart@example.com/'));
+ like($res->content,
+ qr/hi\n.*-- Attachment #2.*\nbye\n/s, 'multipart split');
+
+ $res = $cb->(GET($pfx . '/patch@example.com/'));
+ $html = $res->content;
+ like($html, qr!see attached!, 'original body');
+ like($html, qr!.*Attachment #2: foo&(?:amp|#38);\.patch --!,
+ 'parts split with filename');
+
+ $res = $cb->(GET($pfx . '/qp@example.com/'));
+ like($res->content, qr/\bhi = bye\b/, "HTML output decoded QP");
+});
+
+test_psgi($app, sub {
+ my ($cb) = @_;
+ my $res = $cb->(GET($pfx . '/blah@example.com/raw'));
+ is(200, $res->code, 'success response received for /*/raw');
+ like($res->content, qr!^From !sm, "mbox returned");
+
+ $res = $cb->(GET($pfx . '/blah@example.com/t.mbox.gz'));
+ is(501, $res->code, '501 when overview missing');
+ like($res->content, qr!\bOverview\b!, 'overview omission noted');
+});
+
+# legacy redirects
+foreach my $t (qw(m f)) {