From 399077176778adcfdc68065246602b4d288d7a7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lecour?= Date: Wed, 27 Feb 2019 23:37:58 +0100 Subject: [PATCH] =?UTF-8?q?Add=2050=20new=20TLDs=20(.info,=20.au,=20.asia?= =?UTF-8?q?=E2=80=A6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PIR is technically managed by Afilias (like many other registries). Renaming/replacing PIR with Afilias brings support to dozens of other TLDs. --- app/services/whois/parser.rb | 4 +- .../whois/parser/{pir.rb => afilias.rb} | 44 +++++- test/fixtures/files/whois/domain.info.txt | 149 ++++++++++++++++++ .../files/whois/willneverexist.info.txt | 59 +++++++ test/services/whois/parser/afilias_test.rb | 75 +++++++++ test/services/whois/parser/pir_test.rb | 43 ----- test/services/whois/parser_test.rb | 4 + 7 files changed, 331 insertions(+), 47 deletions(-) rename app/services/whois/parser/{pir.rb => afilias.rb} (62%) create mode 100644 test/fixtures/files/whois/domain.info.txt create mode 100644 test/fixtures/files/whois/willneverexist.info.txt create mode 100644 test/services/whois/parser/afilias_test.rb delete mode 100644 test/services/whois/parser/pir_test.rb diff --git a/app/services/whois/parser.rb b/app/services/whois/parser.rb index 3783b8d..2045008 100644 --- a/app/services/whois/parser.rb +++ b/app/services/whois/parser.rb @@ -3,13 +3,13 @@ require "null_logger" require "whois/errors" +require "whois/parser/afilias" require "whois/parser/afnic" -require "whois/parser/pir" require "whois/parser/verisign" module Whois module Parser - PARSERS = [AFNIC, Verisign, PIR].freeze + PARSERS = [AFNIC, Verisign, Afilias].freeze class << self def for(domain, logger: NullLogger.new) diff --git a/app/services/whois/parser/pir.rb b/app/services/whois/parser/afilias.rb similarity index 62% rename from app/services/whois/parser/pir.rb rename to app/services/whois/parser/afilias.rb index abb5ea3..d4e1f6b 100644 --- a/app/services/whois/parser/pir.rb +++ b/app/services/whois/parser/afilias.rb @@ -7,12 +7,52 @@ require_relative "base" module Whois module Parser - class PIR < Base + class Afilias < Base + # https://afilias.info/products-services + # https://afilias.info/global-registry-services/ctlds + # https://afilias.info/global-registry-services/gtlds SUPPORTED_TLD = %w[ + .info + .ag + .bz + .gi + .au + .lc + .me + .mn + .sc + .vc .org + .aero + .asia + .xxx + .post + .global + .vegas + .onl + .rich + .ltda + .srl + .adult + .porn .ngo .ong - .opr + .bet + .pet + .lotto + .poker + .lgbt + .vote + .voto + .organic + .green + .black + .red + .pink + .blue + .kim + .shiksha + .promo ].freeze COMMENT_REGEX = /^(%|>)+ +(?.+)$/ diff --git a/test/fixtures/files/whois/domain.info.txt b/test/fixtures/files/whois/domain.info.txt new file mode 100644 index 0000000..4118494 --- /dev/null +++ b/test/fixtures/files/whois/domain.info.txt @@ -0,0 +1,149 @@ +% IANA WHOIS server +% for more information on IANA, visit http://www.iana.org +% This query returned 1 object + +refer: whois.afilias.net + +domain: INFO + +organisation: Afilias Limited +address: Office 107 +address: 3013 Lake Drive +address: CityWest +address: Dublin 24 +address: Ireland + +contact: administrative +name: Ram Mohan +organisation: Afilias Limited +address: C/O Afilias USA, Inc. +address: 300 Welsh Road, Building 3 +address: Suite 105 +address: Horsham Pennsylvania 19044 +address: United States +phone: +1 215 706 5700 +fax-no: +1 215 706 5701 +e-mail: domainadmin@afilias.info + +contact: technical +name: Howard Eland +organisation: Afilias Limited +address: C/O Afilias USA, Inc. +address: 300 Welsh Road, Building 3 +address: Suite 105 +address: Horsham Pennsylvania 19044 +address: United States +phone: +1 215 706 5700 +fax-no: +1 215 706 5701 +e-mail: domaintech@afilias.info + +nserver: A0.INFO.AFILIAS-NST.INFO 199.254.31.1 2001:500:19:0:0:0:0:1 +nserver: A2.INFO.AFILIAS-NST.INFO 199.249.113.1 2001:500:41:0:0:0:0:1 +nserver: B0.INFO.AFILIAS-NST.ORG 199.254.48.1 2001:500:1a:0:0:0:0:1 +nserver: B2.INFO.AFILIAS-NST.ORG 199.249.121.1 2001:500:49:0:0:0:0:1 +nserver: C0.INFO.AFILIAS-NST.INFO 199.254.49.1 2001:500:1b:0:0:0:0:1 +nserver: D0.INFO.AFILIAS-NST.ORG 199.254.50.1 2001:500:1c:0:0:0:0:1 +ds-rdata: 8674 7 1 197789a2cbaba6fecd0b5ac88c5bc414ce1fc309 +ds-rdata: 8674 7 2 ec9b6082b96b5f87143696f2b483acc9b2c433dce0c94e70f1ff5648ca18008b + +whois: whois.afilias.net + +status: ACTIVE +remarks: Registration information: http://www.nic.info + +created: 2001-06-26 +changed: 2015-09-09 +source: IANA + +Domain Name: DOMAIN.INFO +Registry Domain ID: D11252785-LRMS +Registrar WHOIS Server: whois.gandi.net +Registrar URL: https://www.gandi.net/whois +Updated Date: 2018-12-03T21:21:22Z +Creation Date: 2006-03-25T14:01:14Z +Registry Expiry Date: 2020-03-25T14:01:14Z +Registrar Registration Expiration Date: +Registrar: Gandi SAS +Registrar IANA ID: 81 +Registrar Abuse Contact Email: abuse@support.gandi.net +Registrar Abuse Contact Phone: +33.170377661 +Reseller: +Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited +Registrant Organization: Evolix SARL +Registrant State/Province: +Registrant Country: FR +Name Server: NS1.DOMAIN.NET +Name Server: NS0.DOMAIN.COM +DNSSEC: unsigned +URL of the ICANN Whois Inaccuracy Complaint Form is https://www.icann.org/wicf/ +>>> Last update of WHOIS database: 2019-02-27T21:27:43Z <<< + +Domain Name: domain.info +Registry Domain ID: D11252785-LRMS +Registrar WHOIS Server: whois.gandi.net +Registrar URL: http://www.gandi.net +Updated Date: 2018-12-03T22:21:23Z +Creation Date: 2006-03-25T14:01:14Z +Registrar Registration Expiration Date: 2020-03-25T14:01:14Z +Registrar: GANDI SAS +Registrar IANA ID: 81 +Registrar Abuse Contact Email: abuse@support.gandi.net +Registrar Abuse Contact Phone: +33.170377661 +Reseller: +Domain Status: clientTransferProhibited http://www.icann.org/epp#clientTransferProhibited +Domain Status: +Domain Status: +Domain Status: +Domain Status: +Registry Registrant ID: REDACTED FOR PRIVACY +Registrant Name: REDACTED FOR PRIVACY +Registrant Organization: Evolix SARL +Registrant Street: REDACTED FOR PRIVACY +Registrant City: REDACTED FOR PRIVACY +Registrant State/Province: +Registrant Postal Code: REDACTED FOR PRIVACY +Registrant Country: FR +Registrant Phone: REDACTED FOR PRIVACY +Registrant Phone Ext: +Registrant Fax: REDACTED FOR PRIVACY +Registrant Fax Ext: +Registrant Email: 7487d1824de2ffea6b1ba98ba8b83342-793288@contact.gandi.net +Registry Admin ID: REDACTED FOR PRIVACY +Admin Name: REDACTED FOR PRIVACY +Admin Organization: REDACTED FOR PRIVACY +Admin Street: REDACTED FOR PRIVACY +Admin City: REDACTED FOR PRIVACY +Admin State/Province: REDACTED FOR PRIVACY +Admin Postal Code: REDACTED FOR PRIVACY +Admin Country: REDACTED FOR PRIVACY +Admin Phone: REDACTED FOR PRIVACY +Admin Phone Ext: +Admin Fax: REDACTED FOR PRIVACY +Admin Fax Ext: +Admin Email: 7487d1824de2ffea6b1ba98ba8b83342-793288@contact.gandi.net +Registry Tech ID: REDACTED FOR PRIVACY +Tech Name: REDACTED FOR PRIVACY +Tech Organization: REDACTED FOR PRIVACY +Tech Street: REDACTED FOR PRIVACY +Tech City: REDACTED FOR PRIVACY +Tech State/Province: REDACTED FOR PRIVACY +Tech Postal Code: REDACTED FOR PRIVACY +Tech Country: REDACTED FOR PRIVACY +Tech Phone: REDACTED FOR PRIVACY +Tech Phone Ext: +Tech Fax: REDACTED FOR PRIVACY +Tech Fax Ext: +Tech Email: 7487d1824de2ffea6b1ba98ba8b83342-793288@contact.gandi.net +Name Server: NS1.DOMAIN.NET +Name Server: NS0.DOMAIN.COM +Name Server: +Name Server: +Name Server: +Name Server: +Name Server: +Name Server: +Name Server: +Name Server: +DNSSEC: Unsigned +URL of the ICANN WHOIS Data Problem Reporting System: http://wdprs.internic.net/ +>>> Last update of WHOIS database: 2019-02-27T21:28:43Z <<< diff --git a/test/fixtures/files/whois/willneverexist.info.txt b/test/fixtures/files/whois/willneverexist.info.txt new file mode 100644 index 0000000..43eb0ad --- /dev/null +++ b/test/fixtures/files/whois/willneverexist.info.txt @@ -0,0 +1,59 @@ +% IANA WHOIS server +% for more information on IANA, visit http://www.iana.org +% This query returned 1 object + +refer: whois.afilias.net + +domain: INFO + +organisation: Afilias Limited +address: Office 107 +address: 3013 Lake Drive +address: CityWest +address: Dublin 24 +address: Ireland + +contact: administrative +name: Ram Mohan +organisation: Afilias Limited +address: C/O Afilias USA, Inc. +address: 300 Welsh Road, Building 3 +address: Suite 105 +address: Horsham Pennsylvania 19044 +address: United States +phone: +1 215 706 5700 +fax-no: +1 215 706 5701 +e-mail: domainadmin@afilias.info + +contact: technical +name: Howard Eland +organisation: Afilias Limited +address: C/O Afilias USA, Inc. +address: 300 Welsh Road, Building 3 +address: Suite 105 +address: Horsham Pennsylvania 19044 +address: United States +phone: +1 215 706 5700 +fax-no: +1 215 706 5701 +e-mail: domaintech@afilias.info + +nserver: A0.INFO.AFILIAS-NST.INFO 199.254.31.1 2001:500:19:0:0:0:0:1 +nserver: A2.INFO.AFILIAS-NST.INFO 199.249.113.1 2001:500:41:0:0:0:0:1 +nserver: B0.INFO.AFILIAS-NST.ORG 199.254.48.1 2001:500:1a:0:0:0:0:1 +nserver: B2.INFO.AFILIAS-NST.ORG 199.249.121.1 2001:500:49:0:0:0:0:1 +nserver: C0.INFO.AFILIAS-NST.INFO 199.254.49.1 2001:500:1b:0:0:0:0:1 +nserver: D0.INFO.AFILIAS-NST.ORG 199.254.50.1 2001:500:1c:0:0:0:0:1 +ds-rdata: 8674 7 1 197789a2cbaba6fecd0b5ac88c5bc414ce1fc309 +ds-rdata: 8674 7 2 ec9b6082b96b5f87143696f2b483acc9b2c433dce0c94e70f1ff5648ca18008b + +whois: whois.afilias.net + +status: ACTIVE +remarks: Registration information: http://www.nic.info + +created: 2001-06-26 +changed: 2015-09-09 +source: IANA + +NOT FOUND +>>> Last update of WHOIS database: 2019-02-27T21:42:44Z <<< diff --git a/test/services/whois/parser/afilias_test.rb b/test/services/whois/parser/afilias_test.rb new file mode 100644 index 0000000..e5e4b9a --- /dev/null +++ b/test/services/whois/parser/afilias_test.rb @@ -0,0 +1,75 @@ +# Copyright (C) 2018 Colin Darie , 2018 Evolix +# License: GNU AGPL-3+ (see full text in LICENSE file) + +require "test_helper" +require "whois/parser/afilias" +require "whois/response" +require "whois/errors" + +module Whois + class AfiliasTest < ActiveSupport::TestCase + test "should parse a whois response for .info" do + parser = Parser::Afilias.new("domain.info") + whois_output = file_fixture("whois/domain.info.txt").read + response = parser.parse(whois_output) + assert_kind_of Response, response + + assert_equal Time.new(2006, 3, 25, 14, 1, 14, 0), response.created_at + assert response.created_at.utc? + + assert_equal Time.new(2018, 12, 3, 21, 21, 22, 0), response.updated_at + assert_equal Time.new(2020, 3, 25, 14, 1, 14, 0), response.expire_at + end + + test "should raises DomainNotFoundError for .info when domain is not registered" do + parser = Parser::Afilias.new("willneverexist.info") + not_found = file_fixture("whois/willneverexist.info.txt").read + + assert_raises DomainNotFoundError do + parser.parse(not_found) + end + end + + test "should raises InvalidDateError for .info when a date is not parsable" do + parser = Parser::Afilias.new("domain.info") + whois_output = file_fixture("whois/domain.info.txt").read + whois_output.gsub!("2020-03-25T14:01:14Z", "not a date") + + assert_raises InvalidDateError do + parser.parse(whois_output) + end + end + + test "should parse a whois response for .org" do + parser = Parser::Afilias.new("domain.org") + domain_com = file_fixture("whois/domain.org.txt").read + response = parser.parse(domain_com) + assert_kind_of Response, response + + assert_equal Time.new(1995, 4, 30, 4, 0, 0, 0), response.created_at + assert response.created_at.utc? + + assert_equal Time.new(2018, 4, 2, 3, 47, 23, 0), response.updated_at + assert_equal Time.new(2019, 5, 1, 4, 0, 0, 0), response.expire_at + end + + test "should raises DomainNotFoundError for .org when domain is not registered" do + parser = Parser::Afilias.new("willneverexist.org") + not_found = file_fixture("whois/willneverexist.org.txt").read + + assert_raises DomainNotFoundError do + parser.parse(not_found) + end + end + + test "should raises InvalidDateError for .org when a date is not parsable" do + parser = Parser::Afilias.new("domain.org") + domain_com = file_fixture("whois/domain.org.txt").read + domain_com.gsub!("2018-04-02T03:47:23Z", "not a date") + + assert_raises InvalidDateError do + parser.parse(domain_com) + end + end + end +end diff --git a/test/services/whois/parser/pir_test.rb b/test/services/whois/parser/pir_test.rb deleted file mode 100644 index c92fc2b..0000000 --- a/test/services/whois/parser/pir_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (C) 2018 Colin Darie , 2018 Evolix -# License: GNU AGPL-3+ (see full text in LICENSE file) - -require "test_helper" -require "whois/parser/pir" -require "whois/response" -require "whois/errors" - -module Whois - class PIRTest < ActiveSupport::TestCase - test "should parse a whois response" do - parser = Parser::PIR.new("domain.org") - domain_com = file_fixture("whois/domain.org.txt").read - response = parser.parse(domain_com) - assert_kind_of Response, response - - assert_equal Time.new(1995, 4, 30, 4, 0, 0, 0), response.created_at - assert response.created_at.utc? - - assert_equal Time.new(2018, 4, 2, 3, 47, 23, 0), response.updated_at - assert_equal Time.new(2019, 5, 1, 4, 0, 0, 0), response.expire_at - end - - test "should raises DomainNotFoundError when domain is not registered" do - parser = Parser::PIR.new("willneverexist.org") - not_found = file_fixture("whois/willneverexist.org.txt").read - - assert_raises DomainNotFoundError do - parser.parse(not_found) - end - end - - test "should raises InvalidDateError when a date is not parsable" do - parser = Parser::PIR.new("domain.org") - domain_com = file_fixture("whois/domain.org.txt").read - domain_com.gsub!("2018-04-02T03:47:23Z", "not a date") - - assert_raises InvalidDateError do - parser.parse(domain_com) - end - end - end -end diff --git a/test/services/whois/parser_test.rb b/test/services/whois/parser_test.rb index d1b4739..9ec2f3b 100644 --- a/test/services/whois/parser_test.rb +++ b/test/services/whois/parser_test.rb @@ -16,6 +16,10 @@ module Whois assert_kind_of Parser::Verisign, Parser.for("example.net") end + test "should instanciate a parser class matching Afilias tlds" do + assert_kind_of Parser::Afilias, Parser.for("example.info") + end + test "should raises an exception when a domain is not supported" do assert_raises UnsupportedDomainError do Parser.for("example.xyz")