diff options
author | dakkar <dakkar@thenautilus.net> | 2023-03-31 16:50:45 +0100 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2023-03-31 16:50:45 +0100 |
commit | 28eb39cf2b231c34880a959fc7ccce1d0e339357 (patch) | |
tree | 36d140c7eb84ab4d1c526180f694e296cf6fb8c4 /t/tests | |
parent | v1.1.1 (diff) | |
download | Sietima-28eb39cf2b231c34880a959fc7ccce1d0e339357.tar.gz Sietima-28eb39cf2b231c34880a959fc7ccce1d0e339357.tar.bz2 Sietima-28eb39cf2b231c34880a959fc7ccce1d0e339357.zip |
new role NoSpoof::DMARC
Diffstat (limited to 't/tests')
-rw-r--r-- | t/tests/sietima/role/nospoof/dmarc.t | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/t/tests/sietima/role/nospoof/dmarc.t b/t/tests/sietima/role/nospoof/dmarc.t new file mode 100644 index 0000000..18d70c8 --- /dev/null +++ b/t/tests/sietima/role/nospoof/dmarc.t @@ -0,0 +1,65 @@ +#!perl +use lib 't/lib'; +use Test::Sietima; +use Net::DNS::Resolver::Mock; + +my $resolver = Net::DNS::Resolver::Mock->new(); + +my $s = make_sietima( + with_traits => ['NoSpoof::DMARC'], + subscribers => [ + 'one@users.example.com', + ], + dmarc_resolver => $resolver, +); + +sub test_rewriting($from) { + subtest "$from should rewrite" => sub { + test_sending( + sietima => $s, + mail => { + from => "a user <$from>", + }, + mails => [ + object { + call [ header_str => 'from' ] => '"a user" <'.$s->return_path->address.'>'; + call [ header_str => 'original-from' ] => qq{"a user" <$from>}; + }, + ], + ); + } +} + +sub test_no_rewriting($from) { + subtest "$from should not rewrite" => sub { + test_sending( + sietima => $s, + mail => { + from => "a user <$from>", + }, + mails => [ + object { + call [ header_str => 'sender' ] => $s->return_path->address; + call [ header_str => 'from' ] => qq{"a user" <$from>}; + }, + ], + ); + } +} + +$resolver->zonefile_parse(<<'EOZ'); +_dmarc.none-none-pol.com 3600 TXT "v=DMARC1; p=none; sp=none; rua=mailto:foo@example.com" +_dmarc.none-q-pol.com 3600 TXT "v=DMARC1; p=none; sp=quarantine; rua=mailto:foo@example.com" +_dmarc.q-q-pol.com 3600 TXT "v=DMARC1; p=quarantine; sp=quarantine; rua=mailto:foo@example.com" +EOZ + +test_no_rewriting 'foo@none-none-pol.com'; +test_no_rewriting 'foo@sub.none-none-pol.com'; + +test_no_rewriting 'foo@none-q-pol.com'; +test_rewriting 'foo@sub.none-q-pol.com'; + +test_rewriting 'foo@q-q-pol.com'; +test_rewriting 'foo@sub.q-q-pol.com'; + +done_testing; |