]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/mda.t
mda, watch: wire up List-ID header support
[public-inbox.git] / t / mda.t
diff --git a/t/mda.t b/t/mda.t
index 966600a899d56d792e24471145d2e62977a2d8b0..3cab590b78f9a9d2728c213706bc229e3ba81aad 100644 (file)
--- a/t/mda.t
+++ b/t/mda.t
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2018 all contributors <meta@public-inbox.org>
+# Copyright (C) 2014-2019 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use warnings;
@@ -267,6 +267,34 @@ EOF
        }
 }
 
+# List-ID based delivery
+{
+       local $ENV{PI_EMERGENCY} = $faildir;
+       local $ENV{HOME} = $home;
+       local $ENV{ORIGINAL_RECIPIENT} = undef;
+       local $ENV{PATH} = $main_path;
+       my $list_id = 'foo.example.com';
+       my $mid = 'list-id-delivery@example.com';
+       my $simple = Email::Simple->new(<<EOF);
+From: user <user\@example.com>
+To: You <you\@example.com>
+Cc: $addr
+Message-ID: <$mid>
+List-Id: <$list_id>
+Subject: this message will be trained as spam
+Date: Thu, 01 Jan 1970 00:00:00 +0000
+
+EOF
+       system(qw(git config --file), $pi_config, "$cfgpfx.listid", $list_id);
+       $? == 0 or die "failed to set listid $?";
+       my $in = $simple->as_string;
+       IPC::Run::run([$mda], \$in);
+       is($?, 0, 'mda OK with List-Id match');
+       my $path = mid2path($mid);
+       my $msg = `git --git-dir=$maindir cat-file blob HEAD:$path`;
+       like($msg, qr/\Q$list_id\E/, 'delivered message w/ List-ID matches');
+}
+
 done_testing();
 
 sub fail_bad_header {