lib/Net/DHCPv6/Option/Auth.pm

filter: Statementstmt 100% 49 / 49 Branchbran 83.3% 5 / 6 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 14 / 14 Podpod 100% 7 / 7 totaltotal 89.5% 77 / 86 CC 7 SCAR 10.0
CC
7
Cov
92%
new
6.4
from_bytes_inner
2.0
BEGIN
1.0
CRAP 2.7
« blib/lib/Net/DHCPv6/Option/ServerId.pm ↑ Summary lib/Net/DHCPv6/Option/VendorClass.pm »
1 #!/bin/false
2 # ABSTRACT: Authentication option (code 11) -- protocol/algorithm/rdm/replay/auth-info
3 # PODNAME: Net::DHCPv6::Option::Auth
4 15 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 package Net::DHCPv6::Option::Auth;
7 15 $Net::DHCPv6::Option::Auth::VERSION = '0.002';
8 15 ▶use Net::DHCPv6::OptionList;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 15 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 15 ▶use Net::DHCPv6::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 15 ▶use Net::DHCPv6::X::Truncated;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 15 ▶use parent 'Net::DHCPv6::Option';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 15 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 15 my $EMPTY = q();
15 15 my $REPLAY_WIRE_LEN = 8; ## no critic (ValuesAndExpressions::ProhibitMagicNumbers)
16 15 my $MIN_PAYLOAD = 11; ## no critic (ValuesAndExpressions::ProhibitMagicNumbers)
17  
18 sub new {
19 6 ▶ my ( $class, %args ) = @_;
Subroutine new: called CC=6 SCAR=18.5
Pod documented
20 6 for my $field ( qw(protocol algorithm rdm replay) ) {
21 22 ▶ croak "Auth requires $field" unless defined $args{$field};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{$field} 2 20 22
22 }
23 croak 'Auth replay must be exactly 8 bytes'
24 4 ▶ if CORE::length( $args{replay} ) != $REPLAY_WIRE_LEN;
Branch: 1 branch
BranchTrueFalseTotal
if length $args{"replay"} != $REPLAY_WIRE_LEN 0 4 4
25 4 $args{code} = $OPTION_AUTH;
26 $args{data} =
27 4 ▶ pack( 'C C C a8 a*', $args{protocol}, $args{algorithm}, $args{rdm}, $args{replay}, $args{auth_info} // $EMPTY );
Condition33%1/3
$args{"auth_info"} // $EMPTY
l!l&&r!l&&!r
400
MC/DC0%0/2
$args{"auth_info"} // $EMPTY
$args{"auth_info"} $EMPTY
Truth table33%1/3
A // B
A= $args{"auth_info"}B= $EMPTY
ABresult
1X1
011
000
28 4 my $self = $class->SUPER::new( %args );
29 4 $self->{protocol} = $args{protocol};
30 4 $self->{algorithm} = $args{algorithm};
31 4 $self->{rdm} = $args{rdm};
32 4 $self->{replay} = $args{replay};
33 4 ▶ $self->{auth_info} = $args{auth_info} // $EMPTY;
Condition33%1/3
$args{"auth_info"} // $EMPTY
l!l&&r!l&&!r
400
MC/DC0%0/2
$args{"auth_info"} // $EMPTY
$args{"auth_info"} $EMPTY
Truth table33%1/3
A // B
A= $args{"auth_info"}B= $EMPTY
ABresult
1X1
011
000
34 4 return bless $self, $class;
35 }
36  
37 2 ▶sub protocol { return shift->{protocol} }
Subroutine protocol: called CC=1 SCAR=0.0
Pod documented
38 2 ▶sub algorithm { return shift->{algorithm} }
Subroutine algorithm: called CC=1 SCAR=0.0
Pod documented
39 2 ▶sub rdm { return shift->{rdm} }
Subroutine rdm: called CC=1 SCAR=0.0
Pod documented
40 2 ▶sub replay { return shift->{replay} }
Subroutine replay: called CC=1 SCAR=0.0
Pod documented
41 2 ▶sub auth_info { return shift->{auth_info} }
Subroutine auth_info: called CC=1 SCAR=0.0
Pod documented
42  
43 sub from_bytes_inner {
44 3 ▶ my ( $class, $code, $payload ) = @_;
Subroutine from_bytes_inner: called CC=2 SCAR=6.9
Pod documented
45 3 ▶ Net::DHCPv6::X::Truncated->throw( message => 'Truncated Auth option' )
Branch: 1 branch
BranchTrueFalseTotal
if length $payload < $MIN_PAYLOAD 1 2 3
46 if CORE::length( $payload ) < $MIN_PAYLOAD;
47 2 my ( $proto, $alg, $rdm, $replay, $auth_info ) = unpack( 'C C C a8 a*', $payload );
48 2 return $class->new(
49 protocol => $proto,
50 algorithm => $alg,
51 rdm => $rdm,
52 replay => $replay,
53 auth_info => $auth_info,
54 );
55 }
56  
57 15 $Net::DHCPv6::OptionList::OPTION_CLASS{$OPTION_AUTH} = __PACKAGE__;
58 15 1;
59  
60 __END__
« blib/lib/Net/DHCPv6/Option/ServerId.pm ↑ Summary lib/Net/DHCPv6/Option/VendorClass.pm »