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

filter: Statementstmt 20.3% 13 / 64 Branchbran 0.0% 0 / 32 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 36.3% 4 / 11 Podpod 0.0% 0 / 7 totaltotal 14.2% 17 / 119 CC 19 SCAR 36.9
CC
19
Cov
13%
update
90.0
info_parse
30.0
add_coa
30.0
CRAP 39.9
« DRI/Protocol/EPP/Extensions/NSgroup.pm ↑ Summary DRI/Protocol/EPP/Extensions/Afilias/Message.pm »
1 ## Domain Registry Interface, VeriSign EPP Client Object Attribute Extension
2 ## From epp-client-object-attribute.pdf
3 ##
4 ## Copyright (c) 2011-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::VeriSign::ClientAttributes;
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 Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 ####################################################################################################
25  
26 sub register_commands
27 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
28 0 my ($class,$version)=@_;
29  
30 0 return { 'domain' => { 'info' => [ undef, \&info_parse ],
31 'create' => [ \&create, undef ],
32 'update' => [ \&update, undef ],
33 } };
34 }
35  
36 sub setup
37 0 ▶{
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
38 0 my ($class,$po,$version)=@_;
39 0 $po->ns({ 'coa' => 'urn:ietf:params:xml:ns:coa-1.0' });
40 0 return;
41 }
42  
43 0 ▶sub capabilities_add { return ('domain_update','client_attributes',['add','del']); }
Subroutine capabilities_add: not called CC=1 SCAR=6.9
Pod undocumented
44  
45 ####################################################################################################
46  
47 sub info_parse
48 0 ▶{
Subroutine info_parse: not called CC=5 SCAR=34.0
Pod undocumented
49 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
50 0 my $mes=$po->message();
51 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
52  
53 0 my $infdata=$mes->get_extension('coa','infData');
54 0 ▶ return unless defined $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $infdata 0 0 0
55  
56 0 my %coa;
57 0 my $ns=$mes->ns('coa');
58  
59 0 foreach my $el (Net::DRI::Util::xml_list_children($infdata))
60 {
61 0 my ($name,$node)=@$el;
62 0 ▶ next unless $name eq 'attr';
Branch: 1 branch
BranchTrueFalseTotal
unless $name eq "attr" 0 0 0
63 0 $coa{Net::DRI::Util::xml_child_content($node,$ns,'key')}=Net::DRI::Util::xml_child_content($node,$ns,'value');
64 }
65  
66 0 $rinfo->{domain}->{$oname}->{'client_attributes'}=\%coa;
67 0 return;
68 }
69  
70 sub add_coa
71 0 ▶{
Subroutine add_coa: not called CC=5 SCAR=34.0
Pod undocumented
72 0 my ($name,$coa)=@_;
73  
74 0 my @d;
75 0 ▶ while(my ($k,$v)=each(%$coa))
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$coa) 0 0 0
76 {
77 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Key parameter must be XML token of 50 characters or less, not: '.$k) unless Net::DRI::Util::xml_is_token($k,1,50);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($k, 1, 50) 0 0 0
78 0 ▶ if ($name eq 'rem')
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "rem") 0 0 0
79 {
80 0 push @d,['coa:key',$k];
81 0 next;
82 }
83 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Value parameter must be XML token of 1000 characters or less, not: '.$v) unless Net::DRI::Util::xml_is_token($v,1,1000);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($v, 1, 1000) 0 0 0
84 0 push @d,['coa:attr',['coa:key',$k],['coa:value',$v]];
85 }
86  
87 0 return @d;
88 }
89  
90 sub create
91 0 ▶{
Subroutine create: not called CC=3 SCAR=24.8
Pod undocumented
92 0 my ($epp,$domain,$rd)=@_;
93  
94 0 ▶ return unless Net::DRI::Util::has_key($rd,'client_attributes');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "client_attributes") 0 0 0
95  
96 0 my $rcoa=$rd->{client_attributes};
97 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('client_attributes must be a hash ref') unless ref $rcoa eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $rcoa eq "HASH" 0 0 0
98  
99 0 $epp->message()->command_extension('coa', ['create', add_coa('create',$rcoa)]);
100 0 return;
101 }
102  
103 sub update
104 0 ▶{
Subroutine update: not called CC=9 SCAR=45.0
Pod undocumented
105 0 my ($epp,$domain,$todo)=@_;
106  
107 0 my $rem=$todo->del('client_attributes');
108 0 my $put=$todo->add('client_attributes');
109 0 ▶ return unless defined $rem || defined $put;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rem or defined $put 0 0 0
Condition0%0/3
defined $rem or defined $put
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $rem or defined $put
defined $rem defined $put
Truth table0%0/3
A or B
A= defined $remB= defined $put
ABresult
1X1
011
000
110  
111 0 my @d;
112 0 ▶ if (defined $rem)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rem) 0 0 0
113 {
114 0 ▶ $rem={ $rem => undef } if ! ref $rem;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $rem 0 0 0
115 0 ▶ $rem={ map { $_ => undef } @$rem } if ref $rem eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $rem eq "ARRAY" 0 0 0
116 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('client_attributes to delete must be a hash ref') unless ref $rem eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $rem eq "HASH" 0 0 0
117 0 push @d,['coa:rem',add_coa('rem',$rem)];
118 }
119 0 ▶ if (defined $put)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $put) 0 0 0
120 {
121 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('client_attributes to add must be a hash ref') unless ref $put eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $put eq "HASH" 0 0 0
122 0 push @d,['coa:put',add_coa('put',$put)];
123 }
124  
125 0 $epp->message()->command_extension('coa', ['update', @d]);
126 0 return;
127 }
128  
129 #########################################################################################################
130 1 1;
131  
132 __END__
« DRI/Protocol/EPP/Extensions/NSgroup.pm ↑ Summary DRI/Protocol/EPP/Extensions/Afilias/Message.pm »