DRI/Protocol/EPP/Extensions/COOP/Contact.pm

filter: Statementstmt 16.6% 13 / 78 Branchbran 0.0% 0 / 40 Conditioncond 0.0% 0 / 15 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 33.3% 4 / 12 Podpod 0.0% 0 / 8 totaltotal 10.6% 17 / 160 CC 26 SCAR 35.5
CC
26
Cov
10%
domain_parse
72.0
info_parse
56.0
update
30.0
CRAP 34.8
« DRI/Protocol/EPP/Extensions/AT/IOptions.pm ↑ Summary DRI/Protocol/AdamsNames/WS/Message.pm »
1 ## Domain Registry Interface, .COOP Contact EPP extension commands
2 ## (based on document: EPP Extensions for the .coop TLD Registrant Verification version 1.6)
3 ##
4 ## Copyright (c) 2006,2008,2013-2014,2016 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::COOP::Contact;
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::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 =pod
25  
26 =head1 NAME
27  
28 Net::DRI::Protocol::EPP::Extensions::COOP::Contact - .COOP EPP Contact extension commands for Net::DRI
29  
30 =head1 DESCRIPTION
31  
32 Please see the README file for details.
33  
34 =head1 SUPPORT
35  
36 For now, support questions should be sent to:
37  
38 E<lt>netdri@dotandco.comE<gt>
39  
40 Please also see the SUPPORT file in the distribution.
41  
42 =head1 SEE ALSO
43  
44 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
45  
46 =head1 AUTHOR
47  
48 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
49  
50 =head1 COPYRIGHT
51  
52 Copyright (c) 2006,2008,2013-2014,2016 Patrick Mevzek <netdri@dotandco.com>.
53 All rights reserved.
54  
55 This program is free software; you can redistribute it and/or modify
56 it under the terms of the GNU General Public License as published by
57 the Free Software Foundation; either version 2 of the License, or
58 (at your option) any later version.
59  
60 See the LICENSE file that comes with this distribution for more details.
61  
62 =cut
63  
64 ####################################################################################################
65  
66 sub register_commands
67 {
68 0 ▶ my ($class,$version)=@_;
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
69 0 my %tmp1=(
70 create => [ \&create, undef ],
71 update => [ \&update, undef ],
72 info => [ undef, \&info_parse ],
73 );
74 0 my %tmp2=(
75 create => [ \&domain_create, \&domain_parse ],
76 update => [ undef, \&domain_parse ],
77 );
78  
79 0 return { 'contact' => \%tmp1, 'domain' => \%tmp2 };
80 }
81  
82 ####################################################################################################
83  
84 sub build_sponsors
85 {
86 0 ▶ my $s=shift;
Subroutine build_sponsors: not called CC=2 SCAR=17.9
Pod undocumented
87 0 ▶ return map { ['coop:sponsor',$_] } (ref($s)? @$s : $s);
Branch: 1 branch
BranchTrueFalseTotal
ref $s ? : 0 0 0
88 }
89  
90 sub build_prefs
91 {
92 0 ▶ my $contact=shift;
Subroutine build_prefs: not called CC=3 SCAR=24.8
Pod undocumented
93 0 my @n;
94 0 ▶ push @n,['coop:langPref',$contact->lang()] if $contact->lang();
Branch: 1 branch
BranchTrueFalseTotal
if $contact->lang 0 0 0
95 0 ▶ push @n,['coop:mailingListPref',$contact->mailing_list()] if $contact->mailing_list();
Branch: 1 branch
BranchTrueFalseTotal
if $contact->mailing_list 0 0 0
96 0 return @n;
97 }
98  
99 sub create
100 {
101 0 ▶ my ($epp,$contact)=@_;
Subroutine create: not called CC=3 SCAR=24.8
Pod undocumented
102  
103 ## validate() has been called
104 0 my @n;
105 0 push @n,build_prefs($contact);
106 0 ▶ push @n,build_sponsors($contact->sponsors()) if $contact->sponsors();
Branch: 1 branch
BranchTrueFalseTotal
if $contact->sponsors 0 0 0
107  
108 0 ▶ return unless @n;
Branch: 1 branch
BranchTrueFalseTotal
unless @n 0 0 0
109  
110 0 my $mes=$epp->message();
111 0 my $eid=$mes->command_extension_register('coop', 'create');
112 0 $mes->command_extension($eid,\@n);
113 0 return;
114 }
115  
116 sub update
117 {
118 0 ▶ my ($epp,$domain,$todo)=@_;
Subroutine update: not called CC=5 SCAR=34.0
Pod undocumented
119  
120 0 my @n;
121 0 ▶ push @n,['coop:add',build_sponsors($todo->add('sponsor'))] if $todo->add('sponsor');
Branch: 1 branch
BranchTrueFalseTotal
if $todo->add("sponsor") 0 0 0
122 0 ▶ push @n,['coop:rem',build_sponsors($todo->del('sponsor'))] if $todo->del('sponsor');
Branch: 1 branch
BranchTrueFalseTotal
if $todo->del("sponsor") 0 0 0
123 0 my @nn=build_prefs($todo->set('info'));
124 0 ▶ push @n,['coop:chg',\@nn] if @nn;
Branch: 1 branch
BranchTrueFalseTotal
if @nn 0 0 0
125 0 ▶ return unless @n;
Branch: 1 branch
BranchTrueFalseTotal
unless @n 0 0 0
126  
127 0 my $mes=$epp->message();
128 0 my $eid=$mes->command_extension_register('coop', 'update');
129 0 $mes->command_extension($eid,\@n);
130 0 return;
131 }
132  
133 sub info_parse
134 {
135 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine info_parse: not called CC=7 SCAR=40.3
Pod undocumented
136 0 my $mes=$po->message();
137 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
138  
139 0 my $infdata=$mes->get_extension('coop','infData');
140 0 ▶ return unless $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $infdata 0 0 0
141  
142 0 my $s=$rinfo->{contact}->{$oname}->{self};
143  
144 0 my $ns=$mes->ns('coop');
145 0 my $el=$infdata->getChildrenByTagNameNS($ns,'state');
146 0 ▶ $s->state($el->get_node(1)->getAttribute('code')) if defined($el->get_node(1));
Branch: 1 branch
BranchTrueFalseTotal
if defined $el->get_node(1) 0 0 0
147  
148 0 my @s=map { $_->getFirstChild()->getData() } $infdata->getChildrenByTagNameNS($ns,'sponsor');
149 0 ▶ $s->sponsors(\@s) if @s;
Branch: 1 branch
BranchTrueFalseTotal
if @s 0 0 0
150  
151 0 $el=$infdata->getChildrenByTagNameNS($ns,'langPref');
152 0 ▶ $s->lang($el->get_node(1)->getFirstChild()->getData()) if defined($el->get_node(1));
Branch: 1 branch
BranchTrueFalseTotal
if defined $el->get_node(1) 0 0 0
153 0 $el=$infdata->getChildrenByTagNameNS($ns,'mailingListPref');
154 0 ▶ $s->mailing_list($el->get_node(1)->getFirstChild()->getData()) if defined($el->get_node(1));
Branch: 1 branch
BranchTrueFalseTotal
if defined $el->get_node(1) 0 0 0
155 0 return;
156 }
157  
158 ####################################################################################################
159  
160 sub domain_create
161 {
162 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine domain_create: not called CC=4 SCAR=30.0
Pod undocumented
163  
164 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('registrant is mandatory') unless (Net::DRI::Util::has_contact($rd) && $rd->{contact}->get('registrant'));
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_contact($rd) and $rd->{"contact"}->get("registrant") 0 0 0
Condition0%0/3
Net::DRI::Util::has_contact($rd) and $rd->{"contact"}->get("registrant")
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::has_contact($rd) and $rd->{"contact"}->get("registrant")
Net::DRI::Util::has_contact($rd) $rd->{"contact"}->get("registrant")
Truth table0%0/3
A and B
A= Net::DRI::Util::has_contact($rd)B= $rd->{"contact"}->get("registrant")
ABresult
0X0
100
111
165 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('registrant org is mandatory') unless $rd->{contact}->get('registrant')->org();
Branch: 1 branch
BranchTrueFalseTotal
unless $rd->{"contact"}->get("registrant")->org 0 0 0
166 0 return;
167 }
168  
169 sub domain_parse
170 {
171 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine domain_parse: not called CC=8 SCAR=42.8
Pod undocumented
172 0 my $mes=$po->message();
173 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
174  
175 0 my $data=$mes->get_extension('coop','stateChange');
176 0 ▶ return unless $data;
Branch: 1 branch
BranchTrueFalseTotal
unless $data 0 0 0
177  
178 0 my $id=$data->getChildrenByTagNameNS($mes->ns('coop'),'id')->get_node(1)->getFirstChild()->getData();
179 0 $rinfo->{contact}->{$id}->{state}=$data->getChildrenByTagNameNS($mes->ns('coop'),'state')->get_node(1)->getAttribute('code');
180 0 $rinfo->{contact}->{$id}->{action}='verification_review';
181  
182 0 ▶ if (defined($otype) && ($otype eq 'domain') && defined($oaction) && ($oaction eq 'create' || $oaction eq 'update'))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $otype and $otype eq "domain" and defined $oaction and $oaction eq "create" || $oaction eq "update") 0 0 0
Condition0%0/12
defined $otype and $otype eq "domain" and defined $oaction and $oaction eq "create" || $oaction eq "update"
!ll&&!rl&&r
000
defined $otype and $otype eq "domain" and defined $oaction
!ll&&!rl&&r
000
defined $otype and $otype eq "domain"
!ll&&!rl&&r
000
$oaction eq "create" or $oaction eq "update"
l!l&&r!l&&!r
000
MC/DC0%0/5
defined $otype and $otype eq "domain" and defined $oaction and $oaction eq "create" || $oaction eq "update"
defined $otype $otype eq "domain" defined $oaction $oaction eq "create" $oaction eq "update"
Truth table0%0/6
A and B and C and D or E
A= defined $otypeB= $otype eq "domain"C= defined $oactionD= $oaction eq "create"E= $oaction eq "update"
ABCDEresult
0XXXX0
10XXX0
110XX0
111000
1111X1
111011
183 {
184 0 $rinfo->{domain}->{$oname}->{registrant_id}=$id;
185 0 $rinfo->{domain}->{$oname}->{registrant_state}=$rinfo->{contact}->{$id}->{state};
186 }
187 0 return;
188 }
189  
190 ####################################################################################################
191 1 1;
« DRI/Protocol/EPP/Extensions/AT/IOptions.pm ↑ Summary DRI/Protocol/AdamsNames/WS/Message.pm »