From be298ae3e210cec03e32cbf7560bfbb1fa9fcc07 Mon Sep 17 00:00:00 2001 From: Cork Date: Thu, 3 May 2018 15:16:48 +0200 Subject: [PATCH] Add support for whois.domain.com --- lib/whois/parsers/whois.domain.com.rb | 60 ++++++++ .../status_available.expected | 42 +++++ .../whois.domain.com/status_available.txt | 1 + .../status_registered.expected | 95 ++++++++++++ .../whois.domain.com/status_registered.txt | 70 +++++++++ .../whois.domain.com/status_available_spec.rb | 93 +++++++++++ .../status_registered_spec.rb | 144 ++++++++++++++++++ 7 files changed, 505 insertions(+) create mode 100644 lib/whois/parsers/whois.domain.com.rb create mode 100644 spec/fixtures/responses/whois.domain.com/status_available.expected create mode 100644 spec/fixtures/responses/whois.domain.com/status_available.txt create mode 100644 spec/fixtures/responses/whois.domain.com/status_registered.expected create mode 100644 spec/fixtures/responses/whois.domain.com/status_registered.txt create mode 100644 spec/whois/parsers/responses/whois.domain.com/status_available_spec.rb create mode 100644 spec/whois/parsers/responses/whois.domain.com/status_registered_spec.rb diff --git a/lib/whois/parsers/whois.domain.com.rb b/lib/whois/parsers/whois.domain.com.rb new file mode 100644 index 00000000..ab5bd6bf --- /dev/null +++ b/lib/whois/parsers/whois.domain.com.rb @@ -0,0 +1,60 @@ +#-- +# Ruby Whois +# +# An intelligent pure Ruby WHOIS client and parser. +# +# Copyright (c) 2009-2018 Simone Carletti +#++ + + +require_relative 'base_icann_compliant' + + +module Whois + class Parsers + + class WhoisDomainCom < BaseIcannCompliant + self.scanner = Scanners::BaseIcannCompliant, { + pattern_available: /^Can't get information on non-local domain/ + } + + property_supported :domain_id do + node("Domain ID") + end + + property_supported :registrant_contacts do + build_contact("Registrant", Parser::Contact::TYPE_REGISTRANT) + end + + property_supported :admin_contacts do + build_contact("Admin", Parser::Contact::TYPE_ADMINISTRATIVE) + end + + property_supported :technical_contacts do + build_contact("Tech", Parser::Contact::TYPE_TECHNICAL) + end + + private + + def build_contact(element, type) + node("#{element} Name") do + Parser::Contact.new( + type: type, + id: node("Registry #{element} ID").presence, + name: value_for_property(element, 'Name'), + organization: value_for_property(element, 'Organization'), + address: value_for_property(element, 'Street'), + city: value_for_property(element, 'City'), + zip: value_for_property(element, 'Postal Code'), + state: value_for_property(element, 'State/Province'), + country_code: value_for_property(element, 'Country'), + phone: value_for_phone_property(element, 'Phone'), + fax: value_for_phone_property(element, 'Fax'), + email: value_for_property(element, 'Email') + ) + end + end + + end + end +end diff --git a/spec/fixtures/responses/whois.domain.com/status_available.expected b/spec/fixtures/responses/whois.domain.com/status_available.expected new file mode 100644 index 00000000..f0e6a67f --- /dev/null +++ b/spec/fixtures/responses/whois.domain.com/status_available.expected @@ -0,0 +1,42 @@ +#domain + %s == nil + +#domain_id + %s == nil + +#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 == [] diff --git a/spec/fixtures/responses/whois.domain.com/status_available.txt b/spec/fixtures/responses/whois.domain.com/status_available.txt new file mode 100644 index 00000000..9d64dcfb --- /dev/null +++ b/spec/fixtures/responses/whois.domain.com/status_available.txt @@ -0,0 +1 @@ +Can't get information on non-local domain U34JEDZCQ.COM diff --git a/spec/fixtures/responses/whois.domain.com/status_registered.expected b/spec/fixtures/responses/whois.domain.com/status_registered.expected new file mode 100644 index 00000000..098c9a07 --- /dev/null +++ b/spec/fixtures/responses/whois.domain.com/status_registered.expected @@ -0,0 +1,95 @@ +#domain + %s == "domain.com" + +#domain_id + %s == "608082_DOMAIN_COM-VRSN" + +#status + %s == :registered + +#available? + %s == false + +#registered? + %s == true + +#created_on + %s %CLASS{time} + %s %TIME{1994-07-01 04:00:00 UTC} + +#updated_on + %s %CLASS{time} + %s %TIME{2016-10-21 20:11:05 UTC} + +#expires_on + %s %CLASS{time} + %s %TIME{2021-01-07 13:34:24 UTC} + +#registrar + %s %CLASS{registrar} + %s.id == "886" + %s.name == "Domain.com, LLC" + %s.organization == "Domain.com, LLC" + %s.url == "www.domain.com" + + +#registrant_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Parser::Contact::TYPE_REGISTRANT + %s[0].name == "Domain Administrator" + %s[0].organization == "Endurance International Group West, Inc" + %s[0].address == "10 Corporate Drive Suite 300" + %s[0].city == "Burlington" + %s[0].zip == "01803" + %s[0].state == "MA" + %s[0].country_code == "US" + %s[0].phone == "+1.3604495900" + %s[0].fax == "+1.3602534234" + %s[0].email == "corpdomains@endurance.com" + +#admin_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Parser::Contact::TYPE_ADMINISTRATIVE + %s[0].name == "Domain Administrator" + %s[0].organization == "Endurance International Group West, Inc" + %s[0].address == "10 Corporate Drive Suite 300" + %s[0].city == "Burlington" + %s[0].zip == "01803" + %s[0].state == "MA" + %s[0].country_code == "US" + %s[0].phone == "+1.3604495900" + %s[0].fax == "+1.3602534234" + %s[0].email == "corpdomains@endurance.com" + +#technical_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Parser::Contact::TYPE_TECHNICAL + %s[0].name == "Domain Administrator" + %s[0].organization == "Endurance International Group West, Inc" + %s[0].address == "10 Corporate Drive Suite 300" + %s[0].city == "Burlington" + %s[0].zip == "01803" + %s[0].state == "MA" + %s[0].country_code == "US" + %s[0].phone == "+1.3604495900" + %s[0].fax == "+1.3602534234" + %s[0].email == "corpdomains@endurance.com" + + +#nameservers + %s %CLASS{array} + %s %SIZE{4} + %s[0] %CLASS{nameserver} + %s[0].name == "ns-166.awsdns-20.com" + %s[1] %CLASS{nameserver} + %s[1].name == "ns-683.awsdns-21.net" + %s[2] %CLASS{nameserver} + %s[2].name == "ns-1250.awsdns-28.org" + %s[3] %CLASS{nameserver} + %s[3].name == "ns-2022.awsdns-60.co.uk" diff --git a/spec/fixtures/responses/whois.domain.com/status_registered.txt b/spec/fixtures/responses/whois.domain.com/status_registered.txt new file mode 100644 index 00000000..9b3a25a8 --- /dev/null +++ b/spec/fixtures/responses/whois.domain.com/status_registered.txt @@ -0,0 +1,70 @@ +Domain Name: DOMAIN.COM +Domain ID: 608082_DOMAIN_COM-VRSN +Registrar WHOIS Server: whois.domain.com +Registrar URL: www.domain.com +Updated Date: 2016-10-21T20:11:05Z +Creation Date: 1994-07-01T04:00:00Z +Registrar Registration Expiration Date: 2021-01-07T13:34:24Z +Registrar: Domain.com, LLC +Registrar IANA ID: 886 +Reseller: Domain Name Holding Company, Inc +Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited +Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited +Domain Status: clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited +Registry Registrant ID: +Registrant Name: Domain Administrator +Registrant Organization: Endurance International Group West, Inc +Registrant Street: 10 Corporate Drive Suite 300 +Registrant City: Burlington +Registrant State/Province: MA +Registrant Postal Code: 01803 +Registrant Country: US +Registrant Phone: +1.3604495900 +Registrant Phone Ext: +Registrant Fax: +1.3602534234 +Registrant Fax Ext: +Registrant Email: corpdomains@endurance.com +Registry Admin ID: +Admin Name: Domain Administrator +Admin Organization: Endurance International Group West, Inc +Admin Street: 10 Corporate Drive Suite 300 +Admin City: Burlington +Admin State/Province: MA +Admin Postal Code: 01803 +Admin Country: US +Admin Phone: +1.3604495900 +Admin Phone Ext: +Admin Fax: +1.3602534234 +Admin Fax Ext: +Admin Email: corpdomains@endurance.com +Registry Tech ID: +Tech Name: Domain Administrator +Tech Organization: Endurance International Group West, Inc +Tech Street: 10 Corporate Drive Suite 300 +Tech City: Burlington +Tech State/Province: MA +Tech Postal Code: 01803 +Tech Country: US +Tech Phone: +1.3604495900 +Tech Phone Ext: +Tech Fax: +1.3602534234 +Tech Fax Ext: +Tech Email: corpdomains@endurance.com +Name Server: NS-166.AWSDNS-20.COM +Name Server: NS-683.AWSDNS-21.NET +Name Server: NS-1250.AWSDNS-28.ORG +Name Server: NS-2022.AWSDNS-60.CO.UK +DNSSEC: unsigned +Registrar Abuse Contact Email: compliance@domain-inc.net +Registrar Abuse Contact Phone: +1.6027165396 +URL of the ICANN WHOIS Data Problem Reporting System: http://wdprs.internic.net/ +>>> Last update of WHOIS database: 2016-10-21T20:11:05Z <<< + +"For more information on Whois status codes, please visit https://icann.org/epp" + +Registration Service Provider: + Domain Name Holding Company, Inc, corpdomains@endurance.com + +1.8007972958 + This company may be contacted for domain login/passwords, + DNS/Nameserver changes, and general domain support questions. + diff --git a/spec/whois/parsers/responses/whois.domain.com/status_available_spec.rb b/spec/whois/parsers/responses/whois.domain.com/status_available_spec.rb new file mode 100644 index 00000000..c6d6611f --- /dev/null +++ b/spec/whois/parsers/responses/whois.domain.com/status_available_spec.rb @@ -0,0 +1,93 @@ +# 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.domain.com/status_available.expected +# +# and regenerate the tests with the following rake task +# +# $ rake spec:generate +# + +require 'spec_helper' +require 'whois/parsers/whois.domain.com.rb' + +describe Whois::Parsers::WhoisDomainCom, "status_available.expected" do + + subject do + file = fixture("responses", "whois.domain.com/status_available.txt") + part = Whois::Record::Part.new(body: File.read(file)) + described_class.new(part) + end + + describe "#domain" do + it do + expect(subject.domain).to eq(nil) + end + end + describe "#domain_id" do + it do + expect(subject.domain_id).to eq(nil) + 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 +end diff --git a/spec/whois/parsers/responses/whois.domain.com/status_registered_spec.rb b/spec/whois/parsers/responses/whois.domain.com/status_registered_spec.rb new file mode 100644 index 00000000..78e9a752 --- /dev/null +++ b/spec/whois/parsers/responses/whois.domain.com/status_registered_spec.rb @@ -0,0 +1,144 @@ +# 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.domain.com/status_registered.expected +# +# and regenerate the tests with the following rake task +# +# $ rake spec:generate +# + +require 'spec_helper' +require 'whois/parsers/whois.domain.com.rb' + +describe Whois::Parsers::WhoisDomainCom, "status_registered.expected" do + + subject do + file = fixture("responses", "whois.domain.com/status_registered.txt") + part = Whois::Record::Part.new(body: File.read(file)) + described_class.new(part) + end + + describe "#domain" do + it do + expect(subject.domain).to eq("domain.com") + end + end + describe "#domain_id" do + it do + expect(subject.domain_id).to eq("608082_DOMAIN_COM-VRSN") + 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("1994-07-01 04:00:00Z UTC")) + end + end + describe "#updated_on" do + it do + expect(subject.updated_on).to be_a(Time) + expect(subject.updated_on).to eq(Time.parse("2016-10-21 20:11:05 UTC")) + end + end + describe "#expires_on" do + it do + expect(subject.expires_on).to be_a(Time) + expect(subject.expires_on).to eq(Time.parse("2021-01-07 13:34:24 UTC")) + end + end + describe "#registrar" do + it do + expect(subject.registrar).to be_a(Whois::Parser::Registrar) + expect(subject.registrar.id).to eq("886") + expect(subject.registrar.name).to eq("Domain.com, LLC") + expect(subject.registrar.organization).to eq("Domain.com, LLC") + expect(subject.registrar.url).to eq("www.domain.com") + 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].name).to eq("Domain Administrator") + expect(subject.registrant_contacts[0].organization).to eq("Endurance International Group West, Inc") + expect(subject.registrant_contacts[0].address).to eq("10 Corporate Drive Suite 300") + expect(subject.registrant_contacts[0].city).to eq("Burlington") + expect(subject.registrant_contacts[0].zip).to eq("01803") + expect(subject.registrant_contacts[0].state).to eq("MA") + expect(subject.registrant_contacts[0].country_code).to eq("US") + expect(subject.registrant_contacts[0].phone).to eq("+1.3604495900") + expect(subject.registrant_contacts[0].fax).to eq("+1.3602534234") + expect(subject.registrant_contacts[0].email).to eq("corpdomains@endurance.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].name).to eq("Domain Administrator") + expect(subject.admin_contacts[0].organization).to eq("Endurance International Group West, Inc") + expect(subject.admin_contacts[0].address).to eq("10 Corporate Drive Suite 300") + expect(subject.admin_contacts[0].city).to eq("Burlington") + expect(subject.admin_contacts[0].zip).to eq("01803") + expect(subject.admin_contacts[0].state).to eq("MA") + expect(subject.admin_contacts[0].country_code).to eq("US") + expect(subject.admin_contacts[0].phone).to eq("+1.3604495900") + expect(subject.admin_contacts[0].fax).to eq("+1.3602534234") + expect(subject.admin_contacts[0].email).to eq("corpdomains@endurance.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].name).to eq("Domain Administrator") + expect(subject.technical_contacts[0].organization).to eq("Endurance International Group West, Inc") + expect(subject.technical_contacts[0].address).to eq("10 Corporate Drive Suite 300") + expect(subject.technical_contacts[0].city).to eq("Burlington") + expect(subject.technical_contacts[0].zip).to eq("01803") + expect(subject.technical_contacts[0].state).to eq("MA") + expect(subject.technical_contacts[0].country_code).to eq("US") + expect(subject.technical_contacts[0].phone).to eq("+1.3604495900") + expect(subject.technical_contacts[0].fax).to eq("+1.3602534234") + expect(subject.technical_contacts[0].email).to eq("corpdomains@endurance.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("ns-166.awsdns-20.com") + expect(subject.nameservers[1]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[1].name).to eq("ns-683.awsdns-21.net") + expect(subject.nameservers[2]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[2].name).to eq("ns-1250.awsdns-28.org") + expect(subject.nameservers[3]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[3].name).to eq("ns-2022.awsdns-60.co.uk") + end + end +end