1 # Copyright (C) 2014, Eric Wong <normalperson@yhbt.net> and all contributors
2 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
13 my $f = Email::Filter->new(data => $s->as_string);
15 ok(PublicInbox->precheck($f, undef),
16 "RECIPIENT unset is OK");
18 my $recipient = 'foo@example.com';
19 ok(!PublicInbox->precheck($f, $recipient),
20 "wrong RECIPIENT rejected");
22 $recipient = 'b@example.com';
23 ok(PublicInbox->precheck($f, $recipient),
24 "RECIPIENT in To: is OK");
26 $recipient = 'c@example.com';
27 ok(PublicInbox->precheck($f, $recipient),
28 "RECIPIENT in Cc: is OK");
32 do_checks(Email::Simple->create(
34 From => 'a@example.com',
35 To => 'b@example.com',
36 Cc => 'c@example.com',
37 'Content-Type' => 'text/plain',
38 Subject => 'this is a subject',
39 'Message-ID' => '<MID@host>',
40 Date => 'Wed, 09 Apr 2014 01:28:34 +0000',
42 body => "hello world\n",
47 do_checks(Email::Simple->create(
49 From => 'a@example.com',
50 To => 'b+plus@example.com',
51 Cc => 'John Doe <c@example.com>',
52 'Content-Type' => 'text/plain',
53 Subject => 'this is a subject',
54 'Message-ID' => '<MID@host>',
55 Date => 'Wed, 09 Apr 2014 01:28:34 +0000',
57 body => "hello world\n",
62 my $recipient = 'b@example.com';
63 my $s = Email::Simple->create(
65 To => 'b@example.com',
66 Cc => 'c@example.com',
67 'Content-Type' => 'text/plain',
68 Subject => 'this is a subject',
69 'Message-ID' => '<MID@host>',
70 Date => 'Wed, 09 Apr 2014 01:28:34 +0000',
72 body => "hello world\n",
74 my $f = Email::Filter->new(data => $s->as_string);
75 ok(!PublicInbox->precheck($f, $recipient), "missing From: is rejected");