Fix Sonic parsing

This commit is contained in:
Jérémy Lecour 2019-02-28 23:27:56 +01:00
parent e5979c4b2b
commit 3fd1deceb7
2 changed files with 8 additions and 3 deletions

View File

@ -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)

View File

@ -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