diff -Nru libmail-authenticationresults-perl-2.20210915/Changes libmail-authenticationresults-perl-2.20230112/Changes --- libmail-authenticationresults-perl-2.20210915/Changes 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/Changes 2023-01-12 22:49:12.000000000 +0000 @@ -1,5 +1,9 @@ Change log for Mail::AuthenticationResults +2.20230112 2023-01-12 22:49:04+00:00 UTC + - Add parser method to parse json serialized object back + into the object(s) it represents + 2.20210915 2021-09-15 11:10:20+00:00 UTC - Fix for older versions of Perl diff -Nru libmail-authenticationresults-perl-2.20210915/debian/changelog libmail-authenticationresults-perl-2.20230112/debian/changelog --- libmail-authenticationresults-perl-2.20210915/debian/changelog 2021-09-28 15:38:27.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/debian/changelog 2023-01-15 01:25:27.000000000 +0000 @@ -1,3 +1,11 @@ +libmail-authenticationresults-perl (2.20230112-1) unstable; urgency=medium + + * Team upload. + * Import upstream version 2.20230112. + * Declare compliance with Debian Policy 4.6.2. + + -- gregor herrmann Sun, 15 Jan 2023 02:25:27 +0100 + libmail-authenticationresults-perl (2.20210915-1) unstable; urgency=medium * Team upload. diff -Nru libmail-authenticationresults-perl-2.20210915/debian/control libmail-authenticationresults-perl-2.20230112/debian/control --- libmail-authenticationresults-perl-2.20210915/debian/control 2021-09-28 15:38:27.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/debian/control 2023-01-15 01:25:27.000000000 +0000 @@ -11,7 +11,7 @@ libtest-exception-perl , libtest-simple-perl , perl -Standards-Version: 4.6.0 +Standards-Version: 4.6.2 Vcs-Browser: https://salsa.debian.org/perl-team/modules/packages/libmail-authenticationresults-perl Vcs-Git: https://salsa.debian.org/perl-team/modules/packages/libmail-authenticationresults-perl.git Homepage: https://metacpan.org/release/Mail-AuthenticationResults diff -Nru libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/FoldableHeader.pm libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/FoldableHeader.pm --- libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/FoldableHeader.pm 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/FoldableHeader.pm 2023-01-12 22:49:12.000000000 +0000 @@ -4,7 +4,7 @@ require 5.008; use strict; use warnings; -our $VERSION = '2.20210915'; # VERSION +our $VERSION = '2.20230112'; # VERSION use Carp; use Mail::AuthenticationResults::Token::String; @@ -248,7 +248,7 @@ =head1 VERSION -version 2.20210915 +version 2.20230112 =head1 DESCRIPTION diff -Nru libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Header/AuthServID.pm libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Header/AuthServID.pm --- libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Header/AuthServID.pm 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Header/AuthServID.pm 2023-01-12 22:49:12.000000000 +0000 @@ -4,7 +4,7 @@ require 5.008; use strict; use warnings; -our $VERSION = '2.20210915'; # VERSION +our $VERSION = '2.20230112'; # VERSION use Carp; use base 'Mail::AuthenticationResults::Header::Base'; @@ -49,7 +49,7 @@ =head1 VERSION -version 2.20210915 +version 2.20230112 =head1 DESCRIPTION diff -Nru libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Header/Base.pm libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Header/Base.pm --- libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Header/Base.pm 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Header/Base.pm 2023-01-12 22:49:12.000000000 +0000 @@ -4,7 +4,7 @@ require 5.008; use strict; use warnings; -our $VERSION = '2.20210915'; # VERSION +our $VERSION = '2.20230112'; # VERSION use Scalar::Util qw{ weaken refaddr }; use JSON; use Carp; @@ -426,7 +426,7 @@ =head1 VERSION -version 2.20210915 +version 2.20230112 =head1 DESCRIPTION diff -Nru libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Header/Comment.pm libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Header/Comment.pm --- libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Header/Comment.pm 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Header/Comment.pm 2023-01-12 22:49:12.000000000 +0000 @@ -4,7 +4,7 @@ require 5.008; use strict; use warnings; -our $VERSION = '2.20210915'; # VERSION +our $VERSION = '2.20230112'; # VERSION use Scalar::Util qw{ weaken }; use Carp; @@ -88,7 +88,7 @@ =head1 VERSION -version 2.20210915 +version 2.20230112 =head1 DESCRIPTION diff -Nru libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Header/Entry.pm libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Header/Entry.pm --- libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Header/Entry.pm 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Header/Entry.pm 2023-01-12 22:49:12.000000000 +0000 @@ -4,7 +4,7 @@ require 5.008; use strict; use warnings; -our $VERSION = '2.20210915'; # VERSION +our $VERSION = '2.20230112'; # VERSION use Scalar::Util qw{ refaddr }; use Carp; @@ -37,7 +37,7 @@ =head1 VERSION -version 2.20210915 +version 2.20230112 =head1 DESCRIPTION diff -Nru libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Header/Group.pm libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Header/Group.pm --- libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Header/Group.pm 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Header/Group.pm 2023-01-12 22:49:12.000000000 +0000 @@ -4,7 +4,7 @@ require 5.008; use strict; use warnings; -our $VERSION = '2.20210915'; # VERSION +our $VERSION = '2.20230112'; # VERSION use Scalar::Util qw{ refaddr }; use Carp; @@ -76,7 +76,7 @@ =head1 VERSION -version 2.20210915 +version 2.20230112 =head1 DESCRIPTION diff -Nru libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Header/SubEntry.pm libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Header/SubEntry.pm --- libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Header/SubEntry.pm 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Header/SubEntry.pm 2023-01-12 22:49:12.000000000 +0000 @@ -4,7 +4,7 @@ require 5.008; use strict; use warnings; -our $VERSION = '2.20210915'; # VERSION +our $VERSION = '2.20230112'; # VERSION use Carp; use base 'Mail::AuthenticationResults::Header::Base'; @@ -35,7 +35,7 @@ =head1 VERSION -version 2.20210915 +version 2.20230112 =head1 DESCRIPTION diff -Nru libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Header/Version.pm libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Header/Version.pm --- libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Header/Version.pm 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Header/Version.pm 2023-01-12 22:49:12.000000000 +0000 @@ -4,7 +4,7 @@ require 5.008; use strict; use warnings; -our $VERSION = '2.20210915'; # VERSION +our $VERSION = '2.20230112'; # VERSION use Scalar::Util qw{ weaken }; use Carp; @@ -67,7 +67,7 @@ =head1 VERSION -version 2.20210915 +version 2.20230112 =head1 DESCRIPTION diff -Nru libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Header.pm libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Header.pm --- libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Header.pm 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Header.pm 2023-01-12 22:49:12.000000000 +0000 @@ -4,7 +4,7 @@ require 5.008; use strict; use warnings; -our $VERSION = '2.20210915'; # VERSION +our $VERSION = '2.20230112'; # VERSION use Carp; use Mail::AuthenticationResults::Header::AuthServID; @@ -246,7 +246,7 @@ =head1 VERSION -version 2.20210915 +version 2.20230112 =head1 DESCRIPTION diff -Nru libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Parser.pm libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Parser.pm --- libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Parser.pm 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Parser.pm 2023-01-12 22:49:12.000000000 +0000 @@ -4,7 +4,7 @@ require 5.008; use strict; use warnings; -our $VERSION = '2.20210915'; # VERSION +our $VERSION = '2.20230112'; # VERSION use Carp; use Mail::AuthenticationResults::Header; @@ -20,6 +20,8 @@ use Mail::AuthenticationResults::Token::Separator; use Mail::AuthenticationResults::Token::String; +use JSON; + sub new { my ( $class, $auth_header ) = @_; @@ -49,6 +51,45 @@ } +sub from_authentication_results_json { + my ( $self, $json ) = @_; + my $j = JSON->new(); + my $hashref = $j->decode( $json ); + return $self->_from_hashref( $hashref ); +} + +sub _from_hashref { + my ( $self, $hashref ) = @_; + my $type = $hashref->{'type'}; + my $object + = $type eq 'header' ? Mail::AuthenticationResults::Header->new() + : $type eq 'authservid' ? Mail::AuthenticationResults::Header::AuthServID->new() + : $type eq 'entry' ? Mail::AuthenticationResults::Header::Entry->new() + : $type eq 'subentry' ? Mail::AuthenticationResults::Header::SubEntry->new() + : $type eq 'comment' ? Mail::AuthenticationResults::Header::Comment->new() + : croak "unknown type $type"; + + if ( $type eq 'header' ) { + my $authserv_id = $self->_from_hashref( $hashref->{ 'authserv_id' } ); + $object->set_value( $authserv_id ); + } + else { + $object->set_key( $hashref->{'key'} ) if exists $hashref->{'key'}; + $object->safe_set_value( $hashref->{'value'} ) if exists $hashref->{'value'}; + } + + if ( exists $hashref->{'children'} ) { + for my $child ( @{ $hashref->{'children'} } ) { + my $child_object = $self->_from_hashref( $child ); + $object->add_child( $child_object ); + } + } + + return $object; +} + + + sub tokenise { my ( $self, $header ) = @_; @@ -325,7 +366,7 @@ =head1 VERSION -version 2.20210915 +version 2.20230112 =head1 DESCRIPTION @@ -345,6 +386,10 @@ Parse $header and return the parsed object. +=head2 from_authentication_results_json( $json ) + +Parse $json as the json returned from an as_json method call and return the parsed object. + =head2 tokenise( $header ) Tokenise the given $header string diff -Nru libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Token/Assignment.pm libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Token/Assignment.pm --- libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Token/Assignment.pm 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Token/Assignment.pm 2023-01-12 22:49:12.000000000 +0000 @@ -4,7 +4,7 @@ require 5.008; use strict; use warnings; -our $VERSION = '2.20210915'; # VERSION +our $VERSION = '2.20230112'; # VERSION use Carp; use base 'Mail::AuthenticationResults::Token'; @@ -48,7 +48,7 @@ =head1 VERSION -version 2.20210915 +version 2.20230112 =head1 DESCRIPTION diff -Nru libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Token/Comment.pm libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Token/Comment.pm --- libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Token/Comment.pm 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Token/Comment.pm 2023-01-12 22:49:12.000000000 +0000 @@ -4,7 +4,7 @@ require 5.008; use strict; use warnings; -our $VERSION = '2.20210915'; # VERSION +our $VERSION = '2.20230112'; # VERSION use Carp; use base 'Mail::AuthenticationResults::Token'; @@ -67,7 +67,7 @@ =head1 VERSION -version 2.20210915 +version 2.20230112 =head1 DESCRIPTION diff -Nru libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Token/QuotedString.pm libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Token/QuotedString.pm --- libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Token/QuotedString.pm 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Token/QuotedString.pm 2023-01-12 22:49:12.000000000 +0000 @@ -4,7 +4,7 @@ require 5.008; use strict; use warnings; -our $VERSION = '2.20210915'; # VERSION +our $VERSION = '2.20230112'; # VERSION use Carp; use base 'Mail::AuthenticationResults::Token'; @@ -58,7 +58,7 @@ =head1 VERSION -version 2.20210915 +version 2.20230112 =head1 DESCRIPTION diff -Nru libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Token/Separator.pm libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Token/Separator.pm --- libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Token/Separator.pm 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Token/Separator.pm 2023-01-12 22:49:12.000000000 +0000 @@ -4,7 +4,7 @@ require 5.008; use strict; use warnings; -our $VERSION = '2.20210915'; # VERSION +our $VERSION = '2.20230112'; # VERSION use Carp; use base 'Mail::AuthenticationResults::Token'; @@ -46,7 +46,7 @@ =head1 VERSION -version 2.20210915 +version 2.20230112 =head1 DESCRIPTION diff -Nru libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Token/Space.pm libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Token/Space.pm --- libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Token/Space.pm 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Token/Space.pm 2023-01-12 22:49:12.000000000 +0000 @@ -4,7 +4,7 @@ require 5.008; use strict; use warnings; -our $VERSION = '2.20210915'; # VERSION +our $VERSION = '2.20230112'; # VERSION use Carp; use base 'Mail::AuthenticationResults::Token'; @@ -45,7 +45,7 @@ =head1 VERSION -version 2.20210915 +version 2.20230112 =head1 DESCRIPTION diff -Nru libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Token/String.pm libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Token/String.pm --- libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Token/String.pm 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Token/String.pm 2023-01-12 22:49:12.000000000 +0000 @@ -4,7 +4,7 @@ require 5.008; use strict; use warnings; -our $VERSION = '2.20210915'; # VERSION +our $VERSION = '2.20230112'; # VERSION use Carp; use base 'Mail::AuthenticationResults::Token'; @@ -74,7 +74,7 @@ =head1 VERSION -version 2.20210915 +version 2.20230112 =head1 DESCRIPTION diff -Nru libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Token.pm libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Token.pm --- libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults/Token.pm 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults/Token.pm 2023-01-12 22:49:12.000000000 +0000 @@ -4,7 +4,7 @@ require 5.008; use strict; use warnings; -our $VERSION = '2.20210915'; # VERSION +our $VERSION = '2.20230112'; # VERSION use Carp; @@ -69,7 +69,7 @@ =head1 VERSION -version 2.20210915 +version 2.20230112 =head1 DESCRIPTION diff -Nru libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults.pm libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults.pm --- libmail-authenticationresults-perl-2.20210915/lib/Mail/AuthenticationResults.pm 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/lib/Mail/AuthenticationResults.pm 2023-01-12 22:49:12.000000000 +0000 @@ -4,7 +4,7 @@ require 5.008; use strict; use warnings; -our $VERSION = '2.20210915'; # VERSION +our $VERSION = '2.20230112'; # VERSION use Carp; use Mail::AuthenticationResults::Parser; @@ -37,7 +37,7 @@ =head1 VERSION -version 2.20210915 +version 2.20230112 =head1 DESCRIPTION diff -Nru libmail-authenticationresults-perl-2.20210915/Makefile.PL libmail-authenticationresults-perl-2.20230112/Makefile.PL --- libmail-authenticationresults-perl-2.20210915/Makefile.PL 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/Makefile.PL 2023-01-12 22:49:12.000000000 +0000 @@ -30,7 +30,7 @@ "Test::More" => 0, "lib" => 0 }, - "VERSION" => "2.20210915", + "VERSION" => "2.20230112", "test" => { "TESTS" => "t/*.t" } diff -Nru libmail-authenticationresults-perl-2.20210915/MANIFEST libmail-authenticationresults-perl-2.20230112/MANIFEST --- libmail-authenticationresults-perl-2.20210915/MANIFEST 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/MANIFEST 2023-01-12 22:49:12.000000000 +0000 @@ -30,6 +30,7 @@ t/02-get.t t/02-none.t t/02-parser-begin-dot.t +t/02-parser-json.t t/02-parser-quoted.t t/02-parser.t t/02-safe_set.t diff -Nru libmail-authenticationresults-perl-2.20210915/META.yml libmail-authenticationresults-perl-2.20230112/META.yml --- libmail-authenticationresults-perl-2.20210915/META.yml 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/META.yml 2023-01-12 22:49:12.000000000 +0000 @@ -24,7 +24,7 @@ perl: '5.008' strict: '0' warnings: '0' -version: '2.20210915' +version: '2.20230112' x_contributors: - 'Ricardo Signes ' x_generated_by_perl: v5.34.0 diff -Nru libmail-authenticationresults-perl-2.20210915/README libmail-authenticationresults-perl-2.20230112/README --- libmail-authenticationresults-perl-2.20210915/README 2021-09-15 11:10:25.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/README 2023-01-12 22:49:12.000000000 +0000 @@ -5,7 +5,7 @@ VERSION - version 2.20210915 + version 2.20230112 DESCRIPTION diff -Nru libmail-authenticationresults-perl-2.20210915/t/02-parser-json.t libmail-authenticationresults-perl-2.20230112/t/02-parser-json.t --- libmail-authenticationresults-perl-2.20210915/t/02-parser-json.t 1970-01-01 00:00:00.000000000 +0000 +++ libmail-authenticationresults-perl-2.20230112/t/02-parser-json.t 2023-01-12 22:49:12.000000000 +0000 @@ -0,0 +1,62 @@ +#!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; + +#plan tests => noplan1; + +chdir 't'; + +my $Input = [ + 'iprev=fail policy.iprev=123.123.123.123 (NOT FOUND)', + 'x-ptr=fail x-ptr-helo=bad.name.google.com x-ptr-lookup=', + 'spf=fail smtp.mailfrom=test@goestheweasel.com smtp.helo=bad.name.google.com', + 'dkim=none (no signatures found)', + 'x-google-dkim=none (no signatures found)', + 'dmarc=fail (p=none,d=none) header.from=marcbradshaw.net', + 'dmarc=fail (p=reject,d=reject) header.from=goestheweasel.com', + 'dmarc=none (p=none,d=none) header.from=example.com' +]; + +my $Output = [ + 'iprev=fail policy.iprev=123.123.123.123 (NOT FOUND)', + 'x-ptr=fail x-ptr-helo=bad.name.google.com x-ptr-lookup=""', + 'spf=fail smtp.mailfrom=test@goestheweasel.com smtp.helo=bad.name.google.com', + 'dkim=none (no signatures found)', + 'x-google-dkim=none (no signatures found)', + 'dmarc=fail (p=none,d=none) header.from=marcbradshaw.net', + 'dmarc=fail (p=reject,d=reject) header.from=goestheweasel.com', + 'dmarc=none (p=none,d=none) header.from=example.com' +]; + +my $InputARHeader = join( ";\n", 'test.example.com', @$Input ); + +my $Parser; +lives_ok( sub{ $Parser = Mail::AuthenticationResults::Parser->new( $InputARHeader ) }, 'Parser parses' ); +is( ref $Parser, 'Mail::AuthenticationResults::Parser', 'Returns Parser Object' ); + +my $JSON = $Parser->parsed()->as_json(); +my $Header = Mail::AuthenticationResults::Parser->new()->from_authentication_results_json($JSON); + +is( ref $Header, 'Mail::AuthenticationResults::Header', 'Returns Header Object' ); +is( $Header->value()->value(), 'test.example.com', 'Authserve Id correct' ); +is( $Header->as_string(), join( ";\n ", 'test.example.com', @$Output ), 'As String data matches input data' ); + +my $Search; +lives_ok( sub{ $Search = $Header->search({ 'key'=>'dmarc','value'=>'none' }) }, 'Searches returns data' ); +is( ref $Search, 'Mail::AuthenticationResults::Header::Group', 'Returns Header Group Object' ); +is( $Search->as_string(), $Input->[7], 'As String data matches expected data' ); + +my $MultiSearch; +lives_ok( sub{ $MultiSearch = $Header->search({ 'key'=>'dmarc' }) }, 'Searches returns data' ); +is( ref $MultiSearch, 'Mail::AuthenticationResults::Header::Group', 'Returns Header Group Object' ); +is( $MultiSearch->as_string(), join( ";\n", $Input->[5] , $Input->[6], $Input->[7] ), 'As String data matches expected data' ); + +done_testing(); +