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