DRI/Protocol/EPP/Extensions/CoCCA/IPVerification.pm

filter: Statementstmt 27.6% 13 / 47 Branchbran 0.0% 0 / 30 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 57.1% 4 / 7 Podpod 0.0% 0 / 3 totaltotal 18.4% 17 / 92 CC 18 SCAR 55.5
CC
18
Cov
16%
create
342.0
register_commands
2.0
setup
2.0
CRAP 256.8
« DRI/Protocol/EPP/Extensions/NO/Domain.pm ↑ Summary DRI/Data/Contact/Nominet.pm »
1 ## Domain Registry Interface, CoCCA IP Protection
2 ## from http://cocca.org.nz/index.php/cocca-tools/extensions.html
3 ##
4 ## Copyright (c) 2011,2013,2016,2018-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::CoCCA::IPVerification;
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::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 =pod
25  
26 =head1 NAME
27  
28 Net::DRI::Protocol::EPP::Extensions::CoCCA::IPVerification - CoCCA IP Protection EPP Extension 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) 2011,2013,2016,2018-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 %tmp=(
70 create => [ \&create, undef ],
71 );
72  
73 0 return { 'domain' => \%tmp };
74 }
75  
76 sub setup
77 0 ▶{
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
78 0 my ($class,$po,$version)=@_;
79 0 $po->ns({ 'cocca' => 'https://production.coccaregistry.net/cocca-ip-verification-1.1' });
80 0 return;
81 }
82  
83 ####################################################################################################
84  
85 sub create
86 0 ▶{
Subroutine create: not called CC=18 SCAR=58.3
Pod undocumented
87 0 my ($epp,$domain,$rd)=@_;
88  
89 0 my @ipv;
90  
91 0 ▶ if (Net::DRI::Util::has_key($rd,'chip'))
Branch: 2 branches
BranchTrueFalseTotal
if (Net::DRI::Util::has_key($rd, 'chip')) { } 0 0 0
elsif (Net::DRI::Util::has_key($rd, 'trademark')) { } 0 0 0
92 {
93 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('chip code must be an XML token from 1 to 255 characters') unless Net::DRI::Util::xml_is_token($rd->{chip},1,255);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($rd->{"chip"}, 1, 255) 0 0 0
94 0 push @ipv,['cocca:chip',['cocca:code',$rd->{chip}]];
95 } elsif (Net::DRI::Util::has_key($rd,'trademark'))
96 {
97 0 ▶ foreach my $tm (ref $rd->{trademark} eq 'ARRAY' ? @{$rd->{trademark}} : ($rd->{trademark}))
Branch: 1 branch
BranchTrueFalseTotal
ref $rd->{'trademark'} eq 'ARRAY' ? : 0 0 0
98 {
99 0 my @t;
100  
101 ## Key names were chosen to mimic the ones in CloudRegistry/LaunchPhase
102 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('trademark name is mandatory') unless Net::DRI::Util::has_key($tm,'trademark_name');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($tm, "trademark_name") 0 0 0
103 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('trademark name must be an XML token from 1 to 255 characters') unless Net::DRI::Util::xml_is_token($tm->{trademark_name},1,255);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($tm->{"trademark_name"}, 1, 255) 0 0 0
104 0 push @t,['cocca:registeredMark',$tm->{trademark_name}];
105  
106 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('trademark number is mandatory') unless Net::DRI::Util::has_key($tm,'trademark_number');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($tm, "trademark_number") 0 0 0
107 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('trademark number must be an XML token from 1 to 255 characters') unless Net::DRI::Util::xml_is_token($tm->{trademark_number},1,255);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($tm->{"trademark_number"}, 1, 255) 0 0 0
108 0 push @t,['cocca:registrationNumber',$tm->{trademark_number}];
109  
110 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('trademark locality is mandatory') unless Net::DRI::Util::has_key($tm,'trademark_locality');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($tm, "trademark_locality") 0 0 0
111 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('trademark locality must be a 2 letters country code') unless Net::DRI::Util::xml_is_token($tm->{trademark_locality},2,2);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($tm->{"trademark_locality"}, 2, 2) 0 0 0
112 0 push @t,['cocca:registrationLocality',$tm->{trademark_locality}];
113  
114 0 ▶ Net::DRI::Exception::usererr_insufficient_parameters('trademark entitlement is mandatory') unless Net::DRI::Util::has_key($tm,'trademark_entitlement');
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::has_key($tm, "trademark_entitlement") 0 0 0
115 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('trademark entitlement must be "OWNER" or "ASSIGNEE"') unless Net::DRI::Util::xml_is_token($tm->{trademark_entitlement}) && $tm->{trademark_entitlement}=~m/^(?:OWNER|ASSIGNEE)$/i;
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($tm->{"trademark_entitlement"}) and $tm->{"trademark_entitlement"} =~ /^(?:OWNER|ASSIGNEE)$/i 0 0 0
Condition0%0/3
Net::DRI::Util::xml_is_token($tm->{"trademark_entitlement"}) and $tm->{"trademark_entitlement"} =~ /^(?:OWNER|ASSIGNEE)$/i
!ll&&!rl&&r
000
MC/DC0%0/2
Net::DRI::Util::xml_is_token($tm->{"trademark_entitlement"}) and $tm->{"trademark_entitlement"} =~ /^(?:OWNER|ASSIGNEE)$/i
Net::DRI::Util::xml_is_token($tm->{"trademark_entitlement"}) $tm->{"trademark_entitlement"} =~ /^(?:OWNER|ASSIGNEE)$/i
Truth table0%0/3
A and B
A= Net::DRI::Util::xml_is_token($tm->{"trademark_entitlement"})B= $tm->{"trademark_entitlement"} =~ /^(?:OWNER|ASSIGNEE)$/i
ABresult
0X0
100
111
116 0 push @t,['cocca:capacity',uc $tm->{trademark_entitlement}];
117  
118 0 ▶ if (Net::DRI::Util::has_key($tm,'legal_id'))
Branch: 1 branch
BranchTrueFalseTotal
if (Net::DRI::Util::has_key($tm, "legal_id")) 0 0 0
119 {
120 0 ▶ Net::DRI::Exception::usererr_invalid_parameters('legal id must be an XML token from 1 to 255 characters') unless Net::DRI::Util::xml_is_token($tm->{legal_id},1,255);
Branch: 1 branch
BranchTrueFalseTotal
unless Net::DRI::Util::xml_is_token($tm->{"legal_id"}, 1, 255) 0 0 0
121 0 push @t,['cocca:companyNumber',$tm->{legal_id}];
122 }
123  
124 0 push @ipv,['cocca:trademark',@t];
125 }
126 0 @ipv=['cocca:trademarks',@ipv];
127 }
128  
129 0 ▶ return unless @ipv;
Branch: 1 branch
BranchTrueFalseTotal
unless @ipv 0 0 0
130  
131 0 $epp->message()->command_extension('cocca', ['extension', @ipv]);
132 0 return;
133 }
134  
135 ####################################################################################################
136 1 1;
« DRI/Protocol/EPP/Extensions/NO/Domain.pm ↑ Summary DRI/Data/Contact/Nominet.pm »