1 # Copyright (C) 2019-2020 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
7 use PublicInbox::Config;
8 use PublicInbox::TestCommon;
9 my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape DBD::SQLite);
11 use_ok 'PublicInbox::V2Writable';
12 foreach my $mod (@mods) { use_ok $mod; }
13 my ($tmp, $for_destroy) = tmpdir();
16 foreach my $i (1..2) {
17 my $cfgpfx = "publicinbox.test-$i";
18 my $addr = "test-$i\@example.com";
19 my $inboxdir = "$tmp/$i";
20 $cfg .= "$cfgpfx.address=$addr\n";
21 $cfg .= "$cfgpfx.inboxdir=$inboxdir\n";
22 $cfg .= "$cfgpfx.url=http://example.com/$i\n";
24 inboxdir => $inboxdir,
27 indexlevel => 'basic',
28 -primary_address => $addr,
30 my $ibx = PublicInbox::Inbox->new($opt);
31 my $im = PublicInbox::V2Writable->new($ibx, 1);
34 my $mime = PublicInbox::MIME->new(<<EOF);
38 Message-ID: <a-mid-$i\@b>
39 Date: Fri, 02 Oct 1993 00:00:00 +0000
44 ok($im->add($mime), "added message to $i");
47 my $config = PublicInbox::Config->new(\$cfg);
48 use_ok 'PublicInbox::WWW';
49 my $www = PublicInbox::WWW->new($config);
51 test_psgi(sub { $www->call(@_) }, sub {
53 foreach my $i (1..2) {
54 foreach my $end ('', '/') {
55 my $res = $cb->(GET("/a-mid-$i\@b$end"));
56 is($res->code, 302, 'got 302');
57 is($res->header('Location'),
58 "http://example.com/$i/a-mid-$i\@b/",
59 "redirected OK to $i");
62 foreach my $x (qw(inv@lid inv@lid/ i/v/a l/i/d/)) {
63 my $res = $cb->(GET("/$x"));
64 is($res->code, 404, "404 on $x");