1#!perl 2use 5.008; 3use strict; 4use warnings FATAL => 'all'; 5use lib 't'; 6use Test::More; 7use Test::Exception; 8 9use lib 'lib'; 10use Mail::AuthenticationResults::Parser; 11 12#plan tests => noplan1; 13 14chdir 't'; 15 16my $Input = [ 17 '"iprev"="fail" "policy"."iprev"="123.123.123.123" (NOT FOUND)', 18 '"x-ptr"="fail" "x-ptr-helo"="bad.name.google.com" "x-ptr-lookup"=""', 19 '"spf"="fail" "smtp.mailfrom"="test@goestheweasel.com" "smtp"."helo"="bad.name.google.com"', 20 '"dkim"="none" (no signatures found)', 21 '"x-google-dkim"="none" (no signatures found)', 22 '"dmarc"="fail" (p=none,d=none) "header"."from"="marcbradshaw.net"', 23 '"dmarc"="fail" (p=reject,d=reject) "header.from"="goestheweasel.com"', 24 '"dmarc"="none" (p=none,d=none) "header"."from"="example.com"' 25]; 26 27my $Output = [ 28 'iprev=fail policy.iprev=123.123.123.123 (NOT FOUND)', 29 'x-ptr=fail x-ptr-helo=bad.name.google.com x-ptr-lookup=""', 30 'spf=fail smtp.mailfrom=test@goestheweasel.com smtp.helo=bad.name.google.com', 31 'dkim=none (no signatures found)', 32 'x-google-dkim=none (no signatures found)', 33 'dmarc=fail (p=none,d=none) header.from=marcbradshaw.net', 34 'dmarc=fail (p=reject,d=reject) header.from=goestheweasel.com', 35 'dmarc=none (p=none,d=none) header.from=example.com' 36]; 37 38my $InputARHeader = join( ";\n", '"test.example.com"', @$Input ); 39 40my $Parser; 41lives_ok( sub{ $Parser = Mail::AuthenticationResults::Parser->new( $InputARHeader ) }, 'Parser parses' ); 42is( ref $Parser, 'Mail::AuthenticationResults::Parser', 'Returns Parser Object' ); 43 44my $Header; 45lives_ok( sub{ $Header = $Parser->parsed() }, 'Parser returns data' ); 46is( ref $Header, 'Mail::AuthenticationResults::Header', 'Returns Header Object' ); 47is( $Header->value()->value(), 'test.example.com', 'Authserve Id correct' ); 48is( $Header->as_string(), join( ";\n ", 'test.example.com', @$Output ), 'As String data matches input data' ); 49 50done_testing(); 51 52