DRI/DRD/NORID.pm

filter: Statementstmt 27.1% 29 / 107 Branchbran 2.7% 1 / 36 Conditioncond 0.0% 0 / 33 MC/DCmcdc 0.0% 0 / 18 Subroutinesub 43.4% 10 / 23 Podpod 23.5% 4 / 17 totaltotal 18.8% 44 / 234 CC 35 SCAR 49.3
CC
35
Cov
17%
host_update
380.0
verify_duration_renew
56.0
message_count
30.0
CRAP 138.7
« DRI/Protocol/EPP/Extensions/TCI/Contact.pm ↑ Summary DRI/Protocol/OpenSRS/XCP/Domain.pm »
1 ## Domain Registry Interface, NORID (.NO) policies for Net::DRI
2 ##
3 ## Copyright (c) 2008-2010 UNINETT Norid AS, E<lt>http://www.norid.noE<gt>, Trond Haugen E<lt>info@norid.noE<gt>. All rights reserved.
4 ## (c) 2011,2013,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::DRD::NORID;
17  
18 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 2 ▶use base qw/Net::DRI::DRD/;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 2 ▶use DateTime::Duration;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 2 ▶use Net::DRI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 2 ▶use Net::DRI::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 # let contact check support be decided by the server policy
28 2 __PACKAGE__->make_exception_for_unavailable_operations(qw/domain_transfer_accept domain_transfer_refuse contact_transfer_stop contact_transfer_query contact_transfer_accept contact_transfer_refuse/);
29  
30 =pod
31  
32 =head1 NAME
33  
34 Net::DRI::DRD::NORID - NORID (.NO) policies for Net::DRI
35  
36 =head1 DESCRIPTION
37  
38 Please see the README file for details.
39  
40 =head1 SUPPORT
41  
42 For now, support questions should be sent to:
43  
44 E<lt>netdri@dotandco.comE<gt>
45  
46 Please also see the SUPPORT file in the distribution.
47  
48 =head1 SEE ALSO
49  
50 E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt>
51  
52 =head1 AUTHOR
53  
54 Trond Haugen E<lt>info@norid.noE<gt>
55  
56 =head1 COPYRIGHT
57  
58 Copyright (c) 2008-2010 UNINETT Norid AS, E<lt>http://www.norid.noE<gt>, Trond Haugen E<lt>info@norid.noE<gt>
59 (c) 2011,2013,2016 Patrick Mevzek <netdri@dotandco.com>. All rights reserved.
60 All rights reserved.
61  
62 This program is free software; you can redistribute it and/or modify
63 it under the terms of the GNU General Public License as published by
64 the Free Software Foundation; either version 2 of the License, or
65 (at your option) any later version.
66  
67 See the LICENSE file that comes with this distribution for more details.
68  
69 =cut
70  
71 ####################################################################################################
72  
73 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
74 1 my $class = shift;
75 1 my $self = $class->SUPER::new(@_);
76 1 $self->{info}->{host_as_attr} = 0; # means make host objects
77 1 $self->{info}->{use_null_auth}= 1; # means using domain:null for empty authinfo password
78 1 return $self;
79 }
80  
81 0 ▶sub periods {
Subroutine periods: not called CC=1 SCAR=6.9
Pod documented
82 0 return map { DateTime::Duration->new( years => $_ ) } (1);
83 }
84 1 ▶sub name { return 'NORID'; }
Subroutine name: called CC=1 SCAR=0.0
Pod documented
85 1 ▶sub tlds { return ('no'); }
Subroutine tlds: called CC=1 SCAR=0.0
Pod documented
86 0 ▶sub object_types { return ( 'domain', 'contact', 'ns' ); }
Subroutine object_types: not called CC=1 SCAR=6.9
Pod documented
87 0 ▶sub profile_types { return qw/epp/; }
Subroutine profile_types: not called CC=1 SCAR=6.9
Pod undocumented
88  
89 1 ▶sub transport_protocol_default {
Subroutine transport_protocol_default: called CC=2 SCAR=8.1
Pod undocumented
90 1 my ($self,$type)=@_;
91  
92 1 ▶ return ('Net::DRI::Transport::Socket',{},'Net::DRI::Protocol::EPP::Extensions::NO',{}) if $type eq 'epp';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "epp" 1 0 1
93 # suppress until whois is supported
94 #return ('Net::DRI::Transport::Socket',{remote_host=>'whois.norid.no'},'Net::DRI::Protocol::Whois',{}) if $type eq 'whois';
95  
96 0 return;
97 }
98  
99 ####################################################################################################
100  
101 =head1 verify_name_domain
102  
103 .NO allows country codes in labels on the left, so we need to subclass
104 the verify_name_domain to avoid the CCA2 table check.
105  
106 We then clone the .AT code also here, but remove the dot-count and check
107 in 'check_name'.
108  
109 However, we do not subclass the 'is_my_tld' as .AT has done,
110 but we then have to call it in a non-strict mode to allow for
111 domain names with multiple labels.
112  
113 The combination should then allow multiple labels and also
114 to use CC-codes in lables, like 'se.vgs.no'
115  
116 =cut
117  
118 sub verify_name_domain
119 0 ▶{
Subroutine verify_name_domain: not called CC=1 SCAR=6.9
Pod undocumented
120 0 my ($self,$ndr,$domain,$op)=@_;
121 0 return $self->_verify_name_rules($domain,$op,{check_name_no_dots => 1,
122 my_tld_not_strict => 0,
123 });
124 }
125  
126 0 ▶sub verify_duration_renew {
Subroutine verify_duration_renew: not called CC=7 SCAR=40.3
Pod undocumented
127 0 my ( $self, $ndr, $duration, $domain, $curexp ) = @_;
128  
129 0 ▶ if ( defined($duration) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $duration) 0 0 0
130 0 my ( $y, $m ) = $duration->in_units( 'years', 'months' );
131  
132 ## Only 1..12m or 1y allowed in a renew
133 0 ▶ unless ( ( $y == 1 && $m == 0 )
Branch: 1 branch
BranchTrueFalseTotal
unless ($y == 1 and $m == 0 or $y == 0 and ($m >= 1 and $m <= 12)) 0 0 0
Condition0%0/12
$y == 1 and $m == 0 or $y == 0 and ($m >= 1 and $m <= 12)
l!l&&r!l&&!r
000
$y == 1 and $m == 0
!ll&&!rl&&r
000
$y == 0 and ($m >= 1 and $m <= 12)
!ll&&!rl&&r
000
$m >= 1 and $m <= 12
!ll&&!rl&&r
000
MC/DC0%0/5
$y == 1 and $m == 0 or $y == 0 and ($m >= 1 and $m <= 12)
$y == 1 $m == 0 $y == 0 $m >= 1 $m <= 12
Truth table0%0/9
A and B or C and D and E
A= $y == 1B= $m == 0C= $y == 0D= $m >= 1E= $m <= 12
ABCDEresult
11XXX1
0X1111
101111
0X0XX0
0X10X0
0X1100
100XX0
1010X0
101100
134 || ( $y == 0 && ( $m >= 1 && $m <= 12 ) ) )
135 {
136 0 return 1; # if exception is removed, return an error
137 }
138 }
139 0 return 0; ## everything ok
140 }
141  
142 0 ▶sub domain_operation_needs_is_mine {
Subroutine domain_operation_needs_is_mine: not called CC=4 SCAR=30.0
Pod undocumented
143 0 my ( $self, $ndr, $domain, $op ) = @_;
144 0 ▶ return unless defined($op);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $op 0 0 0
145  
146 0 ▶ return 1 if ( $op =~ m/^(?:renew|update|delete|withdraw)$/mx );
Branch: 1 branch
BranchTrueFalseTotal
if $op =~ /^(?:renew|update|delete|withdraw)$/mx 0 0 0
147 0 ▶ return 0 if ( $op eq 'transfer' );
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "transfer" 0 0 0
148 0 return;
149 }
150  
151 0 ▶sub domain_withdraw {
Subroutine domain_withdraw: not called CC=1 SCAR=6.9
Pod undocumented
152 0 my ( $self, $ndr, $domain, $rd ) = @_;
153 0 $self->enforce_domain_name_constraints($ndr,$domain,'withdraw');
154  
155 0 $rd=Net::DRI::Util::create_params('domain_withdraw',$rd);
156 0 $rd->{transactionname} = 'withdraw';
157  
158 0 my $rc = $ndr->process( 'domain', 'withdraw', [ $domain, $rd ] );
159 0 return $rc;
160 }
161  
162 sub domain_transfer_execute
163 0 ▶{
Subroutine domain_transfer_execute: not called CC=1 SCAR=6.9
Pod undocumented
164 0 my ($self,$ndr,$domain,$rd)=@_;
165 0 $self->enforce_domain_name_constraints($ndr,$domain,'transfer_execute');
166  
167 0 $rd=Net::DRI::Util::create_params('domain_transfer_execute',$rd);
168 0 $rd->{transactionname} = 'transfer_execute';
169  
170 0 my $rc=$ndr->process('domain','transfer_execute',[$domain,$rd]);
171 0 return $rc;
172 }
173  
174 # need to accept also t=contact as an element-type to be updated
175 #
176 0 ▶sub host_update {
Subroutine host_update: not called CC=19 SCAR=59.4
Pod undocumented
177 0 my ( $self, $ndr, $dh, $tochange, $rh ) = @_;
178 0 my $fp = $ndr->protocol->nameversion();
179  
180 0 ▶ my $name=Net::DRI::Util::is_class($dh,'Net::DRI::Data::Hosts') ? $dh->get_details(1) : $dh;
Branch: 1 branch
BranchTrueFalseTotal
Net::DRI::Util::is_class($dh, 'Net::DRI::Data::Hosts') ? : 0 0 0
181 0 $self->enforce_host_name_constraints($ndr,$name);
182 0 Net::DRI::Util::check_isa( $tochange, 'Net::DRI::Data::Changes' );
183  
184 0 foreach my $t ( $tochange->types() ) {
185 0 ▶ Net::DRI::Exception->die( 0, 'DRD', 6,
Branch: 1 branch
BranchTrueFalseTotal
unless $t =~ /^(?:ip|status|name|contact|facets)$/mx 0 0 0
186 "Change host_update/${t} not handled" )
187 unless ( $t =~ m/^(?:ip|status|name|contact|facets)$/mx );
188 0 ▶ next if $ndr->protocol_capable( 'host_update', $t );
Branch: 1 branch
BranchTrueFalseTotal
if $ndr->protocol_capable("host_update", $t) 0 0 0
189 0 Net::DRI::Exception->die( 0, 'DRD', 5,
190 "Protocol ${fp} is not capable of host_update/${t}" );
191 }
192  
193 0 my %what = (
194 'ip' => [ $tochange->all_defined('ip') ],
195 'status' => [ $tochange->all_defined('status') ],
196 'name' => [ $tochange->all_defined('name') ],
197 );
198 0 foreach ( @{ $what{ip} } ) {
199 0 Net::DRI::Util::check_isa( $_, 'Net::DRI::Data::Hosts' );
200 }
201 0 foreach ( @{ $what{status} } ) {
202 0 Net::DRI::Util::check_isa( $_, 'Net::DRI::Data::StatusList' );
203 }
204 0 foreach ( @{ $what{name} } ) {
205 0 $self->enforce_host_name_constraints($ndr,$_);
206 }
207  
208 0 foreach my $w ( keys(%what) ) {
209 0 my @s = @{ $what{$w} };
210 0 ▶ next unless @s; ## no changes of that type
Branch: 1 branch
BranchTrueFalseTotal
unless @s 0 0 0
211  
212 0 my $add = $tochange->add($w);
213 0 my $del = $tochange->del($w);
214 0 my $set = $tochange->set($w);
215  
216 0 ▶ Net::DRI::Exception->die( 0, 'DRD', 5,
Branch: 1 branch
BranchTrueFalseTotal
if defined $add and not $ndr->protocol_capable("host_update", $w, "add") 0 0 0
Condition0%0/3
defined $add and not $ndr->protocol_capable("host_update", $w, "add")
!ll&&!rl&&r
000
MC/DC0%0/2
defined $add and not $ndr->protocol_capable("host_update", $w, "add")
defined $add not $ndr->protocol_capable("host_update", $w, "add")
Truth table0%0/3
A and not(B)
A= defined $addB= not $ndr->protocol_capable("host_update", $w, "add")
ABresult
0X0
100
111
217 "Protocol ${fp} is not capable for host_update/${w} to add" )
218 if ( defined($add)
219 && !$ndr->protocol_capable( 'host_update', $w, 'add' ) );
220 0 ▶ Net::DRI::Exception->die( 0, 'DRD', 5,
Branch: 1 branch
BranchTrueFalseTotal
if defined $del and not $ndr->protocol_capable("host_update", $w, "del") 0 0 0
Condition0%0/3
defined $del and not $ndr->protocol_capable("host_update", $w, "del")
!ll&&!rl&&r
000
MC/DC0%0/2
defined $del and not $ndr->protocol_capable("host_update", $w, "del")
defined $del not $ndr->protocol_capable("host_update", $w, "del")
Truth table0%0/3
A and not(B)
A= defined $delB= not $ndr->protocol_capable("host_update", $w, "del")
ABresult
0X0
100
111
221 "Protocol ${fp} is not capable for host_update/${w} to del" )
222 if ( defined($del)
223 && !$ndr->protocol_capable( 'host_update', $w, 'del' ) );
224 0 ▶ Net::DRI::Exception->die( 0, 'DRD', 5,
Branch: 1 branch
BranchTrueFalseTotal
if defined $set and not $ndr->protocol_capable("host_update", $w, "set") 0 0 0
Condition0%0/3
defined $set and not $ndr->protocol_capable("host_update", $w, "set")
!ll&&!rl&&r
000
MC/DC0%0/2
defined $set and not $ndr->protocol_capable("host_update", $w, "set")
defined $set not $ndr->protocol_capable("host_update", $w, "set")
Truth table0%0/3
A and not(B)
A= defined $setB= not $ndr->protocol_capable("host_update", $w, "set")
ABresult
0X0
100
111
225 "Protocol ${fp} is not capable for host_update/${w} to set" )
226 if ( defined($set)
227 && !$ndr->protocol_capable( 'host_update', $w, 'set' ) );
228 0 ▶ Net::DRI::Exception->die( 0, 'DRD', 6,
Branch: 1 branch
BranchTrueFalseTotal
if defined $set and defined $add || defined $del 0 0 0
Condition0%0/6
defined $set and defined $add || defined $del
!ll&&!rl&&r
000
defined $add or defined $del
l!l&&r!l&&!r
000
MC/DC0%0/3
defined $set and defined $add || defined $del
defined $set defined $add defined $del
Truth table0%0/4
A and B or C
A= defined $setB= defined $addC= defined $del
ABCresult
0XX0
1000
11X1
1011
229 "Change host_update/${w} with simultaneous set and add or del not supported"
230 ) if ( defined($set) && ( defined($add) || defined($del) ) );
231 }
232  
233 0 my $rc = $ndr->process( 'host', 'update', [ $dh, $tochange, $rh ] );
234 0 return $rc;
235 }
236  
237 0 ▶sub message_retrieve {
Subroutine message_retrieve: not called CC=1 SCAR=6.9
Pod undocumented
238 0 my ( $self, $ndr, $rd ) = @_;
239  
240 0 my $rc = $ndr->process( 'message', 'noretrieve', [$rd] );
241 0 return $rc;
242 }
243  
244 0 ▶sub message_delete {
Subroutine message_delete: not called CC=1 SCAR=6.9
Pod undocumented
245 0 my ( $self, $ndr, $id, $rd ) = @_;
246  
247 0 my $rc = $ndr->process( 'message', 'nodelete', [$id, $rd] );
248 0 return $rc;
249 }
250  
251 0 ▶sub message_waiting {
Subroutine message_waiting: not called CC=3 SCAR=24.8
Pod undocumented
252 0 my ( $self, $ndr, $rd ) = @_;
253  
254 0 my $c = $self->message_count($ndr, $rd);
255 0 ▶ return ( defined($c) && $c ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $c && $c ? : 0 0 0
Condition0%0/3
defined $c and $c
!ll&&!rl&&r
000
MC/DC0%0/2
defined $c and $c
defined $c $c
Truth table0%0/3
A and B
A= defined $cB= $c
ABresult
0X0
100
111
256 }
257  
258 0 ▶sub message_count {
Subroutine message_count: not called CC=5 SCAR=34.0
Pod undocumented
259 0 my ( $self, $ndr, $rd ) = @_;
260  
261 0 my $count = $ndr->get_info( 'count', 'message', 'info' );
262 0 ▶ return $count if defined($count);
Branch: 1 branch
BranchTrueFalseTotal
if defined $count 0 0 0
263  
264 0 my $rc = $ndr->process( 'message', 'noretrieve', [$rd] );
265  
266 0 ▶ return unless $rc->is_success();
Branch: 1 branch
BranchTrueFalseTotal
unless $rc->is_success 0 0 0
267 0 $count = $ndr->get_info( 'count', 'message', 'info' );
268 0 ▶ return ( defined($count) && $count ) ? $count : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $count && $count ? : 0 0 0
Condition0%0/3
defined $count and $count
!ll&&!rl&&r
000
MC/DC0%0/2
defined $count and $count
defined $count $count
Truth table0%0/3
A and B
A= defined $countB= $count
ABresult
0X0
100
111
269 }
270  
271 ####################################################################################################
272 2 1;
« DRI/Protocol/EPP/Extensions/TCI/Contact.pm ↑ Summary DRI/Protocol/OpenSRS/XCP/Domain.pm »