MANIFEST | 12 ++++++++++++
lib/PublicInbox/TestCommon.pm | 23 +++--------------------
t/filter_base-junk.eml | 19 +++++++++++++++++++
t/filter_base-xhtml.eml | 19 +++++++++++++++++++
t/filter_base.t | 53 ++---------------------------------------------------
t/filter_mirror.t | 27 +--------------------------
t/mda-mime.eml | 21 +++++++++++++++++++++
t/mda.t | 34 ++--------------------------------
t/msg_iter-nested.eml | 26 ++++++++++++++++++++++++++
t/msg_iter-order.eml | 16 ++++++++++++++++
t/msg_iter.t | 17 ++---------------
t/plack-2-txt-bodies.eml | 17 +++++++++++++++++
t/plack-attached-patch.eml | 20 ++++++++++++++++++++
t/plack-qp.eml | 8 ++++++++
t/plack.t | 57 +++--------------------------------------------------
t/psgi_attach.eml | 38 ++++++++++++++++++++++++++++++++++++++
t/psgi_attach.t | 37 +------------------------------------
t/psgi_v2-new.eml | 17 +++++++++++++++++
t/psgi_v2-old.eml | 17 +++++++++++++++++
t/psgi_v2.t | 23 ++---------------------
t/search-amsg.eml | 23 +++++++++++++++++++++++
t/search.t | 34 ++--------------------------------
diff --git a/MANIFEST b/MANIFEST
index b06aa67960ad01068707c05264279d7ec030c53f..e3e0f2a886e8bf9183eaa9c8ce67cec7cae22c2a 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -231,6 +231,8 @@ t/emergency.t
t/epoll.t
t/fail-bin/spamc
t/feed.t
+t/filter_base-junk.eml
+t/filter_base-xhtml.eml
t/filter_base.t
t/filter_mirror.t
t/filter_rubylang.t
@@ -257,10 +259,13 @@ t/init.t
t/iso-2202-jp.eml
t/linkify.t
t/main-bin/spamc
+t/mda-mime.eml
t/mda.t
t/mda_filter_rubylang.t
t/mid.t
t/mime.t
+t/msg_iter-nested.eml
+t/msg_iter-order.eml
t/msg_iter.t
t/msgmap.t
t/msgtime.t
@@ -270,8 +275,12 @@ t/nntpd-tls.t
t/nntpd.t
t/nulsubject.t
t/over.t
+t/plack-2-txt-bodies.eml
+t/plack-attached-patch.eml
+t/plack-qp.eml
t/plack.t
t/precheck.t
+t/psgi_attach.eml
t/psgi_attach.t
t/psgi_bad_mids.t
t/psgi_mount.t
@@ -279,12 +288,15 @@ t/psgi_multipart_not.t
t/psgi_scan_all.t
t/psgi_search.t
t/psgi_text.t
+t/psgi_v2-new.eml
+t/psgi_v2-old.eml
t/psgi_v2.t
t/purge.t
t/qspawn.t
t/replace.t
t/reply.t
t/run.perl
+t/search-amsg.eml
t/search-thr-index.t
t/search.t
t/sigfd.t
diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index ac14d27bc87b9ba406edd22eb475f704a8dabc39..27390ab2f52e80f59d68bf7486edd233c61047ad 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -11,27 +11,10 @@ use IO::Socket::INET;
our @EXPORT = qw(tmpdir tcp_server tcp_connect require_git require_mods
run_script start_script key2sub xsys xqx mime_load);
-sub mime_load ($;&) {
+sub mime_load ($) {
my ($path, $cb) = @_;
- if (open(my $fh, '<', $path)) {
- PublicInbox::MIME->new(\(do { local $/; <$fh> }));
- } elsif ($cb) {
- require File::Temp;
-
- my $mime = $cb->();
- my ($dir) = ($path =~ m!(.+)/(?:[^/]+)\z!);
- -d $dir or die "BUG: dir=$dir is not the dir of $path";
- my $fh = File::Temp->new(DIR => $dir);
- $fh->autoflush(1);
- print $fh $mime->as_string or die "print: $!";
- my $fn = $fh->filename;
- rename($fn, $path) or die "link $fn => $path: $!";
- $fh->unlink_on_destroy(0);
- pop @_; # retry via tail recursion
- goto &mime_load;
- } else {
- die "open $path: $!";
- }
+ open(my $fh, '<', $path) or die "open $path: $!";
+ PublicInbox::MIME->new(\(do { local $/; <$fh> }));
}
sub tmpdir (;$) {
diff --git a/t/filter_base-junk.eml b/t/filter_base-junk.eml
new file mode 100644
index 0000000000000000000000000000000000000000..4733bbe573acb1196c40c0c19eadbafc57584262
--- /dev/null
+++ b/t/filter_base-junk.eml
@@ -0,0 +1,19 @@
+From: a@example.com
+Subject: blah
+Content-Type: multipart/mixed; boundary="b"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+
+--b
+Content-Type: application/vnd.ms-excel
+Content-Transfer-Encoding: base64
+
+anVuaw==
+
+--b
+Content-Type: text/plain
+Content-Transfer-Encoding: quoted-printable
+
+junk=
+
+--b--
diff --git a/t/filter_base-xhtml.eml b/t/filter_base-xhtml.eml
new file mode 100644
index 0000000000000000000000000000000000000000..d13a11cdc14f72e568031d356a3b054fff7bdd9f
--- /dev/null
+++ b/t/filter_base-xhtml.eml
@@ -0,0 +1,19 @@
+From: a@example.com
+Subject: blah
+Content-Type: multipart/alternative; boundary="b"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+
+--b
+Content-Type: text/xhtml; charset=UTF-8
+Content-Transfer-Encoding: base64
+
+PGh0bWw+PGJvZHk+aGk8L2JvZHk+PC9odG1sPg==
+
+--b
+Content-Type: text/plain
+Content-Transfer-Encoding: quoted-printable
+
+hi =3D "bye"=
+
+--b--
diff --git a/t/filter_base.t b/t/filter_base.t
index 7919dd65098e0309662a2f7b7fec70bc9035376f..bbd64189fb5fa2a2484d100bd6a3035708ecade0 100644
--- a/t/filter_base.t
+++ b/t/filter_base.t
@@ -21,62 +21,13 @@ }
{
my $f = PublicInbox::Filter::Base->new;
- my $email = mime_load 't/filter_base-xhtml.eml', sub {
- my $html_body = "
hi";
- my $parts = [
- Email::MIME->create(
- attributes => {
- content_type => 'text/xhtml; charset=UTF-8',
- encoding => 'base64',
- },
- body => $html_body,
- ),
- Email::MIME->create(
- attributes => {
- content_type => 'text/plain',
- encoding => 'quoted-printable',
- },
- body => 'hi = "bye"',
- )
- ];
- Email::MIME->create(
- header_str => [
- From => 'a@example.com',
- Subject => 'blah',
- 'Content-Type' => 'multipart/alternative'
- ],
- parts => $parts,
- )}; # mime_load sub
+ my $email = mime_load 't/filter_base-xhtml.eml';
is($f->delivery($email), 100, "xhtml rejected");
}
{
my $f = PublicInbox::Filter::Base->new;
- my $email = mime_load 't/filter_base-junk.eml', sub {
- my $parts = [
- Email::MIME->create(
- attributes => {
- content_type => 'application/vnd.ms-excel',
- encoding => 'base64',
- },
- body => 'junk',
- ),
- Email::MIME->create(
- attributes => {
- content_type => 'text/plain',
- encoding => 'quoted-printable',
- },
- body => 'junk',
- )
- ];
- Email::MIME->create(
- header_str => [
- From => 'a@example.com',
- Subject => 'blah',
- 'Content-Type' => 'multipart/mixed'
- ],
- parts => $parts,
- )}; # mime_load sub
+ my $email = mime_load 't/filter_base-junk.eml';
is($f->delivery($email), 100, 'proprietary format rejected on glob');
}
diff --git a/t/filter_mirror.t b/t/filter_mirror.t
index 694209d9e07076f5e404d1ade759ccd58886f9f4..0e641a03ca61544a7abfacf8d238d3084acaaade 100644
--- a/t/filter_mirror.t
+++ b/t/filter_mirror.t
@@ -9,32 +9,7 @@
my $f = PublicInbox::Filter::Mirror->new;
ok($f, 'created PublicInbox::Filter::Mirror object');
{
- my $email = mime_load 't/filter_mirror.eml', sub {
- my $html_body = "hi";
- my $parts = [
- Email::MIME->create(
- attributes => {
- content_type => 'text/html; charset=UTF-8',
- encoding => 'base64',
- },
- body => $html_body,
- ),
- Email::MIME->create(
- attributes => {
- content_type => 'text/plain',
- encoding => 'quoted-printable',
- },
- body => 'hi = "bye"',
- )
- ];
- Email::MIME->create(
- header_str => [
- From => 'a@example.com',
- Subject => 'blah',
- 'Content-Type' => 'multipart/alternative'
- ],
- parts => $parts,
- )}; # mime_laod sub
+ my $email = mime_load 't/mda-mime.eml';
is($f->ACCEPT, $f->delivery($email), 'accept any trash that comes');
}
diff --git a/t/mda-mime.eml b/t/mda-mime.eml
new file mode 100644
index 0000000000000000000000000000000000000000..64a92816094e3d536ceffd2a2c8942246b5da9b2
--- /dev/null
+++ b/t/mda-mime.eml
@@ -0,0 +1,21 @@
+From: a@example.com
+Subject: blah
+Cc: test-public@example.com
+Message-ID:
+Content-Type: multipart/alternative; boundary="b"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+
+--b
+Content-Type: text/html; charset=UTF-8
+Content-Transfer-Encoding: base64
+
+PGh0bWw+PGJvZHk+aGk8L2JvZHk+PC9odG1sPg==
+
+--b
+Content-Type: text/plain
+Content-Transfer-Encoding: quoted-printable
+
+hi =3D "bye"=
+
+--b--
diff --git a/t/mda.t b/t/mda.t
index 5457f17f3cde72e2186f48c079715564114a3bb6..863eaf8fe2dda3d3316b84ddb3737b379efebcce 100644
--- a/t/mda.t
+++ b/t/mda.t
@@ -3,7 +3,6 @@ # License: AGPL-3.0+
use strict;
use warnings;
use Test::More;
-use Email::MIME;
use Cwd qw(getcwd);
use PublicInbox::MID qw(mid2path);
use PublicInbox::Git;
@@ -22,7 +21,6 @@ my $fail_path = "$fail_bin:$ENV{PATH}"; # for spamc spam mock
my $addr = 'test-public@example.com';
my $cfgpfx = "publicinbox.test";
my $faildir = "$home/faildir/";
-my $mime;
my $git = PublicInbox::Git->new($maindir);
my $fail_bad_header = sub ($$$) {
@@ -233,36 +231,8 @@ ok(run_script(['-learn', 'ham'], undef, { 0 => \$in }),
"learned ham idempotently ");
# ensure trained email is filtered, too
- $mime = mime_load 't/mda-mime.eml', sub {
- my $html_body = "hi";
- my $parts = [
- Email::MIME->create(
- attributes => {
- content_type => 'text/html; charset=UTF-8',
- encoding => 'base64',
- },
- body => $html_body,
- ),
- Email::MIME->create(
- attributes => {
- content_type => 'text/plain',
- encoding => 'quoted-printable',
- },
- body => 'hi = "bye"',
- )
- ];
- $mid = 'multipart-html-sucks@11';
- Email::MIME->create(
- header_str => [
- From => 'a@example.com',
- Subject => 'blah',
- Cc => $addr,
- 'Message-ID' => "<$mid>",
- 'Content-Type' => 'multipart/alternative',
- ],
- parts => $parts,
- )}; # mime_load sub
-
+ my $mime = mime_load 't/mda-mime.eml';
+ ($mid) = ($mime->header_raw('message-id') =~ /<([^>]+)>/);
{
$in = $mime->as_string;
ok(run_script(['-learn', 'ham'], undef, { 0 => \$in }),
diff --git a/t/msg_iter-nested.eml b/t/msg_iter-nested.eml
new file mode 100644
index 0000000000000000000000000000000000000000..08d0adac4e82ab8a8427360522361044b3c7a64f
--- /dev/null
+++ b/t/msg_iter-nested.eml
@@ -0,0 +1,26 @@
+From: root@localhost
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: multipart/mixed; boundary="outer"
+
+--outer
+From: sub@localhost
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: multipart/mixed; boundary="inner"
+
+--inner
+MIME-Version: 1.0
+
+a
+--inner
+MIME-Version: 1.0
+
+b
+--inner--
+
+--outer
+MIME-Version: 1.0
+
+sig
+--outer--
diff --git a/t/msg_iter-order.eml b/t/msg_iter-order.eml
new file mode 100644
index 0000000000000000000000000000000000000000..153af800c9c7b5fbf1c25da659a777235883e831
--- /dev/null
+++ b/t/msg_iter-order.eml
@@ -0,0 +1,16 @@
+From: root@localhost
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: multipart/mixed; boundary="b"
+
+--b
+MIME-Version: 1.0
+
+a
+
+--b
+MIME-Version: 1.0
+
+b
+
+--b--
diff --git a/t/msg_iter.t b/t/msg_iter.t
index ac2066a2780d8d4fd7acb09a242633ae1863a183..6adbf165b0713268cfb87bf73c9b7b9d7c45d1a9 100644
--- a/t/msg_iter.t
+++ b/t/msg_iter.t
@@ -9,12 +9,7 @@ use PublicInbox::InboxWritable;
use_ok('PublicInbox::MsgIter');
{
- my $mime = mime_load 't/msg_iter-order.eml', sub {
- my $parts = [ Email::MIME->create(body => "a\n"),
- Email::MIME->create(body => "b\n") ];
- Email::MIME->create(parts => $parts,
- header_str => [ From => 'root@localhost' ]);
- }; # mime_load sub
+ my $mime = mime_load 't/msg_iter-order.eml';
my @parts;
msg_iter($mime, sub {
my ($part, $level, @ex) = @{$_[0]};
@@ -26,15 +21,7 @@ is_deeply(\@parts, [ [ qw(a 1 1) ], [ qw(b 1 2) ] ], 'order is fine');
}
{
- my $mime = mime_load 't/msg_iter-nested.eml', sub {
- my $parts = [ Email::MIME->create(body => 'a'),
- Email::MIME->create(body => 'b') ];
- $parts = [ Email::MIME->create(parts => $parts,
- header_str => [ From => 'sub@localhost' ]),
- Email::MIME->create(body => 'sig') ];
- Email::MIME->create(parts => $parts,
- header_str => [ From => 'root@localhost' ]);
- }; # mime_load sub
+ my $mime = mime_load 't/msg_iter-nested.eml';
my @parts;
msg_iter($mime, sub {
my ($part, $level, @ex) = @{$_[0]};
diff --git a/t/plack-2-txt-bodies.eml b/t/plack-2-txt-bodies.eml
new file mode 100644
index 0000000000000000000000000000000000000000..a06cd6888e9853bee2f25f7dfe52c62d5aab1a62
--- /dev/null
+++ b/t/plack-2-txt-bodies.eml
@@ -0,0 +1,17 @@
+From: a@example.com
+Subject: blargh
+Message-ID:
+In-Reply-To:
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: multipart/mixed; boundary="b"
+
+--b
+Content-Type: text/plain
+
+hi
+--b
+Content-Type: text/plain
+
+bye
+--b--
diff --git a/t/plack-attached-patch.eml b/t/plack-attached-patch.eml
new file mode 100644
index 0000000000000000000000000000000000000000..bc6d295dcf4098e31ec3d7b49f48c84e1595af4c
--- /dev/null
+++ b/t/plack-attached-patch.eml
@@ -0,0 +1,20 @@
+From: a@example.com
+Subject: [PATCH] asdf
+Message-ID:
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: multipart/mixed; boundary="b"
+
+--b
+Content-Type: text/plain
+
+hi, see attached
+--b
+Content-Type: text/plain
+Content-Disposition: inline; filename="foo&.patch"
+
+--- a/file
++++ b/file
+@@ -49, 7 +49,34 @@
+
+--b--
diff --git a/t/plack-qp.eml b/t/plack-qp.eml
new file mode 100644
index 0000000000000000000000000000000000000000..d9008c8e1b92e41de4a6dfc6f48be17124fdb253
--- /dev/null
+++ b/t/plack-qp.eml
@@ -0,0 +1,8 @@
+From: qp@example.com
+Subject: QP
+Message-ID:
+MIME-Version: 1.0
+Content-Transfer-Encoding: quoted-printable
+Content-Type: text/plain
+
+hi =3D bye=
diff --git a/t/plack.t b/t/plack.t
index d45dbcd2085b2a286625a43299fd7ff359d4f87b..4fff977352b567671bc562934ff8018bc0d98190 100644
--- a/t/plack.t
+++ b/t/plack.t
@@ -3,7 +3,6 @@ # License: AGPL-3.0+
use strict;
use warnings;
use Test::More;
-use Email::MIME;
use PublicInbox::TestCommon;
my $psgi = "./examples/public-inbox.psgi";
my ($tmpdir, $for_destroy) = tmpdir();
@@ -51,65 +50,15 @@ @ls = $git->qx(qw(ls-tree -r --name-only HEAD));
chomp @ls;
# multipart with two text bodies
- my %attr_text = (attributes => { content_type => 'text/plain' });
- $mime = mime_load 't/plack-2-txt-bodies.eml', sub {
- my $parts = [
- Email::MIME->create(%attr_text, body => 'hi'),
- Email::MIME->create(%attr_text, body => 'bye')
- ];
- Email::MIME->create(
- header_str => [
- From => 'a@example.com',
- Subject => 'blargh',
- 'Message-ID' => '',
- 'In-Reply-To' => ''
- ],
- parts => $parts,
- )}; # mime_load sub
+ $mime = mime_load 't/plack-2-txt-bodies.eml';
$im->add($mime);
# multipart with attached patch + filename
- $mime = mime_load 't/plack-attached-patch.eml', sub {
- my $parts = [
- Email::MIME->create(%attr_text, body => 'hi, see attached'),
- Email::MIME->create(
- attributes => {
- content_type => 'text/plain',
- filename => "foo&.patch",
- },
- body => "--- a/file\n+++ b/file\n" .
- "@@ -49, 7 +49,34 @@\n"
- )
- ];
- Email::MIME->create(
- header_str => [
- From => 'a@example.com',
- Subject => '[PATCH] asdf',
- 'Message-ID' => ''
- ],
- parts => $parts
- )}; # mime_load sub
+ $mime = mime_load 't/plack-attached-patch.eml';
$im->add($mime);
# multipart collapsed to single quoted-printable text/plain
- $mime = mime_load 't/plack-qp.eml', sub {
- my $parts = [
- Email::MIME->create(
- attributes => {
- content_type => 'text/plain',
- encoding => 'quoted-printable'
- },
- body => 'hi = bye',
- )
- ];
- Email::MIME->create(
- header_str => [
- From => 'qp@example.com',
- Subject => 'QP',
- 'Message-ID' => '',
- ],
- parts => $parts,
- )};
+ $mime = mime_load 't/plack-qp.eml';
like($mime->body_raw, qr/hi =3D bye=/, 'our test used QP correctly');
$im->add($mime);
diff --git a/t/psgi_attach.eml b/t/psgi_attach.eml
new file mode 100644
index 0000000000000000000000000000000000000000..cfa3622cbeffc9bd6b0fc66c4d60d420ba74f60d
--- /dev/null
+++ b/t/psgi_attach.eml
@@ -0,0 +1,38 @@
+From: root@z
+Message-Id:
+Subject: hi
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: multipart/mixed; boundary="b"
+
+--b
+Content-Type: text/plain
+Content-Transfer-Encoding: quoted-printable
+Content-Disposition: inline; filename="queue-pee"
+
+abcdef=3Dg
+=3D=3Dblah
+
+--b
+Content-Type: appication/octet-stream
+Content-Transfer-Encoding: base64
+Content-Disposition: inline; filename="bayce-sixty-four"
+
+YjY03q2+7wo=
+
+--b
+Content-Type: text/plain
+Content-Disposition: inline; filename="noop.txt"
+
+plain
+text
+pass
+through
+
+--b
+Content-Type: text/plain
+Content-Disposition: inline; filename=".dotfile"
+
+dotfile
+
+--b--
diff --git a/t/psgi_attach.t b/t/psgi_attach.t
index 0dde9323dc3943a265284be192abf63022caa48b..af0fbdd397727db319759e3906825906dc4577e7 100644
--- a/t/psgi_attach.t
+++ b/t/psgi_attach.t
@@ -3,7 +3,6 @@ # License: AGPL-3.0+
use strict;
use warnings;
use Test::More;
-use Email::MIME;
use PublicInbox::TestCommon;
my ($tmpdir, $for_destroy) = tmpdir();
my $maindir = "$tmpdir/main.git";
@@ -30,41 +29,7 @@ my $qp = "abcdef=g\n==blah\n";
my $b64 = "b64\xde\xad\xbe\xef\n";
my $txt = "plain\ntext\npass\nthrough\n";
my $dot = "dotfile\n";
- my $mime = mime_load 't/psgi_attach.eml', sub {
- my $parts = [
- Email::MIME->create(
- attributes => {
- filename => 'queue-pee',
- content_type => 'text/plain',
- encoding => 'quoted-printable'
- },
- body => $qp),
- Email::MIME->create(
- attributes => {
- filename => 'bayce-sixty-four',
- content_type => 'appication/octet-stream',
- encoding => 'base64',
- },
- body => $b64),
- Email::MIME->create(
- attributes => {
- filename => 'noop.txt',
- content_type => 'text/plain',
- },
- body => $txt),
- Email::MIME->create(
- attributes => {
- filename => '.dotfile',
- content_type => 'text/plain',
- },
- body => $dot),
- ];
- Email::MIME->create(
- parts => $parts,
- header_str => [ From => 'root@z', 'Message-Id' => '',
- Subject => 'hi']
- )}; # mime_load sub
- $im->add($mime);
+ $im->add(mime_load('t/psgi_attach.eml'));
$im->done;
my $www = PublicInbox::WWW->new($config);
diff --git a/t/psgi_v2-new.eml b/t/psgi_v2-new.eml
new file mode 100644
index 0000000000000000000000000000000000000000..2c264714673cc7096a1af085afe9425c9d0345e6
--- /dev/null
+++ b/t/psgi_v2-new.eml
@@ -0,0 +1,17 @@
+From: root@z
+Message-ID:
+Subject: hi
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: multipart/mixed; boundary="b"
+
+--b
+Content-Type: text/plain
+
+blah
+--b
+Content-Type: text/plain
+Content-Disposition: inline; filename="attach.txt"
+
+new
+--b--
diff --git a/t/psgi_v2-old.eml b/t/psgi_v2-old.eml
new file mode 100644
index 0000000000000000000000000000000000000000..f82dbf2f6be25aa96d42bae2bd2cf9dcb9a9d01b
--- /dev/null
+++ b/t/psgi_v2-old.eml
@@ -0,0 +1,17 @@
+From: root@z
+Message-ID:
+Subject: hi
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: multipart/mixed; boundary="b"
+
+--b
+Content-Type: text/plain
+
+blah
+--b
+Content-Type: text/plain
+Content-Disposition: inline; filename="attach.txt"
+
+old
+--b--
diff --git a/t/psgi_v2.t b/t/psgi_v2.t
index 5d212ca6f7ca1bb126bef8f92d02123f01789891..9c19b0413dd1f0c20b61e58ea21c751006b88c9f 100644
--- a/t/psgi_v2.t
+++ b/t/psgi_v2.t
@@ -9,7 +9,7 @@ use PublicInbox::MIME;
use PublicInbox::Config;
use PublicInbox::MID qw(mids);
require_mods(qw(DBD::SQLite Search::Xapian HTTP::Request::Common Plack::Test
- URI::Escape Plack::Builder Email::MIME));
+ URI::Escape Plack::Builder));
use_ok($_) for (qw(HTTP::Request::Common Plack::Test));
use_ok 'PublicInbox::WWW';
use_ok 'PublicInbox::V2Writable';
@@ -225,26 +225,7 @@ is($res->code, 404, 'v2 git URL w/o shard fails');
# ensure conflicted attachments can be resolved
foreach my $body (qw(old new)) {
- $mime = mime_load "t/psgi_v2-$body.eml", sub {
- my $parts = [
- Email::MIME->create(
- attributes => { content_type => 'text/plain' },
- body => 'blah',
- ),
- Email::MIME->create(
- attributes => {
- filename => 'attach.txt',
- content_type => 'text/plain',
- },
- body => $body
- )
- ];
- Email::MIME->create(
- parts => $parts,
- header_str => [ From => 'root@z',
- 'Message-ID' => '',
- Subject => 'hi']
- )}; # mime_load sub
+ $mime = mime_load "t/psgi_v2-$body.eml";
ok($im->add($mime), "added attachment $body");
}
$im->done;
diff --git a/t/search-amsg.eml b/t/search-amsg.eml
new file mode 100644
index 0000000000000000000000000000000000000000..c87c0f1517b388b719b9ee94b2df5346dc839c35
--- /dev/null
+++ b/t/search-amsg.eml
@@ -0,0 +1,23 @@
+Subject: see attachment
+Message-ID:
+From: "John Smith"
+To: list@example.com
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Content-Type: multipart/mixed; boundary="b"
+
+--b
+Content-Type: text/plain; charset="US-ASCII"
+Content-Transfer-Encoding: quoted-printable
+Content-Disposition: attachment; filename="attached_fart.txt"
+
+inside the attachment=
+
+--b
+Content-Type: text/plain; charset="US-ASCII"
+Content-Disposition: attachment; filename="part_deux.txt"
+Content-Transfer-Encoding: quoted-printable
+
+inside another=
+
+--b--
diff --git a/t/search.t b/t/search.t
index 0301fd90b6289f379063400ac888343f7ed9d433..40264345985477bc0609381d5dbdd4c606c317ac 100644
--- a/t/search.t
+++ b/t/search.t
@@ -4,7 +4,7 @@ use strict;
use warnings;
use Test::More;
use PublicInbox::TestCommon;
-require_mods(qw(DBD::SQLite Search::Xapian Email::MIME));
+require_mods(qw(DBD::SQLite Search::Xapian));
require PublicInbox::SearchIdx;
require PublicInbox::Inbox;
require PublicInbox::InboxWritable;
@@ -371,37 +371,7 @@ }
}
$ibx->with_umask(sub {
- my $amsg = mime_load 't/search-amsg.eml', sub {
- my $part1 = Email::MIME->create(
- attributes => {
- content_type => 'text/plain',
- disposition => 'attachment',
- charset => 'US-ASCII',
- encoding => 'quoted-printable',
- filename => 'attached_fart.txt',
- },
- body_str => 'inside the attachment',
- );
- my $part2 = Email::MIME->create(
- attributes => {
- content_type => 'text/plain',
- disposition => 'attachment',
- charset => 'US-ASCII',
- encoding => 'quoted-printable',
- filename => 'part_deux.txt',
- },
- body_str => 'inside another',
- );
- Email::MIME->create(
- header_str => [
- Subject => 'see attachment',
- 'Message-ID' => '',
- From => 'John Smith ',
- To => 'list@example.com',
- ],
- parts => [ $part1, $part2 ],
- )}; # mime_load sub
-
+ my $amsg = mime_load 't/search-amsg.eml';
ok($rw->add_message($amsg), 'added attachment');
$rw_commit->();
$ro->reopen;