mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 06:34:46 +02:00
Merge pull request #1076 from internetee/improve-epp-domain-info
Handle blocked and reserved domains in EPP domain:info
This commit is contained in:
commit
35957d2d84
6 changed files with 122 additions and 45 deletions
|
@ -4,43 +4,53 @@ class Epp::DomainsController < EppController
|
||||||
skip_authorization_check only: :info
|
skip_authorization_check only: :info
|
||||||
|
|
||||||
def info
|
def info
|
||||||
if Domain.release_to_auction
|
domain_name = DNS::DomainName.new(params[:parsed_frame].at_css('name').text.strip.downcase)
|
||||||
domain_name = DNS::DomainName.new(params[:parsed_frame].at_css('name').text.strip.downcase)
|
|
||||||
|
|
||||||
|
if Domain.release_to_auction
|
||||||
if domain_name.at_auction?
|
if domain_name.at_auction?
|
||||||
@name = domain_name
|
@name = domain_name
|
||||||
@status = 'At auction'
|
@status = 'At auction'
|
||||||
render_epp_response '/epp/domains/info_auction'
|
render_epp_response '/epp/domains/info/unregistered_domain'
|
||||||
return
|
return
|
||||||
elsif domain_name.awaiting_payment?
|
elsif domain_name.awaiting_payment?
|
||||||
@name = domain_name
|
@name = domain_name
|
||||||
@status = 'Awaiting payment'
|
@status = 'Awaiting payment'
|
||||||
render_epp_response '/epp/domains/info_auction'
|
render_epp_response '/epp/domains/info/unregistered_domain'
|
||||||
return
|
return
|
||||||
elsif domain_name.pending_registration?
|
elsif domain_name.pending_registration?
|
||||||
@name = domain_name
|
@name = domain_name
|
||||||
@status = 'Reserved'
|
@status = 'Reserved'
|
||||||
render_epp_response '/epp/domains/info_auction'
|
render_epp_response '/epp/domains/info/unregistered_domain'
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
find_domain
|
if domain_name.registered?
|
||||||
find_password
|
find_domain
|
||||||
authorize! :info, @domain, @password
|
find_password
|
||||||
|
authorize! :info, @domain, @password
|
||||||
|
|
||||||
@hosts = params[:parsed_frame].css('name').first['hosts'] || 'all'
|
@hosts = params[:parsed_frame].css('name').first['hosts'] || 'all'
|
||||||
|
|
||||||
case @hosts
|
case @hosts
|
||||||
when 'del'
|
when 'del'
|
||||||
@nameservers = @domain.delegated_nameservers.sort
|
@nameservers = @domain.delegated_nameservers.sort
|
||||||
when 'sub'
|
when 'sub'
|
||||||
@nameservers = @domain.subordinate_nameservers.sort
|
@nameservers = @domain.subordinate_nameservers.sort
|
||||||
when 'all'
|
when 'all'
|
||||||
@nameservers = @domain.nameservers.sort
|
@nameservers = @domain.nameservers.sort
|
||||||
|
end
|
||||||
|
|
||||||
|
render_epp_response '/epp/domains/info/registered_domain'
|
||||||
|
elsif domain_name.blocked?
|
||||||
|
@name = domain_name
|
||||||
|
@status = 'Blocked'
|
||||||
|
render_epp_response '/epp/domains/info/unregistered_domain'
|
||||||
|
elsif domain_name.reserved?
|
||||||
|
@name = domain_name
|
||||||
|
@status = 'Reserved'
|
||||||
|
render_epp_response '/epp/domains/info/unregistered_domain'
|
||||||
end
|
end
|
||||||
|
|
||||||
render_epp_response '/epp/domains/info'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|
|
@ -53,14 +53,6 @@ module DNS
|
||||||
Whois::Record.refresh(self)
|
Whois::Record.refresh(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
|
||||||
name
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
attr_reader :name
|
|
||||||
|
|
||||||
def registered?
|
def registered?
|
||||||
Domain.find_by_idn(name)
|
Domain.find_by_idn(name)
|
||||||
end
|
end
|
||||||
|
@ -69,6 +61,18 @@ module DNS
|
||||||
BlockedDomain.where(name: name).any?
|
BlockedDomain.where(name: name).any?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reserved?
|
||||||
|
ReservedDomain.where(name: name).any?
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
name
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
attr_reader :name
|
||||||
|
|
||||||
def zone_with_same_origin?
|
def zone_with_same_origin?
|
||||||
DNS::Zone.where(origin: name).any?
|
DNS::Zone.where(origin: name).any?
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ xml.epp_head do
|
||||||
end
|
end
|
||||||
|
|
||||||
xml.resData do
|
xml.resData do
|
||||||
xml.tag!('domain:infData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd') do
|
xml.tag! 'domain:infData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd' do
|
||||||
xml.tag!('domain:name', @domain.name)
|
xml.tag!('domain:name', @domain.name)
|
||||||
xml.tag!('domain:roid', @domain.roid)
|
xml.tag!('domain:roid', @domain.roid)
|
||||||
@domain.statuses.each do |s|
|
@domain.statuses.each do |s|
|
||||||
|
@ -27,32 +27,32 @@ xml.epp_head do
|
||||||
@nameservers.each do |x|
|
@nameservers.each do |x|
|
||||||
xml.tag!('domain:hostAttr') do
|
xml.tag!('domain:hostAttr') do
|
||||||
xml.tag!('domain:hostName', x.hostname)
|
xml.tag!('domain:hostName', x.hostname)
|
||||||
x.ipv4.each{|ip| xml.tag!('domain:hostAddr', ip, 'ip' => 'v4') } if x.ipv4.present?
|
if x.ipv4.present?
|
||||||
x.ipv6.each{|ip| xml.tag!('domain:hostAddr', ip, 'ip' => 'v6') } if x.ipv6.present?
|
x.ipv4.each { |ip| xml.tag!('domain:hostAddr', ip, 'ip' => 'v4') }
|
||||||
|
end
|
||||||
|
|
||||||
|
if x.ipv6.present?
|
||||||
|
x.ipv6.each { |ip| xml.tag!('domain:hostAddr', ip, 'ip' => 'v6') }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
## TODO Find out what this domain:host is all about
|
|
||||||
|
|
||||||
xml.tag!('domain:clID', @domain.registrar.code)
|
xml.tag!('domain:clID', @domain.registrar.code)
|
||||||
|
|
||||||
xml.tag!('domain:crID', @domain.cr_id)
|
xml.tag!('domain:crID', @domain.cr_id)
|
||||||
xml.tag!('domain:crDate', @domain.created_at.try(:iso8601))
|
xml.tag!('domain:crDate', @domain.created_at.try(:iso8601))
|
||||||
|
|
||||||
if @domain.updated_at > @domain.created_at
|
if @domain.updated_at > @domain.created_at
|
||||||
upID = @domain.updator.try(:registrar)
|
updator = @domain.updator.try(:registrar)
|
||||||
upID = upID.code if upID.present? # Did updator return a kind of User that has a registrar?
|
updator = updator.code if updator.present?
|
||||||
xml.tag!('domain:upID', upID) if upID.present? # optional upID
|
xml.tag!('domain:upID', updator) if updator.present?
|
||||||
xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601))
|
xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601))
|
||||||
end
|
end
|
||||||
|
|
||||||
xml.tag!('domain:exDate', @domain.valid_to.iso8601)
|
xml.tag!('domain:exDate', @domain.valid_to.iso8601)
|
||||||
|
|
||||||
# TODO Make domain transferrable
|
|
||||||
#xml.tag!('domain:trDate', @domain.transferred_at) if @domain.transferred_at
|
|
||||||
|
|
||||||
if can? :view_password, @domain, @password
|
if can? :view_password, @domain, @password
|
||||||
xml.tag!('domain:authInfo') do
|
xml.tag!('domain:authInfo') do
|
||||||
xml.tag!('domain:pw', @domain.transfer_code)
|
xml.tag!('domain:pw', @domain.transfer_code)
|
||||||
|
@ -62,10 +62,11 @@ xml.epp_head do
|
||||||
end
|
end
|
||||||
|
|
||||||
if @domain.dnskeys.any?
|
if @domain.dnskeys.any?
|
||||||
ds_data = Setting.ds_data_allowed ? @domain.dnskeys.find_all { |key| key.ds_digest.present? } : []
|
ds_data = Setting.ds_data_allowed ?
|
||||||
key_data = Setting.key_data_allowed ? @domain.dnskeys.find_all { |key| key.public_key.present? } : []
|
@domain.dnskeys.find_all { |key| key.ds_digest.present? } : []
|
||||||
|
key_data = Setting.key_data_allowed ?
|
||||||
|
@domain.dnskeys.find_all { |key| key.public_key.present? } : []
|
||||||
|
|
||||||
# is there any reason to include <extension> without <secDNS:infData>
|
|
||||||
xml.extension do
|
xml.extension do
|
||||||
def tag_key_data(xml, key)
|
def tag_key_data(xml, key)
|
||||||
xml.tag!('secDNS:keyData') do
|
xml.tag!('secDNS:keyData') do
|
|
@ -1,16 +1,16 @@
|
||||||
xml.epp_head do
|
xml.epp_head do
|
||||||
xml.response do
|
xml.response do
|
||||||
xml.result('code' => '1000') do
|
xml.result code: '1000' do
|
||||||
xml.msg 'Command completed successfully'
|
xml.msg 'Command completed successfully'
|
||||||
end
|
end
|
||||||
|
|
||||||
xml.resData do
|
xml.resData do
|
||||||
xml.tag! 'domain:infData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd' do
|
xml.tag! 'domain:infData', 'xmlns:domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd' do
|
||||||
xml.tag!('domain:name', @name)
|
xml.tag! 'domain:name', @name
|
||||||
xml.tag!('domain:status', 's' => @status)
|
xml.tag! 'domain:status', 's' => @status
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
render('epp/shared/trID', builder: xml)
|
render 'epp/shared/trID', builder: xml
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -106,4 +106,54 @@ class EppDomainInfoBaseTest < ApplicationIntegrationTest
|
||||||
assert_nil response_xml.at_xpath('//domain:authInfo/domain:pw',
|
assert_nil response_xml.at_xpath('//domain:authInfo/domain:pw',
|
||||||
'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')
|
'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_blocked_domain
|
||||||
|
assert_equal 'blocked.test', blocked_domains(:one).name
|
||||||
|
|
||||||
|
request_xml = <<-XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||||
|
<command>
|
||||||
|
<info>
|
||||||
|
<domain:info xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||||
|
<domain:name>blocked.test</domain:name>
|
||||||
|
</domain:info>
|
||||||
|
</info>
|
||||||
|
</command>
|
||||||
|
</epp>
|
||||||
|
XML
|
||||||
|
|
||||||
|
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||||
|
|
||||||
|
response_xml = Nokogiri::XML(response.body)
|
||||||
|
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||||
|
assert_equal 1, response_xml.css('result').size
|
||||||
|
assert_equal 'blocked.test', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
|
||||||
|
assert_equal 'Blocked', response_xml.at_xpath('//domain:status', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['s']
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_reserved_domain
|
||||||
|
assert_equal 'reserved.test', reserved_domains(:one).name
|
||||||
|
|
||||||
|
request_xml = <<-XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||||
|
<command>
|
||||||
|
<info>
|
||||||
|
<domain:info xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||||
|
<domain:name>reserved.test</domain:name>
|
||||||
|
</domain:info>
|
||||||
|
</info>
|
||||||
|
</command>
|
||||||
|
</epp>
|
||||||
|
XML
|
||||||
|
|
||||||
|
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||||
|
|
||||||
|
response_xml = Nokogiri::XML(response.body)
|
||||||
|
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||||
|
assert_equal 1, response_xml.css('result').size
|
||||||
|
assert_equal 'reserved.test', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
|
||||||
|
assert_equal 'Reserved', response_xml.at_xpath('//domain:status', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['s']
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -111,4 +111,16 @@ class DNS::DomainNameTest < ActiveSupport::TestCase
|
||||||
domain_name = DNS::DomainName.new('shop.test')
|
domain_name = DNS::DomainName.new('shop.test')
|
||||||
assert_equal 'shop.test', domain_name.to_s
|
assert_equal 'shop.test', domain_name.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_blocked
|
||||||
|
assert_equal 'blocked.test', blocked_domains(:one).name
|
||||||
|
assert DNS::DomainName.new('blocked.test').blocked?
|
||||||
|
assert_not DNS::DomainName.new('nonblocked .test').blocked?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_reserved
|
||||||
|
assert_equal 'reserved.test', reserved_domains(:one).name
|
||||||
|
assert DNS::DomainName.new('reserved.test').reserved?
|
||||||
|
assert_not DNS::DomainName.new('unreserved.test').reserved?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue