Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added a parser for whois.networksolution.com. #168

Merged
merged 2 commits into from

2 participants

@bramp

Second attempt at sending over the networksolutions parser.

@weppos
Owner

Thanks! The status_available.txt file is missing the corresponding .expected test.

Also, once you have both .expected files, make sure to generate the tests and run them.

$ rake spec:generate
$ rake

The test suite will run and output any parser error.

@weppos
Owner

Actually, the status_available.expected file is not required since the parser is never invoked on unavailable domains.

You have two choices:

  1. delete the status_available.txt file
  2. implement the support for the status_available response (and provide the .expected file)
@weppos weppos merged commit a7c16c3 into weppos:master
@weppos
Owner

Merged, thank you. I had to apply some changes and generate the tests that haven't been generated.

@weppos weppos referenced this pull request from a commit
@weppos Update fixtures for whois.networksolutions.com (references GH-168).
Make sure the fixture contains the full response, not just a portion.
b236125
@weppos weppos referenced this pull request from a commit
@weppos $ rake spec:generate
and fix broken tests (references GH-168).
f835668
@weppos weppos referenced this pull request from a commit
@weppos Update changelog (references GH-168) b31e132
@weppos weppos was assigned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
153 lib/whois/record/parser/whois.networksolutions.com.rb
@@ -0,0 +1,153 @@
+#--
+# Ruby Whois
+#
+# An intelligent pure Ruby WHOIS client and parser.
+#
+# Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
+#++
+
+
+require 'whois/record/parser/base'
+
+
+module Whois
+ class Record
+ class Parser
+
+ # Parser for the whois.networksolutions.com server.
+ #
+ # @note This parser is just a stub and provides only a few basic methods
+ # to check for domain availability and get domain status.
+ # Please consider to contribute implementing missing methods.
+ #
+ # @see Whois::Record::Parser::Example
+ # The Example parser for the list of all available methods.
+ #
+ # @author Andrew Brampton <me@bramp.net>
+ #
+ class WhoisNetworksolutionsCom < Base
+
+ property_not_supported :status
+
+ # The server is contacted only in case of a registered domain.
+ property_supported :available? do
+ false
+ end
+
+ property_supported :registered? do
+ !available?
+ end
+
+ property_supported :registrar do
+ Record::Registrar.new(
+ :name => 'Network Solutions',
+ :organization => 'Network Solutions, LLC',
+ :url => 'http://www.networksolutions.com/'
+ )
+ end
+
+ property_supported :created_on do
+ if content_for_scanner =~ /Record created on (.+)\.\n/
+ Time.parse($1)
+ end
+ end
+
+ property_supported :updated_on do
+ if content_for_scanner =~ /Database last updated on (.+)\.\n/
+ Time.parse($1)
+ end
+ end
+
+ property_supported :expires_on do
+ if content_for_scanner =~ /Record expires on (.+)\.\n/
+ Time.parse($1)
+ end
+ end
+
+ property_supported :registrant_contacts do
+ build_contact('Registrant:', Record::Contact::TYPE_REGISTRANT)
+ end
+
+ property_supported :admin_contacts do
+ build_contact('Administrative Contact', Record::Contact::TYPE_ADMIN)
+ end
+
+ property_supported :technical_contacts do
+ build_contact('Technical Contact', Record::Contact::TYPE_TECHNICAL)
+ end
+
+
+ property_supported :nameservers do
+ if content_for_scanner =~ /Domain servers in listed order:\n\n((?:[^\n]+\n)+)/
+ $1.split("\n").map do |line|
+ # NS01.XIF.COM 63.240.200.70
+ dns = line.strip.split(" ")
+ Record::Nameserver.new(dns[0].downcase, dns[1])
+ end
+ end
+ end
+
+
+ private
+
+ def build_contact(element, type)
+ match = content_for_scanner.slice(/#{element}.*\n((.+\n){4,7})/, 1)
+ return unless match
+
+ lines = match.split("\n").map(&:strip)
+
+ # 0 XIF Communications | mpowers LLC
+ # 1 1200 New Hampshire Avenue NW | 21010 Southbank St #575
+ # 2 Suite 410 | Potomac Falls, VA 20165
+ # 3 Washington, DC 20036 | US
+ # 4 US
+
+ # 0 Communications, XIF ContactMiddleName noc@xif.com | mpowers LLC michael@mpowers.net
+ # 1 XIF Communications | 21010 Southbank St #575
+ # 2 1200 New Hampshire Avenue NW | Potomac Falls, VA 20165
+ # 3 Suite 410 | US
+ # 4 Washington, DC 20036 | +1.5712832829
+ # 5 US
+ # 6 202-463-7200 fax: 202-318-4003
+
+ # Does the first line end in something that looks like a email address?
+ if lines[0].to_s =~ /\S+@\S+$/
+ # The record has a extra name and number line
+ name, email = lines.shift.scan(/^(.+)\s(\S+@\S+)$/).first
+ name = name.strip
+ end
+
+ # Does the last line contains the word fax, or has >9 digits
+ if lines[-1].to_s =~ / fax: /
+ phone, fax = lines.pop.to_s.scan(/^(.+) fax: (.+)$/).first
+ phone = phone.strip
+ fax = fax.strip
+
+ elsif lines[-1].to_s.gsub(/[^\d]+/, '').length > 9
+ phone = lines.pop
+ end
+
+ country_code = lines.pop
+ city, state, zip = lines.pop.scan(/^(.+), ([A-Z]{2}) ([\sA-Z0-9\-]+)$/).first
+ organization = lines.shift if lines.length >= 2
+
+ address = lines.join("\n")
+
+ Record::Contact.new(
+ :type => type,
+ :name => name,
+ :organization => organization,
+ :address => address,
+ :city => city,
+ :state => state,
+ :zip => zip,
+ :country_code => country_code,
+ :email => email,
+ :phone => phone,
+ :fax => fax
+ )
+ end
+ end
+ end
+ end
+end
View
47 spec/fixtures/responses/whois.networksolutions.com/property_contact_short.expected
@@ -0,0 +1,47 @@
+
+#registrant_contacts
+ should: %s CLASS(array)
+ should: %s SIZE(1)
+ should: %s[0] CLASS(contact)
+ should: %s[0].type == Whois::Record::Contact::TYPE_REGISTRANT
+ should: %s[0].organization == "mpowers LLC"
+ should: %s[0].address == "21010 Southbank St #575"
+ should: %s[0].city == "Potomac Falls"
+ should: %s[0].zip == "20165"
+ should: %s[0].state == "VA"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == nil
+ should: %s[0].fax == nil
+ should: %s[0].email == nil
+
+#admin_contacts
+ should: %s CLASS(array)
+ should: %s SIZE(1)
+ should: %s[0] CLASS(contact)
+ should: %s[0].type == Whois::Record::Contact::TYPE_ADMIN
+ should: %s[0].name == "mpowers LLC"
+ should: %s[0].organization == nil
+ should: %s[0].address == "21010 Southbank St #575"
+ should: %s[0].city == "Potomac Falls"
+ should: %s[0].zip == "20165"
+ should: %s[0].state == "VA"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == "+1.5712832829"
+ should: %s[0].fax == nil
+ should: %s[0].email == "michael@mpowers.net"
+
+#technical_contacts
+ should: %s CLASS(array)
+ should: %s SIZE(1)
+ should: %s[0] CLASS(contact)
+ should: %s[0].type == Whois::Record::Contact::TYPE_TECHNICAL
+ should: %s[0].name == "mpowers LLC"
+ should: %s[0].organization == nil
+ should: %s[0].address == "21010 Southbank St #575"
+ should: %s[0].city == "Potomac Falls"
+ should: %s[0].zip == "20165"
+ should: %s[0].state == "VA"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == "+1.5712832829"
+ should: %s[0].fax == nil
+ should: %s[0].email == "michael@mpowers.net"
View
21 spec/fixtures/responses/whois.networksolutions.com/property_contact_short.txt
@@ -0,0 +1,21 @@
+
+Registrant:
+mpowers LLC
+ 21010 Southbank St #575
+ Potomac Falls, VA 20165
+ US
+
+ Domain Name: APPTAP.COM
+
+ ------------------------------------------------------------------------
+ Promote your business to millions of viewers for only $1 a month
+ Learn how you can get an Enhanced Business Listing here for your domain name.
+ Learn more at http://www.NetworkSolutions.com/
+ ------------------------------------------------------------------------
+
+ Administrative Contact, Technical Contact:
+ mpowers LLC michael@mpowers.net
+ 21010 Southbank St #575
+ Potomac Falls, VA 20165
+ US
+ +1.5712832829
View
25 spec/fixtures/responses/whois.networksolutions.com/status_available.txt
@@ -0,0 +1,25 @@
+NOTICE AND TERMS OF USE: You are not authorized to access or query our WHOIS
+database through the use of high-volume, automated, electronic processes. The
+Data in Network Solutions' WHOIS database is provided by Network Solutions for information
+purposes only, and to assist persons in obtaining information about or related
+to a domain name registration record. Network Solutions 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 Network Solutions (or its computer systems). The
+compilation, repackaging, dissemination or other use of this Data is expressly
+prohibited without the prior written consent of Network Solutions. You agree not to use
+high-volume, automated, electronic processes to access or query the WHOIS
+database. Network Solutions reserves the right to terminate your access to the WHOIS
+database in its sole discretion, including without limitation, for excessive
+querying of the WHOIS database or for failure to otherwise abide by this policy.
+Network Solutions reserves the right to modify these terms at any time.
+
+Get a FREE domain name registration, transfer, or renewal with any annual hosting package.
+
+http://www.networksolutions.com
+
+No match for "BLAHBLAHBLAH.COM".
+
View
90 spec/fixtures/responses/whois.networksolutions.com/status_registered.expected
@@ -0,0 +1,90 @@
+#status
+ should: %s raise_error(Whois::PropertyNotSupported)
+
+#available?
+ should: %s == false
+
+#registered?
+ should: %s == true
+
+
+#created_on
+ should: %s CLASS(time)
+ should: %s == Time.parse("1997-06-10")
+
+#updated_on
+ should: %s CLASS(time)
+ should: %s == Time.parse("2012-05-27 22:19:52 EDT")
+
+#expires_on
+ should: %s CLASS(time)
+ should: %s == Time.parse("2014-06-09")
+
+
+#registrar
+ should: %s CLASS(registrar)
+ should: %s.name == 'Network Solutions'
+ should: %s.organization == 'Network Solutions, LLC'
+ should: %s.url == 'http://www.networksolutions.com/'
+
+
+#registrant_contacts
+ should: %s CLASS(array)
+ should: %s SIZE(1)
+ should: %s[0] CLASS(contact)
+ should: %s[0].type == Whois::Record::Contact::TYPE_REGISTRANT
+ should: %s[0].name == nil
+ should: %s[0].organization == "XIF Communications"
+ should: %s[0].address == "1200 New Hampshire Avenue NW\nSuite 410"
+ should: %s[0].city == "Washington"
+ should: %s[0].zip == "20036"
+ should: %s[0].state == "DC"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == nil
+ should: %s[0].fax == nil
+ should: %s[0].email == nil
+
+#admin_contacts
+ should: %s CLASS(array)
+ should: %s SIZE(1)
+ should: %s[0] CLASS(contact)
+ should: %s[0].type == Whois::Record::Contact::TYPE_ADMIN
+ should: %s[0].name == "Communications, XIF ContactMiddleName"
+ should: %s[0].organization == "XIF Communications"
+ should: %s[0].address == "1200 New Hampshire Avenue NW\nSuite 410"
+ should: %s[0].city == "Washington"
+ should: %s[0].zip == "20036"
+ should: %s[0].state == "DC"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == "202-463-7200"
+ should: %s[0].fax == "202-318-4003"
+ should: %s[0].email == "noc@xif.com"
+
+#technical_contacts
+ should: %s CLASS(array)
+ should: %s SIZE(1)
+ should: %s[0] CLASS(contact)
+ should: %s[0].type == Whois::Record::Contact::TYPE_TECHNICAL
+ should: %s[0].name == "Communications, XIF ContactMiddleName"
+ should: %s[0].organization == "XIF Communications"
+ should: %s[0].address == "1200 New Hampshire Avenue NW\nSuite 410"
+ should: %s[0].city == "Washington"
+ should: %s[0].zip == "20036"
+ should: %s[0].state == "DC"
+ should: %s[0].country_code == "US"
+ should: %s[0].phone == "202-463-7200"
+ should: %s[0].fax == "202-318-4003"
+ should: %s[0].email == "noc@xif.com"
+
+#nameservers
+ should: %s CLASS(array)
+ should: %s SIZE(3)
+ should: %s[0] CLASS(nameserver)
+ should: %s[0].name == "ns01.xif.com"
+ should: %s[0].ipv4 == "63.240.200.70"
+ should: %s[1] CLASS(nameserver)
+ should: %s[1].name == "ns-east.cerf.net"
+ should: %s[1].ipv4 == "207.252.96.3"
+ should: %s[2] CLASS(nameserver)
+ should: %s[2].name == "ns-west.cerf.net"
+ should: %s[2].ipv4 == "192.153.156.3"
View
66 spec/fixtures/responses/whois.networksolutions.com/status_registered.txt
@@ -0,0 +1,66 @@
+NOTICE AND TERMS OF USE: You are not authorized to access or query our WHOIS
+database through the use of high-volume, automated, electronic processes. The
+Data in Network Solutions' WHOIS database is provided by Network Solutions for information
+purposes only, and to assist persons in obtaining information about or related
+to a domain name registration record. Network Solutions 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 Network Solutions (or its computer systems). The
+compilation, repackaging, dissemination or other use of this Data is expressly
+prohibited without the prior written consent of Network Solutions. You agree not to use
+high-volume, automated, electronic processes to access or query the WHOIS
+database. Network Solutions reserves the right to terminate your access to the WHOIS
+database in its sole discretion, including without limitation, for excessive
+querying of the WHOIS database or for failure to otherwise abide by this policy.
+Network Solutions reserves the right to modify these terms at any time.
+
+Get a FREE domain name registration, transfer, or renewal with any annual hosting package.
+
+http://www.networksolutions.com
+
+Visit AboutUs.org for more information about XIF.COM
+<a href="http://www.aboutus.org/XIF.COM">AboutUs: XIF.COM </a>
+
+
+
+
+Registrant:
+XIF Communications
+ 1200 New Hampshire Avenue NW
+ Suite 410
+ Washington, DC 20036
+ US
+
+ Domain Name: XIF.COM
+
+ ------------------------------------------------------------------------
+ Promote your business to millions of viewers for only $1 a month
+ Learn how you can get an Enhanced Business Listing here for your domain name.
+ Learn more at http://www.NetworkSolutions.com/
+ ------------------------------------------------------------------------
+
+ Administrative Contact, Technical Contact:
+ Communications, XIF ContactMiddleName noc@xif.com
+ XIF Communications
+ 1200 New Hampshire Avenue NW
+ Suite 410
+ Washington, DC 20036
+ US
+ 202-463-7200 fax: 202-318-4003
+
+
+ Record expires on 09-Jun-2014.
+ Record created on 10-Jun-1997.
+ Database last updated on 27-May-2012 22:19:52 EDT.
+
+ Domain servers in listed order:
+
+ NS01.XIF.COM 63.240.200.70
+ NS-EAST.CERF.NET 207.252.96.3
+ NS-WEST.CERF.NET 192.153.156.3
+
+
+
Something went wrong with that request. Please try again.