mirror of
https://github.com/Evolix/chexpire.git
synced 2024-04-29 15:30:49 +02:00
Add Sonic registry for .so TLD
This commit is contained in:
parent
734a957edc
commit
e5979c4b2b
|
@ -7,6 +7,7 @@ require "whois/parser/afilias"
|
|||
require "whois/parser/afnic"
|
||||
require "whois/parser/cira"
|
||||
require "whois/parser/neustar"
|
||||
require "whois/parser/sonic"
|
||||
require "whois/parser/verisign"
|
||||
|
||||
module Whois
|
||||
|
@ -16,6 +17,7 @@ module Whois
|
|||
AFNIC,
|
||||
CIRA,
|
||||
Neustar,
|
||||
Sonic,
|
||||
Verisign,
|
||||
].freeze
|
||||
|
||||
|
|
47
app/services/whois/parser/sonic.rb
Normal file
47
app/services/whois/parser/sonic.rb
Normal file
|
@ -0,0 +1,47 @@
|
|||
# Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr>
|
||||
# License: GNU AGPL-3+ (see full text in LICENSE file)
|
||||
|
||||
require "domain_helper"
|
||||
require "whois/errors"
|
||||
require_relative "base"
|
||||
|
||||
module Whois
|
||||
module Parser
|
||||
class Sonic < Base
|
||||
# https://sonic.so
|
||||
SUPPORTED_TLD = %w[
|
||||
.so
|
||||
].freeze
|
||||
|
||||
COMMENT_REGEX = /^(%|>)+ +(?<text>.+)$/
|
||||
FIELD_REGEX = /^(?<name>[^:]+)\s*:\s+(?<value>.+)$/
|
||||
|
||||
def self.supports?(domain)
|
||||
SUPPORTED_TLD.include?(tld(domain))
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def do_parse
|
||||
raise_not_found if get_field("Domain Status", value: "No Object Found")
|
||||
|
||||
extract_values
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def extract_values
|
||||
domain_index = get_field!("Domain Name", value: domain.upcase).index
|
||||
|
||||
created_date = get_value!("Creation Date", after: domain_index)
|
||||
response.created_at = parse_date(created_date)
|
||||
|
||||
expire_date = get_value!("Registry Expiry Date", after: domain_index)
|
||||
response.expire_at = parse_date(expire_date)
|
||||
|
||||
updated_date = get_value!("Updated Date", after: domain_index)
|
||||
response.updated_at = parse_date(updated_date)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
90
test/fixtures/files/whois/domain.so.txt
vendored
Normal file
90
test/fixtures/files/whois/domain.so.txt
vendored
Normal file
|
@ -0,0 +1,90 @@
|
|||
% IANA WHOIS server
|
||||
% for more information on IANA, visit http://www.iana.org
|
||||
% This query returned 1 object
|
||||
|
||||
refer: whois.nic.so
|
||||
|
||||
domain: SO
|
||||
|
||||
organisation: Ministry of Post and Telecommunications
|
||||
address: Mogadishu
|
||||
address: Somalia
|
||||
|
||||
contact: administrative
|
||||
name: Administrator
|
||||
organisation: Ministry of Post and Telecommunications
|
||||
address: Mogadishu
|
||||
address: Somalia
|
||||
phone: +252 1 587 1200
|
||||
fax-no: +252 1 231 599
|
||||
e-mail: admin@mipt.gov.so
|
||||
|
||||
contact: technical
|
||||
name: Tech Manager
|
||||
organisation: soNIC
|
||||
address: Via Republic
|
||||
address: Mogadishu Benadir 1000
|
||||
address: Somalia
|
||||
phone: +252 61 8250888
|
||||
fax-no: +252 61 8250991
|
||||
e-mail: admin@sonic.gov.so
|
||||
|
||||
nserver: D.NIC.SO 196.216.168.54 2001:43f8:120:0:0:0:0:54
|
||||
nserver: E.NIC.SO 2001:500:14:6101:ad:0:0:1 204.61.216.101
|
||||
|
||||
whois: whois.nic.so
|
||||
|
||||
status: ACTIVE
|
||||
remarks: Registration information: http://www.nic.so/
|
||||
|
||||
created: 1997-08-28
|
||||
changed: 2016-04-18
|
||||
source: IANA
|
||||
|
||||
Domain Name: domain.so
|
||||
Domain ID: 35445-sonic
|
||||
WHOIS Server: whois.nic.so
|
||||
Updated Date: 2018-11-11T11:09:47.823Z
|
||||
Creation Date: 2010-10-31T00:00:00.0Z
|
||||
Registry Expiry Date: 2021-10-31T00:00:00.0Z
|
||||
Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited
|
||||
Domain Status: inactive https://icann.org/epp#inactive
|
||||
Registrar: SONIC
|
||||
Registrar Abuse Phone: +252.618250888
|
||||
Registrar Abuse Email: admin@sonic.gov.so
|
||||
Registrant ID: 53306-sonic
|
||||
Registrant Name: SONIC
|
||||
Registrant Organization: 0
|
||||
Registrant Street: Via Republic
|
||||
Registrant City: Mogadishu
|
||||
Registrant State/Province: Benadir
|
||||
Registrant Postal Code: 1000
|
||||
Registrant Country: SO
|
||||
Registrant Phone: +252.618250888
|
||||
Registrant Fax: +252.618250991
|
||||
Registrant Email: admin@sonic.gov.so
|
||||
Admin ID: 53306-sonic
|
||||
Admin Name: SONIC
|
||||
Admin Organization: 0
|
||||
Admin Street: Via Republic
|
||||
Admin City: Mogadishu
|
||||
Admin State/Province: Benadir
|
||||
Admin Postal Code: 1000
|
||||
Admin Country: SO
|
||||
Admin Phone: +252.618250888
|
||||
Admin Fax: +252.618250991
|
||||
Admin Email: admin@sonic.gov.so
|
||||
Tech ID: 53306-sonic
|
||||
Tech Name: SONIC
|
||||
Tech Organization: 0
|
||||
Tech Street: Via Republic
|
||||
Tech City: Mogadishu
|
||||
Tech State/Province: Benadir
|
||||
Tech Postal Code: 1000
|
||||
Tech Country: SO
|
||||
Tech Phone: +252.618250888
|
||||
Tech Fax: +252.618250991
|
||||
Tech Email: admin@sonic.gov.so
|
||||
DNSSEC: unsigned
|
||||
>>> Last update of WHOIS database: 2019-02-28T21:14:58.920Z <<<
|
||||
|
47
test/fixtures/files/whois/willneverexist.so.txt
vendored
Normal file
47
test/fixtures/files/whois/willneverexist.so.txt
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
% IANA WHOIS server
|
||||
% for more information on IANA, visit http://www.iana.org
|
||||
% This query returned 1 object
|
||||
|
||||
refer: whois.nic.so
|
||||
|
||||
domain: SO
|
||||
|
||||
organisation: Ministry of Post and Telecommunications
|
||||
address: Mogadishu
|
||||
address: Somalia
|
||||
|
||||
contact: administrative
|
||||
name: Administrator
|
||||
organisation: Ministry of Post and Telecommunications
|
||||
address: Mogadishu
|
||||
address: Somalia
|
||||
phone: +252 1 587 1200
|
||||
fax-no: +252 1 231 599
|
||||
e-mail: admin@mipt.gov.so
|
||||
|
||||
contact: technical
|
||||
name: Tech Manager
|
||||
organisation: soNIC
|
||||
address: Via Republic
|
||||
address: Mogadishu Benadir 1000
|
||||
address: Somalia
|
||||
phone: +252 61 8250888
|
||||
fax-no: +252 61 8250991
|
||||
e-mail: admin@sonic.gov.so
|
||||
|
||||
nserver: D.NIC.SO 196.216.168.54 2001:43f8:120:0:0:0:0:54
|
||||
nserver: E.NIC.SO 2001:500:14:6101:ad:0:0:1 204.61.216.101
|
||||
|
||||
whois: whois.nic.so
|
||||
|
||||
status: ACTIVE
|
||||
remarks: Registration information: http://www.nic.so/
|
||||
|
||||
created: 1997-08-28
|
||||
changed: 2016-04-18
|
||||
source: IANA
|
||||
|
||||
Domain Name: willneverexist.so
|
||||
Domain Status: No Object Found
|
||||
>>> Last update of WHOIS database: 2019-02-28T21:14:58.920Z <<<
|
||||
|
43
test/services/whois/parser/sonic_test.rb
Normal file
43
test/services/whois/parser/sonic_test.rb
Normal file
|
@ -0,0 +1,43 @@
|
|||
# Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr>
|
||||
# License: GNU AGPL-3+ (see full text in LICENSE file)
|
||||
|
||||
require "test_helper"
|
||||
require "whois/parser/sonic"
|
||||
require "whois/response"
|
||||
require "whois/errors"
|
||||
|
||||
module Whois
|
||||
class SonicTest < ActiveSupport::TestCase
|
||||
test "should parse a whois response for .so" do
|
||||
parser = Parser::Sonic.new("domain.so")
|
||||
whois_output = file_fixture("whois/domain.so.txt").read
|
||||
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 response.created_at.utc?
|
||||
|
||||
assert_equal Time.new(2018, 12, 3, 21, 21, 22, 0), response.updated_at
|
||||
assert_equal Time.new(2021, 10, 31, 0, 0, 0, 0), response.expire_at
|
||||
end
|
||||
|
||||
test "should raises DomainNotFoundError for .so when domain is not registered" do
|
||||
parser = Parser::Sonic.new("willneverexist.so")
|
||||
not_found = file_fixture("whois/willneverexist.so.txt").read
|
||||
|
||||
assert_raises DomainNotFoundError do
|
||||
parser.parse(not_found)
|
||||
end
|
||||
end
|
||||
|
||||
test "should raises InvalidDateError for .so when a date is not parsable" do
|
||||
parser = Parser::Sonic.new("domain.so")
|
||||
whois_output = file_fixture("whois/domain.so.txt").read
|
||||
whois_output.gsub!("2010-10-31T00:00:00.0Z", "not a date")
|
||||
|
||||
assert_raises InvalidDateError do
|
||||
parser.parse(whois_output)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue