File: 04-outlook.t

package info (click to toggle)
libmail-authenticationresults-perl 2.20230112-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 364 kB
  • sloc: perl: 2,803; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 1,317 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!perl
use 5.008;
use strict;
use warnings FATAL => 'all';
use lib 't';
use Test::More;
use Test::Exception;

use lib 'lib';
use Mail::AuthenticationResults::Parser;

#outlook header is not to the expected spec
#plan( skip_all => 'Outlook does not currently parse correctly' );
#my $ARHeader = 'Authentication-Results: spf=pass (sender IP is 66.111.4.222)
# smtp.mailfrom=fastmail.com; outlook.com; dkim=pass (signature was verified)
# header.d=fastmail.com;outlook.com; dmarc=pass action=none
# header.from=fastmail.com;';

# Refactor the actual outlook.com header for the tests

my $ARHeader = 'Authentication-Results: outlook.com; spf=pass (sender IP is 66.111.4.222)
 smtp.mailfrom=fastmail.com; outlook.com; dkim=pass (signature was verified)
 header.d=fastmail.com; dmarc=pass action=none
 header.from=fastmail.com;';

my $Parsed;
lives_ok( sub{ $Parsed = Mail::AuthenticationResults::Parser->new()->parse( $ARHeader ) }, 'Parse lives' );

is ( $Parsed->value()->value(), 'outlook.com', 'ServID' );
is ( scalar @{$Parsed->search({ 'key'=>'spf','value'=>'pass' })->children() }, 1, 'SPF Pass' );
is ( scalar @{$Parsed->search({ 'key'=>'dkim','value'=>'pass' })->children() }, 1, 'DKIM Pass' );
is ( scalar @{$Parsed->search({ 'key'=>'dmarc','value'=>'pass' })->children() }, 1, 'DMARC Pass' );

done_testing();