| 1 | ## Domain Registry Interface, EPP AusRegistry Domain Variant Extension | ||||||||||||||||||||||||||||
| 2 | ## | ||||||||||||||||||||||||||||
| 3 | ## Copyright (c) 2013,2018-2019 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::AusRegistry::Variant; | ||||||||||||||||||||||||||||
| 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 | |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use Net::DRI::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use Net::DRI::Exception; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | #################################################################################################### | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | sub register_commands | ||||||||||||||||||||||||||||
| 26 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
register_commands: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 0 | my ($class,$version)=@_; | |||||||||||||||||||||||||||
| 28 | 0 | my %tmp=( | |||||||||||||||||||||||||||
| 29 | info => [ \&info_build, \&info_parse ], | ||||||||||||||||||||||||||||
| 30 | create => [ undef, \&create_parse ], | ||||||||||||||||||||||||||||
| 31 | update => [ \&update_build, undef ], | ||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | return { 'domain' => \%tmp }; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | sub setup | ||||||||||||||||||||||||||||
| 38 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
setup: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 39 | 0 | my ($class,$po,$version)=@_; | |||||||||||||||||||||||||||
| 40 | 0 | $po->ns({ 'variant' => 'urn:X-ar:params:xml:ns:variant-1.0' }); | |||||||||||||||||||||||||||
| 41 | 0 | return; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub capabilities_add { return ('domain_update','variants',['add','del']); } | ||||||||||||||||||||||||||
|
Subroutine
capabilities_add: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | #################################################################################################### | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | ## (This extension is mandatory) | ||||||||||||||||||||||||||||
| 49 | ## <extension> | ||||||||||||||||||||||||||||
| 50 | ## <info xmlns="urn:X-ar:params:xml:ns:variant-1.0" variants="all"/> | ||||||||||||||||||||||||||||
| 51 | ## </extension> | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | sub info_build | ||||||||||||||||||||||||||||
| 54 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
info_build: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 55 | 0 | my ($epp,$domain,$rd)=@_; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | my $variants='all'; ## default value | |||||||||||||||||||||||||||
| 58 | 0 | ▶ | $variants=$rd->{variants} if Net::DRI::Util::has_key($rd,'variants') && $rd->{variants}=~m/^(?:all|none)$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
Net::DRI::Util::has_key($rd, "variants") and $rd->{"variants"} =~ /^(?:all|none)$/
MC/DC0%0/2
Net::DRI::Util::has_key($rd, "variants") and $rd->{"variants"} =~ /^(?:all|none)$/
Net::DRI::Util::has_key($rd, "variants")
$rd->{"variants"} =~ /^(?:all|none)$/
Truth table0%0/3
A and B
A= Net::DRI::Util::has_key($rd, "variants")B= $rd->{"variants"} =~ /^(?:all|none)$/
| |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | $epp->message()->command_extension('variant', ['info', {variants => $variants}]); | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | return; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | ## <extension> | ||||||||||||||||||||||||||||
| 66 | ## <infData xmlns="urn:X-ar:params:xml:ns:variant-1.0"> | ||||||||||||||||||||||||||||
| 67 | ## <variant userForm="ωσ.example">xn--4xal.example</variant> | ||||||||||||||||||||||||||||
| 68 | ## </infData> | ||||||||||||||||||||||||||||
| 69 | ## </extension> | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | sub parse_variant | ||||||||||||||||||||||||||||
| 72 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
parse_variant: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 73 | 0 | my ($rh,$data)=@_; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | my %variants; | |||||||||||||||||||||||||||
| 76 | 0 | foreach my $el (Net::DRI::Util::xml_list_children($data)) | |||||||||||||||||||||||||||
| 77 | { | ||||||||||||||||||||||||||||
| 78 | 0 | my ($name,$node)=@$el; | |||||||||||||||||||||||||||
| 79 | 0 | ▶ | if ($name eq 'variant') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | { | ||||||||||||||||||||||||||||
| 81 | 0 | $variants{$node->textContent()}=$node->getAttribute('userForm'); ## A-label => U-label | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | $rh->{variants}=\%variants; | |||||||||||||||||||||||||||
| 86 | 0 | return; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | sub info_parse | ||||||||||||||||||||||||||||
| 90 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
info_parse: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 91 | 0 | my ($po,$otype,$oaction,$oname,$rinfo)=@_; | |||||||||||||||||||||||||||
| 92 | 0 | my $mes=$po->message(); | |||||||||||||||||||||||||||
| 93 | 0 | ▶ | return unless $mes->is_success(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | my $data=$mes->get_extension('variant','infData'); | |||||||||||||||||||||||||||
| 96 | 0 | ▶ | return unless defined $data; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 0 | parse_variant($rinfo->{domain}->{$oname},$data); | |||||||||||||||||||||||||||
| 99 | 0 | return; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | ## <extension> | ||||||||||||||||||||||||||||
| 103 | ## <creData xmlns="urn:X-ar:params:xml:ns:variant-1.0"> | ||||||||||||||||||||||||||||
| 104 | ## <variant userForm="ωσ.example">xn--4xal.example</variant> | ||||||||||||||||||||||||||||
| 105 | ## </creData> | ||||||||||||||||||||||||||||
| 106 | ## </extension> | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | sub create_parse | ||||||||||||||||||||||||||||
| 109 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
create_parse: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 110 | 0 | my ($po,$otype,$oaction,$oname,$rinfo)=@_; | |||||||||||||||||||||||||||
| 111 | 0 | my $mes=$po->message(); | |||||||||||||||||||||||||||
| 112 | 0 | ▶ | return unless $mes->is_success(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 0 | my $data=$mes->get_extension('variant','creData'); | |||||||||||||||||||||||||||
| 115 | 0 | ▶ | return unless defined $data; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 0 | parse_variant($rinfo->{domain}->{$oname},$data); | |||||||||||||||||||||||||||
| 118 | 0 | return; | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | ## <extension> | ||||||||||||||||||||||||||||
| 122 | ## <update xmlns="urn:X-ar:params:xml:ns:variant-1.0"> | ||||||||||||||||||||||||||||
| 123 | ## <add> | ||||||||||||||||||||||||||||
| 124 | ## <variant userForm="ωσ.example">xn--4xal.example</variant> | ||||||||||||||||||||||||||||
| 125 | ## </add> | ||||||||||||||||||||||||||||
| 126 | ## </update> | ||||||||||||||||||||||||||||
| 127 | ## </extension> | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | ## <extension> | ||||||||||||||||||||||||||||
| 130 | ## <update xmlns="urn:X-ar:params:xml:ns:variant-1.0"> | ||||||||||||||||||||||||||||
| 131 | ## <rem> | ||||||||||||||||||||||||||||
| 132 | ## <variant userForm="ωσ.example">xn--4xal.example</variant> | ||||||||||||||||||||||||||||
| 133 | ## </rem> | ||||||||||||||||||||||||||||
| 134 | ## </update> | ||||||||||||||||||||||||||||
| 135 | ## </extension> | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | sub build_variants | ||||||||||||||||||||||||||||
| 138 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
build_variants: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 139 | 0 | my ($d)=@_; | |||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 0 | my @v; | |||||||||||||||||||||||||||
| 142 | 0 | foreach my $alabel ( sort { $a cmp $b } keys %$d) | |||||||||||||||||||||||||||
| 143 | { | ||||||||||||||||||||||||||||
| 144 | 0 | push @v,['variants:variant',{userForm => $d->{$alabel}},$alabel]; | |||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 0 | return @v; | |||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | sub update_build | ||||||||||||||||||||||||||||
| 151 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
update_build: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 152 | 0 | my ($epp,$domain,$todo)=@_; | |||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 0 | my $toadd=$todo->add('variants'); | |||||||||||||||||||||||||||
| 155 | 0 | my $todel=$todo->del('variants'); | |||||||||||||||||||||||||||
| 156 | 0 | ▶ | return unless defined $toadd || defined $todel; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $toadd or defined $todel
MC/DC0%0/2
defined $toadd or defined $todel
defined $toadd
defined $todel
Truth table0%0/3
A or B
A= defined $toaddB= defined $todel
| |||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 0 | my @v; | |||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 0 | ▶ | if (defined $toadd) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | { | ||||||||||||||||||||||||||||
| 162 | 0 | ▶ | Net::DRI::Exception::usererr_invalid_parameters(q{add variants value must be a ref hash, not: }.$toadd) unless ref $toadd eq 'HASH'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | 0 | push @v,['variants:add',build_variants($toadd)]; | |||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||
| 165 | 0 | ▶ | if (defined $todel) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | { | ||||||||||||||||||||||||||||
| 167 | 0 | ▶ | Net::DRI::Exception::usererr_invalid_parameters(q{del variants value must be a ref hash, not: }.$todel) unless ref $todel eq 'HASH'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 168 | 0 | push @v,['variants:rem',build_variants($todel)]; | |||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 0 | $epp->message()->command_extension('variants', ['update', @v]); | |||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | 0 | return; | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | #################################################################################################### | ||||||||||||||||||||||||||||
| 177 | 1 | 1; | |||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | __END__ | ||||||||||||||||||||||||||||