DRI/Protocol/EPP/Extensions/EURid/Sunrise.pm

filter: Statementstmt 24.5% 28 / 114 Branchbran 0.0% 0 / 70 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 60.0% 9 / 15 Podpod 0.0% 0 / 6 totaltotal 15.7% 37 / 235 CC 42 SCAR 53.2
CC
42
Cov
14%
apply
420.0
info_parse
182.0
apply_parse
72.0
CRAP 204.2
« DRI/Protocol/EPP/Extensions/Nomulus/Allocate.pm ↑ Summary DRI/Protocol/Gandi/WS/Message.pm »
1 ## Domain Registry Interface, EURid Sunrise EPP extension for Net::DRI
2 ## (from registration_guidelines_v1_0F-appendix2-sunrise.pdf )
3 ##
4 ## Copyright (c) 2005,2007-2010,2012,2013,2016,2018-2019 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
5 ##
6 ## This file is part of Net::DRI
7 ##
8 ## Net::DRI is free software; you can redistribute it and/or modify
9 ## it under the terms of the GNU General Public License as published by
10 ## the Free Software Foundation; either version 2 of the License, or
11 ## (at your option) any later version.
12 ##
13 ## See the LICENSE file that comes with this distribution for more details.
14 ####################################################################################################
15  
16 package Net::DRI::Protocol::EPP::Extensions::EURid::Sunrise;
17  
18 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use Email::Valid;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use DateTime::Format::ISO8601;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use Net::DRI::Protocol::EPP::Extensions::EURid::Domain;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶use Net::DRI::DRD::EURid;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 ▶use Net::DRI::Protocol::EPP::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 =pod
31  
32 =head1 NAME
33  
34 Net::DRI::Protocol::EPP::Extensions::EURid::Sunrise - EURid Sunrise EPP extension for Net::DRI
35  
36 =head1 DESCRIPTION
37  
38 Please see the README file for details.
39  
40 =head1 SUPPORT
41  
42 For now, support questions should be sent to:
43  
44 E<lt>netdri@dotandco.comE<gt>
45  
46 Please also see the SUPPORT file in the distribution.
47  
48 =head1 SEE ALSO
49  
50 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
51  
52 =head1 AUTHOR
53  
54 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
55  
56 =head1 COPYRIGHT
57  
58 Copyright (c) 2005,2007-2010,2012,2013,2016,2018-2019 Patrick Mevzek <netdri@dotandco.com>.
59 All rights reserved.
60  
61 This program is free software; you can redistribute it and/or modify
62 it under the terms of the GNU General Public License as published by
63 the Free Software Foundation; either version 2 of the License, or
64 (at your option) any later version.
65  
66 See the LICENSE file that comes with this distribution for more details.
67  
68 =cut
69  
70 ####################################################################################################
71  
72 sub register_commands
73 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
74 0 my ($class,$version)=@_;
75 0 my %tmp=(
76 apply => [ \&apply, \&apply_parse ],
77 apply_info => [ \&info, \&info_parse ],
78 );
79  
80 0 return { 'domain' => \%tmp };
81 }
82  
83 sub setup
84 0 ▶{
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
85 0 my ($class,$po,$version)=@_;
86 0 $po->ns({ 'sunrise' => 'http://www.eurid.eu/xml/epp/sunrise-1.0' });
87 0 return;
88 }
89  
90 ####################################################################################################
91  
92 ########### Query commands
93  
94 sub info
95 0 ▶{
Subroutine info: not called CC=4 SCAR=30.0
Pod undocumented
96 0 my ($epp,$reference)=@_;
97 0 my $mes=$epp->message();
98  
99 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Apply_info action needs a reference') unless defined($reference) && $reference;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $reference and $reference 0 0 0
Condition0%0/3
defined $reference and $reference
!ll&&!rl&&r
000
MC/DC0%0/2
defined $reference and $reference
defined $reference $reference
Truth table0%0/3
A and B
A= defined $referenceB= $reference
ABresult
0X0
100
111
100 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('reference must be a xml normalizedstring from 1 to 100 characters long') unless Net::DRI::Util::xml_is_normalizedstring($reference,1,100);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_normalizedstring($reference, 1, 100) 0 0 0
101  
102 0 $mes->command(['apply-info','domain:apply-info',sprintf('xmlns:domain="%s"',$mes->nsattrs('domain'))]);
103 0 $mes->command_body([['domain:reference',$reference]]);
104 0 return;
105 }
106  
107 sub info_parse
108 0 ▶{
Subroutine info_parse: not called CC=13 SCAR=52.0
Pod undocumented
109 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
110 0 my $mes=$po->message();
111 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
112  
113 0 my $infdata=$mes->get_response('domain','appInfoData');
114 0 ▶ return unless $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $infdata 0 0 0
115  
116 0 my $cs=Net::DRI::Data::ContactSet->new();
117 0 my $pd=DateTime::Format::ISO8601->new();
118 0 my $c=$infdata->firstChild();
119 0 ▶ while ($c)
Branch: 1 branch
BranchTrueFalseTotal
if ($c) 0 0 0
120 {
121 0 ▶ next unless ($c->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $c->nodeType == 1 0 0 0
122 0 my $name=$c->nodeName();
123 0 ▶ next unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 0 0
124  
125 0 ▶ if ($name=~m/^domain:(name|reference|code)$/)
Branch: 7 branches
BranchTrueFalseTotal
if ($name =~ /^domain:(name|reference|code)$/) { } 0 0 0
elsif ($name eq 'domain:status') { } 0 0 0
elsif ($name =~ /^domain:(crDate|docsReceivedDate)$/) { } 0 0 0
elsif ($name eq 'domain:registrant') { } 0 0 0
elsif ($name eq 'domain:contact') { } 0 0 0
elsif ($name eq 'domain:ns') { } 0 0 0
elsif ($name eq 'domain:adr') { } 0 0 0
126 {
127 0 $rinfo->{domain}->{$oname}->{$1}=$c->firstChild->getData();
128 } elsif ($name eq 'domain:status')
129 {
130 0 $rinfo->{domain}->{$oname}->{application_status}=$c->firstChild->getData();
131 } elsif ($name=~m/^domain:(crDate|docsReceivedDate)$/)
132 {
133 0 $rinfo->{domain}->{$oname}->{$1}=$pd->parse_datetime($c->firstChild->getData());
134 } elsif ($name eq 'domain:registrant')
135 {
136 0 $cs->set($po->create_local_object('contact')->srid($c->firstChild->getData()),'registrant');
137 } elsif ($name eq 'domain:contact')
138 {
139 0 $cs->add($po->create_local_object('contact')->srid($c->firstChild->getData()),$c->getAttribute('type'));
140 } elsif ($name eq 'domain:ns')
141 {
142 0 $rinfo->{domain}->{$oname}->{ns}=Net::DRI::Protocol::EPP::Util::parse_ns($po,$c);
143 } elsif ($name eq 'domain:adr')
144 {
145 0 $rinfo->{domain}->{$oname}->{adr}=Net::DRI::Util::xml_parse_boolean($c->firstChild->getData());
146 }
147 0 } continue { $c=$c->getNextSibling(); }
148  
149 0 $rinfo->{domain}->{$oname}->{contact}=$cs;
150 0 return;
151 }
152  
153 ############ Transform commands
154  
155 sub apply
156 0 ▶{
Subroutine apply: not called CC=20 SCAR=60.4
Pod undocumented
157 0 my ($epp,$domain,$rd)=@_;
158 0 my $mes=$epp->message();
159 0 my @d=Net::DRI::Protocol::EPP::Util::domain_build_command($mes,'apply',$domain);
160  
161 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('Apply action needs parameters') unless (defined($rd) && (ref($rd) eq 'HASH'));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rd and ref $rd eq "HASH" 0 0 0
Condition0%0/3
defined $rd and ref $rd eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $rd and ref $rd eq "HASH"
defined $rd ref $rd eq "HASH"
Truth table0%0/3
A and B
A= defined $rdB= ref $rd eq "HASH"
ABresult
0X0
100
111
162 0 ▶ my @need=grep { !(exists($rd->{$_}) && $rd->{$_}) } qw/reference right prior-right-on-name prior-right-country documentaryevidence evidence-lang/;
Condition0%0/3
exists $rd->{$_} && $rd->{$_}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rd->{$_} && $rd->{$_}
exists $rd->{$_} $rd->{$_}
Truth table0%0/3
A && B
A= exists $rd->{$_}B= $rd->{$_}
ABresult
0X0
100
111
163 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('The following parameters are needed: '.join(' ',@need)) if @need;
Branch: 1 branch
BranchTrueFalseTotal
if @need 0 0 0
164  
165 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('reference must be a xml normalizedstring from 1 to 100 characters long') unless Net::DRI::Util::xml_is_normalizedstring($rd->{reference},1,100);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_normalizedstring($rd->{"reference"}, 1, 100) 0 0 0
166 0 push @d,['domain:reference',$rd->{reference}];
167  
168 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('right must be PUBLICBODY, REG-TM-NAT, REG-TM-COM-INTL, GEO-DOO, COMP-ID, UNREG-TM, TITLES-ART, OTHER') unless ($rd->{right}=~m/^(?:PUBLICBODY|REG-TM-NAT|REG-TM-COM-INTL|GEO-DOO|COMP-ID|UNREG-TM|TITLES-ART|OTHER)/);
Branch: 1 branch
BranchTrueFalseTotal
unless $rd->{"right"} =~ /^(?:PUBLICBODY|REG-TM-NAT|REG-TM-COM-INTL|GEO-DOO|COMP-ID|UNREG-TM|TITLES-ART|OTHER)/ 0 0 0
169 0 push @d,['domain:right',$rd->{right}];
170  
171 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('prior-right-on-name must be a xml token from 1 to 255 characters long') unless Net::DRI::Util::xml_is_token($rd->{'prior-right-on-name'},1,255);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($rd->{"prior-right-on-name"}, 1, 255) 0 0 0
172 0 push @d,['domain:prior-right-on-name',$rd->{'prior-right-on-name'}];
173  
174 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('prior-right-country must be a CC of EU member') unless (length($rd->{'prior-right-country'})==2 && exists($Net::DRI::DRD::EURid::CCA2_EU{uc($rd->{'prior-right-country'})})); ####
Branch: 1 branch
BranchTrueFalseTotal
unless length $rd->{"prior-right-country"} == 2 and exists $Net::DRI::DRD::EURid::CCA2_EU{uc $rd->{"prior-right-country"}} 0 0 0
Condition0%0/3
length $rd->{"prior-right-country"} == 2 and exists $Net::DRI::DRD::EURid::CCA2_EU{uc $rd->{"prior-right-country"}}
!ll&&!rl&&r
000
MC/DC0%0/2
length $rd->{"prior-right-country"} == 2 and exists $Net::DRI::DRD::EURid::CCA2_EU{uc $rd->{"prior-right-country"}}
length $rd->{"prior-right-country"} == 2 exists $Net::DRI::DRD::EURid::CCA2_EU{uc $rd->{"prior-right-country"}}
Truth table0%0/3
A and B
A= length $rd->{"prior-right-country"} == 2B= exists $Net::DRI::DRD::EURid::CCA2_EU{uc $rd->{"prior-right-country"}}
ABresult
0X0
100
111
175 0 push @d,['domain:prior-right-country',uc($rd->{'prior-right-country'})];
176  
177 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('documentaryevidence must be applicant, registrar or thirdparty') unless $rd->{documentaryevidence}=~m/^(?:applicant|registrar|thirdparty)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $rd->{"documentaryevidence"} =~ /^(?:applicant|registrar|thirdparty)$/ 0 0 0
178 0 ▶ if ($rd->{documentaryevidence} eq 'thirdparty')
Branch: 1 branch
BranchTrueFalseTotal
if ($rd->{'documentaryevidence'} eq 'thirdparty') { } 0 0 0
179 {
180 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('documentaryevidence_email must be a valid email address') unless (defined($rd->{documentaryevidence_email}) && Email::Valid->rfc822($rd->{documentaryevidence_email}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rd->{"documentaryevidence_email"} and "Email::Valid"->rfc822($rd->{"documentaryevidence_email"}) 0 0 0
Condition0%0/3
defined $rd->{"documentaryevidence_email"} and "Email::Valid"->rfc822($rd->{"documentaryevidence_email"})
!ll&&!rl&&r
000
MC/DC0%0/2
defined $rd->{"documentaryevidence_email"} and "Email::Valid"->rfc822($rd->{"documentaryevidence_email"})
defined $rd->{"documentaryevidence_email"} "Email::Valid"->rfc822($rd->{"documentaryevidence_email"})
Truth table0%0/3
A and B
A= defined $rd->{"documentaryevidence_email"}B= "Email::Valid"->rfc822($rd->{"documentaryevidence_email"})
ABresult
0X0
100
111
181 0 push @d,['domain:documentaryevidence',['domain:thirdparty',$rd->{documentaryevidence_email}]];
182 } else
183 {
184 0 push @d,['domain:documentaryevidence',['domain:'.$rd->{documentaryevidence}]];
185 }
186  
187 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('evidence-lang must be a lang of EU member') unless (length($rd->{'evidence-lang'})==2 && exists($Net::DRI::DRD::EURid::LANGA2_EU{lc($rd->{'evidence-lang'})})); ####
Branch: 1 branch
BranchTrueFalseTotal
unless length $rd->{"evidence-lang"} == 2 and exists $Net::DRI::DRD::EURid::LANGA2_EU{lc $rd->{"evidence-lang"}} 0 0 0
Condition0%0/3
length $rd->{"evidence-lang"} == 2 and exists $Net::DRI::DRD::EURid::LANGA2_EU{lc $rd->{"evidence-lang"}}
!ll&&!rl&&r
000
MC/DC0%0/2
length $rd->{"evidence-lang"} == 2 and exists $Net::DRI::DRD::EURid::LANGA2_EU{lc $rd->{"evidence-lang"}}
length $rd->{"evidence-lang"} == 2 exists $Net::DRI::DRD::EURid::LANGA2_EU{lc $rd->{"evidence-lang"}}
Truth table0%0/3
A and B
A= length $rd->{"evidence-lang"} == 2B= exists $Net::DRI::DRD::EURid::LANGA2_EU{lc $rd->{"evidence-lang"}}
ABresult
0X0
100
111
188 0 push @d,['domain:evidence-lang',lc($rd->{'evidence-lang'})];
189  
190  
191 ## Nameservers, OPTIONAL
192 0 ▶ push @d,Net::DRI::Protocol::EPP::Util::build_ns($epp,$rd->{ns},$domain,'domain') if Net::DRI::Util::has_ns($rd);
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::has_ns($rd) 0 0 0
193  
194 ## Contacts, all OPTIONAL
195 0 ▶ if (Net::DRI::Util::has_contact($rd))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::has_contact($rd)) 0 0 0
196 {
197 0 my $cs=$rd->{contact};
198 0 my @o=$cs->get('registrant');
199 0 ▶ push @d,['domain:registrant',$o[0]->srid()] if (@o);
Branch: 1 branch
BranchTrueFalseTotal
if @o 0 0 0
200 0 push @d,Net::DRI::Protocol::EPP::Util::build_core_contacts($epp,$cs);
201 }
202  
203 0 $mes->command_body(\@d);
204  
205 ## Nameserver groups
206 0 ▶ if (exists($rd->{nsgroup}))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $rd->{"nsgroup"}) 0 0 0
207 {
208 0 my @n=Net::DRI::Protocol::EPP::Extensions::EURid::Domain::add_nsgroup($rd->{nsgroup});
209 0 $epp->message()->command_extension('domain-ext', ['ext', ['apply', ['domain', @n]]]);
210 }
211 0 return;
212 }
213  
214 sub apply_parse
215 0 ▶{
Subroutine apply_parse: not called CC=8 SCAR=42.8
Pod undocumented
216 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
217 0 my $mes=$po->message();
218 0 $rinfo->{_internal}->{must_reconnect}=1; ## All apply commands (successful or not) close the connection
219 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
220  
221 0 my $credata=$mes->get_response('domain','appData');
222 0 ▶ return unless $credata;
Branch: 1 branch
BranchTrueFalseTotal
unless $credata 0 0 0
223  
224 0 $rinfo->{domain}->{$oname}->{exist}=1;
225  
226 0 my $c=$credata->firstChild();
227 0 ▶ while ($c)
Branch: 1 branch
BranchTrueFalseTotal
if ($c) 0 0 0
228 {
229 0 ▶ next unless ($c->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $c->nodeType == 1 0 0 0
230 0 my $name=$c->nodeName();
231 0 ▶ next unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 0 0
232  
233 0 ▶ if ($name=~m/^domain:(name|reference|code)$/)
Branch: 2 branches
BranchTrueFalseTotal
if ($name =~ /^domain:(name|reference|code)$/) { } 0 0 0
elsif ($name =~ /^domain:(crDate)$/) { } 0 0 0
234 {
235 0 $rinfo->{domain}->{$oname}->{$1}=$c->firstChild->getData();
236 } elsif ($name=~m/^domain:(crDate)$/)
237 {
238 0 $rinfo->{domain}->{$oname}->{$1}=DateTime::Format::ISO8601->new()->parse_datetime($c->firstChild->getData());
239 }
240 0 } continue { $c=$c->getNextSibling(); }
241 0 return;
242 }
243  
244 ####################################################################################################
245 1 1;
« DRI/Protocol/EPP/Extensions/Nomulus/Allocate.pm ↑ Summary DRI/Protocol/Gandi/WS/Message.pm »