Skip to content

Commit

Permalink
whois.cat must support multiple statuses.
Browse files Browse the repository at this point in the history
  • Loading branch information
weppos committed Jan 20, 2011
1 parent a507629 commit f3d60f2
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 23 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
* FIXED: The very first time a Whois::Answer method/property question method is invoked,
the corresponding method is called instead of the question one.

* FIXED: whois.cat must support multiple statuses.


== Release 1.6.6

Expand Down
8 changes: 1 addition & 7 deletions lib/whois/answer/parser/whois.cat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,7 @@ class WhoisCat < Base

property_supported :status do
@status ||= if content_for_scanner =~ /Status:\s+(.+?)\n/
case $1.downcase
when "ok" then :registered
else
Whois.bug!(ParserError, "Unknown status `#{$1}'.")
end
else
:available
[*$1.split(", ")]
end
end

Expand Down
83 changes: 83 additions & 0 deletions spec/fixtures/responses/whois.cat/property_status_multiple.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
% puntCAT Whois Server Copyright (C) 2007 Fundacio puntCAT
%
% NOTICE: Access to puntCAT Whois information is provided to assist in
% determining the contents of an object name registration record in the
% puntCAT database. The data in this record is provided by puntCAT for
% informational purposes only, and puntCAT does not guarantee its
% accuracy. This service is intended only for query-based access. You
% agree that you will use this data only for lawful purposes and that,
% under no circumstances will you use this data to: (a) allow, enable,
% or otherwise support the transmission by e-mail, telephone or
% facsimile of unsolicited, commercial advertising or solicitations; or
% (b) enable automated, electronic processes that send queries or data
% to the systems of puntCAT or registry operators, except as reasonably
% necessary to register object names or modify existing registrations.
% All rights reserved. puntCAT reserves the right to modify these terms at
% any time. By submitting this query, you agree to abide by this policy.
%
Domain ID: REG-D42136
Domain Name: abril.cat
Domain Name ACE: abril.cat
Domain Language: ca
Registrar ID: R-2002 (Entorno Digital)
Created On: 2006-04-22 09:48:30 GMT
Last Updated On: 2011-01-12 16:50:09 GMT
Expiration Date: 2011-04-22 09:48:30 GMT
Status: clientTransferProhibited, clientDeleteProhibited
Registrant ID: edig-001455
Registrant Name: Amadeu Abril i Abril
Registrant Organization:
Registrant Street: Carrer del carme 47
Registrant City: Barcelona
Registrant State/Province:
Registrant Postal Code: 08001
Registrant Country: ES
Registrant Phone: +34.932701520
Registrant Phone Ext:
Registrant Fax:
Registrant Fax Ext:
Registrant Email: Amadeu@abril.info
Admin ID: ento0027519
Admin Name: Amadeu Abril i Abril
Admin Organization:
Admin Street: Carrer del Carme 47
Admin City: Barcelona
Admin State/Province: BARCELONA
Admin Postal Code: 08001
Admin Country: ES
Admin Phone: +34.932701520
Admin Phone Ext:
Admin Fax:
Admin Fax Ext:
Admin Email: dominisadmin@mac.com
Tech ID: ento0027519
Tech Name: Amadeu Abril i Abril
Tech Organization:
Tech Street: Carrer del Carme 47
Tech City: Barcelona
Tech State/Province: BARCELONA
Tech Postal Code: 08001
Tech Country: ES
Tech Phone: +34.932701520
Tech Phone Ext:
Tech Fax:
Tech Fax Ext:
Tech Email: dominisadmin@mac.com
Billing ID: ento0027519
Billing Name: Amadeu Abril i Abril
Billing Organization:
Billing Street: Carrer del Carme 47
Billing City: Barcelona
Billing State/Province: BARCELONA
Billing Postal Code: 08001
Billing Country: ES
Billing Phone: +34.932701520
Billing Phone Ext:
Billing Fax:
Billing Fax Ext:
Billing Email: dominisadmin@mac.com
Name Server: ns14.zoneedit.com
Name Server ACE: ns14.zoneedit.com
Name Server: ns12.zoneedit.com
Name Server ACE: ns12.zoneedit.com

18 changes: 18 additions & 0 deletions spec/fixtures/responses/whois.cat/status_available.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
% puntCAT Whois Server Copyright (C) 2007 Fundacio puntCAT
%
% NOTICE: Access to puntCAT Whois information is provided to assist in
% determining the contents of an object name registration record in the
% puntCAT database. The data in this record is provided by puntCAT for
% informational purposes only, and puntCAT does not guarantee its
% accuracy. This service is intended only for query-based access. You
% agree that you will use this data only for lawful purposes and that,
% under no circumstances will you use this data to: (a) allow, enable,
% or otherwise support the transmission by e-mail, telephone or
% facsimile of unsolicited, commercial advertising or solicitations; or
% (b) enable automated, electronic processes that send queries or data
% to the systems of puntCAT or registry operators, except as reasonably
% necessary to register object names or modify existing registrations.
% All rights reserved. puntCAT reserves the right to modify these terms at
% any time. By submitting this query, you agree to abide by this policy.
%
% Object "u34jedzcq.cat" NOT FOUND.
83 changes: 83 additions & 0 deletions spec/fixtures/responses/whois.cat/status_registered.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
% puntCAT Whois Server Copyright (C) 2007 Fundacio puntCAT
%
% NOTICE: Access to puntCAT Whois information is provided to assist in
% determining the contents of an object name registration record in the
% puntCAT database. The data in this record is provided by puntCAT for
% informational purposes only, and puntCAT does not guarantee its
% accuracy. This service is intended only for query-based access. You
% agree that you will use this data only for lawful purposes and that,
% under no circumstances will you use this data to: (a) allow, enable,
% or otherwise support the transmission by e-mail, telephone or
% facsimile of unsolicited, commercial advertising or solicitations; or
% (b) enable automated, electronic processes that send queries or data
% to the systems of puntCAT or registry operators, except as reasonably
% necessary to register object names or modify existing registrations.
% All rights reserved. puntCAT reserves the right to modify these terms at
% any time. By submitting this query, you agree to abide by this policy.
%
Domain ID: REG-D3862
Domain Name: gencat.cat
Domain Name ACE: gencat.cat
Domain Language: ca
Registrar ID: R-2001 (Nominalia)
Created On: 2006-02-14 09:12:37 GMT
Last Updated On: 2009-03-31 16:22:42 GMT
Expiration Date: 2010-02-14 09:12:37 GMT
Status: ok
Registrant ID: NOM_P_15605701
Registrant Name: Generalitat de Catalunya Departament de la Presidencia
Registrant Organization:
Registrant Street: Via Laietana, 14
Registrant City: Barcelona
Registrant State/Province: BARCELONA
Registrant Postal Code: 08003
Registrant Country: ES
Registrant Phone: +34.935676330
Registrant Phone Ext:
Registrant Fax:
Registrant Fax Ext:
Registrant Email: jcolomer@gencat.net
Admin ID: NOM_8727301
Admin Name: Marta Continente Gonzalo
Admin Organization: Generalitat de Catalunya Departament de la Presidencia (2)
Admin Street: Via Laietana, 14
Admin City: Barcelona
Admin State/Province: BARCELONA
Admin Postal Code: 08003
Admin Country: ES
Admin Phone: +34.935676330
Admin Phone Ext:
Admin Fax: +34.935676331
Admin Fax Ext:
Admin Email: dominisgencat@gencat.net
Tech ID: NOM_8727401
Tech Name: Jaume Colomer Garcia
Tech Organization: Generalitat de Catalunya - Departament de la Presidencia
Tech Street: Via Laietana, 14
Tech City: Barcelona
Tech State/Province: BARCELONA
Tech Postal Code: 08003
Tech Country: ES
Tech Phone: +34.935676330
Tech Phone Ext:
Tech Fax: +34.935676331
Tech Fax Ext:
Tech Email: dominisgencat@gencat.net
Billing ID: NOM_8727401
Billing Name: Jaume Colomer Garcia
Billing Organization: Generalitat de Catalunya - Departament de la Presidencia
Billing Street: Via Laietana, 14
Billing City: Barcelona
Billing State/Province: BARCELONA
Billing Postal Code: 08003
Billing Country: ES
Billing Phone: +34.935676330
Billing Phone Ext:
Billing Fax: +34.935676331
Billing Fax Ext:
Billing Email: dominisgencat@gencat.net
Name Server: dns2.gencat.cat 83.247.132.4
Name Server ACE: dns2.gencat.cat 83.247.132.4
Name Server: dns.gencat.net
Name Server ACE: dns.gencat.net

37 changes: 21 additions & 16 deletions test/whois/answer/parser/whois.cat_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,86 +10,91 @@ def setup


def test_status
parser = @klass.new(load_part('registered.txt'))
expected = :registered
parser = @klass.new(load_part('property_status_ok.txt'))
expected = %w( ok )
assert_equal expected, parser.status
assert_equal expected, parser.instance_eval { @status }

parser = @klass.new(load_part('available.txt'))
expected = :available
parser = @klass.new(load_part('property_status_missing.txt'))
expected = nil
assert_equal expected, parser.status
assert_equal expected, parser.instance_eval { @status }

parser = @klass.new(load_part('property_status_multiple.txt'))
expected = %w( clientTransferProhibited clientDeleteProhibited )
assert_equal expected, parser.status
assert_equal expected, parser.instance_eval { @status }
end

def test_available?
parser = @klass.new(load_part('registered.txt'))
parser = @klass.new(load_part('status_registered.txt'))
expected = false
assert_equal expected, parser.available?
assert_equal expected, parser.instance_eval { @available }

parser = @klass.new(load_part('available.txt'))
parser = @klass.new(load_part('status_available.txt'))
expected = true
assert_equal expected, parser.available?
assert_equal expected, parser.instance_eval { @available }
end

def test_registered?
parser = @klass.new(load_part('registered.txt'))
parser = @klass.new(load_part('status_registered.txt'))
expected = true
assert_equal expected, parser.registered?
assert_equal expected, parser.instance_eval { @registered }

parser = @klass.new(load_part('available.txt'))
parser = @klass.new(load_part('status_available.txt'))
expected = false
assert_equal expected, parser.registered?
assert_equal expected, parser.instance_eval { @registered }
end


def test_created_on
parser = @klass.new(load_part('registered.txt'))
parser = @klass.new(load_part('status_registered.txt'))
expected = Time.parse("2006-02-14 09:12:37 GMT")
assert_equal expected, parser.created_on
assert_equal expected, parser.instance_eval { @created_on }

parser = @klass.new(load_part('available.txt'))
parser = @klass.new(load_part('status_available.txt'))
expected = nil
assert_equal expected, parser.created_on
assert_equal expected, parser.instance_eval { @created_on }
end

def test_updated_on
parser = @klass.new(load_part('registered.txt'))
parser = @klass.new(load_part('status_registered.txt'))
expected = Time.parse("2009-03-31 16:22:42 GMT")
assert_equal expected, parser.updated_on
assert_equal expected, parser.instance_eval { @updated_on }

parser = @klass.new(load_part('available.txt'))
parser = @klass.new(load_part('status_available.txt'))
expected = nil
assert_equal expected, parser.updated_on
assert_equal expected, parser.instance_eval { @updated_on }
end

def test_expires_on
parser = @klass.new(load_part('registered.txt'))
parser = @klass.new(load_part('status_registered.txt'))
expected = Time.parse("2010-02-14 09:12:37 GMT")
assert_equal expected, parser.expires_on
assert_equal expected, parser.instance_eval { @expires_on }

parser = @klass.new(load_part('available.txt'))
parser = @klass.new(load_part('status_available.txt'))
expected = nil
assert_equal expected, parser.expires_on
assert_equal expected, parser.instance_eval { @expires_on }
end


def test_nameservers
parser = @klass.new(load_part('registered.txt'))
parser = @klass.new(load_part('status_registered.txt'))
expected = %w( dns2.gencat.cat dns.gencat.net )
assert_equal expected, parser.nameservers
assert_equal expected, parser.instance_eval { @nameservers }

parser = @klass.new(load_part('available.txt'))
parser = @klass.new(load_part('status_available.txt'))
expected = %w()
assert_equal expected, parser.nameservers
assert_equal expected, parser.instance_eval { @nameservers }
Expand Down

0 comments on commit f3d60f2

Please sign in to comment.