21
1
Fork 0
mirror of https://github.com/Evolix/chexpire.git synced 2024-05-04 01:35:10 +02:00
chexpire/test/services/whois/parser/afnic_test.rb

41 lines
1.4 KiB
Ruby
Raw Normal View History

# Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr>
# License: GNU AGPL-3+ (see full text in LICENSE file)
2018-05-30 12:04:07 +02:00
require "test_helper"
module Whois
2018-06-05 16:42:04 +02:00
class AFNICTest < ActiveSupport::TestCase
2018-05-30 12:04:07 +02:00
test "should parse a whois response" do
2019-03-03 11:03:04 +01:00
parser = Whois::Parser::AFNIC.new("domain.fr")
2018-05-30 18:15:20 +02:00
domain_fr = file_fixture("whois/domain.fr.txt").read
response = parser.parse(domain_fr)
2019-03-03 11:03:04 +01:00
assert_kind_of Whois::Response, response
2018-05-30 12:04:07 +02:00
2018-05-30 16:48:25 +02:00
assert_equal Time.new(2004, 2, 18, 0, 0, 0, 0), response.created_at
assert response.created_at.utc?
assert_equal Time.new(2017, 1, 28, 0, 0, 0, 0), response.updated_at
assert_equal Time.new(2019, 2, 17, 0, 0, 0, 0), response.expire_at
2018-05-30 12:04:07 +02:00
end
2018-05-30 18:15:20 +02:00
test "should raises DomainNotFoundError when domain is not registered" do
2019-03-03 11:03:04 +01:00
parser = Whois::Parser::AFNIC.new("willneverexist.fr")
2018-05-30 18:15:20 +02:00
not_found_fr = file_fixture("whois/willneverexist.fr.txt").read
assert_raises DomainNotFoundError do
parser.parse(not_found_fr)
end
end
2018-06-05 16:39:08 +02:00
test "should raises InvalidDateError when a date is not in the expected format" do
2019-03-03 11:03:04 +01:00
parser = Whois::Parser::AFNIC.new("domain.fr")
2018-06-05 16:39:08 +02:00
domain_fr = file_fixture("whois/domain.fr.txt").read
domain_fr.gsub!("17/02/2019", "17-02-2019")
assert_raises InvalidDateError do
parser.parse(domain_fr)
end
end
2018-05-30 12:04:07 +02:00
end
end