Commit 01cec399 authored by Mattias Päivirinta's avatar Mattias Päivirinta
Browse files

Merge pull request #7 in PDT/whois-selftest-tool from...

Merge pull request #7 in PDT/whois-selftest-tool from ~MATTIASP/whois-selftest-tool:registrar to develop

* commit '998f3055':
  PDTT-395 - Update Fax number section grammar
  PDTT-393 - Update registrar object email grammar
  PDTT-392 - Update registrar object phone number grammar
  Tidy
parents fd6a6b09 998f3055
......@@ -185,10 +185,10 @@ Registrar details section:
- State/Province: { quantifier: optional-constrained, line: field, type: postal line }
- Postal Code: { quantifier: optional-constrained, line: field, type: postal code }
- Country: { line: field, type: country code }
- Phone Number: { line: field, type: phone number }
- Phone number section: { quantifier: repeatable }
- Phone Ext: { quantifier: optional-free, line: field, type: token }
- Fax number section: { quantifier: optional-free }
- Email: { line: field, type: email address }
- Fax number section: { quantifier: required }
- Email: { quantifier: repeatable, line: field, type: email address }
- WHOIS Server: { quantifier: optional-constrained, line: field, type: hostname }
- Referral URL: { line: field, type: http url }
- Admin contact section: { quantifier: optional-repeatable }
......@@ -197,19 +197,28 @@ Registrar details section:
Admin contact section:
- Admin Contact: { line: field, type: postal line }
- Phone number section: { quantifier: repeatable }
- Fax number section: { quantifier: optional-repeatable }
- Fax number section: { quantifier: required }
- Email: { line: field, type: email address, quantifier: repeatable }
Technical contact section:
- Technical Contact: { line: field, type: postal line }
- Phone number section: { quantifier: repeatable }
- Fax number section: { quantifier: optional-repeatable }
- Fax number section: { quantifier: required }
- Email: { line: field, type: email address, quantifier: repeatable }
Phone number section:
- Phone Number: { line: field, type: phone number }
- Phone Ext: { quantifier: optional-free, line: field, type: token }
Fax number section:
- Fax Number: { line: field, type: phone number }
- Fax Ext: { quantifier: optional-free, line: field, type: token }
Fax number section type A: { quantifier: repeatable }
Fax number section type B: { quantifier: required }
Fax number section type C: { quantifier: required }
Fax number section type A:
- Fax Number: { line: field, type: phone number, quantifier: required }
- Fax Ext: { line: field, type: token, quantifier: optional-free }
Fax number section type B:
- Fax Number: { line: field, type: void, quantifier: empty-constrained }
- Fax Ext: { line: field, type: token, quantifier: optional-free }
Fax number section type C:
- Fax Number: { line: field, type: void, quantifier: omitted-constrained }
Domain name details section:
- Domain Name: { line: field, type: query domain name }
- Internationalized Domain Name: { quantifier: optional-free, line: field, type: u-label }
......
......@@ -51,7 +51,7 @@ The default types are:
=cut
Readonly my %DOMAIN_STATUS_CODES =>(
Readonly my %DOMAIN_STATUS_CODES => (
addPeriod => 1,
autoRenewPeriod => 1,
clientDeleteProhibited => 1,
......
......@@ -50,8 +50,8 @@ sub extract_roid {
}
elsif ( $token eq 'roid line' ) {
ref $value eq 'ARRAY' or croak "'roid line' value expected to be arrayref";
defined $value->[0] or croak "'roid line' value expected to have roid at position 0";
defined $value->[1] or croak "'hostname' value expected to have roid at position 1";
defined $value->[0] or croak "'roid line' value expected to have roid at position 0";
defined $value->[1] or croak "'hostname' value expected to have roid at position 1";
my ( $roid, $hostname ) = @{$value};
my @errors;
push @errors, grep { $_ ne 'expected roid suffix to be a registered epp repo id' } $types->validate_type( 'roid', $roid );
......
......@@ -49,6 +49,7 @@ City: Marina del Rey
State/Province: CA
Country: US
Phone Number: +1.3105551212
Phone Number: +1.3105551215
Email: registrar@example.tld
Referral URL: http://www.example-registrar.tld
......@@ -58,7 +59,8 @@ City: Marina del Rey
State/Province: CA
Country: US
Phone Number: +1.3105551212
Email: registrar@example.tld
Email: registrar1@example.tld
Email: registrar2@example.tld
Referral URL: http://www.example-registrar.tld
>>> Last update of WHOIS database: 2009-05-29T20:15:00Z <<<
......
use strict;
use warnings;
use 5.014;
use Test::More tests => 6;
use Test::Differences;
use PDT::TS::Whois::Lexer;
use PDT::TS::Whois::Validator qw( validate );
use PDT::TS::Whois::Grammar qw( $grammar );
use PDT::TS::Whois::Types;
sub accept_registrar {
my $test_name = shift;
my $input = shift =~ s/\r?$/\r/gmr;
my $types = PDT::TS::Whois::Types->new;
$types->add_type( 'query registrar name' => sub { return (shift !~ /Example Registrar, Inc\./ ) ? ( 'expected matching registrar name' ) : () } );
my $lexer = PDT::TS::Whois::Lexer->new( $input );
my @errors = validate( rule => 'Registrar Object query', lexer => $lexer, grammar => $grammar, types => $types );
eq_or_diff \@errors, [], 'Should accept valid registrar reply';
}
accept_registrar 'Fax number section type A, empty' => <<EOF;
Registrar Name: Example Registrar, Inc.
Street: 1234 Admiralty Way
City: Marina del Rey
State/Province: CA
Postal Code:
Country: US
Phone Number: +1.3105551212
Fax Number: +1.3105551213
Fax Ext:
Fax Number: +1.3105551214
Email: registrar\@example.tld
WHOIS Server:
Referral URL: http://www.example-registrar.tld
>>> Last update of WHOIS database: 2009-05-29T20:15:00Z <<<
For more information on Whois status codes, please visit https://icann.org/epp
Disclaimer: This is a legal disclaimer.
EOF
accept_registrar 'Fax number section type A, omitted' => <<EOF;
Registrar Name: Example Registrar, Inc.
Street: 1234 Admiralty Way
City: Marina del Rey
State/Province: CA
Country: US
Phone Number: +1.3105551212
Fax Number: +1.3105551213
Fax Ext:
Fax Number: +1.3105551214
Email: registrar\@example.tld
Referral URL: http://www.example-registrar.tld
>>> Last update of WHOIS database: 2009-05-29T20:15:00Z <<<
For more information on Whois status codes, please visit https://icann.org/epp
Disclaimer: This is a legal disclaimer.
EOF
accept_registrar 'Fax number section type B, non-empty field' => <<EOF;
Registrar Name: Example Registrar, Inc.
Street: 1234 Admiralty Way
City: Marina del Rey
State/Province: CA
Postal Code:
Country: US
Phone Number: +1.3105551212
Fax Number:
Fax Ext: 567
Email: registrar\@example.tld
WHOIS Server:
Referral URL: http://www.example-registrar.tld
>>> Last update of WHOIS database: 2009-05-29T20:15:00Z <<<
For more information on Whois status codes, please visit https://icann.org/epp
Disclaimer: This is a legal disclaimer.
EOF
accept_registrar 'Fax number section type B, empty field' => <<EOF;
Registrar Name: Example Registrar, Inc.
Street: 1234 Admiralty Way
City: Marina del Rey
State/Province: CA
Postal Code:
Country: US
Phone Number: +1.3105551212
Fax Number:
Fax Ext:
Email: registrar\@example.tld
WHOIS Server:
Referral URL: http://www.example-registrar.tld
>>> Last update of WHOIS database: 2009-05-29T20:15:00Z <<<
For more information on Whois status codes, please visit https://icann.org/epp
Disclaimer: This is a legal disclaimer.
EOF
accept_registrar 'Fax number section type B, omitted field' => <<EOF;
Registrar Name: Example Registrar, Inc.
Street: 1234 Admiralty Way
City: Marina del Rey
State/Province: CA
Postal Code:
Country: US
Phone Number: +1.3105551212
Fax Number:
Email: registrar\@example.tld
WHOIS Server:
Referral URL: http://www.example-registrar.tld
>>> Last update of WHOIS database: 2009-05-29T20:15:00Z <<<
For more information on Whois status codes, please visit https://icann.org/epp
Disclaimer: This is a legal disclaimer.
EOF
accept_registrar 'Fax number section type C' => <<EOF;
Registrar Name: Example Registrar, Inc.
Street: 1234 Admiralty Way
City: Marina del Rey
State/Province: CA
Country: US
Phone Number: +1.3105551212
Email: registrar\@example.tld
Referral URL: http://www.example-registrar.tld
>>> Last update of WHOIS database: 2009-05-29T20:15:00Z <<<
For more information on Whois status codes, please visit https://icann.org/epp
Disclaimer: This is a legal disclaimer.
EOF
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment