2 # Copyright (C) all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
5 use PublicInbox::TestCommon;
7 my @req = qw(URI::Escape DBD::SQLite);
9 require_mods qw(DBD::SQLite psgi);
10 use_ok 'PublicInbox::WWW';
12 foreach my $i (1..2) {
13 my $ibx = create_inbox "test-$i", version => 2, indexlevel => 'basic',
16 $im->add(PublicInbox::Eml->new(<<EOF)) or BAIL_OUT;
18 To: $ibx->{-primary_address}
20 Message-ID: <a-mid-$i\@b>
21 Date: Fri, 02 Oct 1993 00:00:00 +0000
27 [publicinbox "test-$i"]
28 address = $ibx->{-primary_address}
29 inboxdir = $ibx->{inboxdir}
30 url = http://example.com/$i
34 my $www = PublicInbox::WWW->new(cfg_new($tmpdir, $cfgtxt));
36 test_psgi(sub { $www->call(@_) }, sub {
38 foreach my $i (1..2) {
39 foreach my $end ('', '/') {
40 my $res = $cb->(GET("/a-mid-$i\@b$end"));
41 is($res->code, 302, 'got 302');
42 is($res->header('Location'),
43 "http://example.com/$i/a-mid-$i\@b/",
44 "redirected OK to $i");
47 foreach my $x (qw(inv@lid inv@lid/ i/v/a l/i/d/)) {
48 my $res = $cb->(GET("/$x"));
49 is($res->code, 404, "404 on $x");