2 # Copyright (C) 2019-2021 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 use PublicInbox::TestCommon;
8 use PublicInbox::Config;
9 my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape DBD::SQLite);
12 use_ok 'PublicInbox::WWW';
13 foreach my $mod (@mods) { use_ok $mod; }
15 foreach my $i (1..2) {
16 my $ibx = create_inbox "test-$i", version => 2, indexlevel => 'basic',
19 $im->add(PublicInbox::Eml->new(<<EOF)) or BAIL_OUT;
21 To: $ibx->{-primary_address}
23 Message-ID: <a-mid-$i\@b>
24 Date: Fri, 02 Oct 1993 00:00:00 +0000
29 my $cfgpfx = "publicinbox.test-$i";
30 $cfg .= "$cfgpfx.address=$ibx->{-primary_address}\n";
31 $cfg .= "$cfgpfx.inboxdir=$ibx->{inboxdir}\n";
32 $cfg .= "$cfgpfx.url=http://example.com/$i\n";
35 my $www = PublicInbox::WWW->new(PublicInbox::Config->new(\$cfg));
37 test_psgi(sub { $www->call(@_) }, sub {
39 foreach my $i (1..2) {
40 foreach my $end ('', '/') {
41 my $res = $cb->(GET("/a-mid-$i\@b$end"));
42 is($res->code, 302, 'got 302');
43 is($res->header('Location'),
44 "http://example.com/$i/a-mid-$i\@b/",
45 "redirected OK to $i");
48 foreach my $x (qw(inv@lid inv@lid/ i/v/a l/i/d/)) {
49 my $res = $cb->(GET("/$x"));
50 is($res->code, 404, "404 on $x");