| 1 | package Net::DNS::Check::Test; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Net::DNS::Check::Config; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Net::DNS::Check::Test::unknown; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | # use vars qw( %_LOADED ); | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | my %PUBLIC_ARGS = map { $_ => 1 } qw( | |||||||||||||||||||||||||||
| 13 | config | ||||||||||||||||||||||||||||
| 14 | domain | ||||||||||||||||||||||||||||
| 15 | type | ||||||||||||||||||||||||||||
| 16 | nsquery | ||||||||||||||||||||||||||||
| 17 | nsauth | ||||||||||||||||||||||||||||
| 18 | hostslist | ||||||||||||||||||||||||||||
| 19 | debug | ||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 24 | 0 | my ($class) = shift; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | unless ( @_ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | # Some error | ||||||||||||||||||||||||||||
| 28 | 0 | return; | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 0 | my (%args) = @_; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | my $subclass = _get_subclass($class, $args{type} ); | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | if ($subclass) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | my $self = $subclass->new(@_); | |||||||||||||||||||||||||||
| 38 | # $self->{test_detail} = {}; | ||||||||||||||||||||||||||||
| 39 | 0 | return $self; | |||||||||||||||||||||||||||
| 40 | } else { | ||||||||||||||||||||||||||||
| 41 | 0 | return new Net::DNS::Check::Test::unknown(); | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | # Defined in subclass | ||||||||||||||||||||||||||||
| 47 | 0 | ▶ | sub test { | ||||||||||||||||||||||||||
|
Subroutine
test: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | # | ||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub test_status { | ||||||||||||||||||||||||||
|
Subroutine
test_status: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 55 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 56 | 0 | return $self->{test_status}; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | # | ||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub test_detail { | ||||||||||||||||||||||||||
|
Subroutine
test_detail: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 62 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 63 | 0 | my $key = shift; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | ▶ | if ($key) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ( exists $self->{test_detail}->{$key} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 0 | return %{ $self->{test_detail}->{$key} }; | |||||||||||||||||||||||||||
| 68 | } else { | ||||||||||||||||||||||||||||
| 69 | 0 | return (); | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | } else { | ||||||||||||||||||||||||||||
| 72 | 0 | return %{ $self->{test_detail} }; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub test_detail_desc { | ||||||||||||||||||||||||||
|
Subroutine
test_detail_desc: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 79 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 80 | 0 | my $key = shift; | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if ($key && exists $self->{test_detail}->{$key} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$key and exists $self->{"test_detail"}{$key}
MC/DC0%0/2
$key and exists $self->{"test_detail"}{$key}
$key
exists $self->{"test_detail"}{$key}
Truth table0%0/3
A and B
A= $keyB= exists $self->{"test_detail"}{$key}
| |||||||||||||||||||||||||||||
| 83 | 0 | return $self->{test_detail}->{$key}->{desc}; | |||||||||||||||||||||||||||
| 84 | } else { | ||||||||||||||||||||||||||||
| 85 | 0 | return; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub test_detail_status { | ||||||||||||||||||||||||||
|
Subroutine
test_detail_status: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 90 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 91 | 0 | my $key = shift; | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | ▶ | if ($key && exists $self->{test_detail}->{$key} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$key and exists $self->{"test_detail"}{$key}
MC/DC0%0/2
$key and exists $self->{"test_detail"}{$key}
$key
exists $self->{"test_detail"}{$key}
Truth table0%0/3
A and B
A= $keyB= exists $self->{"test_detail"}{$key}
| |||||||||||||||||||||||||||||
| 94 | 0 | return $self->{test_detail}->{$key}->{status}; | |||||||||||||||||||||||||||
| 95 | } else { | ||||||||||||||||||||||||||||
| 96 | 0 | return; | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 0 | ▶ | sub _process_args { | ||||||||||||||||||||||||||
|
Subroutine
_process_args: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||
| 104 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 0 | foreach my $attr ( keys %args) { | |||||||||||||||||||||||||||
| 107 | 0 | ▶ | next unless $PUBLIC_ARGS{$attr}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | # Controllare se effettivamente funziona questo test | ||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if ($attr eq 'nsquery' || $attr eq 'nsauth') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$attr eq "nsquery" or $attr eq "nsauth"
MC/DC0%0/2
$attr eq "nsquery" or $attr eq "nsauth"
$attr eq "nsquery"
$attr eq "nsauth"
Truth table0%0/3
A or B
A= $attr eq "nsquery"B= $attr eq "nsauth"
| |||||||||||||||||||||||||||||
| 111 | 0 | ▶ | unless ( UNIVERSAL::isa($args{$attr}, 'ARRAY') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | 0 | die "Net::DNS::Check::Test->new(): $attr must be an arrayref\n"; | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 0 | $self->{$attr} = $args{$attr}; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 0 | ▶ | $self->{config} ||= new Net::DNS::Check::Config(); | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"config"} ||= "Net::DNS::Check::Config"->new
MC/DC0%0/2
$self->{"config"} ||= "Net::DNS::Check::Config"->new
$self->{"config"}
"Net::DNS::Check::Config"->new
Truth table0%0/3
A ||= B
A= $self->{"config"}B= "Net::DNS::Check::Config"->new
| |||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 0 | ▶ | $self->{debug} ||= $self->{config}->debug_default(); | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"debug"} ||= $self->{"config"}->debug_default
MC/DC0%0/2
$self->{"debug"} ||= $self->{"config"}->debug_default
$self->{"debug"}
$self->{"config"}->debug_default
Truth table0%0/3
A ||= B
A= $self->{"debug"}B= $self->{"config"}->debug_default
| |||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 0 | ▶ | sub _get_subclass { | ||||||||||||||||||||||||||
|
Subroutine
_get_subclass: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 126 | 0 | my ($class, $type) = @_; | |||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 0 | ▶ | return unless $type; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 0 | my $subclass = join('::', $class, $type); | |||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | # probably this is useless because "require" function | ||||||||||||||||||||||||||||
| 133 | # load files only once | ||||||||||||||||||||||||||||
| 134 | #unless ($_LOADED{$subclass}) { | ||||||||||||||||||||||||||||
| 135 | 0 | eval "require $subclass"; | |||||||||||||||||||||||||||
| 136 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | 0 | carp $@; | |||||||||||||||||||||||||||
| 138 | 0 | $subclass = ''; | |||||||||||||||||||||||||||
| 139 | } #else { | ||||||||||||||||||||||||||||
| 140 | # $_LOADED{$subclass}++; | ||||||||||||||||||||||||||||
| 141 | #} | ||||||||||||||||||||||||||||
| 142 | #} | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 0 | return $subclass; | |||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 0 | ▶ | sub DESTROY {} | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 1 | 1; | |||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | __END__ | ||||||||||||||||||||||||||||