From febbd29ac1e7853cfa0e8991cc5769b841038a25 Mon Sep 17 00:00:00 2001 From: Simone Carletti Date: Wed, 26 Feb 2014 13:44:02 +0100 Subject: [PATCH] whois.ati.tn crashes when contact update is "None" --- CHANGELOG.md | 2 ++ lib/whois/record/parser/whois.ati.tn.rb | 17 +++++---- .../property_contact_updated_none.expected | 8 +++++ .../property_contact_updated_none.txt | 34 ++++++++++++++++++ .../property_contact_updated_none_spec.rb | 35 +++++++++++++++++++ 5 files changed, 87 insertions(+), 9 deletions(-) create mode 100644 spec/fixtures/responses/whois.ati.tn/property_contact_updated_none.expected create mode 100644 spec/fixtures/responses/whois.ati.tn/property_contact_updated_none.txt create mode 100644 spec/whois/record/parser/responses/whois.ati.tn/property_contact_updated_none_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index d0970837e..1d8574243 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ - FIXED: whois.nic.cx crashes when update date is empty. +- FIXED: whois.ati.tn crashes when contact update is "None". + - CHANGED: Updated whois.nic.ec parser to the new response format. - CHANGED: Updated whois.pandi.or.id parser to the new response format. diff --git a/lib/whois/record/parser/whois.ati.tn.rb b/lib/whois/record/parser/whois.ati.tn.rb index 34fd00af9..2e06ce1d3 100644 --- a/lib/whois/record/parser/whois.ati.tn.rb +++ b/lib/whois/record/parser/whois.ati.tn.rb @@ -99,15 +99,14 @@ class WhoisAtiTn < Base def build_contact(element, type) node("#{element} Name") do Record::Contact.new( - :type => type, - :id => nil, - :name => node("#{element} Name"), - :address => node("#{element} Address"), - :phone => node("#{element} Tel"), - :fax => node("#{element} Fax"), - :email => node("#{element} Email"), - :created_on => node("#{element} Created") { |value| Time.parse(value) }, - :updated_on => node("#{element} Updated") { |value| Time.parse(value) } + type: type, + name: node("#{element} Name"), + address: node("#{element} Address"), + phone: node("#{element} Tel"), + fax: node("#{element} Fax"), + email: node("#{element} Email"), + created_on: node("#{element} Created") { |value| Time.parse(value) }, + updated_on: node("#{element} Updated") { |value| Time.parse(value) if value != "None" } ) end end diff --git a/spec/fixtures/responses/whois.ati.tn/property_contact_updated_none.expected b/spec/fixtures/responses/whois.ati.tn/property_contact_updated_none.expected new file mode 100644 index 000000000..c40278c86 --- /dev/null +++ b/spec/fixtures/responses/whois.ati.tn/property_contact_updated_none.expected @@ -0,0 +1,8 @@ +#registrant_contacts + %s %CLASS{array} + %s %SIZE{1} + %s[0] %CLASS{contact} + %s[0].type == Whois::Record::Contact::TYPE_REGISTRANT + %s[0].name == "MAISON DE BIEN HOTELIERS ET EQ Farhat Riadh" + %s[0].created_on %TIME{2013-12-13 20:00:57} + %s[0].updated_on == nil diff --git a/spec/fixtures/responses/whois.ati.tn/property_contact_updated_none.txt b/spec/fixtures/responses/whois.ati.tn/property_contact_updated_none.txt new file mode 100644 index 000000000..3a118eed0 --- /dev/null +++ b/spec/fixtures/responses/whois.ati.tn/property_contact_updated_none.txt @@ -0,0 +1,34 @@ +All rights reserved. +Copyright "Tunisian Internet Agency - http://whois.tn" + +Domain : equipements-pro.com.tn +Acivated : 2013-12-13 22:15:08 +Registrar : I-HOSTERS + +NameServers : ns.steerbook.com. [91.121.103.174] +NameServers : dns.steerbook.com. [46.105.59.229] + +Owner Name : MAISON DE BIEN HOTELIERS ET EQ Farhat Riadh +Owner Address : complexe commercial Boukris 2 rue Om Larayes +Owner Tel : 98639096 +Owner Fax : +Owner Email : mbh@tunet.tn +Owner Created : 2013-12-13 20:00:57 +Owner Updated : None + +Admin. Name : MAISON DE BIEN HOTELIERS ET EQ Farhat Riadh +Admin. Address : complexe commercial Boukris 2 rue Om Larayes +Admin. Tel : 98639096 +Admin. Fax : +Admin. Email : mbh@tunet.tn +Admin. Created : 2013-12-13 20:00:57 +Admin. Updated : None + +Tech. Name : MAISON DE BIEN HOTELIERS ET EQ Farhat Riadh +Tech. Address : complexe commercial Boukris 2 rue Om Larayes +Tech. Tel : 98639096 +Tech. Fax : +Tech. Email : mbh@tunet.tn +Tech. Created : 2013-12-13 20:00:57 +Tech. Updated : None + diff --git a/spec/whois/record/parser/responses/whois.ati.tn/property_contact_updated_none_spec.rb b/spec/whois/record/parser/responses/whois.ati.tn/property_contact_updated_none_spec.rb new file mode 100644 index 000000000..a68beb9e4 --- /dev/null +++ b/spec/whois/record/parser/responses/whois.ati.tn/property_contact_updated_none_spec.rb @@ -0,0 +1,35 @@ +# 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.ati.tn/property_contact_updated_none.expected +# +# and regenerate the tests with the following rake task +# +# $ rake spec:generate +# + +require 'spec_helper' +require 'whois/record/parser/whois.ati.tn.rb' + +describe Whois::Record::Parser::WhoisAtiTn, "property_contact_updated_none.expected" do + + subject do + file = fixture("responses", "whois.ati.tn/property_contact_updated_none.txt") + part = Whois::Record::Part.new(body: File.read(file)) + described_class.new(part) + 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].name).to eq("MAISON DE BIEN HOTELIERS ET EQ Farhat Riadh") + expect(subject.registrant_contacts[0].created_on).to eq(Time.parse("2013-12-13 20:00:57")) + expect(subject.registrant_contacts[0].updated_on).to eq(nil) + end + end +end