From f486ad1586c799a91c00f0f212a72eb4ce4ecf9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Beamonte?= Date: Thu, 7 Nov 2019 15:22:12 -0500 Subject: [PATCH] parsers: whois.cira.ca: Add new version support for 2019 whois output Most recent whois output from CIRA, with year 2019, has a very different output than what was expected in the past. This adds support for it while keeping support for previous versions of the whois output. --- lib/whois/parsers/whois.cira.ca.rb | 202 +++++++++++++----- .../ca/property_status_available_v3.expected | 8 + .../ca/property_status_available_v3.txt | 7 + .../ca/status_available_v3.expected | 57 +++++ .../whois.cira.ca/ca/status_available_v3.txt | 7 + .../ca/status_invalid_v3.expected | 9 + .../whois.cira.ca/ca/status_invalid_v3.txt | 7 + .../ca/status_registered_v3.expected | 111 ++++++++++ .../whois.cira.ca/ca/status_registered_v3.txt | 84 ++++++++ .../ca/property_status_available_v3_spec.rb | 39 ++++ .../ca/status_available_v3_spec.rb | 108 ++++++++++ .../ca/status_invalid_v3_spec.rb | 39 ++++ .../ca/status_registered_v3_spec.rb | 162 ++++++++++++++ 13 files changed, 790 insertions(+), 50 deletions(-) create mode 100644 spec/fixtures/responses/whois.cira.ca/ca/property_status_available_v3.expected create mode 100644 spec/fixtures/responses/whois.cira.ca/ca/property_status_available_v3.txt create mode 100644 spec/fixtures/responses/whois.cira.ca/ca/status_available_v3.expected create mode 100644 spec/fixtures/responses/whois.cira.ca/ca/status_available_v3.txt create mode 100644 spec/fixtures/responses/whois.cira.ca/ca/status_invalid_v3.expected create mode 100644 spec/fixtures/responses/whois.cira.ca/ca/status_invalid_v3.txt create mode 100644 spec/fixtures/responses/whois.cira.ca/ca/status_registered_v3.expected create mode 100644 spec/fixtures/responses/whois.cira.ca/ca/status_registered_v3.txt create mode 100644 spec/whois/parsers/responses/whois.cira.ca/ca/property_status_available_v3_spec.rb create mode 100644 spec/whois/parsers/responses/whois.cira.ca/ca/status_available_v3_spec.rb create mode 100644 spec/whois/parsers/responses/whois.cira.ca/ca/status_invalid_v3_spec.rb create mode 100644 spec/whois/parsers/responses/whois.cira.ca/ca/status_registered_v3_spec.rb diff --git a/lib/whois/parsers/whois.cira.ca.rb b/lib/whois/parsers/whois.cira.ca.rb index 0ce796a6..c14035c7 100644 --- a/lib/whois/parsers/whois.cira.ca.rb +++ b/lib/whois/parsers/whois.cira.ca.rb @@ -31,6 +31,7 @@ class WhoisCiraCa < Base property_supported :domain do + return node("Domain Name") || node("Not found") if version == "3" node("Domain name") end @@ -38,28 +39,8 @@ class WhoisCiraCa < Base property_supported :status do - if content_for_scanner =~ /Domain status:\s+(.+?)\n/ - case node("Domain status", &:downcase) - when "registered" - :registered - when "redemption" - :registered - when "auto-renew grace" - :registered - when "to be released" - :registered - when "pending delete" - :registered - when "available" - :available - when "unavailable" - :invalid - else - Whois::Parser.bug!(ParserError, "Unknown status `#{$1}'.") - end - else - Whois::Parser.bug!(ParserError, "Unable to parse status.") - end + return status_v3 if version == "3" + status_v1 end property_supported :available? do @@ -72,50 +53,54 @@ class WhoisCiraCa < Base property_supported :created_on do - node("Creation date") { |str| parse_time(str) } + node_name = if version == "3" + "Creation Date" + else + "Creation date" + end + + node(node_name) { |str| parse_time(str) } end property_supported :updated_on do - node("Updated date") { |str| parse_time(str) } + node_name = if version == "3" + "Updated Date" + else + "Updated date" + end + + node(node_name) { |str| parse_time(str) } end property_supported :expires_on do - node("Expiry date") { |str| parse_time(str) } + node_name = if version == "3" + "Registry Expiry Date" + else + "Expiry date" + end + + node(node_name) { |str| parse_time(str) } end property_supported :registrar do - node("Registrar") do |hash| - Parser::Registrar.new( - id: hash["Number"], - name: hash["Name"], - organization: hash["Name"] - ) - end + return registrar_v3 if version == "3" + registrar_v1 end property_supported :registrant_contacts do - build_contact("Registrant", Parser::Contact::TYPE_REGISTRANT) + build_contact(Parser::Contact::TYPE_REGISTRANT) end property_supported :admin_contacts do - build_contact("Administrative contact", Parser::Contact::TYPE_ADMINISTRATIVE) + build_contact(Parser::Contact::TYPE_ADMINISTRATIVE) end property_supported :technical_contacts do - build_contact("Technical contact", Parser::Contact::TYPE_TECHNICAL) - end - - - property_supported :nameservers do - Array.wrap(node("nserver")).map do |line| - name, ipv4 = line.split(/\s+/) - Parser::Nameserver.new(:name => name, :ipv4 => ipv4) - end + build_contact(Parser::Contact::TYPE_TECHNICAL) end - # Nameservers are listed in the following formats: # # ns1.google.com @@ -125,13 +110,18 @@ class WhoisCiraCa < Base # ns2.google.com 216.239.34.10 # property_supported :nameservers do - Array.wrap(node("field:nameservers")).map do |line| + node_name = if version == "3" + "Name Server" + else + "field:nameservers" + end + + Array.wrap(node(node_name)).map do |line| name, ipv4 = line.strip.split(/\s+/) Parser::Nameserver.new(:name => name, :ipv4 => ipv4) end end - # Attempts to detect and returns the version. # # TODO: This is very empiric. @@ -141,9 +131,13 @@ class WhoisCiraCa < Base def version cached_properties_fetch :version do version = if content_for_scanner =~ /^% \(c\) (.+?) Canadian Internet Registration Authority/ - case $1 - when "2007" then "1" - when "2010" then "2" + year = $1.to_i + if year >= 2019 + "3" + elsif year >= 2010 + "2" + elsif year >= 2007 + "1" end end version || Whois::Parser.bug!(ParserError, "Unable to detect version.") @@ -167,7 +161,80 @@ def invalid? private - def build_contact(element, type) + def status_v1 + if content_for_scanner =~ /Domain status:\s+(.+?)\n/ + case node("Domain status", &:downcase) + when "registered" + :registered + when "redemption" + :registered + when "auto-renew grace" + :registered + when "to be released" + :registered + when "pending delete" + :registered + when "available" + :available + when "unavailable" + :invalid + else + Whois::Parser.bug!(ParserError, "Unknown status `#{$1}'.") + end + else + Whois::Parser.bug!(ParserError, "Unable to parse status.") + end + end + + def status_v3 + if node("Not found") + :available + else + :registered + end + end + + def registrar_v1 + node("Registrar") do |hash| + Parser::Registrar.new( + id: hash["Number"], + name: hash["Name"], + organization: hash["Name"] + ) + end + end + + def registrar_v3 + registrar_information = { + id: node("Registrar IANA ID"), + name: node("Registrar"), + organization: node("Registrar"), + } + registrar_information.compact! + return if registrar_information.empty? + + Parser::Registrar.new( + **registrar_information, + ) + end + + def build_contact(type) + return build_contact_v3(type) if version == "3" + build_contact_v1(type) + end + + def build_contact_v1(type) + element = case type + when Parser::Contact::TYPE_REGISTRANT + 'Registrant' + when Parser::Contact::TYPE_ADMINISTRATIVE + 'Administrative contact' + when Parser::Contact::TYPE_TECHNICAL + 'Technical contact' + else + Whois::Parser.bug!(ParserError, "Invalid contact type #{type}.") + end + node(element) do |hash| Parser::Contact.new( :type => type, @@ -186,6 +253,41 @@ def build_contact(element, type) end end + def build_contact_v3(type) + prefix = case type + when Parser::Contact::TYPE_REGISTRANT + 'Registrant' + when Parser::Contact::TYPE_ADMINISTRATIVE + 'Admin' + when Parser::Contact::TYPE_TECHNICAL + 'Tech' + else + Whois::Parser.bug!(ParserError, "Invalid contact type #{type}.") + end + + contact_information = { + id: node("Registry #{prefix} ID"), + name: node("#{prefix} Name"), + organization: node("#{prefix} Organization"), + address: node("#{prefix} Street"), + city: node("#{prefix} City"), + zip: node("#{prefix} Postal Code"), + state: node("#{prefix} State/Province"), + country: node("#{prefix} Country"), + country_code: node("#{prefix} Country"), + phone: node("#{prefix} Phone"), + fax: node("#{prefix} Fax"), + email: node("#{prefix} Email"), + } + contact_information.compact! + return if contact_information.empty? + + Parser::Contact.new( + type: type, + **contact_information, + ) + end + end end diff --git a/spec/fixtures/responses/whois.cira.ca/ca/property_status_available_v3.expected b/spec/fixtures/responses/whois.cira.ca/ca/property_status_available_v3.expected new file mode 100644 index 00000000..0a5c9d4a --- /dev/null +++ b/spec/fixtures/responses/whois.cira.ca/ca/property_status_available_v3.expected @@ -0,0 +1,8 @@ +#status + %s == :available + +#available? + %s == true + +#registered? + %s == false diff --git a/spec/fixtures/responses/whois.cira.ca/ca/property_status_available_v3.txt b/spec/fixtures/responses/whois.cira.ca/ca/property_status_available_v3.txt new file mode 100644 index 00000000..6299f340 --- /dev/null +++ b/spec/fixtures/responses/whois.cira.ca/ca/property_status_available_v3.txt @@ -0,0 +1,7 @@ +Not found: u34jedzcq.ca + +% +% Use of CIRA's WHOIS service is governed by the Terms of Use in its Legal +% Notice, available at http://www.cira.ca/legal-notice/?lang=en +% +% (c) 2019 Canadian Internet Registration Authority, (http://www.cira.ca/) diff --git a/spec/fixtures/responses/whois.cira.ca/ca/status_available_v3.expected b/spec/fixtures/responses/whois.cira.ca/ca/status_available_v3.expected new file mode 100644 index 00000000..38143750 --- /dev/null +++ b/spec/fixtures/responses/whois.cira.ca/ca/status_available_v3.expected @@ -0,0 +1,57 @@ +#disclaimer + %s == "Use of CIRA's WHOIS service is governed by the Terms of Use in its Legal\nNotice, available at http://www.cira.ca/legal-notice/?lang=en\n\n(c) 2019 Canadian Internet Registration Authority, (http://www.cira.ca/)" + + +#domain + %s == "u34jedzcq.ca" + +#domain_id + %s %ERROR{AttributeNotSupported} + + +#status + %s == :available + +#available? + %s == true + +#registered? + %s == false + + +#created_on + %s == nil + +#updated_on + %s == nil + +#expires_on + %s == nil + + +#registrar + %s == nil + +#registrant_contacts + %s %CLASS{array} + %s == [] + +#admin_contacts + %s %CLASS{array} + %s == [] + +#technical_contacts + %s %CLASS{array} + %s == [] + + +#nameservers + %s %CLASS{array} + %s == [] + + +#valid? + %s == true + +#invalid? + %s == false diff --git a/spec/fixtures/responses/whois.cira.ca/ca/status_available_v3.txt b/spec/fixtures/responses/whois.cira.ca/ca/status_available_v3.txt new file mode 100644 index 00000000..2d912e2d --- /dev/null +++ b/spec/fixtures/responses/whois.cira.ca/ca/status_available_v3.txt @@ -0,0 +1,7 @@ +Not found: u34jedzcq.ca + +% +% Use of CIRA's WHOIS service is governed by the Terms of Use in its Legal +% Notice, available at http://www.cira.ca/legal-notice/?lang=en +% +% (c) 2019 Canadian Internet Registration Authority, (http://www.cira.ca/) \ No newline at end of file diff --git a/spec/fixtures/responses/whois.cira.ca/ca/status_invalid_v3.expected b/spec/fixtures/responses/whois.cira.ca/ca/status_invalid_v3.expected new file mode 100644 index 00000000..3d893175 --- /dev/null +++ b/spec/fixtures/responses/whois.cira.ca/ca/status_invalid_v3.expected @@ -0,0 +1,9 @@ +#status + %s == :available + + +#valid? + %s == true + +#invalid? + %s == false diff --git a/spec/fixtures/responses/whois.cira.ca/ca/status_invalid_v3.txt b/spec/fixtures/responses/whois.cira.ca/ca/status_invalid_v3.txt new file mode 100644 index 00000000..eb7cd184 --- /dev/null +++ b/spec/fixtures/responses/whois.cira.ca/ca/status_invalid_v3.txt @@ -0,0 +1,7 @@ +Not found: mediom.ca + +% +% Use of CIRA's WHOIS service is governed by the Terms of Use in its Legal +% Notice, available at http://www.cira.ca/legal-notice/?lang=en +% +% (c) 2019 Canadian Internet Registration Authority, (http://www.cira.ca/) \ No newline at end of file diff --git a/spec/fixtures/responses/whois.cira.ca/ca/status_registered_v3.expected b/spec/fixtures/responses/whois.cira.ca/ca/status_registered_v3.expected new file mode 100644 index 00000000..6195d384 --- /dev/null +++ b/spec/fixtures/responses/whois.cira.ca/ca/status_registered_v3.expected @@ -0,0 +1,111 @@ +#disclaimer + %s == "Use of CIRA's WHOIS service is governed by the Terms of Use in its Legal\nNotice, available at http://www.cira.ca/legal-notice/?lang=en\n\n(c) 2019 Canadian Internet Registration Authority, (http://www.cira.ca/)" + + +#domain + %s == "google.ca" + +#domain_id + %s %ERROR{AttributeNotSupported} + + +#status + %s == :registered + +#available? + %s == false + +#registered? + %s == true + + +#created_on + %s %CLASS{time} + %s %TIME{2000-10-04 02:21:23.000000000 +0000} + +#updated_on + %s %CLASS{time} + %s %TIME{2019-04-28 04:04:23.000000000 +0000} + +#expires_on + %s %CLASS{time} + %s %TIME{2020-04-28 04:00:00.000000000 +0000} + + +#registrar + %s %CLASS{registrar} + %s.id == nil + %s.name == "MarkMonitor International Canada Ltd." + %s.organization == "MarkMonitor International Canada Ltd." + %s.url == nil + +#registrant_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Parser::Contact::TYPE_REGISTRANT + %s[0].id == "59969059-CIRA" + %s[0].name == "Google LLC - TMA868122" + %s[0].organization == nil + %s[0].address == "1600 Amphitheatre Parkway" + %s[0].city == "Mountain View" + %s[0].zip == "94043" + %s[0].state == "CA" + %s[0].country_code == "US" + %s[0].phone == "+1.6502530000" + %s[0].fax == nil + %s[0].email == "dns-admin@google.com" + +#admin_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Parser::Contact::TYPE_ADMINISTRATIVE + %s[0].id == "59969161-CIRA" + %s[0].name == "Lauren Johnston" + %s[0].organization == "Google LLC" + %s[0].address == "1600 Amphitheatre Parkway" + %s[0].city == "Mountain View" + %s[0].zip == "94043" + %s[0].state == "CA" + %s[0].country_code == "US" + %s[0].phone == "+1.6502530000" + %s[0].fax == nil + %s[0].email == "dns-admin@google.com" + +#technical_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Parser::Contact::TYPE_TECHNICAL + %s[0].id == "59969161-CIRA" + %s[0].name == "Lauren Johnston" + %s[0].organization == "Google LLC" + %s[0].address == "1600 Amphitheatre Parkway" + %s[0].city == "Mountain View" + %s[0].zip == "94043" + %s[0].state == "CA" + %s[0].country_code == "US" + %s[0].phone == "+1.6502530000" + %s[0].fax == nil + %s[0].email == "dns-admin@google.com" + + +#nameservers + %s %CLASS{array} + %s %SIZE{4} + %s[0] %CLASS{nameserver} + %s[0].name == "ns1.google.com" + %s[1] %CLASS{nameserver} + %s[1].name == "ns2.google.com" + %s[2] %CLASS{nameserver} + %s[2].name == "ns3.google.com" + %s[3] %CLASS{nameserver} + %s[3].name == "ns4.google.com" + + +#valid? + %s == true + +#invalid? + %s == false diff --git a/spec/fixtures/responses/whois.cira.ca/ca/status_registered_v3.txt b/spec/fixtures/responses/whois.cira.ca/ca/status_registered_v3.txt new file mode 100644 index 00000000..4f1bc3e9 --- /dev/null +++ b/spec/fixtures/responses/whois.cira.ca/ca/status_registered_v3.txt @@ -0,0 +1,84 @@ +Domain Name: google.ca +Registry Domain ID: D73081-CIRA +Registrar WHOIS Server: whois.ca.fury.ca +Registrar URL: Markmonitor.com +Updated Date: 2019-04-28T04:04:23Z +Creation Date: 2000-10-04T02:21:23Z +Registry Expiry Date: 2020-04-28T04:00:00Z +Registrar: MarkMonitor International Canada Ltd. +Registrar IANA ID: +Registrar Abuse Contact Email: +Registrar Abuse Contact Phone: +Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited +Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited +Domain Status: clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited +Domain Status: serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited +Domain Status: serverTransferProhibited https://icann.org/epp#serverTransferProhibited +Domain Status: serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited +Registry Registrant ID: 59969059-CIRA +Registrant Name: Google LLC - TMA868122 +Registrant Organization: +Registrant Street: 1600 Amphitheatre Parkway +Registrant City: Mountain View +Registrant State/Province: CA +Registrant Postal Code: 94043 +Registrant Country: US +Registrant Phone: +1.6502530000 +Registrant Phone Ext: +Registrant Fax: +Registrant Fax Ext: +Registrant Email: dns-admin@google.com +Registry Admin ID: 59969161-CIRA +Admin Name: Lauren Johnston +Admin Organization: Google LLC +Admin Street: 1600 Amphitheatre Parkway +Admin City: Mountain View +Admin State/Province: CA +Admin Postal Code: 94043 +Admin Country: US +Admin Phone: +1.6502530000 +Admin Phone Ext: +Admin Fax: +Admin Fax Ext: +Admin Email: dns-admin@google.com +Registry Tech ID: 59969161-CIRA +Tech Name: Lauren Johnston +Tech Organization: Google LLC +Tech Street: 1600 Amphitheatre Parkway +Tech City: Mountain View +Tech State/Province: CA +Tech Postal Code: 94043 +Tech Country: US +Tech Phone: +1.6502530000 +Tech Phone Ext: +Tech Fax: +Tech Fax Ext: +Tech Email: dns-admin@google.com +Registry Billing ID: +Billing Name: +Billing Organization: +Billing Street: +Billing City: +Billing State/Province: +Billing Postal Code: +Billing Country: +Billing Phone: +Billing Phone Ext: +Billing Fax: +Billing Fax Ext: +Billing Email: +Name Server: ns1.google.com +Name Server: ns2.google.com +Name Server: ns3.google.com +Name Server: ns4.google.com +DNSSEC: unsigned +URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/ +>>> Last update of WHOIS database: 2019-11-07T19:00:13Z <<< + +For more information on Whois status codes, please visit https://icann.org/epp + +% +% Use of CIRA's WHOIS service is governed by the Terms of Use in its Legal +% Notice, available at http://www.cira.ca/legal-notice/?lang=en +% +% (c) 2019 Canadian Internet Registration Authority, (http://www.cira.ca/) \ No newline at end of file diff --git a/spec/whois/parsers/responses/whois.cira.ca/ca/property_status_available_v3_spec.rb b/spec/whois/parsers/responses/whois.cira.ca/ca/property_status_available_v3_spec.rb new file mode 100644 index 00000000..bf77a2c5 --- /dev/null +++ b/spec/whois/parsers/responses/whois.cira.ca/ca/property_status_available_v3_spec.rb @@ -0,0 +1,39 @@ +# encoding: utf-8 + +# This file is autogenerated. Do not edit it manually. +# If you want change the content of this file, edit +# +# /spec/fixtures/responses/whois.cira.ca/ca/property_status_available_v3.expected +# +# and regenerate the tests with the following rake task +# +# $ rake spec:generate +# + +require 'spec_helper' +require 'whois/parsers/whois.cira.ca.rb' + +describe Whois::Parsers::WhoisCiraCa, "property_status_available_v3.expected" do + + subject do + file = fixture("responses", "whois.cira.ca/ca/property_status_available_v3.txt") + part = Whois::Record::Part.new(body: File.read(file)) + described_class.new(part) + end + + describe "#status" do + it do + expect(subject.status).to eq(:available) + end + end + describe "#available?" do + it do + expect(subject.available?).to eq(true) + end + end + describe "#registered?" do + it do + expect(subject.registered?).to eq(false) + end + end +end diff --git a/spec/whois/parsers/responses/whois.cira.ca/ca/status_available_v3_spec.rb b/spec/whois/parsers/responses/whois.cira.ca/ca/status_available_v3_spec.rb new file mode 100644 index 00000000..9dce47a9 --- /dev/null +++ b/spec/whois/parsers/responses/whois.cira.ca/ca/status_available_v3_spec.rb @@ -0,0 +1,108 @@ +# encoding: utf-8 + +# This file is autogenerated. Do not edit it manually. +# If you want change the content of this file, edit +# +# /spec/fixtures/responses/whois.cira.ca/ca/status_available_v3.expected +# +# and regenerate the tests with the following rake task +# +# $ rake spec:generate +# + +require 'spec_helper' +require 'whois/parsers/whois.cira.ca.rb' + +describe Whois::Parsers::WhoisCiraCa, "status_available_v3.expected" do + + subject do + file = fixture("responses", "whois.cira.ca/ca/status_available_v3.txt") + part = Whois::Record::Part.new(body: File.read(file)) + described_class.new(part) + end + + describe "#disclaimer" do + it do + expect(subject.disclaimer).to eq("Use of CIRA's WHOIS service is governed by the Terms of Use in its Legal\nNotice, available at http://www.cira.ca/legal-notice/?lang=en\n\n(c) 2019 Canadian Internet Registration Authority, (http://www.cira.ca/)") + end + end + describe "#domain" do + it do + expect(subject.domain).to eq("u34jedzcq.ca") + end + end + describe "#domain_id" do + it do + expect { subject.domain_id }.to raise_error(Whois::AttributeNotSupported) + end + end + describe "#status" do + it do + expect(subject.status).to eq(:available) + end + end + describe "#available?" do + it do + expect(subject.available?).to eq(true) + end + end + describe "#registered?" do + it do + expect(subject.registered?).to eq(false) + end + end + describe "#created_on" do + it do + expect(subject.created_on).to eq(nil) + end + end + describe "#updated_on" do + it do + expect(subject.updated_on).to eq(nil) + end + end + describe "#expires_on" do + it do + expect(subject.expires_on).to eq(nil) + end + end + describe "#registrar" do + it do + expect(subject.registrar).to eq(nil) + end + end + describe "#registrant_contacts" do + it do + expect(subject.registrant_contacts).to be_a(Array) + expect(subject.registrant_contacts).to eq([]) + end + end + describe "#admin_contacts" do + it do + expect(subject.admin_contacts).to be_a(Array) + expect(subject.admin_contacts).to eq([]) + end + end + describe "#technical_contacts" do + it do + expect(subject.technical_contacts).to be_a(Array) + expect(subject.technical_contacts).to eq([]) + end + end + describe "#nameservers" do + it do + expect(subject.nameservers).to be_a(Array) + expect(subject.nameservers).to eq([]) + end + end + describe "#valid?" do + it do + expect(subject.valid?).to eq(true) + end + end + describe "#invalid?" do + it do + expect(subject.invalid?).to eq(false) + end + end +end diff --git a/spec/whois/parsers/responses/whois.cira.ca/ca/status_invalid_v3_spec.rb b/spec/whois/parsers/responses/whois.cira.ca/ca/status_invalid_v3_spec.rb new file mode 100644 index 00000000..64fad715 --- /dev/null +++ b/spec/whois/parsers/responses/whois.cira.ca/ca/status_invalid_v3_spec.rb @@ -0,0 +1,39 @@ +# encoding: utf-8 + +# This file is autogenerated. Do not edit it manually. +# If you want change the content of this file, edit +# +# /spec/fixtures/responses/whois.cira.ca/ca/status_invalid_v3.expected +# +# and regenerate the tests with the following rake task +# +# $ rake spec:generate +# + +require 'spec_helper' +require 'whois/parsers/whois.cira.ca.rb' + +describe Whois::Parsers::WhoisCiraCa, "status_invalid_v3.expected" do + + subject do + file = fixture("responses", "whois.cira.ca/ca/status_invalid_v3.txt") + part = Whois::Record::Part.new(body: File.read(file)) + described_class.new(part) + end + + describe "#status" do + it do + expect(subject.status).to eq(:available) + end + end + describe "#valid?" do + it do + expect(subject.valid?).to eq(true) + end + end + describe "#invalid?" do + it do + expect(subject.invalid?).to eq(false) + end + end +end diff --git a/spec/whois/parsers/responses/whois.cira.ca/ca/status_registered_v3_spec.rb b/spec/whois/parsers/responses/whois.cira.ca/ca/status_registered_v3_spec.rb new file mode 100644 index 00000000..011a445b --- /dev/null +++ b/spec/whois/parsers/responses/whois.cira.ca/ca/status_registered_v3_spec.rb @@ -0,0 +1,162 @@ +# encoding: utf-8 + +# This file is autogenerated. Do not edit it manually. +# If you want change the content of this file, edit +# +# /spec/fixtures/responses/whois.cira.ca/ca/status_registered_v3.expected +# +# and regenerate the tests with the following rake task +# +# $ rake spec:generate +# + +require 'spec_helper' +require 'whois/parsers/whois.cira.ca.rb' + +describe Whois::Parsers::WhoisCiraCa, "status_registered_v3.expected" do + + subject do + file = fixture("responses", "whois.cira.ca/ca/status_registered_v3.txt") + part = Whois::Record::Part.new(body: File.read(file)) + described_class.new(part) + end + + describe "#disclaimer" do + it do + expect(subject.disclaimer).to eq("Use of CIRA's WHOIS service is governed by the Terms of Use in its Legal\nNotice, available at http://www.cira.ca/legal-notice/?lang=en\n\n(c) 2019 Canadian Internet Registration Authority, (http://www.cira.ca/)") + end + end + describe "#domain" do + it do + expect(subject.domain).to eq("google.ca") + end + end + describe "#domain_id" do + it do + expect { subject.domain_id }.to raise_error(Whois::AttributeNotSupported) + end + end + describe "#status" do + it do + expect(subject.status).to eq(:registered) + end + end + describe "#available?" do + it do + expect(subject.available?).to eq(false) + end + end + describe "#registered?" do + it do + expect(subject.registered?).to eq(true) + end + end + describe "#created_on" do + it do + expect(subject.created_on).to be_a(Time) + expect(subject.created_on).to eq(Time.parse("2000-10-04 02:21:23.000000000 +0000")) + end + end + describe "#updated_on" do + it do + expect(subject.updated_on).to be_a(Time) + expect(subject.updated_on).to eq(Time.parse("2019-04-28 04:04:23.000000000 +0000")) + end + end + describe "#expires_on" do + it do + expect(subject.expires_on).to be_a(Time) + expect(subject.expires_on).to eq(Time.parse("2020-04-28 04:00:00.000000000 +0000")) + end + end + describe "#registrar" do + it do + expect(subject.registrar).to be_a(Whois::Parser::Registrar) + expect(subject.registrar.id).to eq(nil) + expect(subject.registrar.name).to eq("MarkMonitor International Canada Ltd.") + expect(subject.registrar.organization).to eq("MarkMonitor International Canada Ltd.") + expect(subject.registrar.url).to eq(nil) + end + end + describe "#registrant_contacts" do + it do + expect(subject.registrant_contacts).to be_a(Array) + expect(subject.registrant_contacts.size).to eq(1) + expect(subject.registrant_contacts[0]).to be_a(Whois::Parser::Contact) + expect(subject.registrant_contacts[0].type).to eq(Whois::Parser::Contact::TYPE_REGISTRANT) + expect(subject.registrant_contacts[0].id).to eq("59969059-CIRA") + expect(subject.registrant_contacts[0].name).to eq("Google LLC - TMA868122") + expect(subject.registrant_contacts[0].organization).to eq(nil) + expect(subject.registrant_contacts[0].address).to eq("1600 Amphitheatre Parkway") + expect(subject.registrant_contacts[0].city).to eq("Mountain View") + expect(subject.registrant_contacts[0].zip).to eq("94043") + expect(subject.registrant_contacts[0].state).to eq("CA") + expect(subject.registrant_contacts[0].country_code).to eq("US") + expect(subject.registrant_contacts[0].phone).to eq("+1.6502530000") + expect(subject.registrant_contacts[0].fax).to eq(nil) + expect(subject.registrant_contacts[0].email).to eq("dns-admin@google.com") + end + end + describe "#admin_contacts" do + it do + expect(subject.admin_contacts).to be_a(Array) + expect(subject.admin_contacts.size).to eq(1) + expect(subject.admin_contacts[0]).to be_a(Whois::Parser::Contact) + expect(subject.admin_contacts[0].type).to eq(Whois::Parser::Contact::TYPE_ADMINISTRATIVE) + expect(subject.admin_contacts[0].id).to eq("59969161-CIRA") + expect(subject.admin_contacts[0].name).to eq("Lauren Johnston") + expect(subject.admin_contacts[0].organization).to eq("Google LLC") + expect(subject.admin_contacts[0].address).to eq("1600 Amphitheatre Parkway") + expect(subject.admin_contacts[0].city).to eq("Mountain View") + expect(subject.admin_contacts[0].zip).to eq("94043") + expect(subject.admin_contacts[0].state).to eq("CA") + expect(subject.admin_contacts[0].country_code).to eq("US") + expect(subject.admin_contacts[0].phone).to eq("+1.6502530000") + expect(subject.admin_contacts[0].fax).to eq(nil) + expect(subject.admin_contacts[0].email).to eq("dns-admin@google.com") + end + end + describe "#technical_contacts" do + it do + expect(subject.technical_contacts).to be_a(Array) + expect(subject.technical_contacts.size).to eq(1) + expect(subject.technical_contacts[0]).to be_a(Whois::Parser::Contact) + expect(subject.technical_contacts[0].type).to eq(Whois::Parser::Contact::TYPE_TECHNICAL) + expect(subject.technical_contacts[0].id).to eq("59969161-CIRA") + expect(subject.technical_contacts[0].name).to eq("Lauren Johnston") + expect(subject.technical_contacts[0].organization).to eq("Google LLC") + expect(subject.technical_contacts[0].address).to eq("1600 Amphitheatre Parkway") + expect(subject.technical_contacts[0].city).to eq("Mountain View") + expect(subject.technical_contacts[0].zip).to eq("94043") + expect(subject.technical_contacts[0].state).to eq("CA") + expect(subject.technical_contacts[0].country_code).to eq("US") + expect(subject.technical_contacts[0].phone).to eq("+1.6502530000") + expect(subject.technical_contacts[0].fax).to eq(nil) + expect(subject.technical_contacts[0].email).to eq("dns-admin@google.com") + end + end + describe "#nameservers" do + it do + expect(subject.nameservers).to be_a(Array) + expect(subject.nameservers.size).to eq(4) + expect(subject.nameservers[0]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[0].name).to eq("ns1.google.com") + expect(subject.nameservers[1]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[1].name).to eq("ns2.google.com") + expect(subject.nameservers[2]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[2].name).to eq("ns3.google.com") + expect(subject.nameservers[3]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[3].name).to eq("ns4.google.com") + end + end + describe "#valid?" do + it do + expect(subject.valid?).to eq(true) + end + end + describe "#invalid?" do + it do + expect(subject.invalid?).to eq(false) + end + end +end