]> Sergey Matveev's repositories - public-inbox.git/blob - t/psgi_multipart_not.t
treewide: run update-copyrights from gnulib for 2019
[public-inbox.git] / t / psgi_multipart_not.t
1 # Copyright (C) 2018-2020 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3 use strict;
4 use warnings;
5 use Test::More;
6 use Email::MIME;
7 use PublicInbox::Config;
8 use PublicInbox::TestCommon;
9 my @mods = qw(DBD::SQLite Search::Xapian HTTP::Request::Common
10               Plack::Test URI::Escape Plack::Builder Plack::Test);
11 require_mods(@mods);
12 use_ok($_) for (qw(HTTP::Request::Common Plack::Test));
13 use_ok 'PublicInbox::WWW';
14 use_ok 'PublicInbox::V2Writable';
15 my ($repo, $for_destroy) = tmpdir();
16 my $ibx = PublicInbox::Inbox->new({
17         inboxdir => $repo,
18         name => 'multipart-not',
19         version => 2,
20         -primary_address => 'test@example.com',
21 });
22 my $im = PublicInbox::V2Writable->new($ibx, 1);
23 $im->{parallel} = 0;
24
25 my $mime = PublicInbox::MIME->new(<<'EOF');
26 Message-Id: <200308111450.h7BEoOu20077@mail.osdl.org>
27 To: linux-kernel@vger.kernel.org
28 Subject: [OSDL] linux-2.6.0-test3 reaim results
29 Mime-Version: 1.0
30 Content-Type: multipart/mixed ;
31         boundary="==_Exmh_120757360"
32 Date: Mon, 11 Aug 2003 07:50:24 -0700
33 From: exmh user <x@example.com>
34
35 Freed^Wmultipart ain't what it used to be
36 EOF
37
38 ok($im->add($mime), 'added broken multipart message');
39 $im->done;
40
41 my $cfgpfx = "publicinbox.v2test";
42 my $cfg = <<EOF;
43 $cfgpfx.address=$ibx->{-primary_address}
44 $cfgpfx.inboxdir=$repo
45 EOF
46 my $config = PublicInbox::Config->new(\$cfg);
47 my $www = PublicInbox::WWW->new($config);
48
49 my ($res, $raw);
50 test_psgi(sub { $www->call(@_) }, sub {
51         my ($cb) = @_;
52         for my $u ('/v2test/?q=%22ain\'t what it used to be%22&x=t',
53                    '/v2test/new.atom', '/v2test/new.html') {
54                 $res = $cb->(GET($u));
55                 $raw = $res->content;
56                 ok(index($raw, 'Freed^Wmultipart') >= 0, $u);
57                 ok(index($raw, 'Warning: decoded text') >= 0, $u.' warns');
58         }
59 });
60
61 done_testing();
62 1;