DRI/Protocol/EPP/Extensions/PL/Domain.pm

filter: Statementstmt 22.2% 22 / 99 Branchbran 0.0% 0 / 64 Conditioncond 0.0% 0 / 39 MC/DCmcdc 0.0% 0 / 22 Subroutinesub 58.3% 7 / 12 Podpod 0.0% 0 / 5 totaltotal 12.0% 29 / 241 CC 46 SCAR 56.2
CC
46
Cov
11%
create
462.0
update
306.0
info_parse
90.0
CRAP 276.1
« DRI/Protocol/EPP/Extensions/AFNIC/Contact.pm ↑ Summary DRI/Protocol/EPP/Extensions/SecDNS.pm »
1 ## Domain Registry Interface, .PL Domain EPP extension commands
2 ##
3 ## Copyright (c) 2006,2008-2011,2013,2016,2019 Patrick Mevzek <netdri@dotandco.com> and Tonnerre Lombard <tonnerre.lombard@sygroup.ch>.
4 ## 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::PL::Domain;
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 1 ▶use feature 'state';
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use Net::DRI::Data::Hosts;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use Net::DRI::Protocol::EPP::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 =pod
28  
29 =head1 NAME
30  
31 Net::DRI::Protocol::EPP::Extensions::PL::Domain - .PL EPP Domain extension commands for Net::DRI
32  
33 =head1 DESCRIPTION
34  
35 Please see the README file for details.
36  
37 =head1 SUPPORT
38  
39 For now, support questions should be sent to:
40  
41 E<lt>netdri@dotandco.comE<gt>
42  
43 Please also see the SUPPORT file in the distribution.
44  
45 =head1 SEE ALSO
46  
47 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
48  
49 =head1 AUTHORS
50  
51 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
52 Tonnerre Lombard <tonnerre.lombard@sygroup.ch>
53  
54 =head1 COPYRIGHT
55  
56 Copyright (c) 2006,2008-2011,2013,2016,2019 Patrick Mevzek <netdri@dotandco.com> and Tonnerre Lombard <tonnerre.lombard@sygroup.ch>.
57 All rights reserved.
58  
59 This program is free software; you can redistribute it and/or modify
60 it under the terms of the GNU General Public License as published by
61 the Free Software Foundation; either version 2 of the License, or
62 (at your option) any later version.
63  
64 See the LICENSE file that comes with this distribution for more details.
65  
66 =cut
67  
68 ####################################################################################################
69  
70 sub register_commands
71 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
72 0 my ($class,$version)=@_;
73 0 state $cmds = { 'domain' => { create => [ \&create ],
74 update => [ \&update ],
75 info => [ undef, \&info_parse ],
76 }
77 };
78  
79 0 return $cmds;
80 }
81  
82 ####################################################################################################
83  
84 sub build_ns
85 0 ▶{
Subroutine build_ns: not called CC=2 SCAR=17.9
Pod undocumented
86 0 my ($epp,$ns,$domain,$xmlns)=@_;
87 0 ▶ $xmlns='domain' unless defined($xmlns);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $xmlns 0 0 0
88 0 return map { [$xmlns . ':ns',$_] } $ns->get_names();
89 }
90  
91 sub create
92 0 ▶{
Subroutine create: not called CC=21 SCAR=61.4
Pod undocumented
93 0 my ($epp,$domain,$rd)=@_;
94 0 my $mes=$epp->message();
95  
96 0 my @d=Net::DRI::Protocol::EPP::Util::domain_build_command($mes,'create',$domain);
97 0 my $def = $epp->default_parameters();
98  
99 0 ▶ if ($def && (ref($def) eq 'HASH') && exists($def->{domain_create}) && (ref($def->{domain_create}) eq 'HASH'))
Branch: 1 branch
BranchTrueFalseTotal
if ($def and ref $def eq "HASH" and exists $def->{"domain_create"} and ref $def->{"domain_create"} eq "HASH") 0 0 0
Condition0%0/9
$def and ref $def eq "HASH" and exists $def->{"domain_create"} and ref $def->{"domain_create"} eq "HASH"
!ll&&!rl&&r
000
$def and ref $def eq "HASH" and exists $def->{"domain_create"}
!ll&&!rl&&r
000
$def and ref $def eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/4
$def and ref $def eq "HASH" and exists $def->{"domain_create"} and ref $def->{"domain_create"} eq "HASH"
$def ref $def eq "HASH" exists $def->{"domain_create"} ref $def->{"domain_create"} eq "HASH"
Truth table0%0/5
A and B and C and D
A= $defB= ref $def eq "HASH"C= exists $def->{"domain_create"}D= ref $def->{"domain_create"} eq "HASH"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
100 {
101 0 ▶ $rd={} unless ($rd && (ref($rd) eq 'HASH') && keys(%$rd));
Branch: 1 branch
BranchTrueFalseTotal
unless $rd and ref $rd eq "HASH" and keys %$rd 0 0 0
Condition0%0/6
$rd and ref $rd eq "HASH" and keys %$rd
!ll&&!rl&&r
000
$rd and ref $rd eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/3
$rd and ref $rd eq "HASH" and keys %$rd
$rd ref $rd eq "HASH" keys %$rd
Truth table0%0/4
A and B and C
A= $rdB= ref $rd eq "HASH"C= keys %$rd
ABCresult
0XX0
10X0
1100
1111
102 0 ▶ while(my ($k,$v)=each(%{$def->{domain_create}}))
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$def{"domain_create"};}) 0 0 0
103 {
104 0 ▶ next if exists($rd->{$k});
Branch: 1 branch
BranchTrueFalseTotal
if exists $rd->{$k} 0 0 0
105 0 $rd->{$k}=$v
106 }
107 }
108  
109 ## Period, OPTIONAL
110 0 ▶ push @d,Net::DRI::Protocol::EPP::Util::build_period($rd->{duration}) if Net::DRI::Util::has_duration($rd);
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::has_duration($rd) 0 0 0
111  
112 ## Nameservers, OPTIONAL
113 0 ▶ push @d,build_ns($epp,$rd->{ns},$domain) if Net::DRI::Util::has_ns($rd);
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::has_ns($rd) 0 0 0
114  
115 ## Contacts, all OPTIONAL
116 0 ▶ if (Net::DRI::Util::has_contact($rd))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::has_contact($rd)) 0 0 0
117 {
118 0 my $cs=$rd->{contact};
119 0 my @o=$cs->get('registrant');
120 0 ▶ push @d,['domain:registrant',$o[0]->srid()] if (@o);
Branch: 1 branch
BranchTrueFalseTotal
if @o 0 0 0
121 0 push @d,Net::DRI::Protocol::EPP::Util::build_core_contacts($epp,$cs);
122 }
123  
124 ## AuthInfo
125 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters("authInfo is mandatory") unless (Net::DRI::Util::has_auth($rd));
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_auth($rd) 0 0 0
126 0 push @d,Net::DRI::Protocol::EPP::Util::domain_build_authinfo($epp,$rd->{auth});
127 0 $mes->command_body(\@d);
128  
129 0 ▶ return unless exists($rd->{reason}) || exists($rd->{book});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $rd->{"reason"} or exists $rd->{"book"} 0 0 0
Condition0%0/3
exists $rd->{"reason"} or exists $rd->{"book"}
l!l&&r!l&&!r
000
MC/DC0%0/2
exists $rd->{"reason"} or exists $rd->{"book"}
exists $rd->{"reason"} exists $rd->{"book"}
Truth table0%0/3
A or B
A= exists $rd->{"reason"}B= exists $rd->{"book"}
ABresult
1X1
011
000
130  
131 0 my @e;
132 0 ▶ push @e,['extdom:reason',$rd->{reason}] if (exists($rd->{reason}) && $rd->{reason});
Branch: 1 branch
BranchTrueFalseTotal
if exists $rd->{"reason"} and $rd->{"reason"} 0 0 0
Condition0%0/3
exists $rd->{"reason"} and $rd->{"reason"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rd->{"reason"} and $rd->{"reason"}
exists $rd->{"reason"} $rd->{"reason"}
Truth table0%0/3
A and B
A= exists $rd->{"reason"}B= $rd->{"reason"}
ABresult
0X0
100
111
133 0 ▶ push @e,['extdom:book'] if (exists($rd->{book}) && $rd->{book});
Branch: 1 branch
BranchTrueFalseTotal
if exists $rd->{"book"} and $rd->{"book"} 0 0 0
Condition0%0/3
exists $rd->{"book"} and $rd->{"book"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $rd->{"book"} and $rd->{"book"}
exists $rd->{"book"} $rd->{"book"}
Truth table0%0/3
A and B
A= exists $rd->{"book"}B= $rd->{"book"}
ABresult
0X0
100
111
134  
135 0 $mes->command_extension('extdom', ['create', @e]);
136 0 return;
137 }
138  
139 sub update
140 0 ▶{
Subroutine update: not called CC=17 SCAR=57.2
Pod undocumented
141 0 my ($epp,$domain,$todo)=@_;
142 0 my $mes=$epp->message();
143  
144 0 ▶ Net::DRI::Exception::usererr_invalid_parameters($todo.' must be a Net::DRI::Data::Changes object') unless Net::DRI::Util::isa_changes($todo);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::isa_changes($todo) 0 0 0
145  
146 0 my @d=Net::DRI::Protocol::EPP::Util::domain_build_command($mes,'update',$domain);
147  
148 0 my $nsadd=$todo->add('ns');
149 0 my $nsdel=$todo->del('ns');
150 0 my $sadd=$todo->add('status');
151 0 my $sdel=$todo->del('status');
152 0 my $cadd=$todo->add('contact');
153 0 my $cdel=$todo->del('contact');
154 0 my (@add,@del);
155  
156 0 ▶ push @add,build_ns($epp,$nsadd,$domain) if $nsadd && !$nsadd->is_empty();
Branch: 1 branch
BranchTrueFalseTotal
if $nsadd and not $nsadd->is_empty 0 0 0
Condition0%0/3
$nsadd and not $nsadd->is_empty
!ll&&!rl&&r
000
MC/DC0%0/2
$nsadd and not $nsadd->is_empty
$nsadd not $nsadd->is_empty
Truth table0%0/3
A and not(B)
A= $nsaddB= not $nsadd->is_empty
ABresult
0X0
100
111
157 0 ▶ push @add,Net::DRI::Protocol::EPP::Util::build_core_contacts($epp,$cadd) if $cadd;
Branch: 1 branch
BranchTrueFalseTotal
if $cadd 0 0 0
158 0 ▶ push @add,$sadd->build_xml('domain:status','core') if $sadd;
Branch: 1 branch
BranchTrueFalseTotal
if $sadd 0 0 0
159 0 ▶ push @del,build_ns($epp,$nsdel,$domain,undef,1) if $nsdel && !$nsdel->is_empty();
Branch: 1 branch
BranchTrueFalseTotal
if $nsdel and not $nsdel->is_empty 0 0 0
Condition0%0/3
$nsdel and not $nsdel->is_empty
!ll&&!rl&&r
000
MC/DC0%0/2
$nsdel and not $nsdel->is_empty
$nsdel not $nsdel->is_empty
Truth table0%0/3
A and not(B)
A= $nsdelB= not $nsdel->is_empty
ABresult
0X0
100
111
160 0 ▶ push @del,Net::DRI::Protocol::EPP::Util::build_core_contacts($epp,$cdel) if $cdel;
Branch: 1 branch
BranchTrueFalseTotal
if $cdel 0 0 0
161 0 ▶ push @del,$sdel->build_xml('domain:status','core') if $sdel;
Branch: 1 branch
BranchTrueFalseTotal
if $sdel 0 0 0
162  
163 0 ▶ push @d,['domain:add',@add] if @add;
Branch: 1 branch
BranchTrueFalseTotal
if @add 0 0 0
164 0 ▶ push @d,['domain:rem',@del] if @del;
Branch: 1 branch
BranchTrueFalseTotal
if @del 0 0 0
165  
166 0 my $chg=$todo->set('registrant');
167 0 my @chg;
168 0 ▶ push @chg,['domain:registrant',$chg->srid()] if Net::DRI::Util::isa_contact($chg,'Net::DRI::Data::Contact::PL');
Branch: 1 branch
BranchTrueFalseTotal
if Net::DRI::Util::isa_contact($chg, "Net::DRI::Data::Contact::PL") 0 0 0
169 0 $chg=$todo->set('auth');
170 0 ▶ push @chg,Net::DRI::Protocol::EPP::Util::domain_build_authinfo($epp,$chg,1) if ($chg && (ref $chg eq 'HASH') && exists $chg->{pw});
Branch: 1 branch
BranchTrueFalseTotal
if $chg and ref $chg eq "HASH" and exists $chg->{"pw"} 0 0 0
Condition0%0/6
$chg and ref $chg eq "HASH" and exists $chg->{"pw"}
!ll&&!rl&&r
000
$chg and ref $chg eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/3
$chg and ref $chg eq "HASH" and exists $chg->{"pw"}
$chg ref $chg eq "HASH" exists $chg->{"pw"}
Truth table0%0/4
A and B and C
A= $chgB= ref $chg eq "HASH"C= exists $chg->{"pw"}
ABCresult
0XX0
10X0
1100
1111
171 0 ▶ push @d,['domain:chg',@chg] if @chg;
Branch: 1 branch
BranchTrueFalseTotal
if @chg 0 0 0
172 0 $mes->command_body(\@d);
173 0 return;
174 }
175  
176 sub info_parse
177 0 ▶{
Subroutine info_parse: not called CC=9 SCAR=45.0
Pod undocumented
178 0 my ($po, $otype, $oaction, $oname, $rinfo) = @_;
179 0 my $mes = $po->message();
180 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
181 0 my $infdata = $mes->get_response('domain','infData');
182 0 ▶ return unless $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $infdata 0 0 0
183 0 my $ns = Net::DRI::Data::Hosts->new();
184 0 my $c = $infdata->getFirstChild();
185  
186 0 ▶ while ($c)
Branch: 1 branch
BranchTrueFalseTotal
if ($c) 0 0 0
187 {
188 0 ▶ next unless ($c->nodeType() == 1); ## only for element nodes
Branch: 1 branch
BranchTrueFalseTotal
unless $c->nodeType == 1 0 0 0
189 0 ▶ my $name = $c->localname() || $c->nodeName();
Condition0%0/3
$c->localname || $c->nodeName
l!l&&r!l&&!r
000
MC/DC0%0/2
$c->localname || $c->nodeName
$c->localname $c->nodeName
Truth table0%0/3
A || B
A= $c->localnameB= $c->nodeName
ABresult
1X1
011
000
190 0 ▶ next unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 0 0
191  
192 0 ▶ if ($name eq 'name')
Branch: 2 branches
BranchTrueFalseTotal
if ($name eq 'name') { } 0 0 0
elsif ($name eq 'ns') { } 0 0 0
193 {
194 0 $oname = lc($c->getFirstChild()->getData());
195 }
196 elsif ($name eq 'ns')
197 {
198 0 $ns->add($c->getFirstChild()->getData());
199 }
200 0 } continue { $c = $c->getNextSibling(); }
201  
202 0 $rinfo->{domain}->{$oname}->{ns} = $ns;
203 0 return;
204 }
205  
206 ####################################################################################################
207 1 1;
« DRI/Protocol/EPP/Extensions/AFNIC/Contact.pm ↑ Summary DRI/Protocol/EPP/Extensions/SecDNS.pm »