DRI/Protocol/EPP/Extensions/CIRA/IDN.pm

filter: Statementstmt 18.8% 16 / 85 Branchbran 0.0% 0 / 34 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 35.7% 5 / 14 Podpod 0.0% 0 / 8 totaltotal 14.3% 21 / 146 CC 21 SCAR 38.9
CC
21
Cov
13%
bundle_info_parse
132.0
domain_create_build
20.0
_validate_repertoire
12.0
CRAP 48.9
« DRI/DRD/ICANN.pm ↑ Summary DRI/Data/ContactSet.pm »
1 ## Domain Registry Interface, CIRA IDN handling (draft-wilcox-cira-idn-eppext-00)
2 ##
3 ## Copyright (c) 2015,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::CIRA::IDN;
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 1 ▶use feature 'state';
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 {
28 0 ▶ my ($class,$version)=@_;
Subroutine register_commands: not called CC=1 SCAR=6.9
Pod undocumented
29 0 state $ops = { 'domain' => { check => [ \&domain_check_build, undef ],
30 check_multi => [ \&domain_check_build, undef ],
31 info => [ undef, \&domain_info_parse ],
32 create => [ \&domain_create_build, undef ],
33 },
34 'bundle' => { info => [ \&bundle_info_build, \&bundle_info_parse ],
35 },
36 };
37  
38 0 return $ops;
39 }
40  
41 sub setup
42 {
43 0 ▶ my ($class,$po,$version)=@_;
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
44 0 state $ns={ 'cira-idn' => 'urn:ietf:params:xml:ns:cira-idn-1.0',
45 'cira-idn-bundle' => 'urn:ietf:params:xml:ns:cira-idn-bundle-1.0',
46 };
47 0 $po->ns($ns);
48 0 return;
49 }
50  
51 0 ▶sub implements { return 'https://tools.ietf.org/html/draft-wilcox-cira-idn-eppext-00'; }
Subroutine implements: not called CC=1 SCAR=6.9
Pod undocumented
52  
53 ####################################################################################################
54  
55 sub _validate_repertoire
56 {
57 0 ▶ my ($rp)=@_;
Subroutine _validate_repertoire: not called CC=3 SCAR=24.8
58 ## This set is called a repertoire throughout the document, as a synonym with idn_table.
59 0 ▶ return 0 unless Net::DRI::Util::has_key($rp,'idn_table');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($rp, "idn_table") 0 0 0
60 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('idn_table must be of type XML schema token with 2 characters') unless Net::DRI::Util::xml_is_token($rp->{idn_table},2,2);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($rp->{"idn_table"}, 2, 2) 0 0 0
61 0 return 1;
62 }
63  
64 sub domain_check_build
65 {
66 0 ▶ my ($epp,$domain,$rp)=@_;
Subroutine domain_check_build: not called CC=2 SCAR=17.9
Pod undocumented
67 0 my $mes=$epp->message();
68 0 ▶ return unless _validate_repertoire($rp);
Branch: 1 branch
BranchTrueFalseTotal
unless _validate_repertoire($rp) 0 0 0
69 0 my $eid=$mes->command_extension_register('cira-idn','ciraIdnCheck');
70 0 $mes->command_extension($eid,['cira-idn:repertoire',$rp->{idn_table}]);
71 0 return;
72 }
73  
74 sub domain_info_parse
75 {
76 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine domain_info_parse: not called CC=3 SCAR=24.8
Pod undocumented
77 0 my $mes=$po->message();
78 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
79  
80 0 my $data=$mes->get_extension('cira-idn','ciraIdnInfo');
81 0 ▶ return unless defined $data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data 0 0 0
82  
83 0 my @v=map { $_->textContent() } Net::DRI::Util::xml_traverse($data,$mes->ns('cira-idn'),qw/domainVariants name/);
84 0 $rinfo->{domain}->{$oname}->{variants}=\@v;
85 0 return;
86 }
87  
88 sub bundle_info_build
89 {
90 0 ▶ my ($epp,$bundle,$rp)=@_;
Subroutine bundle_info_build: not called CC=3 SCAR=24.8
Pod undocumented
91 0 my $mes=$epp->message();
92  
93 0 my @d;
94 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('bundle name must be of type eppcom:labelType') unless Net::DRI::Util::xml_is_token($bundle,1,255);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($bundle, 1, 255) 0 0 0
95 0 push @d,['cira-idn-bundle:name',$bundle];
96 0 ▶ if (_validate_repertoire($rp))
Branch: 1 branch
BranchTrueFalseTotal
if (_validate_repertoire($rp)) 0 0 0
97 {
98 0 push @d,['cira-idn-bundle:repertoire',$rp->{idn_table}];
99 }
100  
101 0 $mes->command(['info','cira-idn-bundle:info', $mes->nsattrs('cira-idn-bundle')]);
102 0 $mes->command_body(\@d);
103 0 return;
104 }
105  
106 sub bundle_info_parse
107 {
108 0 ▶ my ($po,$otype,$oaction,$oname,$rinfo)=@_;
Subroutine bundle_info_parse: not called CC=11 SCAR=48.8
Pod undocumented
109 0 my $mes=$po->message();
110 0 ▶ return unless $mes->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $mes->is_success 0 0 0
111  
112 0 my $data=$mes->get_extension('cira-idn-bundle','infData');
113 0 ▶ return unless defined $data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data 0 0 0
114  
115 0 my %r;
116 0 my $cs=$po->create_local_object('contactset');
117 0 foreach my $el (Net::DRI::Util::xml_list_children($data))
118 {
119 0 my ($name,$c)=@$el;
120 0 ▶ if ($name eq 'canonicalDomainName' || $name eq 'roid')
Branch: 5 branches
BranchTrueFalseTotal
if ($name eq 'canonicalDomainName' or $name eq 'roid') { } 0 0 0
elsif ($name eq 'registrant') { } 0 0 0
elsif ($name =~ /^(clID|crID|upID)$/) { } 0 0 0
elsif ($name =~ /^(crDate|upDate|trDate)$/) { } 0 0 0
elsif ($name eq 'bundleDomains') { } 0 0 0
Condition0%0/3
$name eq "canonicalDomainName" or $name eq "roid"
l!l&&r!l&&!r
000
MC/DC0%0/2
$name eq "canonicalDomainName" or $name eq "roid"
$name eq "canonicalDomainName" $name eq "roid"
Truth table0%0/3
A or B
A= $name eq "canonicalDomainName"B= $name eq "roid"
ABresult
1X1
011
000
121 {
122 0 $r{Net::DRI::Util::remcam($name)}=$c->textContent();
123 } elsif ($name eq 'registrant')
124 {
125 0 $cs->set($po->create_local_object('contact')->srid($c->textContent()),'registrant');
126 0 $r{contact}=$cs;
127 } elsif ($name=~m/^(clID|crID|upID)$/)
128 {
129 0 $r{$1}=$c->textContent();
130 } elsif ($name=~m/^(crDate|upDate|trDate)$/)
131 {
132 0 $r{$1}=$po->parse_iso8601($c->textContent());
133 } elsif ($name eq 'bundleDomains')
134 {
135 0 $r{variants}=[ map { $_->textContent() } Net::DRI::Util::xml_traverse($c,$mes->ns('cira-idn'),qw/name/) ];
136 }
137 }
138  
139 0 foreach my $domain (@{$r{variants}}, $r{canonical_domain_name}) ## $oname is among $r{variants}
140 {
141 0 $rinfo->{bundle}->{$domain}=\%r;
142 }
143  
144 0 return;
145 }
146  
147 sub domain_create_build
148 {
149 0 ▶ my ($epp,$domain,$rp)=@_;
Subroutine domain_create_build: not called CC=4 SCAR=30.0
Pod undocumented
150 0 my $mes=$epp->message();
151  
152 0 ▶ return unless _validate_repertoire($rp);
Branch: 1 branch
BranchTrueFalseTotal
unless _validate_repertoire($rp) 0 0 0
153  
154 0 my @d;
155 0 push @d,['cira-idn:repertoire',$rp->{idn_table}];
156 0 ▶ if (Net::DRI::Util::has_key($rp,'ulabel')) ## TODO: compute u-label directly from $domain
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::has_key($rp, "ulabel")) 0 0 0
157 {
158 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('ulabel must be of type eppcom:labelType') unless Net::DRI::Util::xml_is_token($rp->{ulabel},1,255);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($rp->{"ulabel"}, 1, 255) 0 0 0
159 0 push @d,['cira-idn:u-label',$rp->{ulabel}];
160 }
161  
162 0 my $eid=$mes->command_extension_register('cira-idn','ciraIdnCreate');
163 0 $mes->command_extension($eid,\@d);
164 0 return;
165 }
166  
167 ####################################################################################################
168 1 1;
169  
170 __END__
171  
172 =pod
173  
174 =head1 NAME
175  
176 Net::DRI::Protocol::EPP::Extensions::CIRA::IDN - CIRA IDN EPP (draft-wilcox-cira-idn-eppext-00) for Net::DRI
177  
178 =head1 DESCRIPTION
179  
180 Please see the README file for details.
181  
182 =head1 SUPPORT
183  
184 For now, support questions should be sent to:
185  
186 E<lt>netdri@dotandco.comE<gt>
187  
188 Please also see the SUPPORT file in the distribution.
189  
190 =head1 SEE ALSO
191  
192 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
193  
194 =head1 AUTHOR
195  
196 Patrick Mevzek, E<lt>netdri@dotandco.comE<gt>
197  
198 =head1 COPYRIGHT
199  
200 Copyright (c) 2015,2018 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
201 All rights reserved.
202  
203 This program is free software; you can redistribute it and/or modify
204 it under the terms of the GNU General Public License as published by
205 the Free Software Foundation; either version 2 of the License, or
206 (at your option) any later version.
207  
208 See the LICENSE file that comes with this distribution for more details.
209  
210 =cut
211  
« DRI/DRD/ICANN.pm ↑ Summary DRI/Data/ContactSet.pm »