From 3b6688b95e6fadcf720cc777ef4bbd2cd644e62b Mon Sep 17 00:00:00 2001 From: Simone Carletti Date: Mon, 10 Mar 2014 17:49:44 +0100 Subject: [PATCH] Add whois.donuts.co parser --- CHANGELOG.md | 4 + lib/whois/record/parser/whois.donuts.co.rb | 63 +++++++ .../parser/whois.networksolutions.com.rb | 2 +- .../bike/status_available.expected | 47 +++++ .../whois.donuts.co/bike/status_available.txt | 3 + .../bike/status_registered.expected | 122 +++++++++++++ .../bike/status_registered.txt | 59 ++++++ .../bike/status_available_spec.rb | 93 ++++++++++ .../bike/status_registered_spec.rb | 168 ++++++++++++++++++ 9 files changed, 560 insertions(+), 1 deletion(-) create mode 100644 lib/whois/record/parser/whois.donuts.co.rb create mode 100644 spec/fixtures/responses/whois.donuts.co/bike/status_available.expected create mode 100644 spec/fixtures/responses/whois.donuts.co/bike/status_available.txt create mode 100644 spec/fixtures/responses/whois.donuts.co/bike/status_registered.expected create mode 100644 spec/fixtures/responses/whois.donuts.co/bike/status_registered.txt create mode 100644 spec/whois/record/parser/responses/whois.donuts.co/bike/status_available_spec.rb create mode 100644 spec/whois/record/parser/responses/whois.donuts.co/bike/status_registered_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 12d27cc39..ecf6851a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ - SERVER: Updated list of latest ASN allocations of 16-bit & 32-bit ASN's from IANA (GH-293). [Thanks @itsbalamurali] +- SERVER: Added new gTLDs (GH-305) + +- NEW: Added whois.donuts.co parser. + - CHANGED: Updated whois.nic.net.sa parser to the new response format. - CHANGED: Updated whois.nic.cz parser to the new response format. diff --git a/lib/whois/record/parser/whois.donuts.co.rb b/lib/whois/record/parser/whois.donuts.co.rb new file mode 100644 index 000000000..9710b7b9a --- /dev/null +++ b/lib/whois/record/parser/whois.donuts.co.rb @@ -0,0 +1,63 @@ +#-- +# Ruby Whois +# +# An intelligent pure Ruby WHOIS client and parser. +# +# Copyright (c) 2009-2014 Simone Carletti +#++ + + +require 'whois/record/parser/base_icann_compliant' + + +module Whois + class Record + class Parser + + # Parser for the whois.donuts.com server. + # + # @see Whois::Record::Parser::Example + # The Example parser for the list of all available methods. + # + class WhoisDonutsCo < BaseIcannCompliant + self.scanner = Scanners::BaseIcannCompliant, { + pattern_available: /^Domain not found\.\n/ + } + + + property_supported :domain_id do + node('Domain ID') + end + + + property_supported :expires_on do + node('Registry Expiry Date') do |value| + Time.parse(value) + end + end + + + property_supported :registrar do + return unless node('Sponsoring Registrar') + Record::Registrar.new( + id: node('Sponsoring Registrar IANA ID'), + name: node('Sponsoring Registrar'), + organization: node('Sponsoring Registrar') + ) + end + + + private + + def build_contact(element, type) + if (contact = super) + contact.id = node("#{element} ID") + end + contact + end + + end + + end + end +end diff --git a/lib/whois/record/parser/whois.networksolutions.com.rb b/lib/whois/record/parser/whois.networksolutions.com.rb index d45a85e0a..2a5b2bbf2 100644 --- a/lib/whois/record/parser/whois.networksolutions.com.rb +++ b/lib/whois/record/parser/whois.networksolutions.com.rb @@ -28,7 +28,7 @@ class WhoisNetworksolutionsCom < BaseIcannCompliant def build_contact(element, type) if (contact = super) && !contact.state.present? - contact.state = value_for_property(element, 'State') + contact.state = node("#{element} State") end contact end diff --git a/spec/fixtures/responses/whois.donuts.co/bike/status_available.expected b/spec/fixtures/responses/whois.donuts.co/bike/status_available.expected new file mode 100644 index 000000000..6bbcc28c5 --- /dev/null +++ b/spec/fixtures/responses/whois.donuts.co/bike/status_available.expected @@ -0,0 +1,47 @@ +#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.donuts.co/bike/status_available.txt b/spec/fixtures/responses/whois.donuts.co/bike/status_available.txt new file mode 100644 index 000000000..3d9e09b3a --- /dev/null +++ b/spec/fixtures/responses/whois.donuts.co/bike/status_available.txt @@ -0,0 +1,3 @@ +Domain not found. + +Terms of Use: Users accessing the Donuts WHOIS service must agree to use the data only for lawful purposes, and under under no circumstances use the data to: Allow, enable, or otherwise support the transmission by e-mail, telephone, or facsimile of mass unsolicited, commercial advertising or solicitations to entities other than the registrar's own existing customers. Enable high volume, automated, electronic processes that send queries or data to the systems of Donuts or any ICANN-accredited registrar, except as reasonably necessary to register domain names or modify existing registrations. When using the Donuts Whois service, please consider the following: The Whois service is not a replacement for standard EPP commands to the SRS service. Whois is not considered authoritative for registered domain objects. The Whois service may be scheduled for downtime during production or OT&E maintenance periods. Queries to the Whois services are throttled. If too many queries are received from a single IP address within a specified time, the service will begin to reject further queries for a period of time to prevent disruption of Whois service access. diff --git a/spec/fixtures/responses/whois.donuts.co/bike/status_registered.expected b/spec/fixtures/responses/whois.donuts.co/bike/status_registered.expected new file mode 100644 index 000000000..37320814e --- /dev/null +++ b/spec/fixtures/responses/whois.donuts.co/bike/status_registered.expected @@ -0,0 +1,122 @@ +#domain + %s == "whereismy.bike" + +#domain_id + %s == "C52CECC9AF044831A7335E8A0ECBC349-D" + + +#status + %s == :registered + +#available? + %s == false + +#registered? + %s == true + + +#created_on + %s %CLASS{time} + %s %TIME{2014-02-21 22:55:07 UTC} + +#updated_on + %s %CLASS{time} + %s %TIME{2014-02-21 22:55:08 UTC} + +#expires_on + %s %CLASS{time} + %s %TIME{2015-02-21 22:55:07 UTC} + + +#registrar + %s %CLASS{registrar} + %s.id == "48" + %s.name == "Enom, Inc." + %s.organization == "Enom, Inc." + %s.url == nil + + +#registrant_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Record::Contact::TYPE_REGISTRANT + %s[0].id == "8ff85c48fbd456f1" + %s[0].name == "whoisguard protected" + %s[0].organization == "WhoisGuard, Inc." + %s[0].address == "P.O. Box 0823-03411" + %s[0].city == "Panama" + %s[0].zip == "00000" + %s[0].state == "Panama" + %s[0].country == nil + %s[0].country_code == "PA" + %s[0].phone == "+507.8365503" + %s[0].fax == "+51.17057182" + %s[0].email == "legal@whoisguard.com" + %s[0].created_on == nil + %s[0].updated_on == nil + +#admin_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Record::Contact::TYPE_ADMINISTRATIVE + %s[0].id == "8ff85c48fbd456f1" + %s[0].name == "whoisguard protected" + %s[0].organization == "WhoisGuard, Inc." + %s[0].address == "P.O. Box 0823-03411" + %s[0].city == "Panama" + %s[0].zip == "00000" + %s[0].state == "Panama" + %s[0].country == nil + %s[0].country_code == "PA" + %s[0].phone == "+507.8365503" + %s[0].fax == "+51.17057182" + %s[0].email == "legal@whoisguard.com" + %s[0].created_on == nil + %s[0].updated_on == nil + +#technical_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Record::Contact::TYPE_TECHNICAL + %s[0].id == "8ff85c48fbd456f1" + %s[0].name == "whoisguard protected" + %s[0].organization == "WhoisGuard, Inc." + %s[0].address == "P.O. Box 0823-03411" + %s[0].city == "Panama" + %s[0].zip == "00000" + %s[0].state == "Panama" + %s[0].country == nil + %s[0].country_code == "PA" + %s[0].phone == "+507.8365503" + %s[0].fax == "+51.17057182" + %s[0].email == "legal@whoisguard.com" + %s[0].created_on == nil + %s[0].updated_on == nil + + +#nameservers + %s %CLASS{array} + %s %SIZE{5} + %s[0] %CLASS{nameserver} + %s[0].name == "dns5.registrar-servers.com" + %s[0].ipv4 == nil + %s[0].ipv6 == nil + %s[1] %CLASS{nameserver} + %s[1].name == "dns3.registrar-servers.com" + %s[1].ipv4 == nil + %s[1].ipv6 == nil + %s[2] %CLASS{nameserver} + %s[2].name == "dns2.registrar-servers.com" + %s[2].ipv4 == nil + %s[2].ipv6 == nil + %s[3] %CLASS{nameserver} + %s[3].name == "dns1.registrar-servers.com" + %s[3].ipv4 == nil + %s[3].ipv6 == nil + %s[4] %CLASS{nameserver} + %s[4].name == "dns4.registrar-servers.com" + %s[4].ipv4 == nil + %s[4].ipv6 == nil diff --git a/spec/fixtures/responses/whois.donuts.co/bike/status_registered.txt b/spec/fixtures/responses/whois.donuts.co/bike/status_registered.txt new file mode 100644 index 000000000..c9abb5119 --- /dev/null +++ b/spec/fixtures/responses/whois.donuts.co/bike/status_registered.txt @@ -0,0 +1,59 @@ +Domain Name: whereismy.bike +Domain ID: C52CECC9AF044831A7335E8A0ECBC349-D +WHOIS Server: http://www.enom.com +Referral URL: http://www.enom.com +Updated Date: 2014-02-21T22:55:08Z +Creation Date: 2014-02-21T22:55:07Z +Registry Expiry Date: 2015-02-21T22:55:07Z +Sponsoring Registrar: Enom, Inc. +Sponsoring Registrar IANA ID: 48 +DomainStatus: clientTransferProhibited +Registrant ID: 8ff85c48fbd456f1 +Registrant Name: whoisguard protected +Registrant Organization: WhoisGuard, Inc. +Registrant Street: P.O. Box 0823-03411 +Registrant City: Panama +Registrant State/Province: Panama +Registrant Postal Code: 00000 +Registrant Country: PA +Registrant Phone: +507.8365503 +Registrant Phone Ext: +Registrant Fax: +51.17057182 +Registrant Fax Ext: +Registrant Email: legal@whoisguard.com +Admin ID: 8ff85c48fbd456f1 +Admin Name: whoisguard protected +Admin Organization: WhoisGuard, Inc. +Admin Street: P.O. Box 0823-03411 +Admin City: Panama +Admin State/Province: Panama +Admin Postal Code: 00000 +Admin Country: PA +Admin Phone: +507.8365503 +Admin Phone Ext: +Admin Fax: +51.17057182 +Admin Fax Ext: +Admin Email: legal@whoisguard.com +Tech ID: 8ff85c48fbd456f1 +Tech Name: whoisguard protected +Tech Organization: WhoisGuard, Inc. +Tech Street: P.O. Box 0823-03411 +Tech City: Panama +Tech State/Province: Panama +Tech Postal Code: 00000 +Tech Country: PA +Tech Phone: +507.8365503 +Tech Phone Ext: +Tech Fax: +51.17057182 +Tech Fax Ext: +Tech Email: legal@whoisguard.com +Name Server: dns5.registrar-servers.com +Name Server: dns3.registrar-servers.com +Name Server: dns2.registrar-servers.com +Name Server: dns1.registrar-servers.com +Name Server: dns4.registrar-servers.com +DNSSEC: unsigned + +>>> Last update of WHOIS database: 2014-03-10T16:17:21Z <<< + +Terms of Use: Users accessing the Donuts WHOIS service must agree to use the data only for lawful purposes, and under under no circumstances use the data to: Allow, enable, or otherwise support the transmission by e-mail, telephone, or facsimile of mass unsolicited, commercial advertising or solicitations to entities other than the registrar's own existing customers. Enable high volume, automated, electronic processes that send queries or data to the systems of Donuts or any ICANN-accredited registrar, except as reasonably necessary to register domain names or modify existing registrations. When using the Donuts Whois service, please consider the following: The Whois service is not a replacement for standard EPP commands to the SRS service. Whois is not considered authoritative for registered domain objects. The Whois service may be scheduled for downtime during production or OT&E maintenance periods. Queries to the Whois services are throttled. If too many queries are received from a single IP address within a specified time, the service will begin to reject further queries for a period of time to prevent disruption of Whois service access. diff --git a/spec/whois/record/parser/responses/whois.donuts.co/bike/status_available_spec.rb b/spec/whois/record/parser/responses/whois.donuts.co/bike/status_available_spec.rb new file mode 100644 index 000000000..d70f466e4 --- /dev/null +++ b/spec/whois/record/parser/responses/whois.donuts.co/bike/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.donuts.co/bike/status_available.expected +# +# and regenerate the tests with the following rake task +# +# $ rake spec:generate +# + +require 'spec_helper' +require 'whois/record/parser/whois.donuts.co.rb' + +describe Whois::Record::Parser::WhoisDonutsCo, "status_available.expected" do + + subject do + file = fixture("responses", "whois.donuts.co/bike/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/record/parser/responses/whois.donuts.co/bike/status_registered_spec.rb b/spec/whois/record/parser/responses/whois.donuts.co/bike/status_registered_spec.rb new file mode 100644 index 000000000..47c2c05c0 --- /dev/null +++ b/spec/whois/record/parser/responses/whois.donuts.co/bike/status_registered_spec.rb @@ -0,0 +1,168 @@ +# 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.donuts.co/bike/status_registered.expected +# +# and regenerate the tests with the following rake task +# +# $ rake spec:generate +# + +require 'spec_helper' +require 'whois/record/parser/whois.donuts.co.rb' + +describe Whois::Record::Parser::WhoisDonutsCo, "status_registered.expected" do + + subject do + file = fixture("responses", "whois.donuts.co/bike/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("whereismy.bike") + end + end + describe "#domain_id" do + it do + expect(subject.domain_id).to eq("C52CECC9AF044831A7335E8A0ECBC349-D") + 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("2014-02-21 22:55:07 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("2014-02-21 22:55:08 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("2015-02-21 22:55:07 UTC")) + end + end + describe "#registrar" do + it do + expect(subject.registrar).to be_a(Whois::Record::Registrar) + expect(subject.registrar.id).to eq("48") + expect(subject.registrar.name).to eq("Enom, Inc.") + expect(subject.registrar.organization).to eq("Enom, Inc.") + 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).to have(1).items + expect(subject.registrant_contacts[0]).to be_a(Whois::Record::Contact) + expect(subject.registrant_contacts[0].type).to eq(Whois::Record::Contact::TYPE_REGISTRANT) + expect(subject.registrant_contacts[0].id).to eq("8ff85c48fbd456f1") + expect(subject.registrant_contacts[0].name).to eq("whoisguard protected") + expect(subject.registrant_contacts[0].organization).to eq("WhoisGuard, Inc.") + expect(subject.registrant_contacts[0].address).to eq("P.O. Box 0823-03411") + expect(subject.registrant_contacts[0].city).to eq("Panama") + expect(subject.registrant_contacts[0].zip).to eq("00000") + expect(subject.registrant_contacts[0].state).to eq("Panama") + expect(subject.registrant_contacts[0].country).to eq(nil) + expect(subject.registrant_contacts[0].country_code).to eq("PA") + expect(subject.registrant_contacts[0].phone).to eq("+507.8365503") + expect(subject.registrant_contacts[0].fax).to eq("+51.17057182") + expect(subject.registrant_contacts[0].email).to eq("legal@whoisguard.com") + expect(subject.registrant_contacts[0].created_on).to eq(nil) + expect(subject.registrant_contacts[0].updated_on).to eq(nil) + end + end + describe "#admin_contacts" do + it do + expect(subject.admin_contacts).to be_a(Array) + expect(subject.admin_contacts).to have(1).items + expect(subject.admin_contacts[0]).to be_a(Whois::Record::Contact) + expect(subject.admin_contacts[0].type).to eq(Whois::Record::Contact::TYPE_ADMINISTRATIVE) + expect(subject.admin_contacts[0].id).to eq("8ff85c48fbd456f1") + expect(subject.admin_contacts[0].name).to eq("whoisguard protected") + expect(subject.admin_contacts[0].organization).to eq("WhoisGuard, Inc.") + expect(subject.admin_contacts[0].address).to eq("P.O. Box 0823-03411") + expect(subject.admin_contacts[0].city).to eq("Panama") + expect(subject.admin_contacts[0].zip).to eq("00000") + expect(subject.admin_contacts[0].state).to eq("Panama") + expect(subject.admin_contacts[0].country).to eq(nil) + expect(subject.admin_contacts[0].country_code).to eq("PA") + expect(subject.admin_contacts[0].phone).to eq("+507.8365503") + expect(subject.admin_contacts[0].fax).to eq("+51.17057182") + expect(subject.admin_contacts[0].email).to eq("legal@whoisguard.com") + expect(subject.admin_contacts[0].created_on).to eq(nil) + expect(subject.admin_contacts[0].updated_on).to eq(nil) + end + end + describe "#technical_contacts" do + it do + expect(subject.technical_contacts).to be_a(Array) + expect(subject.technical_contacts).to have(1).items + expect(subject.technical_contacts[0]).to be_a(Whois::Record::Contact) + expect(subject.technical_contacts[0].type).to eq(Whois::Record::Contact::TYPE_TECHNICAL) + expect(subject.technical_contacts[0].id).to eq("8ff85c48fbd456f1") + expect(subject.technical_contacts[0].name).to eq("whoisguard protected") + expect(subject.technical_contacts[0].organization).to eq("WhoisGuard, Inc.") + expect(subject.technical_contacts[0].address).to eq("P.O. Box 0823-03411") + expect(subject.technical_contacts[0].city).to eq("Panama") + expect(subject.technical_contacts[0].zip).to eq("00000") + expect(subject.technical_contacts[0].state).to eq("Panama") + expect(subject.technical_contacts[0].country).to eq(nil) + expect(subject.technical_contacts[0].country_code).to eq("PA") + expect(subject.technical_contacts[0].phone).to eq("+507.8365503") + expect(subject.technical_contacts[0].fax).to eq("+51.17057182") + expect(subject.technical_contacts[0].email).to eq("legal@whoisguard.com") + expect(subject.technical_contacts[0].created_on).to eq(nil) + expect(subject.technical_contacts[0].updated_on).to eq(nil) + end + end + describe "#nameservers" do + it do + expect(subject.nameservers).to be_a(Array) + expect(subject.nameservers).to have(5).items + expect(subject.nameservers[0]).to be_a(Whois::Record::Nameserver) + expect(subject.nameservers[0].name).to eq("dns5.registrar-servers.com") + expect(subject.nameservers[0].ipv4).to eq(nil) + expect(subject.nameservers[0].ipv6).to eq(nil) + expect(subject.nameservers[1]).to be_a(Whois::Record::Nameserver) + expect(subject.nameservers[1].name).to eq("dns3.registrar-servers.com") + expect(subject.nameservers[1].ipv4).to eq(nil) + expect(subject.nameservers[1].ipv6).to eq(nil) + expect(subject.nameservers[2]).to be_a(Whois::Record::Nameserver) + expect(subject.nameservers[2].name).to eq("dns2.registrar-servers.com") + expect(subject.nameservers[2].ipv4).to eq(nil) + expect(subject.nameservers[2].ipv6).to eq(nil) + expect(subject.nameservers[3]).to be_a(Whois::Record::Nameserver) + expect(subject.nameservers[3].name).to eq("dns1.registrar-servers.com") + expect(subject.nameservers[3].ipv4).to eq(nil) + expect(subject.nameservers[3].ipv6).to eq(nil) + expect(subject.nameservers[4]).to be_a(Whois::Record::Nameserver) + expect(subject.nameservers[4].name).to eq("dns4.registrar-servers.com") + expect(subject.nameservers[4].ipv4).to eq(nil) + expect(subject.nameservers[4].ipv6).to eq(nil) + end + end +end