about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-07-14 21:01:18 +0000
committerEric Wong <e@80x24.org>2015-07-14 21:01:18 +0000
commitf66473b1a41606d8b4cda74c551aa85d12ec37ef (patch)
treed18c2dfa87b74ba9e81a7e108c4af6bcc61448b5 /t
parent49338dea67712c0106c09d871fca7d680c32298f (diff)
downloadpublic-inbox-f66473b1a41606d8b4cda74c551aa85d12ec37ef.tar.gz
This should hopefully reduce the delay between when a user fails
to send plain-text to when an admin such as myself notices the
HTML mail in a sea of spam.

Unfortunately, this can lead to backscatter, so avoid doing it
until its passed through spamc, at least.
Diffstat (limited to 't')
-rw-r--r--t/mda.t35
1 files changed, 34 insertions, 1 deletions
diff --git a/t/mda.t b/t/mda.t
index 53712a56..67e86f47 100644
--- a/t/mda.t
+++ b/t/mda.t
@@ -23,6 +23,7 @@ my $fail_path = "$fail_bin:$ENV{PATH}"; # for spamc spam mock
 my $addr = 'test-public@example.com';
 my $cfgpfx = "publicinbox.test";
 my $failbox = "$home/fail.mbox";
+my $mime;
 
 {
         ok(-x "$main_bin/spamc",
@@ -235,7 +236,7 @@ EOF
                 )
         ];
         $mid = 'multipart-html-sucks@11';
-        my $mime = Email::MIME->create(
+        $mime = Email::MIME->create(
                 header_str => [
                   From => 'a@example.com',
                   Subject => 'blah',
@@ -276,6 +277,38 @@ EOF
         ok(-d $faildir, "emergency exists");
         my @new = glob("$faildir/new/*");
         is(scalar(@new), 1, "message delivered");
+        is(unlink(@new), 1, "removed emergency message");
+
+        local $ENV{PATH} = $main_path;
+        $in = <<EOF;
+From: Faildir <faildir\@example.com>
+To: $addr
+Content-Type: text/html
+Message-ID: <faildir\@example.com>
+Subject: faildir subject
+Date: Thu, 01 Jan 1970 00:00:00 +0000
+
+<html><body>bad</body></html>
+EOF
+        my $out = '';
+        my $err = '';
+        run([$mda], \$in, \$out, \$err);
+        isnt($?, 0, "mda exited with failure");
+        is(length $out, 0, 'nothing in stdout');
+        isnt(length $err, 0, 'error message in stderr');
+
+        @new = glob("$faildir/new/*");
+        is(scalar(@new), 0, "new message did not show up");
+
+        # reject multipart again
+        $in = $mime->as_string;
+        $err = '';
+        run([$mda], \$in, \$out, \$err);
+        isnt($?, 0, "mda exited with failure");
+        is(length $out, 0, 'nothing in stdout');
+        isnt(length $err, 0, 'error message in stderr');
+        @new = glob("$faildir/new/*");
+        is(scalar(@new), 0, "new message did not show up");
 }
 
 done_testing();