From 3fd1deceb75bd7f79f479b8ea327b3f62951e873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lecour?= Date: Thu, 28 Feb 2019 23:27:56 +0100 Subject: [PATCH] Fix Sonic parsing --- app/services/whois/parser/sonic.rb | 3 ++- test/services/whois/parser/sonic_test.rb | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/services/whois/parser/sonic.rb b/app/services/whois/parser/sonic.rb index a33b89b..214dc27 100644 --- a/app/services/whois/parser/sonic.rb +++ b/app/services/whois/parser/sonic.rb @@ -31,7 +31,8 @@ module Whois private def extract_values - domain_index = get_field!("Domain Name", value: domain.upcase).index + + domain_index = get_field!("Domain Name", value: domain.downcase).index created_date = get_value!("Creation Date", after: domain_index) response.created_at = parse_date(created_date) diff --git a/test/services/whois/parser/sonic_test.rb b/test/services/whois/parser/sonic_test.rb index 66a7f42..b3087ee 100644 --- a/test/services/whois/parser/sonic_test.rb +++ b/test/services/whois/parser/sonic_test.rb @@ -14,10 +14,14 @@ module Whois response = parser.parse(whois_output) assert_kind_of Response, response - assert_equal Time.new(2018, 11, 11, 11, 9, 47, 0), response.created_at + assert_equal Time.new(2010, 10, 31, 0, 0, 0, 0), response.created_at assert response.created_at.utc? - assert_equal Time.new(2018, 12, 3, 21, 21, 22, 0), response.updated_at + # We can't use Time.new here + # Sonic times have subseconds and the parsed version + # is different than the generated time (which doesn't have + # subseconds). + assert_equal Time.parse("2018-11-11T11:09:47.823Z"), response.updated_at assert_equal Time.new(2021, 10, 31, 0, 0, 0, 0), response.expire_at end