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

filter: Statementstmt 26.5% 13 / 49 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.0% 17 / 94 CC 18 SCAR 55.5
CC
18
Cov
16%
create
342.0
register_commands
2.0
setup
2.0
CRAP 256.8
« DRI/Protocol/RRI/Contact.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 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 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 %tmp=(
70 create => [ \&create, undef ],
71 );
72  
73 0 return { 'domain' => \%tmp };
74 }
75  
76 sub setup
77 {
78 0 ▶ my ($class,$po,$version)=@_;
Subroutine setup: not called CC=1 SCAR=6.9
Pod undocumented
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 {
87 0 ▶ my ($epp,$domain,$rd)=@_;
Subroutine create: not called CC=18 SCAR=58.3
Pod undocumented
88 0 my $mes=$epp->message();
89  
90 0 my @ipv;
91  
92 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
93 {
94 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
95 0 push @ipv,['cocca:chip',['cocca:code',$rd->{chip}]];
96 } elsif (Net::DRI::Util::has_key($rd,'trademark'))
97 {
98 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
99 {
100 0 my @t;
101  
102 ## Key names were chosen to mimic the ones in CloudRegistry/LaunchPhase
103 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
104 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
105 0 push @t,['cocca:registeredMark',$tm->{trademark_name}];
106  
107 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
108 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
109 0 push @t,['cocca:registrationNumber',$tm->{trademark_number}];
110  
111 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
112 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
113 0 push @t,['cocca:registrationLocality',$tm->{trademark_locality}];
114  
115 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
116 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
117 0 push @t,['cocca:capacity',uc $tm->{trademark_entitlement}];
118  
119 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
120 {
121 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
122 0 push @t,['cocca:companyNumber',$tm->{legal_id}];
123 }
124  
125 0 push @ipv,['cocca:trademark',@t];
126 }
127 0 @ipv=['cocca:trademarks',@ipv];
128 }
129  
130 0 ▶ return unless @ipv;
Branch: 1 branch
BranchTrueFalseTotal
unless @ipv 0 0 0
131  
132 0 my $eid=$mes->command_extension_register('cocca','extension');
133 0 $mes->command_extension($eid,[@ipv]);
134 0 return;
135 }
136  
137 ####################################################################################################
138 1 1;
« DRI/Protocol/RRI/Contact.pm ↑ Summary DRI/Data/Contact/Nominet.pm »