DRI/Protocol/EPP/Extensions/VeriSign/ZoneManagement.pm

filter: Statementstmt 17.8% 13 / 73 Branchbran 0.0% 0 / 38 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 40.0% 4 / 10 Podpod 0.0% 0 / 5 totaltotal 12.9% 17 / 131 CC 24 SCAR 43.4
CC
24
Cov
11%
_generate_rrecs
156.0
domain_info_parse
56.0
domain_update_generate
42.0
CRAP 76.8
« DRI/Protocol/RRI/Message.pm ↑ Summary DRI/Protocol/EPP/Extensions/GracePeriod.pm »
1 ## Domain Registry Interface, VeriSign Zone Management EPP extension
2 ##
3 ## Copyright (c) 2012,2015,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::VeriSign::ZoneManagement;
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  
20 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 ####################################################################################################
24  
25 sub register_commands
26 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
27 0 my ($class,$version)=@_;
28 0 return { 'domain' => { create => [ \&domain_create_generate, undef ],
29 info => [ undef, \&domain_info_parse ],
30 update => [ \&domain_update_generate, undef ] },
31 };
32 }
33  
34 sub setup
35 0 ▶{
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
36 0 my ($class,$po,$version)=@_;
37 0 $po->ns({ 'zoneMgt' => 'http://www.verisign.com/epp/zoneMgt-1.0',
38 });
39 0 return;
40 }
41  
42 ####################################################################################################
43  
44 sub _generate_rrecs
45 0 ▶{
Subroutine _generate_rrecs: not called CC=12 SCAR=50.5
46 0 my ($rr)=@_;
47 0 ▶ my @d=ref $rr eq 'ARRAY' ? @$rr : ($rr);
Branch: 1 branch
BranchTrueFalseTotal
ref $rr eq 'ARRAY' ? : 0 0 0
48  
49 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('RRs must be array of ref hashes') if grep { ref $_ ne 'HASH' } @d;
Branch: 1 branch
BranchTrueFalseTotal
if grep {ref $_ ne "HASH";} @d 0 0 0
50 0 my @r;
51 0 foreach my $r (@d)
52 {
53 0 my @rr;
54 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('In RR, "type" key must exist') unless Net::DRI::Util::has_key($r,'type');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($r, "type") 0 0 0
55 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('In RR, for key "type", value must be an XML token') unless Net::DRI::Util::xml_is_token($r->{type});
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($r->{"type"}) 0 0 0
56 0 push @rr,['zoneMgt:type',$r->{type}];
57 0 ▶ if (Net::DRI::Util::has_key($r,'class'))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::has_key($r, 'class')) { } 0 0 0
58 {
59 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('In RR, for key "class", value must be an XML token, if provided') unless Net::DRI::Util::xml_is_token($r->{class});
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($r->{"class"}) 0 0 0
60 0 push @rr,['zoneMgt:class',$r->{class}];
61 } else
62 {
63 0 push @rr,['zoneMgt:class','IN'];
64 }
65 0 ▶ if (Net::DRI::Util::has_key($r,'ttl'))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::has_key($r, "ttl")) 0 0 0
66 {
67 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('In RR, for key "ttl", value must be an XML integeter, if provided') unless Net::DRI::Util::verify_int($r->{ttl});
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::verify_int($r->{"ttl"}) 0 0 0
68 0 push @rr,['zoneMgt:ttl',$r->{ttl}];
69 }
70 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('In RR, "rdata" key must exist') unless Net::DRI::Util::has_key($r,'rdata');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($r, "rdata") 0 0 0
71 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('In RR, for key "rdata", value must be an XML token') unless Net::DRI::Util::xml_is_token($r->{rdata});
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($r->{"rdata"}) 0 0 0
72 0 push @rr,['zoneMgt:rdata',$r->{rdata}];
73 0 push @r,['zoneMgt:rrec',@rr];
74 }
75 0 return @r;
76 }
77  
78 sub domain_create_generate
79 0 ▶{
Subroutine domain_create_generate: not called CC=2 SCAR=17.9
Pod undocumented
80 0 my ($epp,$domain,$rp)=@_;
81  
82 0 ▶ return unless Net::DRI::Util::has_key($rp,'zone');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rp, "zone") 0 0 0
83  
84 0 $epp->message()->command_extension('zoneMgt', ['create', _generate_rrecs($rp->{zone})]);
85 0 return;
86 }
87  
88 sub domain_info_parse
89 0 ▶{
Subroutine domain_info_parse: not called CC=7 SCAR=40.3
Pod undocumented
90 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
91 0 my $mes=$po->message();
92 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
93  
94 0 my $data=$mes->get_response('zoneMgt','infData');
95 0 ▶ return unless defined $data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data 0 0 0
96  
97 0 my @r;
98 0 foreach my $el (Net::DRI::Util::xml_list_children($data))
99 {
100 0 my ($name,$c)=@$el;
101 0 my %r;
102 0 ▶ if ($name eq 'rrec')
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "rrec") 0 0 0
103 {
104 0 foreach my $subel (Net::DRI::Util::xml_list_children($c))
105 {
106 0 my ($subname,$subc)=@$subel;
107 0 ▶ if ($subname=~m/^(type|class|ttl|rdata)$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($subname =~ /^(type|class|ttl|rdata)$/) 0 0 0
108 {
109 0 $r{$1}=$subc->textContent();
110 }
111 }
112 0 push @r,\%r;
113 }
114 }
115  
116 0 $rinfo->{domain}->{$oname}->{zone}=\@r;
117 0 return;
118 }
119  
120 sub domain_update_generate
121 0 ▶{
Subroutine domain_update_generate: not called CC=6 SCAR=37.4
Pod undocumented
122 0 my ($epp,$domain,$todo,$rp)=@_;
123  
124 0 ▶ if (grep { ! /^(?:add|del)$/ } $todo->types('zone'))
Branch: 1 branch
BranchTrueFalseTotal
if (grep {not /^(?:add|del)$/;} $todo->types("zone")) 0 0 0
125 {
126 0 Net::DRI::Exception->die(0,'protocol/EPP',11,'Only zone add/del available for domain');
127 }
128  
129 0 my $zadd=$todo->add('zone');
130 0 my $zdel=$todo->del('zone');
131 0 ▶ return unless $zadd || $zdel;
Branch: 1 branch
BranchTrueFalseTotal
unless $zadd or $zdel 0 0 0
Condition0%0/3
$zadd or $zdel
l!l&&r!l&&!r
000
MC/DC0%0/2
$zadd or $zdel
$zadd $zdel
Truth table0%0/3
A or B
A= $zaddB= $zdel
ABresult
1X1
011
000
132  
133 0 my @n;
134 0 ▶ push @n,['zoneMgt:add',_generate_rrecs($zadd)] if $zadd;
Branch: 1 branch
BranchTrueFalseTotal
if $zadd 0 0 0
135 0 ▶ push @n,['zoneMgt:rem',_generate_rrecs($zdel)] if $zdel;
Branch: 1 branch
BranchTrueFalseTotal
if $zdel 0 0 0
136  
137 0 $epp->message()->command_extension('zoneMgt', ['update', @n]);
138 0 return;
139 }
140  
141 ####################################################################################################
142 1 1;
143  
144 __END__
« DRI/Protocol/RRI/Message.pm ↑ Summary DRI/Protocol/EPP/Extensions/GracePeriod.pm »