DRI/Protocol/EPP/Extensions/VerificationCode.pm

filter: Statementstmt 18.3% 13 / 71 Branchbran 0.0% 0 / 28 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 36.3% 4 / 11 Podpod 0.0% 0 / 7 totaltotal 12.8% 17 / 132 CC 23 SCAR 42.5
CC
23
Cov
12%
info_parse
156.0
create_build
42.0
info_build
30.0
CRAP 70.3
« DRI/Protocol/EPP/Extensions/FCCN/Contact.pm ↑ Summary DRI/DRD/TCI.pm »
1 ## Domain Registry Interface, Verification Code Extension Mapping for EPP
2 ##
3 ## Copyright (c) 2016,2018,2019 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
4 ##
5 ## This file is part of Net::DRI
6 ##
7 ## Net::DRI is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 2 of the License, or
10 ## (at your option) any later version.
11 ##
12 ## See the LICENSE file that comes with this distribution for more details.
13 ####################################################################################################
14  
15 package Net::DRI::Protocol::EPP::Extensions::VerificationCode;
16  
17 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use feature 'state';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 ####################################################################################################
24  
25 sub register_commands
26 {
27 0 ▶ my ($class,$version)=@_;
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
28 0 state $ractions = { 'info' => [ \&info_build, \&info_parse ],
29 'create' => [ \&create_build, undef ],
30 'delete' => [ \&create_build, undef ],
31 'renew' => [ \&create_build, undef ],
32 'transfer_request' => [ \&create_build, undef ],
33 'update' => [ \&create_build, undef ],
34 };
35 0 state $rcmds = { 'domain' => $ractions,
36 'contact' => $ractions,
37 'host' => $ractions,
38 };
39 0 return $rcmds;
40 }
41  
42 sub setup
43 {
44 0 ▶ my ($class,$po,$version)=@_;
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
45 0 state $rns = { 'verificationCode' => 'urn:ietf:params:xml:ns:verificationCode-1.0' };
46 0 $po->ns($rns);
47 0 return;
48 }
49  
50 0 ▶sub implements { return 'https://tools.ietf.org/html/draft-ietf-regext-verificationcode-06'; }
Subroutine implements: not called CC=1 SCAR=6.9
Pod undocumented
51  
52 ####################################################################################################
53  
54 sub is_verification_code
55 {
56 0 ▶ my ($code) = @_;
Subroutine is_verification_code: not called CC=3 SCAR=24.8
Pod undocumented
57 0 ▶ return defined $code && $code =~m/^\d+-[0-9a-z]+$/i ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $code && $code =~ /^\d+-[0-9a-z]+$/i ? : 0 0 0
Condition0%0/3
defined $code and $code =~ /^\d+-[0-9a-z]+$/i
!ll&&!rl&&r
000
MC/DC0%0/2
defined $code and $code =~ /^\d+-[0-9a-z]+$/i
defined $code $code =~ /^\d+-[0-9a-z]+$/i
Truth table0%0/3
A and B
A= defined $codeB= $code =~ /^\d+-[0-9a-z]+$/i
ABresult
0X0
100
111
58 }
59  
60 ####################################################################################################
61  
62 sub info_build
63 {
64 0 ▶ my ($epp, $oname, $rd)=@_;
Subroutine info_build: not called CC=5 SCAR=34.0
Pod undocumented
65  
66 0 ▶ return unless Net::DRI::Util::has_key($rd, 'verification_code') && $rd->{'verification_code'};
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "verification_code") and $rd->{"verification_code"} 0 0 0
Condition0%0/3
Net::DRI::Util::has_key($rd, "verification_code") and $rd->{"verification_code"}
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::has_key($rd, "verification_code") and $rd->{"verification_code"}
Net::DRI::Util::has_key($rd, "verification_code") $rd->{"verification_code"}
Truth table0%0/3
A and B
A= Net::DRI::Util::has_key($rd, "verification_code")B= $rd->{"verification_code"}
ABresult
0X0
100
111
67  
68 0 my $mes=$epp->message();
69 0 my %attrs;
70 0 ▶ if (Net::DRI::Util::has_key($rd, 'verification_code_profile'))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::has_key($rd, "verification_code_profile")) 0 0 0
71 {
72 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('verification_code_profile must be an XML token') unless Net::DRI::Util::xml_is_token($rd->{verification_code_profile});
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($rd->{"verification_code_profile"}) 0 0 0
73 0 $attrs{profile} = $rd->{verification_code_profile};
74 }
75 0 my $eid=$mes->command_extension_register('verificationCode', 'info', \%attrs);
76 0 return;
77 }
78  
79 sub info_parse
80 {
81 0 ▶ my ($po, $otype, $oaction, $oname, $rinfo)=@_;
Subroutine info_parse: not called CC=12 SCAR=50.5
Pod undocumented
82 0 my $mes = $po->message();
83 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
84  
85 0 my $data = $mes->get_extension('verificationCode', 'infData');
86 0 ▶ return unless defined $data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data 0 0 0
87  
88 0 my %v;
89 0 foreach my $el (Net::DRI::Util::xml_list_children($data))
90 {
91 0 my ($name, $node)=@$el;
92 0 ▶ if ($name eq 'status')
Branch: 2 branches
BranchTrueFalseTotal
if ($name eq 'status') { } 0 0 0
elsif ($name eq 'profile') { } 0 0 0
93 {
94 0 $v{status} = $node->textContent();
95 } elsif ($name eq 'profile')
96 {
97 0 my $pname = $node->getAttribute('name');
98 0 my %p;
99 0 foreach my $subel (Net::DRI::Util::xml_list_children($node))
100 {
101 0 my ($subname, $subnode) = @$subel;
102 0 ▶ if ($subname eq 'status')
Branch: 3 branches
BranchTrueFalseTotal
if ($subname eq 'status') { } 0 0 0
elsif ($subname eq 'missing') { } 0 0 0
elsif ($subname eq 'set') { } 0 0 0
103 {
104 0 $p{status} = $subnode->textContent();
105 } elsif ($subname eq 'missing')
106 {
107 0 foreach my $code (Net::DRI::Util::xml_list_children($subnode, 'code'))
108 {
109 0 my %a = ( type => $code->getAttribute('type'),
110 due => $po->parse_iso8601($code->getAttribute('due')),
111 );
112 0 push @{$p{missing}}, \%a;
113 }
114 } elsif ($subname eq 'set')
115 {
116 0 foreach my $code (Net::DRI::Util::xml_list_children($subnode, 'code'))
117 {
118 0 my %a = ( type => $code->getAttribute('type'),
119 date => $po->parse_iso8601($code->getAttribute('date')),
120 code => $code->textContent(),
121 );
122 0 push @{$p{set}}, \%a;
123 }
124 }
125 }
126 0 $v{profiles}->{$pname} = \%p;
127 }
128 }
129  
130 0 $rinfo->{$otype}->{$oname}->{verification}=\%v;
131  
132 0 return;
133 }
134  
135 sub create_build
136 {
137 0 ▶ my ($epp, $oname, $rd)=@_;
Subroutine create_build: not called CC=6 SCAR=37.4
Pod undocumented
138  
139 0 ▶ return unless Net::DRI::Util::has_key($rd, 'verification_code') && $rd->{'verification_code'};
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "verification_code") and $rd->{"verification_code"} 0 0 0
Condition0%0/3
Net::DRI::Util::has_key($rd, "verification_code") and $rd->{"verification_code"}
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::has_key($rd, "verification_code") and $rd->{"verification_code"}
Net::DRI::Util::has_key($rd, "verification_code") $rd->{"verification_code"}
Truth table0%0/3
A and B
A= Net::DRI::Util::has_key($rd, "verification_code")B= $rd->{"verification_code"}
ABresult
0X0
100
111
140  
141 0 my $vc = $rd->{verification_code};
142 0 ▶ $vc = [ $vc ] unless ref $vc eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $vc eq "ARRAY" 0 0 0
143  
144 ## TODO: handle other encoding than base64
145 0 foreach my $code (@$vc)
146 {
147 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('verification code must be BASE64 formatted') unless Net::DRI::Util::verify_base64($code);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::verify_base64($code) 0 0 0
148 }
149  
150 0 my $mes=$epp->message();
151 0 my $eid=$mes->command_extension_register('verificationCode', 'encodedSignedCode');
152 0 $mes->command_extension($eid,map { ['verificationCode:code', $_] } @$vc);
153 0 return;
154 }
155  
156 ####################################################################################################
157 1 1;
158  
159 __END__
160  
161 =pod
162  
163 =head1 NAME
164  
165 Net::DRI::Protocol::EPP::Extensions::VerificationCode - EPP Verification Code Extension mapping (draft-ietf-regext-verificationcode-06) for Net::DRI
166  
167 =head1 DESCRIPTION
168  
169 Please see the README file for details.
170  
171 =head1 SUPPORT
172  
173 For now, support questions should be sent to:
174  
175 E<lt>netdri@dotandco.comE<gt>
176  
177 Please also see the SUPPORT file in the distribution.
178  
179 =head1 SEE ALSO
180  
181 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
182  
183 =head1 AUTHOR
184  
185 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
186  
187 =head1 COPYRIGHT
188  
189 Copyright (c) 2016,2018,2019 Patrick Mevzek <netdri@dotandco.com>.
190 All rights reserved.
191  
192 This program is free software; you can redistribute it and/or modify
193 it under the terms of the GNU General Public License as published by
194 the Free Software Foundation; either version 2 of the License, or
195 (at your option) any later version.
196  
197 See the LICENSE file that comes with this distribution for more details.
198  
199 =cut
« DRI/Protocol/EPP/Extensions/FCCN/Contact.pm ↑ Summary DRI/DRD/TCI.pm »