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
« lib/Net/DHCPv6/Option/IAPrefix.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.003';
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 qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
11 $OPTION_AUTH
12 15 );
13 15 ▶use Net::DHCPv6::X::Truncated ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 15 ▶use parent 'Net::DHCPv6::Option';
Subroutine BEGIN: called CC=1 SCAR=0.0
15 15 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 15 my $EMPTY = q();
17 15 my $REPLAY_WIRE_LEN = 8; ## no critic (ValuesAndExpressions::ProhibitMagicNumbers)
18 15 my $MIN_PAYLOAD = 11; ## no critic (ValuesAndExpressions::ProhibitMagicNumbers)
19  
20 6 ▶sub new {
Subroutine new: called CC=6 SCAR=18.5
Pod documented
21 6 my ( $class, %args ) = @_;
22 6 for my $field ( qw(protocol algorithm rdm replay) ) {
23 22 ▶ croak "Auth requires $field" unless defined $args{$field};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{$field} 2 20 22
24 }
25 croak 'Auth replay must be exactly 8 bytes'
26 4 ▶ if CORE::length( $args{replay} ) != $REPLAY_WIRE_LEN;
Branch: 1 branch
BranchTrueFalseTotal
if length $args{"replay"} != $REPLAY_WIRE_LEN 0 4 4
27 4 $args{code} = $OPTION_AUTH;
28 $args{data} =
29 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
30 4 my $self = $class->SUPER::new( %args );
31 4 $self->{protocol} = $args{protocol};
32 4 $self->{algorithm} = $args{algorithm};
33 4 $self->{rdm} = $args{rdm};
34 4 $self->{replay} = $args{replay};
35 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
36 4 return bless $self, $class;
37 }
38  
39 2 ▶sub protocol { return shift->{protocol} }
Subroutine protocol: called CC=1 SCAR=0.0
Pod documented
40 2 ▶sub algorithm { return shift->{algorithm} }
Subroutine algorithm: called CC=1 SCAR=0.0
Pod documented
41 2 ▶sub rdm { return shift->{rdm} }
Subroutine rdm: called CC=1 SCAR=0.0
Pod documented
42 2 ▶sub replay { return shift->{replay} }
Subroutine replay: called CC=1 SCAR=0.0
Pod documented
43 2 ▶sub auth_info { return shift->{auth_info} }
Subroutine auth_info: called CC=1 SCAR=0.0
Pod documented
44  
45 3 ▶sub from_bytes_inner {
Subroutine from_bytes_inner: called CC=2 SCAR=6.9
Pod documented
46 3 my ( $class, $code, $payload ) = @_;
47 3 ▶ Net::DHCPv6::X::Truncated->throw( message => 'Truncated Auth option' )
Branch: 1 branch
BranchTrueFalseTotal
if length $payload < $MIN_PAYLOAD 1 2 3
48 if CORE::length( $payload ) < $MIN_PAYLOAD;
49 2 my ( $proto, $alg, $rdm, $replay, $auth_info ) = unpack( 'C C C a8 a*', $payload );
50 2 return $class->new(
51 protocol => $proto,
52 algorithm => $alg,
53 rdm => $rdm,
54 replay => $replay,
55 auth_info => $auth_info,
56 );
57 }
58  
59 15 $Net::DHCPv6::OptionList::OPTION_CLASS{$OPTION_AUTH} = __PACKAGE__;
60 15 1;
61  
62 __END__
« lib/Net/DHCPv6/Option/IAPrefix.pm ↑ Summary lib/Net/DHCPv6/Option/VendorClass.pm »