diff --git a/lib/whois/parsers/whois.directnic.com.rb b/lib/whois/parsers/whois.directnic.com.rb new file mode 100644 index 00000000..38684203 --- /dev/null +++ b/lib/whois/parsers/whois.directnic.com.rb @@ -0,0 +1,65 @@ +#-- +# 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 WhoisDirectnicCom < BaseIcannCompliant + self.scanner = Scanners::BaseIcannCompliant, { + pattern_available: /^No match for domain/ + } + + 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 + + property_supported :registrar do + return unless node("Registrar") + Parser::Registrar.new( + id: node("Sponsoring Registrar IANA ID"), + name: node("Registrar"), + organization: node("Registrar"), + url: node("Registrar URL") + ) + end + + private + + def build_contact(element, type) + node("#{element} Name") do + Parser::Contact.new( + type: type, + 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.directnic.com/status_available.expected b/spec/fixtures/responses/whois.directnic.com/status_available.expected new file mode 100644 index 00000000..57f95b81 --- /dev/null +++ b/spec/fixtures/responses/whois.directnic.com/status_available.expected @@ -0,0 +1,39 @@ +#domain + %s == nil + +#domain_id + %s == nil + +#status + %s == :available + +#available? + %s == true + +#registered? + %s == false + +#created_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.directnic.com/status_available.txt b/spec/fixtures/responses/whois.directnic.com/status_available.txt new file mode 100644 index 00000000..e7fb6407 --- /dev/null +++ b/spec/fixtures/responses/whois.directnic.com/status_available.txt @@ -0,0 +1,18 @@ + + + +No match for domain "U34JEDZCQ.COM" + +The compilation, repackaging, dissemination, or other use of this WHOIS +data is expressly prohibited without the prior written consent of +DNC Holdings, Inc. + +DNC Holdings reserves the right to terminate your access to its WHOIS +database in its sole discretion, including without limitation, for +excessive querying of the database or for failure to otherwise abide by +this policy. + +DNC Holdings reserves the right to modify these terms at any time. + +NOTE: THE WHOIS DATABASE IS A CONTACT DATABASE ONLY. +LACK OF A DOMAIN RECORD DOES NOT SIGNIFY DOMAIN AVAILABILITY. diff --git a/spec/fixtures/responses/whois.directnic.com/status_registered.expected b/spec/fixtures/responses/whois.directnic.com/status_registered.expected new file mode 100644 index 00000000..87fea3b8 --- /dev/null +++ b/spec/fixtures/responses/whois.directnic.com/status_registered.expected @@ -0,0 +1,85 @@ +#domain + %s == "corehub.net" + +#domain_id + %s == "19525357_DOMAIN_COM-VRSN" + +#status + %s == :registered + +#available? + %s == false + +#registered? + %s == true + +#created_on + %s %CLASS{time} + %s %TIME{2000-02-09 17:22:12 UTC} + +#expires_on + %s %CLASS{time} + %s %TIME{2020-02-09 17:22:12 UTC} + +#registrar + %s %CLASS{registrar} + %s.id == "291" + %s.name == "DNC Holdings, Inc." + %s.organization == "DNC Holdings, Inc." + %s.url == "http://www.directnic.com" + +#registrant_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Parser::Contact::TYPE_REGISTRANT + %s[0].name == "CORE ASSOCIATION" + %s[0].organization == "" + %s[0].address == "" + %s[0].city == "Geneva" + %s[0].zip == "CH-1215" + %s[0].state == "WY" + %s[0].country_code == "US" + %s[0].phone == "+41.229295744" + %s[0].fax == "+41.229295745" + %s[0].email == "directnic.com@domainvault.io" + +#admin_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Parser::Contact::TYPE_ADMINISTRATIVE + %s[0].name == "Direct Privacy" + %s[0].organization == "Savvy Investments, LLC Privacy ID# 472417" + %s[0].address == "2123 Pioneer Ave" + %s[0].city == "Cheyenne" + %s[0].zip == "82001" + %s[0].state == "WY" + %s[0].country_code == "US" + %s[0].phone == "+1.5043215074" + %s[0].fax == "" + %s[0].email == "directnic.com@domainvault.io" + +#technical_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Parser::Contact::TYPE_TECHNICAL + %s[0].name == "Direct Privacy" + %s[0].organization == "Savvy Investments, LLC Privacy ID# 472417" + %s[0].address == "2123 Pioneer Ave" + %s[0].city == "Cheyenne" + %s[0].zip == "82001" + %s[0].state == "WY" + %s[0].country_code == "US" + %s[0].phone == "+1.5043215074" + %s[0].fax == "" + %s[0].email == "directnic.com@domainvault.io" + +#nameservers + %s %CLASS{array} + %s %SIZE{2} + %s[0] %CLASS{nameserver} + %s[0].name == "ns0.directnic.com" + %s[1] %CLASS{nameserver} + %s[1].name == "ns1.directnic.com" diff --git a/spec/fixtures/responses/whois.directnic.com/status_registered.txt b/spec/fixtures/responses/whois.directnic.com/status_registered.txt new file mode 100644 index 00000000..ff51293e --- /dev/null +++ b/spec/fixtures/responses/whois.directnic.com/status_registered.txt @@ -0,0 +1,73 @@ + +Domain Name: DIRECTNIC.COM +Registry Domain ID: 19525357_DOMAIN_COM-VRSN +Registrar WHOIS Server: whois.directnic.com +Registrar URL: http://www.directnic.com +Updated Date: 2016-08-09T12:54:08Z +Creation Date: 2000-02-09T17:22:12Z +Registrar Registration Expiration Date: 2020-02-09T17:22:12Z +Registrar: DNC Holdings, Inc. +Sponsoring Registrar IANA ID: 291 +Registrar Abuse Contact Email: abuse@directnic.com +Registrar Abuse Contact Phone: +1.8778569598 +Domain Status: clientDeleteProhibited (https://www.icann.org/epp#clientDeleteProhibited) +Domain Status: clientTransferProhibited (https://www.icann.org/epp#clientTransferProhibited) +Domain Status: clientUpdateProhibited (https://www.icann.org/epp#clientUpdateProhibited) +Registrant Name: Direct Privacy +Registrant Organization: Savvy Investments, LLC Privacy ID# 472417 +Registrant Street: 2123 Pioneer Ave +Registrant City: Cheyenne +Registrant State/Province: WY +Registrant Postal Code: 82001 +Registrant Country: US +Registrant Phone: +1.5043215074 +Registrant Phone Ext: +Registrant Fax: +Registrant Fax Ext: +Registrant Email: directnic.com@domainvault.io +Admin Name: Direct Privacy +Admin Organization: Savvy Investments, LLC Privacy ID# 472417 +Admin Street: 2123 Pioneer Ave +Admin City: Cheyenne +Admin State/Province: WY +Admin Postal Code: 82001 +Admin Country: US +Admin Phone: +1.5043215074 +Admin Phone Ext: +Admin Fax: +Admin Fax Ext: +Admin Email: directnic.com@domainvault.io +Tech Name: Direct Privacy +Tech Organization: Savvy Investments, LLC Privacy ID# 472417 +Tech Street: 2123 Pioneer Ave +Tech City: Cheyenne +Tech State/Province: WY +Tech Postal Code: 82001 +Tech Country: US +Tech Phone: +1.5043215074 +Tech Phone Ext: +Tech Fax: +Tech Fax Ext: +Tech Email: directnic.com@domainvault.io +Name Server: NS0.DIRECTNIC.COM +Name Server: NS1.DIRECTNIC.COM +URL of the ICANN WHOIS Data Problem Reporting System +http://wdprs.internic.net +>>> Last update of WHOIS database: 2018-05-03T20:26:18Z <<< +For more information on Whois status codes, +please visit https://www.icann.org/resources/pages/epp-status-codes-2014-06-16-en. + + +The compilation, repackaging, dissemination, or other use of this WHOIS +data is expressly prohibited without the prior written consent of +DNC Holdings, Inc. + +DNC Holdings reserves the right to terminate your access to its WHOIS +database in its sole discretion, including without limitation, for +excessive querying of the database or for failure to otherwise abide by +this policy. + +DNC Holdings reserves the right to modify these terms at any time. + +NOTE: THE WHOIS DATABASE IS A CONTACT DATABASE ONLY. +LACK OF A DOMAIN RECORD DOES NOT SIGNIFY DOMAIN AVAILABILITY. diff --git a/spec/whois/parsers/responses/whois.directnic.com/status_available_spec.rb b/spec/whois/parsers/responses/whois.directnic.com/status_available_spec.rb new file mode 100644 index 00000000..6490fb7e --- /dev/null +++ b/spec/whois/parsers/responses/whois.directnic.com/status_available_spec.rb @@ -0,0 +1,88 @@ +# 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.directnic.com/status_available.expected +# +# and regenerate the tests with the following rake task +# +# $ rake spec:generate +# + +require 'spec_helper' +require 'whois/parsers/whois.directnic.com.rb' + +describe Whois::Parsers::WhoisDirectnicCom, "status_available.expected" do + + subject do + file = fixture("responses", "whois.directnic.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 "#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.directnic.com/status_registered_spec.rb b/spec/whois/parsers/responses/whois.directnic.com/status_registered_spec.rb new file mode 100644 index 00000000..1831b3cb --- /dev/null +++ b/spec/whois/parsers/responses/whois.directnic.com/status_registered_spec.rb @@ -0,0 +1,134 @@ +# 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.directnic.com/status_registered.expected +# +# and regenerate the tests with the following rake task +# +# $ rake spec:generate +# + +require 'spec_helper' +require 'whois/parsers/whois.directnic.com.rb' + +describe Whois::Parsers::WhoisDirectnicCom, "status_registered.expected" do + + subject do + file = fixture("responses", "whois.directnic.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("directnic.com") + end + end + describe "#domain_id" do + it do + expect(subject.domain_id).to eq("19525357_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("2000-02-09 17:22:12 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("2020-02-09 17:22:12 UTC")) + end + end + describe "#registrar" do + it do + expect(subject.registrar).to be_a(Whois::Parser::Registrar) + expect(subject.registrar.id).to eq("291") + expect(subject.registrar.name).to eq("DNC Holdings, Inc.") + expect(subject.registrar.organization).to eq("DNC Holdings, Inc.") + expect(subject.registrar.url).to eq("http://www.directnic.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("Direct Privacy") + expect(subject.registrant_contacts[0].organization).to eq("Savvy Investments, LLC Privacy ID# 472417") + expect(subject.registrant_contacts[0].address).to eq("2123 Pioneer Ave") + expect(subject.registrant_contacts[0].city).to eq("Cheyenne") + expect(subject.registrant_contacts[0].zip).to eq("82001") + expect(subject.registrant_contacts[0].state).to eq("WY") + expect(subject.registrant_contacts[0].country_code).to eq("US") + expect(subject.registrant_contacts[0].phone).to eq("+1.5043215074") + expect(subject.registrant_contacts[0].fax).to eq("") + expect(subject.registrant_contacts[0].email).to eq("directnic.com@domainvault.io") + 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("Direct Privacy") + expect(subject.admin_contacts[0].organization).to eq("Savvy Investments, LLC Privacy ID# 472417") + expect(subject.admin_contacts[0].address).to eq("2123 Pioneer Ave") + expect(subject.admin_contacts[0].city).to eq("Cheyenne") + expect(subject.admin_contacts[0].zip).to eq("82001") + expect(subject.admin_contacts[0].state).to eq("WY") + expect(subject.admin_contacts[0].country_code).to eq("US") + expect(subject.admin_contacts[0].phone).to eq("+1.5043215074") + expect(subject.admin_contacts[0].fax).to eq("") + expect(subject.admin_contacts[0].email).to eq("directnic.com@domainvault.io") + 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("Direct Privacy") + expect(subject.technical_contacts[0].organization).to eq("Savvy Investments, LLC Privacy ID# 472417") + expect(subject.technical_contacts[0].address).to eq("2123 Pioneer Ave") + expect(subject.technical_contacts[0].city).to eq("Cheyenne") + expect(subject.technical_contacts[0].zip).to eq("82001") + expect(subject.technical_contacts[0].state).to eq("WY") + expect(subject.technical_contacts[0].country_code).to eq("US") + expect(subject.technical_contacts[0].phone).to eq("+1.5043215074") + expect(subject.technical_contacts[0].fax).to eq("") + expect(subject.technical_contacts[0].email).to eq("directnic.com@domainvault.io") + end + end + describe "#nameservers" do + it do + expect(subject.nameservers).to be_a(Array) + expect(subject.nameservers.size).to eq(2) + expect(subject.nameservers[0]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[0].name).to eq("ns0.directnic.com") + expect(subject.nameservers[1]).to be_a(Whois::Parser::Nameserver) + expect(subject.nameservers[1].name).to eq("ns1.directnic.com") + end + end +end