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

filter: Statementstmt 17.5% 13 / 74 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.9% 17 / 156 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,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::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,2019 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 0 ▶{
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
68 0 my ($class,$version)=@_;
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 0 ▶{
Subroutine build_sponsors: not called CC=2 SCAR=17.9
Pod undocumented
86 0 my $s=shift;
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 0 ▶{
Subroutine build_prefs: not called CC=3 SCAR=24.8
Pod undocumented
92 0 my $contact=shift;
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 0 ▶{
Subroutine create: not called CC=3 SCAR=24.8
Pod undocumented
101 0 my ($epp,$contact)=@_;
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 $epp->message()->command_extension('coop', ['create', @n]);
111 0 return;
112 }
113  
114 sub update
115 0 ▶{
Subroutine update: not called CC=5 SCAR=34.0
Pod undocumented
116 0 my ($epp,$domain,$todo)=@_;
117  
118 0 my @n;
119 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
120 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
121 0 my @nn=build_prefs($todo->set('info'));
122 0 ▶ push @n,['coop:chg',\@nn] if @nn;
Branch: 1 branch
BranchTrueFalseTotal
if @nn 0 0 0
123 0 ▶ return unless @n;
Branch: 1 branch
BranchTrueFalseTotal
unless @n 0 0 0
124  
125 0 $epp->message()->command_extension('coop', ['update', @n]);
126 0 return;
127 }
128  
129 sub info_parse
130 0 ▶{
Subroutine info_parse: not called CC=7 SCAR=40.3
Pod undocumented
131 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
132 0 my $mes=$po->message();
133 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
134  
135 0 my $infdata=$mes->get_extension('coop','infData');
136 0 ▶ return unless $infdata;
Branch: 1 branch
BranchTrueFalseTotal
unless $infdata 0 0 0
137  
138 0 my $s=$rinfo->{contact}->{$oname}->{self};
139  
140 0 my $ns=$mes->ns('coop');
141 0 my $el=$infdata->getChildrenByTagNameNS($ns,'state');
142 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
143  
144 0 my @s=map { $_->getFirstChild()->getData() } $infdata->getChildrenByTagNameNS($ns,'sponsor');
145 0 ▶ $s->sponsors(\@s) if @s;
Branch: 1 branch
BranchTrueFalseTotal
if @s 0 0 0
146  
147 0 $el=$infdata->getChildrenByTagNameNS($ns,'langPref');
148 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
149 0 $el=$infdata->getChildrenByTagNameNS($ns,'mailingListPref');
150 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
151 0 return;
152 }
153  
154 ####################################################################################################
155  
156 sub domain_create
157 0 ▶{
Subroutine domain_create: not called CC=4 SCAR=30.0
Pod undocumented
158 0 my ($epp,$domain,$rd)=@_;
159  
160 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
161 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
162 0 return;
163 }
164  
165 sub domain_parse
166 0 ▶{
Subroutine domain_parse: not called CC=8 SCAR=42.8
Pod undocumented
167 0 my ($po,$otype,$oaction,$oname,$rinfo)=@_;
168 0 my $mes=$po->message();
169 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
170  
171 0 my $data=$mes->get_extension('coop','stateChange');
172 0 ▶ return unless $data;
Branch: 1 branch
BranchTrueFalseTotal
unless $data 0 0 0
173  
174 0 my $id=$data->getChildrenByTagNameNS($mes->ns('coop'),'id')->get_node(1)->getFirstChild()->getData();
175 0 $rinfo->{contact}->{$id}->{state}=$data->getChildrenByTagNameNS($mes->ns('coop'),'state')->get_node(1)->getAttribute('code');
176 0 $rinfo->{contact}->{$id}->{action}='verification_review';
177  
178 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
179 {
180 0 $rinfo->{domain}->{$oname}->{registrant_id}=$id;
181 0 $rinfo->{domain}->{$oname}->{registrant_state}=$rinfo->{contact}->{$id}->{state};
182 }
183 0 return;
184 }
185  
186 ####################################################################################################
187 1 1;
« DRI/Protocol/EPP/Extensions/AT/IOptions.pm ↑ Summary DRI/Protocol/AdamsNames/WS/Message.pm »