BIMI/Record/Authority.pm

filter: Statementstmt 88.6% 39 / 44 Branchbran 73.3% 22 / 30 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 81.1% 73 / 90 CC 17 SCAR 15.2
CC
17
Cov
81%
_build_is_authority_valid
6.2
_build_is_valid
5.9
is_relevant
5.0
CRAP 4.6
« BIMI/Role/HasHTTPClient.pm ↑ Summary BIMI/Record/Location.pm »
1 package Mail::BIMI::Record::Authority;
2 # ABSTRACT: Class to model a BIMI authority
3 29 our $VERSION = '3.20261116'; # 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::BIMI::VMC;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 29 extends 'Mail::BIMI::Base';
10 29 with 'Mail::BIMI::Role::HasError';
11 29 has is_authority_valid => ( is => 'rw', lazy => 1, builder => '_build_is_authority_valid' );
12 29 has uri => ( is => 'rw', isa => 'Maybe[Str]', required => 1,
13 documentation => 'inputs: URI of VMC', );
14 29 has is_valid => ( is => 'rw', lazy => 1, builder => '_build_is_valid',
15 documentation => 'Is this Authority valid' );
16 29 has vmc => ( is => 'rw', lazy => 1, builder => '_build_vmc',
17 documentation => 'Mail::BIMI::VMC object for this Authority' );
18  
19  
20 8 ▶sub _build_is_authority_valid($self) {
Subroutine _build_is_authority_valid: called CC=6 SCAR=18.2
21 8 ▶ return 1 if !defined $self->uri;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->uri 5 3 8
22 3 ▶ return 1 if $self->uri eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $self->uri eq "" 1 2 3
23 2 ▶ return 1 if $self->uri eq 'self';
Branch: 1 branch
BranchTrueFalseTotal
if $self->uri eq "self" 1 1 2
24 1 ▶ if ( ! ( $self->uri =~ /^https:\/\// ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->uri =~ m[^https://]u) 1 0 1
25 1 $self->add_error('INVALID_TRANSPORT_A');
26 }
27  
28 1 ▶ return 0 if $self->errors->@*;
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->errors} 1 0 1
29 0 return 1;
30 }
31  
32  
33 77 ▶sub is_relevant($self) {
Subroutine is_relevant: called CC=5 SCAR=16.1
Pod documented
34 77 ▶ return 0 if !defined $self->uri;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->uri 66 11 77
35 11 ▶ return 0 if $self->uri eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $self->uri eq "" 8 3 11
36 3 ▶ return 0 if $self->uri eq 'self';
Branch: 1 branch
BranchTrueFalseTotal
if $self->uri eq "self" 2 1 3
37 1 ▶ return 0 if $self->bimi_object->options->no_validate_cert;
Branch: 1 branch
BranchTrueFalseTotal
if $self->bimi_object->options->no_validate_cert 0 1 1
38 1 $self->log_verbose('Authority is relevant');
39 1 return 1;
40 }
41  
42 3 ▶sub _build_is_valid($self) {
Subroutine _build_is_valid: called CC=5 SCAR=17.8
43 3 ▶ return 0 if !$self->is_authority_valid;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_authority_valid 1 2 3
44 2 ▶ if ( $self->is_relevant && !$self->vmc->is_valid ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_relevant and not $self->vmc->is_valid) 0 2 2
Condition33%1/3
$self->is_relevant and not $self->vmc->is_valid
!ll&&!rl&&r
200
MC/DC0%0/2
$self->is_relevant and not $self->vmc->is_valid
$self->is_relevant not $self->vmc->is_valid
Truth table33%1/3
A and not(B)
A= $self->is_relevantB= not $self->vmc->is_valid
ABresult
0X0
100
111
45 0 $self->add_error_object( $self->vmc->errors );
46 }
47  
48 2 ▶ return 0 if $self->errors->@*;
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->errors} 0 2 2
49 2 $self->log_verbose('Authority is valid');
50 2 return 1;
51 }
52  
53 5 ▶sub _build_vmc($self) {
Subroutine _build_vmc: called CC=3 SCAR=15.1
54 5 ▶ return if !$self->is_authority_valid;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_authority_valid 0 5 5
55 5 ▶ return if !$self->is_relevant;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_relevant 5 0 5
56 0 my $check_domain = $self->bimi_object->record->retrieved_domain;
57 0 my $check_selector = $self->bimi_object->record->retrieved_selector;
58 0 return Mail::BIMI::VMC->new( check_domain => $check_domain, check_selector => $check_selector, uri => $self->uri, bimi_object => $self->bimi_object );
59 }
60  
61  
62 5 ▶sub finish($self) {
Subroutine finish: called CC=2 SCAR=7.6
Pod documented
63 5 ▶ $self->vmc->finish if $self->vmc;
Branch: 1 branch
BranchTrueFalseTotal
if $self->vmc 0 5 5
64 }
65  
66 29 1;
67  
68 __END__
« BIMI/Role/HasHTTPClient.pm ↑ Summary BIMI/Record/Location.pm »