DRI/Protocol/EPP/Extensions/Afilias/Association.pm

filter: Statementstmt 20.3% 13 / 64 Branchbran 0.0% 0 / 30 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 36.3% 4 / 11 Podpod 0.0% 0 / 7 totaltotal 13.3% 17 / 127 CC 21 SCAR 42.7
CC
21
Cov
13%
update
156.0
info_parse
42.0
create
20.0
CRAP 71.8
« DRI/Protocol/EPP/Extensions/SE/Extensions.pm ↑ Summary DRI/Protocol/EPP/Extensions/FCCN/Contact.pm »
1 ## Domain Registry Interface, Afilias Association extension (for .XXX)
2 ##
3 ## Copyright (c) 2010,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::Afilias::Association;
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 my %tmp=(
29 create => [ \&create, undef ],
30 update => [ \&update, undef ],
31 info => [ undef, \&info_parse ]
32 );
33  
34 0 return { 'domain' => \%tmp };
35 }
36  
37 sub setup
38 0 ▶{
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
39 0 my ($class,$po,$version)=@_;
40 0 $po->ns({association => 'urn:afilias:params:xml:ns:association-1.0'});
41 0 return;
42 }
43  
44 0 ▶sub capabilities_add { return ('domain_update','association',['add','del','set']); }
Subroutine capabilities_add: not called CC=1 SCAR=6.9
Pod undocumented
45  
46 ####################################################################################################
47  
48 sub build_association
49 0 ▶{
Subroutine build_association: not called CC=2 SCAR=17.9
Pod undocumented
50 0 my $as = shift;
51 0 ▶ my @pw = defined $as->{'pw'} ? ['association:authInfo',[ 'association:pw',$as->{'pw'}] ] : ();
Branch: 1 branch
BranchTrueFalseTotal
defined $as->{'pw'} ? : 0 0 0
52 return (
53 ['association:contact',{'type' =>'membership'},
54 0 ['association:id',$as->{'id'}],
55 @pw
56 ]
57 );
58 }
59  
60 sub create
61 0 ▶{
Subroutine create: not called CC=4 SCAR=30.0
Pod undocumented
62 0 my ($epp,$domain,$rd)=@_;
63 0 ▶ return unless Net::DRI::Util::has_key($rd,'association');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rd, "association") 0 0 0
64 0 my $as=$rd->{association};
65 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Invalid Association Membership Contact ID and PW') unless Net::DRI::Util::xml_is_token($as->{'id'},1,63) && Net::DRI::Util::xml_is_token($as->{'pw'},6,16);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($as->{"id"}, 1, 63) and Net::DRI::Util::xml_is_token($as->{"pw"}, 6, 16) 0 0 0
Condition0%0/3
Net::DRI::Util::xml_is_token($as->{"id"}, 1, 63) and Net::DRI::Util::xml_is_token($as->{"pw"}, 6, 16)
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::xml_is_token($as->{"id"}, 1, 63) and Net::DRI::Util::xml_is_token($as->{"pw"}, 6, 16)
Net::DRI::Util::xml_is_token($as->{"id"}, 1, 63) Net::DRI::Util::xml_is_token($as->{"pw"}, 6, 16)
Truth table0%0/3
A and B
A= Net::DRI::Util::xml_is_token($as->{"id"}, 1, 63)B= Net::DRI::Util::xml_is_token($as->{"pw"}, 6, 16)
ABresult
0X0
100
111
66 0 my @t = build_association($as);
67 0 $epp->message()->command_extension('association', ['create', @t]);
68  
69 0 return;
70 }
71  
72 sub update
73 0 ▶{
Subroutine update: not called CC=12 SCAR=50.5
Pod undocumented
74 0 my ($epp,$domain,$todo)=@_;
75 0 my $toadd=$todo->add('association');
76 0 my $todel=$todo->del('association');
77 0 my $tochg=$todo->set('association');
78 0 my @def=grep { defined } ($toadd,$todel);
79 0 ▶ return unless @def; ## no updates asked
Branch: 1 branch
BranchTrueFalseTotal
unless @def 0 0 0
80  
81 0 my @n;
82 0 ▶ if (defined $toadd)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $toadd) 0 0 0
83 {
84 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Invalid Association Membership Contact ID and PW') unless Net::DRI::Util::xml_is_token($toadd->{'id'},1,63) && Net::DRI::Util::xml_is_token($toadd->{'pw'},6,16);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($toadd->{"id"}, 1, 63) and Net::DRI::Util::xml_is_token($toadd->{"pw"}, 6, 16) 0 0 0
Condition0%0/3
Net::DRI::Util::xml_is_token($toadd->{"id"}, 1, 63) and Net::DRI::Util::xml_is_token($toadd->{"pw"}, 6, 16)
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::xml_is_token($toadd->{"id"}, 1, 63) and Net::DRI::Util::xml_is_token($toadd->{"pw"}, 6, 16)
Net::DRI::Util::xml_is_token($toadd->{"id"}, 1, 63) Net::DRI::Util::xml_is_token($toadd->{"pw"}, 6, 16)
Truth table0%0/3
A and B
A= Net::DRI::Util::xml_is_token($toadd->{"id"}, 1, 63)B= Net::DRI::Util::xml_is_token($toadd->{"pw"}, 6, 16)
ABresult
0X0
100
111
85 0 push @n,['association:add',build_association($toadd)]
86 }
87 0 ▶ if (defined $todel)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $todel) 0 0 0
88 {
89 0 undef $todel->{'pw'};
90 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Invalid Association Membership Contact ID') unless Net::DRI::Util::xml_is_token($toadd->{'id'},1,63);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($toadd->{"id"}, 1, 63) 0 0 0
91 0 ▶ push @n,['association:rem',build_association($todel)] if (defined $todel);
Branch: 1 branch
BranchTrueFalseTotal
if defined $todel 0 0 0
92 }
93 0 ▶ if (defined $tochg)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tochg) 0 0 0
94 {
95 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('Invalid Association Membership Contact ID and PW') unless Net::DRI::Util::xml_is_token($tochg->{'id'},1,63) && Net::DRI::Util::xml_is_token($tochg->{'pw'},6,16);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($tochg->{"id"}, 1, 63) and Net::DRI::Util::xml_is_token($tochg->{"pw"}, 6, 16) 0 0 0
Condition0%0/3
Net::DRI::Util::xml_is_token($tochg->{"id"}, 1, 63) and Net::DRI::Util::xml_is_token($tochg->{"pw"}, 6, 16)
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::xml_is_token($tochg->{"id"}, 1, 63) and Net::DRI::Util::xml_is_token($tochg->{"pw"}, 6, 16)
Net::DRI::Util::xml_is_token($tochg->{"id"}, 1, 63) Net::DRI::Util::xml_is_token($tochg->{"pw"}, 6, 16)
Truth table0%0/3
A and B
A= Net::DRI::Util::xml_is_token($tochg->{"id"}, 1, 63)B= Net::DRI::Util::xml_is_token($tochg->{"pw"}, 6, 16)
ABresult
0X0
100
111
96 0 ▶ push @n,['association:rem',build_association($tochg)] if (defined $tochg);
Branch: 1 branch
BranchTrueFalseTotal
if defined $tochg 0 0 0
97 }
98  
99 0 $epp->message()->command_extension('association', ['update', @n]);
100  
101 0 return;
102 }
103  
104  
105 sub info_parse
106 0 ▶{
Subroutine info_parse: not called CC=6 SCAR=37.4
Pod undocumented
107 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
108 0 my $mes=$po->message();
109 0 my $infdata=$mes->get_extension('association','infData');
110 0 ▶ return unless defined $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $infdata 0 0 0
111  
112 0 my %t;
113 0 foreach my $el (Net::DRI::Util::xml_list_children($infdata))
114 {
115 0 my ($n,$c)=@$el;
116 0 ▶ next unless $n eq 'contact';
Branch: 1 branch
BranchTrueFalseTotal
unless $n eq "contact" 0 0 0
117 0 $t{'type'} = $c->getAttribute('type');
118 0 foreach my $el2 (Net::DRI::Util::xml_list_children($c))
119 {
120 0 my ($n2,$c2)=@$el2;
121 0 ▶ $t{$n2}=$c->textContent() if ($n2=~m/^(?:id)$/)
Branch: 1 branch
BranchTrueFalseTotal
if $n2 =~ /^(?:id)$/ 0 0 0
122 }
123 }
124  
125 0 $rinfo->{$otype}->{$oname}->{association}=\%t;
126  
127 0 return;
128 }
129  
130 ####################################################################################################
131 1 1;
« DRI/Protocol/EPP/Extensions/SE/Extensions.pm ↑ Summary DRI/Protocol/EPP/Extensions/FCCN/Contact.pm »