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);
12 use_ok 'PublicInbox::V2Writable';
13 foreach my $mod (@mods) { use_ok $mod; }
14 my ($tmp, $for_destroy) = tmpdir();
17 foreach my $i (1..2) {
18 my $cfgpfx = "publicinbox.test-$i";
19 my $addr = "test-$i\@example.com";
20 my $inboxdir = "$tmp/$i";
21 $cfg .= "$cfgpfx.address=$addr\n";
22 $cfg .= "$cfgpfx.inboxdir=$inboxdir\n";
23 $cfg .= "$cfgpfx.url=http://example.com/$i\n";
25 inboxdir => $inboxdir,
28 indexlevel => 'basic',
29 -primary_address => $addr,
31 my $ibx = PublicInbox::Inbox->new($opt);
32 my $im = PublicInbox::V2Writable->new($ibx, 1);
35 my $mime = PublicInbox::Eml->new(<<EOF);
39 Message-ID: <a-mid-$i\@b>
40 Date: Fri, 02 Oct 1993 00:00:00 +0000
45 ok($im->add($mime), "added message to $i");
48 my $config = PublicInbox::Config->new(\$cfg);
49 use_ok 'PublicInbox::WWW';
50 my $www = PublicInbox::WWW->new($config);
52 test_psgi(sub { $www->call(@_) }, sub {
54 foreach my $i (1..2) {
55 foreach my $end ('', '/') {
56 my $res = $cb->(GET("/a-mid-$i\@b$end"));
57 is($res->code, 302, 'got 302');
58 is($res->header('Location'),
59 "http://example.com/$i/a-mid-$i\@b/",
60 "redirected OK to $i");
63 foreach my $x (qw(inv@lid inv@lid/ i/v/a l/i/d/)) {
64 my $res = $cb->(GET("/$x"));
65 is($res->code, 404, "404 on $x");