- # legacy redirects
- foreach my $t (qw(m f)) {
- test_psgi($app, sub {
- my ($cb) = @_;
- my $res = $cb->(GET($pfx . "/$t/blah\@example.com.txt"));
- is(301, $res->code, "redirect for old $t .txt link");
- my $location = $res->header('Location');
- like($location, qr!/blah\@example\.com/raw\z!,
- ".txt redirected to /raw");
- });
- }
-
- 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 $atomurl = 'http://example.com/test/new.atom';
+ my $res = $cb->(GET('http://example.com/test/new.html'));
+ is(200, $res->code, 'success response received');
+ like($res->content, qr!href="new\.atom"!,
+ 'atom URL generated');
+ like($res->content, qr!href="blah\@example\.com/"!,
+ 'index generated');
+ like($res->content, qr!1993-10-02!, 'date set');
+});
+
+test_psgi($app, sub {
+ my ($cb) = @_;
+ my $res = $cb->(GET($pfx . '/atom.xml'));
+ is(200, $res->code, 'success response received for atom');
+ my $body = $res->content;
+ like($body, qr!link\s+href="\Q$pfx\E/blah\@example\.com/"!s,
+ 'atom feed generated correct URL');
+ like($body, qr/<title>test for public-inbox/,
+ "set title in XML feed");
+ like($body, qr/zzzzzz/, 'body included');
+});
+
+test_psgi($app, sub {
+ my ($cb) = @_;
+ my $path = '/blah@example.com/';
+ my $res = $cb->(GET($pfx . $path));
+ is(200, $res->code, "success for $path");
+ like($res->content, qr!<title>hihi - Me</title>!,
+ "HTML returned");
+
+ $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/');
+});
+
+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");
+});
+
+# legacy redirects
+foreach my $t (qw(m f)) {