DRI/Protocol/EPP/Message.pm

filter: Statementstmt 62.9% 146 / 232 Branchbran 37.7% 37 / 98 Conditioncond 17.3% 17 / 98 MC/DCmcdc 0.0% 0 / 52 Subroutinesub 76.3% 29 / 38 Podpod 4.5% 1 / 22 totaltotal 42.5% 230 / 540 CC 88 SCAR 44.9
CC
88
Cov
47%
as_string
264.1
command_extension
90.0
command_extension_register
72.0
CRAP 88.8
« DRI/Protocol/EPP/Core/Contact.pm ↑ Summary DRI/Protocol/EPP/Util.pm »
1 ## Domain Registry Interface, EPP Message
2 ##
3 ## Copyright (c) 2005-2014,2016,2018 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::Message;
16  
17 5 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 5 ▶use DateTime::Format::ISO8601 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
22 5 ▶use DateTime ();
Subroutine BEGIN: called CC=1 SCAR=0.0
23 5 ▶use XML::LibXML ();
Subroutine BEGIN: called CC=1 SCAR=0.0
24 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 5 ▶use Net::DRI::Protocol::ResultStatus;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 5 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 5 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 5 ▶use Net::DRI::Protocol::EPP::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 5 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 5 ▶use base qw(Class::Accessor::Chained::Fast Net::DRI::Protocol::Message);
Subroutine BEGIN: called CC=1 SCAR=0.0
33 5 __PACKAGE__->mk_accessors(qw(version command command_body cltrid svtrid msg_id node_resdata node_extension node_msg node_greeting operation));
34  
35 =pod
36  
37 =head1 NAME
38  
39 Net::DRI::Protocol::EPP::Message - EPP Message for Net::DRI
40  
41 =head1 DESCRIPTION
42  
43 Please see the README file for details.
44  
45 =head1 SUPPORT
46  
47 For now, support questions should be sent to:
48  
49 E<lt>netdri@dotandco.comE<gt>
50  
51 Please also see the SUPPORT file in the distribution.
52  
53 =head1 SEE ALSO
54  
55 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
56  
57 =head1 AUTHOR
58  
59 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
60  
61 =head1 COPYRIGHT
62  
63 Copyright (c) 2005-2014,2016,2018 Patrick Mevzek <netdri@dotandco.com>.
64 All rights reserved.
65  
66 This program is free software; you can redistribute it and/or modify
67 it under the terms of the GNU General Public License as published by
68 the Free Software Foundation; either version 2 of the License, or
69 (at your option) any later version.
70  
71 See the LICENSE file that comes with this distribution for more details.
72  
73 =cut
74  
75 ####################################################################################################
76  
77 sub new
78 {
79 10 ▶ my ($class,$trid,$otype,$oaction)=@_;
Subroutine new: called CC=3 SCAR=11.6
Pod documented
80 10 my $self={ results => [], ns => {} };
81 10 bless($self,$class);
82  
83 10 ▶ $self->cltrid($trid) if (defined $trid && length $trid);
Branch: 1 branch
BranchTrueFalseTotal
if defined $trid and length $trid 0 10 10
Condition33%1/3
defined $trid and length $trid
!ll&&!rl&&r
1000
MC/DC0%0/2
defined $trid and length $trid
defined $trid length $trid
Truth table33%1/3
A and B
A= defined $tridB= length $trid
ABresult
0X0
100
111
84 10 $self->operation([$otype,$oaction]);
85 10 return $self;
86 }
87  
88 sub _get_result
89 {
90 8 ▶ my ($self,$what,$pos)=@_;
Subroutine _get_result: called CC=5 SCAR=18.1
91 8 ▶ my $rh=$self->{results}->[defined $pos ? $pos : 0];
Branch: 1 branch
BranchTrueFalseTotal
defined $pos ? : 4 4 8
92 8 ▶ return unless (defined $rh && ref $rh eq 'HASH' && keys(%$rh)==4);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rh and ref $rh eq "HASH" and keys %$rh == 4 0 8 8
Condition33%2/6
defined $rh and ref $rh eq "HASH" and keys %$rh == 4
!ll&&!rl&&r
008
defined $rh and ref $rh eq "HASH"
!ll&&!rl&&r
008
MC/DC0%0/3
defined $rh and ref $rh eq "HASH" and keys %$rh == 4
defined $rh ref $rh eq "HASH" keys %$rh == 4
Truth table25%1/4
A and B and C
A= defined $rhB= ref $rh eq "HASH"C= keys %$rh == 4
ABCresult
0XX0
10X0
1100
1111
93 8 return $rh->{$what};
94 }
95  
96 3 ▶sub results { return @{shift->{results}}; }
Subroutine results: called CC=1 SCAR=0.0
Pod undocumented
97 1 ▶sub results_code { return map { $_->{code} } shift->results(); }
Subroutine results_code: called CC=1 SCAR=0.0
Pod undocumented
98 1 ▶sub results_message { return map { $_->{message} } shift->results(); }
Subroutine results_message: called CC=1 SCAR=0.0
Pod undocumented
99 1 ▶sub results_lang { return map { $_->{lang} } shift->results(); }
Subroutine results_lang: called CC=1 SCAR=0.0
Pod undocumented
100 0 ▶sub results_extra_info { return map { $_->{extra_info} } shift->results(); }
Subroutine results_extra_info: not called CC=1 SCAR=6.9
Pod undocumented
101  
102 0 ▶sub result_is { my ($self,$code)=@_; return Net::DRI::Protocol::ResultStatus::is($self->_get_result('code'),$code); }
Subroutine result_is: not called CC=1 SCAR=6.9
Pod undocumented
103 3 ▶sub result_code { my ($self,@args)=@_; return $self->_get_result('code',@args); }
Subroutine result_code: called CC=1 SCAR=0.0
Pod undocumented
104 1 ▶sub result_message { my ($self,@args)=@_; return $self->_get_result('message',@args); }
Subroutine result_message: called CC=1 SCAR=0.0
Pod undocumented
105 1 ▶sub result_lang { my ($self,@args)=@_; return $self->_get_result('lang',@args); }
Subroutine result_lang: called CC=1 SCAR=0.0
Pod undocumented
106 3 ▶sub result_extra_info { my ($self,@args)=@_; return $self->_get_result('extra_info',@args); }
Subroutine result_extra_info: called CC=1 SCAR=0.0
Pod undocumented
107  
108 sub ns
109 {
110 15 ▶ my ($self, $ns) = @_;
Subroutine ns: called CC=7 SCAR=20.0
Pod undocumented
111 15 ▶ return $self->{ns} unless defined $ns;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ns 0 15 15
112  
113 15 ▶ if (! ref $ns)
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $ns) 5 10 15
114 {
115 5 ▶ return unless exists $self->{ns}->{$ns};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"ns"}{$ns} 0 5 5
116 5 return $self->{ns}->{$ns};
117 }
118  
119 10 foreach my $alias (keys %$ns)
120 {
121 11 ▶ my $newns = ref $ns->{$alias} ? $ns->{$alias}->[0] : $ns->{$alias}; # the ref case is for old content that did not migrate to no XSD
Branch: 1 branch
BranchTrueFalseTotal
ref $ns->{$alias} ? : 0 11 11
122 11 ▶ Net::DRI::Exception->die(0,'protocol/EPP',1,sprintf('Duplicate namespace definition for "%s": previous="%s" new="%s"', $alias, $self->{ns}->{$alias}, $newns)) if exists $self->{ns}->{$alias};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"ns"}{$alias} 0 11 11
123 11 $self->{ns}->{$alias} = $newns;
124 }
125  
126 10 return $self->{ns};
127 }
128  
129 sub nsattrs
130 {
131 6 ▶ my ($self,$what)=@_;
Subroutine nsattrs: called CC=7 SCAR=21.2
Pod undocumented
132 6 ▶ return unless defined $what;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $what 0 6 6
133 6 ▶ my @d=sort { $a cmp $b } grep { defined $_ && exists $self->{ns}->{$_} } (ref $what eq 'ARRAY' ? @$what : ($what));
Branch: 2 branches
BranchTrueFalseTotal
defined $_ and exists $self->{"ns"}{$_} 6 0 6
ref $what eq 'ARRAY' ? : 0 6 6
134 6 ▶ return unless @d;
Branch: 1 branch
BranchTrueFalseTotal
unless @d 0 6 6
135  
136 6 my @xns;
137 6 foreach my $rdd (@d)
138 {
139 6 ▶ push @xns, $rdd eq 'epp' ? sprintf('xmlns="%s"', $self->{ns}->{$rdd}) : sprintf('xmlns:%s="%s"', $rdd, $self->{ns}->{$rdd});
Branch: 1 branch
BranchTrueFalseTotal
$rdd eq 'epp' ? : 6 0 6
140 }
141 6 return join(' ',@xns);
142 }
143  
144 0 ▶sub is_success { return _is_success(shift->result_code()); }
Subroutine is_success: not called CC=1 SCAR=6.9
Pod undocumented
145 0 ▶sub _is_success { return (shift=~m/^1/)? 1 : 0; } ## 1XXX is for success, 2XXX for failures
Subroutine _is_success: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
(shift()) =~ /^1/ ? : 0 0 0
146  
147 sub result_status
148 {
149 0 ▶ my ($self)=@_;
Subroutine result_status: not called CC=2 SCAR=17.9
Pod undocumented
150 0 my @rs;
151  
152 0 foreach my $result (@{$self->{results}})
153 {
154 0 my $rs=Net::DRI::Protocol::ResultStatus->new('epp',$result->{code},undef,_is_success($result->{code}),$result->{message},$result->{lang},$result->{extra_info});
155 0 $rs->_set_trid([ $self->cltrid(),$self->svtrid() ]);
156 0 push @rs,$rs;
157 }
158 0 return Net::DRI::Util::link_rs(@rs);
159 }
160  
161 sub command_extension_register
162 {
163 0 ▶ my ($self,$ocmd,$ons,$otherattrs)=@_;
Subroutine command_extension_register: not called CC=8 SCAR=42.8
Pod undocumented
164  
165 0 ▶ $self->{extension}=[] unless exists $self->{extension};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"extension"} 0 0 0
166 0 my $eid=1+$#{$self->{extension}};
167 0 ▶ if (defined $ons && $ons!~m/xmlns/) ## new interface, everything should switch to that (TODO)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ons and not $ons =~ /xmlns/) { } 0 0 0
Condition0%0/3
defined $ons and not $ons =~ /xmlns/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ons and not $ons =~ /xmlns/
defined $ons not $ons =~ /xmlns/
Truth table0%0/3
A and not(B)
A= defined $onsB= not $ons =~ /xmlns/
ABresult
0X0
100
111
168 {
169 0 my ($nss,$command)=($ocmd,$ons);
170 0 ▶ $ocmd=(ref $nss eq 'ARRAY' ? $nss->[0] : $nss).':'.$command;
Branch: 1 branch
BranchTrueFalseTotal
ref $nss eq 'ARRAY' ? : 0 0 0
171 0 $ons=$self->nsattrs($nss);
172 ## This is used for other *generic* attributes, not for xmlns: ones !
173 0 ▶ $ons.=' '.join(' ',map { sprintf('%s="%s"',$_,$otherattrs->{$_}) } sort { $a cmp $b } keys %$otherattrs) if defined $otherattrs && ref $otherattrs eq 'HASH' && keys %$otherattrs;
Branch: 1 branch
BranchTrueFalseTotal
if defined $otherattrs and ref $otherattrs eq "HASH" and keys %$otherattrs 0 0 0
Condition0%0/6
defined $otherattrs and ref $otherattrs eq "HASH" and keys %$otherattrs
!ll&&!rl&&r
000
defined $otherattrs and ref $otherattrs eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/3
defined $otherattrs and ref $otherattrs eq "HASH" and keys %$otherattrs
defined $otherattrs ref $otherattrs eq "HASH" keys %$otherattrs
Truth table0%0/4
A and B and C
A= defined $otherattrsB= ref $otherattrs eq "HASH"C= keys %$otherattrs
ABCresult
0XX0
10X0
1100
1111
174 } else
175 {
176 0 carp "Use of command_extension_register old API soon to be removed, contact author to update";
177 }
178 0 $self->{extension}->[$eid]=[$ocmd,$ons,[]];
179 0 return $eid;
180 }
181  
182 sub command_extension
183 {
184 0 ▶ my ($self,$eid,$rdata)=@_;
Subroutine command_extension: not called CC=9 SCAR=45.0
Pod undocumented
185  
186 0 ▶ if (defined $eid && $eid >= 0 && $eid <= $#{$self->{extension}} && defined $rdata && (((ref $rdata eq 'ARRAY') && @$rdata) || ($rdata ne '')))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $eid and $eid >= 0 and $eid <= $#{$$self{"extension"};} and defined $rdata and ref $rdata eq "ARRAY" && @$rdata || $rdata ne "") 0 0 0
Condition0%0/18
defined $eid and $eid >= 0 and $eid <= $#{$$self{"extension"};} and defined $rdata and ref $rdata eq "ARRAY" && @$rdata || $rdata ne ""
!ll&&!rl&&r
000
defined $eid and $eid >= 0 and $eid <= $#{$$self{"extension"};} and defined $rdata
!ll&&!rl&&r
000
defined $eid and $eid >= 0 and $eid <= $#{$$self{"extension"};}
!ll&&!rl&&r
000
defined $eid and $eid >= 0
!ll&&!rl&&r
000
ref $rdata eq "ARRAY" and @$rdata or $rdata ne ""
l!l&&r!l&&!r
000
ref $rdata eq "ARRAY" and @$rdata
!ll&&!rl&&r
000
MC/DC0%0/7
defined $eid and $eid >= 0 and $eid <= $#{$$self{"extension"};} and defined $rdata and ref $rdata eq "ARRAY" && @$rdata || $rdata ne ""
defined $eid $eid >= 0 $eid <= $#{$$self{"extension"};} defined $rdata ref $rdata eq "ARRAY" @$rdata $rdata ne ""
Truth table0%0/9
A and B and C and D and E and F or G
A= defined $eidB= $eid >= 0C= $eid <= $#{$$self{"extension"};}D= defined $rdataE= ref $rdata eq "ARRAY"F= @$rdataG= $rdata ne ""
ABCDEFGresult
0XXXXXX0
10XXXXX0
110XXXX0
1110XXX0
11110X00
11111000
111111X1
11110X11
11111011
187 {
188 0 ▶ $self->{extension}->[$eid]->[2]=(ref($rdata) eq 'ARRAY')? [ @{$self->{extension}->[$eid]->[2]}, @$rdata ] : $rdata;
Branch: 1 branch
BranchTrueFalseTotal
ref $rdata eq 'ARRAY' ? : 0 0 0
189 }
190 0 return $self->{extension};
191 }
192  
193 sub as_string
194 {
195 6 ▶ my ($self,$protect)=@_;
Subroutine as_string: called CC=32 SCAR=55.8
Pod undocumented
196 6 my @d;
197 6 push @d,'<?xml version="1.0" encoding="UTF-8" standalone="no"?>';
198 6 push @d,'<epp '.$self->nsattrs('epp').'>';
199  
200 6 my ($cmd,$ocmd,$ons);
201 6 my $rc=$self->command();
202 6 ▶ ($cmd,$ocmd,$ons)=@$rc if (defined $rc && ref $rc);
Branch: 1 branch
BranchTrueFalseTotal
if defined $rc and ref $rc 6 0 6
Condition33%1/3
defined $rc and ref $rc
!ll&&!rl&&r
006
MC/DC0%0/2
defined $rc and ref $rc
defined $rc ref $rc
Truth table33%1/3
A and B
A= defined $rcB= ref $rc
ABresult
0X0
100
111
203  
204 6 my $attr='';
205 6 ▶ ($cmd,$attr)=($cmd->[0],' '.join(' ',map { $_.'="'.$cmd->[1]->{$_}.'"' } sort { $a cmp $b } keys(%{$cmd->[1]}))) if (defined $cmd && ref $cmd);
Branch: 1 branch
BranchTrueFalseTotal
if defined $cmd and ref $cmd 0 6 6
Condition33%1/3
defined $cmd and ref $cmd
!ll&&!rl&&r
060
MC/DC0%0/2
defined $cmd and ref $cmd
defined $cmd ref $cmd
Truth table33%1/3
A and B
A= defined $cmdB= ref $cmd
ABresult
0X0
100
111
206  
207 6 ▶ if (defined $cmd)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cmd) 6 0 6
208 {
209 6 ▶ push @d,'<command>' if ($cmd ne 'hello');
Branch: 1 branch
BranchTrueFalseTotal
if $cmd ne "hello" 6 0 6
210 6 my $body=$self->command_body();
211  
212 6 ▶ if (!defined $ocmd && !defined $body)
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $ocmd || defined $body) { } 0 6 6
Condition33%1/3
defined $ocmd || defined $body
l!l&&r!l&&!r
600
MC/DC0%0/2
defined $ocmd || defined $body
defined $ocmd defined $body
Truth table33%1/3
A || B
A= defined $ocmdB= defined $body
ABresult
1X1
011
000
213 {
214 0 push @d,'<',$cmd,$attr,'/>';
215 } else
216 {
217 6 push @d,'<',$cmd,$attr,'>';
218 6 ▶ if (defined $body && length $body)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $body and length $body) { } 6 0 6
Condition33%1/3
defined $body and length $body
!ll&&!rl&&r
006
MC/DC0%0/2
defined $body and length $body
defined $body length $body
Truth table33%1/3
A and B
A= defined $bodyB= length $body
ABresult
0X0
100
111
219 {
220 6 ▶ push @d,(defined $ocmd && length $ocmd)? ('<',$ocmd,' ',$ons,'>',Net::DRI::Util::xml_write($body),'</',$ocmd,'>') : Net::DRI::Util::xml_write($body);
Branch: 1 branch
BranchTrueFalseTotal
defined $ocmd && length $ocmd ? : 6 0 6
Condition33%1/3
defined $ocmd and length $ocmd
!ll&&!rl&&r
006
MC/DC0%0/2
defined $ocmd and length $ocmd
defined $ocmd length $ocmd
Truth table33%1/3
A and B
A= defined $ocmdB= length $ocmd
ABresult
0X0
100
111
221 } else
222 {
223 0 push @d,'<',$ocmd,' ',$ons,'/>';
224 }
225 6 push @d,'</',$cmd,'>';
226 }
227 }
228  
229 ## OPTIONAL extension
230 6 my $ext=$self->{extension};
231 6 ▶ if (defined $ext && ref $ext eq 'ARRAY' && @$ext)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ext and ref $ext eq "ARRAY" and @$ext) 0 6 6
Condition33%2/6
defined $ext and ref $ext eq "ARRAY" and @$ext
!ll&&!rl&&r
600
defined $ext and ref $ext eq "ARRAY"
!ll&&!rl&&r
600
MC/DC0%0/3
defined $ext and ref $ext eq "ARRAY" and @$ext
defined $ext ref $ext eq "ARRAY" @$ext
Truth table25%1/4
A and B and C
A= defined $extB= ref $ext eq "ARRAY"C= @$ext
ABCresult
0XX0
10X0
1100
1111
232 {
233 0 push @d,'<extension>';
234 0 foreach my $e (@$ext)
235 {
236 0 my ($ecmd,$ens,$rdata)=@$e;
237 0 ▶ if ($ecmd && $ens)
Branch: 1 branch
BranchTrueFalseTotal
if ($ecmd and $ens) { } 0 0 0
Condition0%0/3
$ecmd and $ens
!ll&&!rl&&r
000
MC/DC0%0/2
$ecmd and $ens
$ecmd $ens
Truth table0%0/3
A and B
A= $ecmdB= $ens
ABresult
0X0
100
111
238 {
239 0 ▶ if ((ref $rdata && @$rdata) || (! ref $rdata && $rdata ne ''))
Branch: 1 branch
BranchTrueFalseTotal
if (ref $rdata and @$rdata or not ref $rdata and $rdata ne '') { } 0 0 0
Condition0%0/9
ref $rdata and @$rdata or not ref $rdata and $rdata ne ""
l!l&&r!l&&!r
000
ref $rdata and @$rdata
!ll&&!rl&&r
000
not ref $rdata and $rdata ne ""
!ll&&!rl&&r
000
MC/DC0%0/4
ref $rdata and @$rdata or not ref $rdata and $rdata ne ""
ref $rdata @$rdata not ref $rdata $rdata ne ""
Truth table0%0/7
A and B or not(C) and D
A= ref $rdataB= @$rdataC= not ref $rdataD= $rdata ne ""
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
240 {
241 0 push @d,'<',$ecmd,' ',$ens,'>';
242 0 ▶ push @d,ref($rdata)? Net::DRI::Util::xml_write($rdata) : Net::DRI::Util::xml_escape($rdata);
Branch: 1 branch
BranchTrueFalseTotal
ref $rdata ? : 0 0 0
243 0 push @d,'</',$ecmd,'>';
244 } else
245 {
246 0 push @d,'<',$ecmd,' ',$ens,'/>';
247 }
248 } else
249 {
250 0 push @d,Net::DRI::Util::xml_escape(@$rdata);
251 }
252 }
253 0 push @d,'</extension>';
254 }
255  
256 ## OPTIONAL clTRID
257 6 my $cltrid=$self->cltrid();
258 6 ▶ if (defined $cmd && $cmd ne 'hello')
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cmd and $cmd ne "hello") 6 0 6
Condition33%1/3
defined $cmd and $cmd ne "hello"
!ll&&!rl&&r
006
MC/DC0%0/2
defined $cmd and $cmd ne "hello"
defined $cmd $cmd ne "hello"
Truth table33%1/3
A and B
A= defined $cmdB= $cmd ne "hello"
ABresult
0X0
100
111
259 {
260 6 ▶ push @d,'<clTRID>',$cltrid,'</clTRID>' if (defined $cltrid && Net::DRI::Util::xml_is_token($cltrid,3,64));
Branch: 1 branch
BranchTrueFalseTotal
if defined $cltrid and Net::DRI::Util::xml_is_token($cltrid, 3, 64) 6 0 6
Condition33%1/3
defined $cltrid and Net::DRI::Util::xml_is_token($cltrid, 3, 64)
!ll&&!rl&&r
006
MC/DC0%0/2
defined $cltrid and Net::DRI::Util::xml_is_token($cltrid, 3, 64)
defined $cltrid Net::DRI::Util::xml_is_token($cltrid, 3, 64)
Truth table33%1/3
A and B
A= defined $cltridB= Net::DRI::Util::xml_is_token($cltrid, 3, 64)
ABresult
0X0
100
111
261 6 push @d,'</command>';
262 }
263 6 push @d,'</epp>';
264  
265 6 my $msg=join('',@d);
266  
267 6 ▶ if (defined $protect && ref $protect eq 'HASH')
Branch: 1 branch
BranchTrueFalseTotal
if (defined $protect and ref $protect eq "HASH") 0 6 6
Condition33%1/3
defined $protect and ref $protect eq "HASH"
!ll&&!rl&&r
600
MC/DC0%0/2
defined $protect and ref $protect eq "HASH"
defined $protect ref $protect eq "HASH"
Truth table33%1/3
A and B
A= defined $protectB= ref $protect eq "HASH"
ABresult
0X0
100
111
268 {
269 0 ▶ if (exists $protect->{session_password} && $protect->{session_password})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $protect->{"session_password"} and $protect->{"session_password"}) 0 0 0
Condition0%0/3
exists $protect->{"session_password"} and $protect->{"session_password"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $protect->{"session_password"} and $protect->{"session_password"}
exists $protect->{"session_password"} $protect->{"session_password"}
Truth table0%0/3
A and B
A= exists $protect->{"session_password"}B= $protect->{"session_password"}
ABresult
0X0
100
111
270 {
271 0 $msg=~s#(?<=</clID>)<pw>(\S+?)</pw>#'<pw>'.('*' x length $1).'</pw>'#e;
272 0 $msg=~s#(?<=</pw>)<newPW>(\S+?)</newPW>#'<newPW>'.('*' x length $1).'</newPW>'#e;
273 }
274 }
275  
276 6 return $msg;
277 }
278  
279 1 ▶sub get_response { my ($self,@args)=@_; return $self->_get_content($self->node_resdata(),@args); }
Subroutine get_response: called CC=1 SCAR=0.0
Pod undocumented
280 0 ▶sub get_extension { my ($self,@args)=@_; return $self->_get_content($self->node_extension(),@args); }
Subroutine get_extension: not called CC=1 SCAR=6.9
Pod undocumented
281  
282 sub _get_content
283 {
284 1 ▶ my ($self, $node, $nstag, $nodename)=@_;
Subroutine _get_content: called CC=7 SCAR=25.1
285 1 ▶ return unless defined $node && defined $nstag && length $nstag && defined $nodename && length $nodename;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $node and defined $nstag and length $nstag and defined $nodename and length $nodename 0 1 1
Condition33%4/12
defined $node and defined $nstag and length $nstag and defined $nodename and length $nodename
!ll&&!rl&&r
001
defined $node and defined $nstag and length $nstag and defined $nodename
!ll&&!rl&&r
001
defined $node and defined $nstag and length $nstag
!ll&&!rl&&r
001
defined $node and defined $nstag
!ll&&!rl&&r
001
MC/DC0%0/5
defined $node and defined $nstag and length $nstag and defined $nodename and length $nodename
defined $node defined $nstag length $nstag defined $nodename length $nodename
Truth table16%1/6
A and B and C and D and E
A= defined $nodeB= defined $nstagC= length $nstagD= defined $nodenameE= length $nodename
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
286 1 my @tmp=$node->getChildrenByTagNameNS($self->ns($nstag), $nodename);
287 1 ▶ return unless @tmp;
Branch: 1 branch
BranchTrueFalseTotal
unless @tmp 0 1 1
288 1 return $tmp[0];
289 }
290  
291 sub parse
292 {
293 4 ▶ my ($self,$dc,$rinfo)=@_;
Subroutine parse: called CC=16 SCAR=41.0
Pod undocumented
294  
295 4 my $NS=$self->ns('epp');
296 4 my $parser=XML::LibXML->new();
297 4 my $doc=$parser->parse_string($dc->as_string());
298 4 my $root=$doc->getDocumentElement();
299 4 ▶ Net::DRI::Exception->die(0,'protocol/EPP',1,'Unsuccessfull parse, root element is not epp') unless ($root->localname() eq 'epp');
Branch: 1 branch
BranchTrueFalseTotal
unless $root->localname eq "epp" 0 4 4
300  
301 4 ▶ if (my $g=$root->getChildrenByTagNameNS($NS,'greeting'))
Branch: 1 branch
BranchTrueFalseTotal
if (my $g = $root->getChildrenByTagNameNS($NS, "greeting")) 0 4 4
302 {
303 0 push @{$self->{results}},{ code => 1000, message => 'Greeting message received', lang => 'en', extra_info => []}; ## fake an OK
304 0 $self->node_greeting($g->get_node(1));
305 0 return;
306 }
307  
308 4 my $c=$root->getChildrenByTagNameNS($NS,'response');
309 4 ▶ Net::DRI::Exception->die(0,'protocol/EPP',1,'Unsuccessfull parse, expected exactly one response block') unless ($c->size()==1);
Branch: 1 branch
BranchTrueFalseTotal
unless $c->size == 1 0 4 4
310  
311 ## result block(s)
312 4 my $res=$c->get_node(1);
313 4 foreach my $result ($res->getChildrenByTagNameNS($NS,'result')) ## one element if success, multiple elements if failure RFC5730 §2.6
314 {
315 5 push @{$self->{results}},Net::DRI::Protocol::EPP::Util::parse_node_result($result,$NS);
316 }
317  
318 4 $rinfo->{message}->{info}={ count => 0, checked_on => DateTime->now() };
319 4 $c=$res->getChildrenByTagNameNS($NS,'msgQ');
320 4 ▶ if ($c->size()) ## OPTIONAL
Branch: 1 branch
BranchTrueFalseTotal
if ($c->size) 0 4 4
321 {
322 0 my $msgq=$c->get_node(1);
323 0 my $id=$msgq->getAttribute('id'); ## id of the message that has just been retrieved and dequeued (RFC5730/RFC4930) OR id of *next* available message (RFC3730)
324 0 $rinfo->{message}->{info}->{id}=$id;
325 0 $rinfo->{message}->{info}->{count}=$msgq->getAttribute('count');
326 0 ▶ if ($msgq->hasChildNodes()) ## We will have childs only as a result of a poll request
Branch: 1 branch
BranchTrueFalseTotal
if ($msgq->hasChildNodes) 0 0 0
327 {
328 0 my %d=( id => $id );
329 0 $self->msg_id($id);
330  
331 0 my $qdate=Net::DRI::Util::xml_child_content($msgq,$NS,'qDate');
332 0 ▶ eval { $d{qdate}=DateTime::Format::ISO8601->new()->parse_datetime($qdate) if defined $qdate && length $qdate; };
Branch: 1 branch
BranchTrueFalseTotal
if defined $qdate and length $qdate 0 0 0
Condition0%0/3
defined $qdate and length $qdate
!ll&&!rl&&r
000
MC/DC0%0/2
defined $qdate and length $qdate
defined $qdate length $qdate
Truth table0%0/3
A and B
A= defined $qdateB= length $qdate
ABresult
0X0
100
111
333  
334 0 my $msg=$msgq->getChildrenByTagNameNS($NS,'msg');
335 0 ▶ if ($msg->size())
Branch: 1 branch
BranchTrueFalseTotal
if ($msg->size) 0 0 0
336 {
337 0 my $msgc=$msg->get_node(1);
338 0 ▶ $d{lang}=$msgc->getAttribute('lang') || 'en';
Condition0%0/2
$msgc->getAttribute('lang') || 'en'
l!l
00
MC/DC0%0/1
$msgc->getAttribute('lang') || 'en'
$msgc->getAttribute('lang')
Truth table0%0/2
A
A= $msgc->getAttribute('lang')
Aresult
11
00
339 0 ▶ if (grep { $_->nodeType() == 1 } $msgc->childNodes())
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_->nodeType == 1;} $msgc->childNodes) { } 0 0 0
340 {
341 0 $d{content}=$msgc->toString();
342 0 $self->node_msg($msgc);
343 } else
344 {
345 0 $d{content}=$msgc->textContent();
346 }
347 }
348 0 $rinfo->{message}->{$id}=\%d;
349 }
350 }
351  
352 4 $c=$res->getChildrenByTagNameNS($NS,'resData');
353 4 ▶ $self->node_resdata($c->get_node(1)) if ($c->size()); ## OPTIONAL
Branch: 1 branch
BranchTrueFalseTotal
if $c->size 2 2 4
354 4 $c=$res->getChildrenByTagNameNS($NS,'extension');
355 4 ▶ $self->node_extension($c->get_node(1)) if ($c->size()); ## OPTIONAL
Branch: 1 branch
BranchTrueFalseTotal
if $c->size 0 4 4
356  
357 ## trID
358 4 my $trid=$res->getChildrenByTagNameNS($NS,'trID')->get_node(1); ## we search only for <trID> as direct child of <response>, hence getChildren and not getElements !
359 4 my $tmp=Net::DRI::Util::xml_child_content($trid,$NS,'clTRID');
360 4 ▶ $self->cltrid($tmp) if defined $tmp;
Branch: 1 branch
BranchTrueFalseTotal
if defined $tmp 4 0 4
361 4 $tmp=Net::DRI::Util::xml_child_content($trid,$NS,'svTRID');
362 4 ▶ $self->svtrid($tmp) if defined $tmp;
Branch: 1 branch
BranchTrueFalseTotal
if defined $tmp 4 0 4
363 4 return;
364 }
365  
366 sub add_to_extra_info
367 {
368 0 ▶ my ($self,$data)=@_;
Subroutine add_to_extra_info: not called CC=1 SCAR=6.9
Pod undocumented
369 0 push @{$self->{results}->[-1]->{extra_info}},$data;
370 0 return;
371 }
372  
373 ####################################################################################################
374 5 1;
« DRI/Protocol/EPP/Core/Contact.pm ↑ Summary DRI/Protocol/EPP/Util.pm »