diff options
author | Eric Wong <e@80x24.org> | 2014-01-10 23:50:16 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2014-01-10 23:50:16 +0000 |
commit | bf4630c098ad7159ba36dea6cfe77c4cf6806ffe (patch) | |
tree | fe3cedc95cc5376a4eeab337da1b9aa93ae76759 /t | |
parent | ef262d1b0139fbb56b7089a3c921087651ffa46a (diff) | |
download | public-inbox-bf4630c098ad7159ba36dea6cfe77c4cf6806ffe.tar.gz |
SpamAssassin doesn't seem to have this heuristic, but the lack of the intended email address in To:/Cc: headers cannot be a good sign (especially when this is a _public_ inbox).
Diffstat (limited to 't')
-rw-r--r-- | t/recipient.t | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/t/recipient.t b/t/recipient.t new file mode 100644 index 00000000..9cb1969e --- /dev/null +++ b/t/recipient.t @@ -0,0 +1,59 @@ +# Copyright (C) 2014, Eric Wong <normalperson@yhbt.net> and all contributors +# License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt) +use strict; +use warnings; +use Test::More; +use Email::Simple; +use Email::Filter; +use PublicInbox; + +sub do_checks { + my ($s) = @_; + + my $f = Email::Filter->new(data => $s->as_string); + local %ENV; + delete $ENV{ORIGINAL_RECIPIENT}; + + ok(PublicInbox->recipient_specified($f), + "ORIGINAL_RECIPIENT unset is OK"); + + $ENV{ORIGINAL_RECIPIENT} = 'foo@example.com'; + ok(!PublicInbox->recipient_specified($f), + "wrong ORIGINAL_RECIPIENT rejected"); + + $ENV{ORIGINAL_RECIPIENT} = 'b@example.com'; + ok(PublicInbox->recipient_specified($f), + "ORIGINAL_RECIPIENT in To: is OK"); + + $ENV{ORIGINAL_RECIPIENT} = 'c@example.com'; + ok(PublicInbox->recipient_specified($f), + "ORIGINAL_RECIPIENT in Cc: is OK"); +} + +{ + do_checks(Email::Simple->create( + header => [ + From => 'a@example.com', + To => 'b@example.com', + Cc => 'c@example.com', + 'Content-Type' => 'text/plain', + Subject => 'this is a subject', + ], + body => "hello world\n", + )); +} + +{ + do_checks(Email::Simple->create( + header => [ + From => 'a@example.com', + To => 'b+plus@example.com', + Cc => 'John Doe <c@example.com>', + 'Content-Type' => 'text/plain', + Subject => 'this is a subject', + ], + body => "hello world\n", + )); +} + +done_testing(); |