From c65b4996c59eee08fbf6716a6b9b66723ba85b89 Mon Sep 17 00:00:00 2001 From: Cork Date: Fri, 4 May 2018 10:57:21 +0200 Subject: [PATCH] Add support for whois.domaininfo.com --- lib/whois/parsers/whois.domaininfo.com.rb | 56 +++++++ .../status_available.expected | 42 +++++ .../whois.domaininfo.com/status_available.txt | 1 + .../status_registered.expected | 93 +++++++++++ .../status_registered.txt | 98 ++++++++++++ .../status_available_spec.rb | 93 +++++++++++ .../status_registered_spec.rb | 144 ++++++++++++++++++ 7 files changed, 527 insertions(+) create mode 100644 lib/whois/parsers/whois.domaininfo.com.rb create mode 100644 spec/fixtures/responses/whois.domaininfo.com/status_available.expected create mode 100644 spec/fixtures/responses/whois.domaininfo.com/status_available.txt create mode 100644 spec/fixtures/responses/whois.domaininfo.com/status_registered.expected create mode 100644 spec/fixtures/responses/whois.domaininfo.com/status_registered.txt create mode 100644 spec/whois/parsers/responses/whois.domaininfo.com/status_available_spec.rb create mode 100644 spec/whois/parsers/responses/whois.domaininfo.com/status_registered_spec.rb diff --git a/lib/whois/parsers/whois.domaininfo.com.rb b/lib/whois/parsers/whois.domaininfo.com.rb new file mode 100644 index 00000000..6e829864 --- /dev/null +++ b/lib/whois/parsers/whois.domaininfo.com.rb @@ -0,0 +1,56 @@ +#-- +# 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 WhoisDomaininfoCom < BaseIcannCompliant + self.scanner = Scanners::BaseIcannCompliant, { + pattern_available: /^Domain does not exist$/ + } + + 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.domaininfo.com/status_available.expected b/spec/fixtures/responses/whois.domaininfo.com/status_available.expected new file mode 100644 index 00000000..f0e6a67f --- /dev/null +++ b/spec/fixtures/responses/whois.domaininfo.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.domaininfo.com/status_available.txt b/spec/fixtures/responses/whois.domaininfo.com/status_available.txt new file mode 100644 index 00000000..38be51e6 --- /dev/null +++ b/spec/fixtures/responses/whois.domaininfo.com/status_available.txt @@ -0,0 +1 @@ +Domain does not exist diff --git a/spec/fixtures/responses/whois.domaininfo.com/status_registered.expected b/spec/fixtures/responses/whois.domaininfo.com/status_registered.expected new file mode 100644 index 00000000..f06e5f47 --- /dev/null +++ b/spec/fixtures/responses/whois.domaininfo.com/status_registered.expected @@ -0,0 +1,93 @@ +#domain + %s == "domain.com" + +#domain_id + %s == "575988_DOMAIN_COM-VRSN" + +#status + %s == :registered + +#available? + %s == false + +#registered? + %s == true + +#created_on + %s %CLASS{time} + %s %TIME{1997-10-25 04:00:00 UTC} + +#updated_on + %s %CLASS{time} + %s %TIME{2017-10-19 12:56:58 UTC} + +#expires_on + %s %CLASS{time} + %s %TIME{2018-10-24 04:00:00 UTC} + +#registrar + %s %CLASS{registrar} + %s.id == "73" + %s.name == "PortsGroup AB" + %s.organization == "PortsGroup AB" + %s.url == "ports.domains" + +#registrant_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Parser::Contact::TYPE_REGISTRANT + %s[0].name == "Domain Name Department" + %s[0].organization == "Ports Group AB" + %s[0].address == "Kalkylvagen 3" + %s[0].city == "Molnlycke" + %s[0].zip == "43533" + %s[0].state == "" + %s[0].country_code == "SE" + %s[0].phone == "+46.317202030" + %s[0].fax == "" + %s[0].email == "dms@dipcon.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 Name Department" + %s[0].organization == "Ports Group AB" + %s[0].address == "Kalkylvagen 3" + %s[0].city == "Molnlycke" + %s[0].zip == "43533" + %s[0].state == "" + %s[0].country_code == "SE" + %s[0].phone == "+46.317202030" + %s[0].fax == "" + %s[0].email == "dms@dipcon.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 Name Department" + %s[0].organization == "Ports Group AB" + %s[0].address == "Kalkylvagen 3" + %s[0].city == "Molnlycke" + %s[0].zip == "43533" + %s[0].state == "" + %s[0].country_code == "SE" + %s[0].phone == "+46.317202030" + %s[0].fax == "" + %s[0].email == "dms@dipcon.com" + +#nameservers + %s %CLASS{array} + %s %SIZE{4} + %s[0] %CLASS{nameserver} + %s[0].name == "dns01.dipcon.com" + %s[1] %CLASS{nameserver} + %s[1].name == "dns02.ports.se" + %s[2] %CLASS{nameserver} + %s[2].name == "dns03.ports.se" + %s[3] %CLASS{nameserver} + %s[3].name == "dns04.ports.net" diff --git a/spec/fixtures/responses/whois.domaininfo.com/status_registered.txt b/spec/fixtures/responses/whois.domaininfo.com/status_registered.txt new file mode 100644 index 00000000..557672bf --- /dev/null +++ b/spec/fixtures/responses/whois.domaininfo.com/status_registered.txt @@ -0,0 +1,98 @@ +Domain Name: domaininfo.com +Registry Domain ID: 575988_DOMAIN_COM-VRSN +Registrar WHOIS Server: whois.domaininfo.com +Registrar URL: ports.domains +Updated Date: 2017-10-19T12:56:58Z +Creation Date: 1997-10-25T04:00:00Z +Registrar Registration Expiration Date: 2018-10-24T04:00:00Z +Registrar: PortsGroup AB +Registrar IANA ID: 73 +Registrar Abuse Contact Email: abuse@portsgroup.se +Registrar Abuse Contact Phone: +46.317202000 +Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited +Domain Status: serverTransferProhibited https://icann.org/epp#serverTransferProhibited +Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited +Domain Status: clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited +Domain Status: serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited +Domain Status: serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited +Registry Registrant ID: +Registrant Name: Domain Name Department +Registrant Organization: Ports Group AB +Registrant Street: Kalkylvagen 3 +Registrant City: Molnlycke +Registrant State/Province: +Registrant Postal Code: 43533 +Registrant Country: SE +Registrant Phone: +46.317202030 +Registrant Fax: +Registrant Email: dms@dipcon.com +Registry Admin ID: +Admin Name: Domain Name Department +Admin Organization: Ports Group AB +Admin Street: Kalkylvagen 3 +Admin City: Molnlycke +Admin State/Province: +Admin Postal Code: 43533 +Admin Country: SE +Admin Phone: +46.317202030 +Admin Fax: +Admin Email: dms@dipcon.com +Registry Tech ID: +Tech Name: Domain Name Department +Tech Organization: Ports Group AB +Tech Street: Kalkylvagen 3 +Tech City: Molnlycke +Tech State/Province: +Tech Postal Code: 43533 +Tech Country: SE +Tech Phone: +46.317202030 +Tech Fax: +Tech Email: dms@dipcon.com +Name Server: DNS01.DIPCON.COM +Name Server: DNS02.PORTS.SE +Name Server: DNS03.PORTS.SE +Name Server: DNS04.PORTS.NET +DNSSEC: unsigned +URL of the ICANN WHOIS Data Problem Reporting System: http://wdprs.internic.net +>>> Last update of WHOIS database: 2018-05-03T22:00:01Z + +NOTICE: The expiration date displayed in this record is the date the +registrar's sponsorship of the domain name registration in the registry is +currently set to expire. This date does not necessarily reflect the expiration +date of the domain name registrant's agreement with the sponsoring +registrar. Users may consult the sponsoring registrar's Whois database to +view the registrar's reported date of expiration for this registration. + +TERMS OF USE: You are not authorized to access or query our Whois +database through the use of electronic processes that are high-volume and +automated except as reasonably necessary to register domain names or +modify existing registrations; the Data in VeriSign Global Registry +Services' ("VeriSign") Whois database is provided by VeriSign for +information purposes only, and to assist persons in obtaining information +about or related to a domain name registration record. VeriSign does not +guarantee its accuracy. By submitting a Whois query, you agree to abide +by the following terms of use: You agree that you may use this Data only +for lawful purposes and that under no circumstances will you use this Data +to: (1) allow, enable, or otherwise support the transmission of mass +unsolicited, commercial advertising or solicitations via e-mail, telephone, +or facsimile; or (2) enable high volume, automated, electronic processes +that apply to VeriSign (or its computer systems). The compilation, +repackaging, dissemination or other use of this Data is expressly +prohibited without the prior written consent of VeriSign. You agree not to +use electronic processes that are automated and high-volume to access or +query the Whois database except as reasonably necessary to register +domain names or modify existing registrations. VeriSign reserves the right +to restrict your access to the Whois database in its sole discretion to ensure +operational stability. VeriSign may restrict or terminate your access to the +Whois database for failure to abide by these terms of use. VeriSign +reserves the right to modify these terms at any time. + +The Registry database contains ONLY .COM, .NET, .EDU domains and +Registrars.---------------------------------------------------------------------------- +You agree that you will not reproduce, sell, transfer, or modify any of the +data presented in response to your search request, or use of any such data +for commercial purpose, without the prior express written permission of +Domaininfo AB - domaininfo.com +Register your name in 200+ top level domains at http://www.domaininfo.com domaininfo.com +---------------------------------------------------------------------------- + diff --git a/spec/whois/parsers/responses/whois.domaininfo.com/status_available_spec.rb b/spec/whois/parsers/responses/whois.domaininfo.com/status_available_spec.rb new file mode 100644 index 00000000..a45cc051 --- /dev/null +++ b/spec/whois/parsers/responses/whois.domaininfo.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.domaininfo.com/status_available.expected +# +# and regenerate the tests with the following rake task +# +# $ rake spec:generate +# + +require 'spec_helper' +require 'whois/parsers/whois.domaininfo.com.rb' + +describe Whois::Parsers::WhoisDomaininfoCom, "status_available.expected" do + + subject do + file = fixture("responses", "whois.domaininfo.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.domaininfo.com/status_registered_spec.rb b/spec/whois/parsers/responses/whois.domaininfo.com/status_registered_spec.rb new file mode 100644 index 00000000..76f15773 --- /dev/null +++ b/spec/whois/parsers/responses/whois.domaininfo.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.domaininfo.com/status_registered.expected +# +# and regenerate the tests with the following rake task +# +# $ rake spec:generate +# + +require 'spec_helper' +require 'whois/parsers/whois.domaininfo.com.rb' + +describe Whois::Parsers::WhoisDomaininfoCom, "status_registered.expected" do + + subject do + file = fixture("responses", "whois.domaininfo.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("domaininfo.com") + end + end + describe "#domain_id" do + it do + expect(subject.domain_id).to eq("575988_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("1997-10-25 04:00:00 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("2017-10-19 12:56:58 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("2018-10-24 04:00:00 UTC")) + end + end + describe "#registrar" do + it do + expect(subject.registrar).to be_a(Whois::Parser::Registrar) + expect(subject.registrar.id).to eq("73") + expect(subject.registrar.name).to eq("PortsGroup AB") + expect(subject.registrar.organization).to eq("PortsGroup AB") + expect(subject.registrar.url).to eq("ports.domains") + 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 Name Department") + expect(subject.registrant_contacts[0].organization).to eq("Ports Group AB") + expect(subject.registrant_contacts[0].address).to eq("Kalkylvagen 3") + expect(subject.registrant_contacts[0].city).to eq("Molnlycke") + expect(subject.registrant_contacts[0].zip).to eq("43533") + expect(subject.registrant_contacts[0].state).to eq("") + expect(subject.registrant_contacts[0].country_code).to eq("SE") + expect(subject.registrant_contacts[0].phone).to eq("+46.317202030") + expect(subject.registrant_contacts[0].fax).to eq("") + expect(subject.registrant_contacts[0].email).to eq("dms@dipcon.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 Name Department") + expect(subject.admin_contacts[0].organization).to eq("Ports Group AB") + expect(subject.admin_contacts[0].address).to eq("Kalkylvagen 3") + expect(subject.admin_contacts[0].city).to eq("Molnlycke") + expect(subject.admin_contacts[0].zip).to eq("43533") + expect(subject.admin_contacts[0].state).to eq("") + expect(subject.admin_contacts[0].country_code).to eq("SE") + expect(subject.admin_contacts[0].phone).to eq("+46.317202030") + expect(subject.admin_contacts[0].fax).to eq("") + expect(subject.admin_contacts[0].email).to eq("dms@dipcon.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 Name Department") + expect(subject.technical_contacts[0].organization).to eq("Ports Group AB") + expect(subject.technical_contacts[0].address).to eq("Kalkylvagen 3") + expect(subject.technical_contacts[0].city).to eq("Molnlycke") + expect(subject.technical_contacts[0].zip).to eq("43533") + expect(subject.technical_contacts[0].state).to eq("") + expect(subject.technical_contacts[0].country_code).to eq("SE") + expect(subject.technical_contacts[0].phone).to eq("+46.317202030") + expect(subject.technical_contacts[0].fax).to eq("") + expect(subject.technical_contacts[0].email).to eq("dms@dipcon.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("dns01.dipcon.com") + expect(subject.nameservers[1]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[1].name).to eq("dns02.ports.se") + expect(subject.nameservers[2]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[2].name).to eq("dns03.ports.se") + expect(subject.nameservers[3]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[3].name).to eq("dns04.ports.net") + end + end +end