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

filter: Statementstmt 19.1% 13 / 68 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 12.9% 17 / 131 CC 21 SCAR 42.7
CC
21
Cov
12%
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 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 {
27 0 ▶ my ($class,$version)=@_;
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
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 {
39 0 ▶ my ($class,$po,$version)=@_;
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
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 {
50 0 ▶ my $as = shift;
Subroutine build_association: not called CC=2 SCAR=17.9
Pod undocumented
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 {
62 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine create: not called CC=4 SCAR=30.0
Pod undocumented
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 my $mes=$epp->message();
68 0 my $eid=$mes->command_extension_register('association','create');
69 0 $mes->command_extension($eid,\@t);
70  
71 0 return;
72 }
73  
74 sub update
75 {
76 0 ▶ my ($epp,$domain,$todo)=@_;
Subroutine update: not called CC=12 SCAR=50.5
Pod undocumented
77 0 my $mes=$epp->message();
78 0 my $toadd=$todo->add('association');
79 0 my $todel=$todo->del('association');
80 0 my $tochg=$todo->set('association');
81 0 my @def=grep { defined } ($toadd,$todel);
82 0 ▶ return unless @def; ## no updates asked
Branch: 1 branch
BranchTrueFalseTotal
unless @def 0 0 0
83  
84 0 my $eid=$mes->command_extension_register('association','update');
85  
86 0 my @n;
87 0 ▶ if (defined $toadd)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $toadd) 0 0 0
88 {
89 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
90 0 push @n,['association:add',build_association($toadd)]
91 }
92 0 ▶ if (defined $todel)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $todel) 0 0 0
93 {
94 0 undef $todel->{'pw'};
95 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
96 0 ▶ push @n,['association:rem',build_association($todel)] if (defined $todel);
Branch: 1 branch
BranchTrueFalseTotal
if defined $todel 0 0 0
97 }
98 0 ▶ if (defined $tochg)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tochg) 0 0 0
99 {
100 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
101 0 ▶ push @n,['association:rem',build_association($tochg)] if (defined $tochg);
Branch: 1 branch
BranchTrueFalseTotal
if defined $tochg 0 0 0
102 }
103  
104 0 $mes->command_extension($eid,\@n);
105  
106 0 return;
107 }
108  
109  
110 sub info_parse
111 {
112 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine info_parse: not called CC=6 SCAR=37.4
Pod undocumented
113 0 my $mes=$po->message();
114 0 my $infdata=$mes->get_extension('association','infData');
115 0 ▶ return unless defined $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $infdata 0 0 0
116  
117 0 my %t;
118 0 foreach my $el (Net::DRI::Util::xml_list_children($infdata))
119 {
120 0 my ($n,$c)=@$el;
121 0 ▶ next unless $n eq 'contact';
Branch: 1 branch
BranchTrueFalseTotal
unless $n eq "contact" 0 0 0
122 0 $t{'type'} = $c->getAttribute('type');
123 0 foreach my $el2 (Net::DRI::Util::xml_list_children($c))
124 {
125 0 my ($n2,$c2)=@$el2;
126 0 ▶ $t{$n2}=$c->textContent() if ($n2=~m/^(?:id)$/)
Branch: 1 branch
BranchTrueFalseTotal
if $n2 =~ /^(?:id)$/ 0 0 0
127 }
128 }
129  
130 0 $rinfo->{$otype}->{$oname}->{association}=\%t;
131  
132 0 return;
133 }
134  
135 ####################################################################################################
136 1 1;
« DRI/Protocol/EPP/Extensions/SE/Extensions.pm ↑ Summary DRI/Protocol/EPP/Extensions/FCCN/Contact.pm »