BIMI/Result.pm

filter: Statementstmt 84.7% 39 / 46 Branchbran 43.7% 7 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 100% 5 / 5 totaltotal 79.4% 62 / 78 CC 9 SCAR 21.5
CC
9
Cov
74%
get_authentication_results_object
18.7
set_result
2.0
BEGIN
1.0
CRAP 8.6
« BIMI/Role/Cacheable.pm ↑ Summary BIMI/Role/HasHTTPClient.pm »
1 package Mail::BIMI::Result;
2 # ABSTRACT: Class to model a BIMI result
3 29 our $VERSION = '3.20260302'; # VERSION
4 29 ▶use 5.20.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 29 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 29 ▶use Mail::BIMI::Prelude;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 29 ▶use Mail::AuthenticationResults::Header::Entry;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 29 ▶use Mail::AuthenticationResults::Header::SubEntry;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 29 ▶use Mail::AuthenticationResults::Header::Comment;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 29 extends 'Mail::BIMI::Base';
12 29 has result => ( is => 'rw', isa => 'Str',
13 documentation => 'Text result' );
14 29 has comment => ( is => 'rw', isa => 'Str',
15 documentation => 'Text comment' );
16 29 has error => ( is => 'rw',
17 documentation => 'Optional Mail::BIMI::Error object detailing failure' );
18 29 has headers => ( is => 'rw', isa => 'HashRef',
19 documentation => 'Hashref of headers to add to message' );
20  
21  
22  
23 ▶sub domain($self) {
Subroutine domain: called CC=1 SCAR=0.0
Pod documented
24 5 return $self->bimi_object->domain;
25 }
26  
27  
28 ▶sub selector($self) {
Subroutine selector: called CC=1 SCAR=0.0
Pod documented
29 5 return $self->bimi_object->selector;
30 }
31  
32  
33 ▶sub set_result($self,$result) {
Subroutine set_result: called CC=2 SCAR=6.9
Pod documented
34 14 ▶ if ( ref $result eq 'Mail::BIMI::Error' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $result eq 'Mail::BIMI::Error') { } 10 4 14
35 10 $self->result($result->result);
36 10 $self->comment($result->description);
37 }
38 else {
39 4 $self->result($result);
40 }
41 }
42  
43  
44 ▶sub get_authentication_results_object($self) {
Subroutine get_authentication_results_object: called CC=8 SCAR=29.3
Pod documented
45 14 my $header = Mail::AuthenticationResults::Header::Entry->new()->set_key( 'bimi' )->safe_set_value( $self->result );
46 14 ▶ if ( $self->comment ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->comment) 10 4 14
47 10 $header->add_child( Mail::AuthenticationResults::Header::Comment->new()->safe_set_value( $self->comment ) );
48 }
49 14 ▶ if ( $self->result eq 'pass' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->result eq "pass") 4 10 14
50 4 $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'header.d' )->safe_set_value( $self->bimi_object->record->retrieved_domain ) );
51 4 $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'header.selector' )->safe_set_value( $self->bimi_object->record->retrieved_selector ) );
52 }
53 14 ▶ if ( $self->bimi_object->record->authority->is_relevant ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->bimi_object->record->authority->is_relevant) 0 14 14
54 0 my $vmc = $self->bimi_object->record->authority->vmc;
55 0 ▶ if ( $vmc ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($vmc) { } 0 0 0
56 0 ▶ $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'policy.authority' )->safe_set_value( $vmc->is_valid ? 'pass' : 'fail' ) );
Branch: 1 branch
BranchTrueFalseTotal
$vmc->is_valid ? : 0 0 0
57 0 ▶ $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'policy.experimental' )->safe_set_value('yes') )
Branch: 1 branch
BranchTrueFalseTotal
if $vmc->is_experimental 0 0 0
58 if $vmc->is_experimental;
59 0 ▶ $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'policy.mark-type' )->safe_set_value($vmc->mark_type) )
Branch: 1 branch
BranchTrueFalseTotal
if $vmc->mark_type 0 0 0
60 if $vmc->mark_type;
61 }
62 else {
63 0 $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'policy.authority' )->safe_set_value( 'fail' ) );
64 }
65 0 $header->add_child( Mail::AuthenticationResults::Header::SubEntry->new()->set_key( 'policy.authority-uri' )->safe_set_value( $self->bimi_object->record->authority->uri ) );
66 }
67  
68 14 return $header;
69 }
70  
71  
72 ▶sub get_authentication_results($self) {
Subroutine get_authentication_results: called CC=1 SCAR=0.0
Pod documented
73 14 return $self->get_authentication_results_object->as_string;
74 }
75  
76 29 1;
77  
78 __END__
79  
80 =pod
81  
82 =encoding UTF-8
83  
84 =head1 NAME
85  
86 Mail::BIMI::Result - Class to model a BIMI result
87  
88 =head1 VERSION
89  
90 version 3.20260302
91  
92 =head1 DESCRIPTION
93  
94 Class for representing a BIMI result
95  
96 =head1 ATTRIBUTES
97  
98 These values are derived from lookups and verifications made based upon the input values, it is however possible to override these with other values should you wish to, for example, validate a record before it is published in DNS, or validate an Indicator which is only available locally
99  
100 =head2 comment
101  
102 is=rw
103  
104 Text comment
105  
106 =head2 error
107  
108 is=rw
109  
110 Optional Mail::BIMI::Error object detailing failure
111  
112 =head2 headers
113  
114 is=rw
115  
116 Hashref of headers to add to message
117  
118 =head2 result
119  
120 is=rw
121  
122 Text result
123  
124 =head1 EXTENDS
125  
126 =over 4
127  
128 =item * L<Mail::BIMI::Base>
129  
130 =back
131  
132 =head1 METHODS
133  
134 =head2 I<domain()>
135  
136 Return the domain of the current operation
137  
138 =head2 I<selector()>
139  
140 Return the selector of the current operation
141  
142 =head2 I<set_result($result)>
143  
144 Set the result text and comment for this Result object
145  
146 If $result is a Mail::BIMI::Error object then the result will be built from
147 its attributes, otherwise the result must be a string.
148  
149 =head2 I<get_authentication_results_object()>
150  
151 Returns a Mail::AuthenticationResults::Header::Entry object with the BIMI results set
152  
153 =head2 I<get_authentication_results()>
154  
155 Return the BIMI Authentication-Results fragment as text
156  
157 =head1 REQUIRES
158  
159 =over 4
160  
161 =item * L<Mail::AuthenticationResults::Header::Comment|Mail::AuthenticationResults::Header::Comment>
162  
163 =item * L<Mail::AuthenticationResults::Header::Entry|Mail::AuthenticationResults::Header::Entry>
164  
165 =item * L<Mail::AuthenticationResults::Header::SubEntry|Mail::AuthenticationResults::Header::SubEntry>
166  
167 =item * L<Mail::BIMI::Prelude|Mail::BIMI::Prelude>
168  
169 =item * L<Moose|Moose>
170  
171 =back
172  
173 =head1 AUTHOR
174  
175 Marc Bradshaw <marc@marcbradshaw.net>
176  
177 =head1 COPYRIGHT AND LICENSE
178  
179 This software is copyright (c) 2020 by Marc Bradshaw.
180  
181 This is free software; you can redistribute it and/or modify it under
182 the same terms as the Perl 5 programming language system itself.
183  
184 =cut
« BIMI/Role/Cacheable.pm ↑ Summary BIMI/Role/HasHTTPClient.pm »