EPP should use unicode to check domain name availability

This commit is contained in:
Maciej Szlosarczyk 2019-04-02 17:35:18 +03:00
parent d471b273f7
commit 888e95a8c7
No known key found for this signature in database
GPG key ID: 41D62D42D3B0D765
2 changed files with 53 additions and 1 deletions

View file

@ -802,7 +802,7 @@ class Epp::Domain < Domain
next
end
domain_name = DNS::DomainName.new(domain_name_as_string)
domain_name = DNS::DomainName.new(SimpleIDN.to_unicode(domain_name_as_string))
if domain_name.unavailable?
reason = I18n.t("errors.messages.epp_domain_#{domain_name.unavailability_reason}")

View file

@ -1,8 +1,10 @@
# encoding: UTF-8
require 'test_helper'
class EppDomainCheckAuctionTest < ApplicationIntegrationTest
setup do
@auction = auctions(:one)
@idn_auction = auctions(:idn)
Domain.release_to_auction = true
end
@ -35,6 +37,56 @@ class EppDomainCheckAuctionTest < ApplicationIntegrationTest
assert_equal 'Domain is at auction', response_xml.at_xpath('//domain:reason', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
end
def test_idn_ascii_domain_is_unavailable_when_at_auction
@idn_auction.update!(status: Auction.statuses[:started])
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>
<check>
<domain:check xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>xn--pramiid-n2a.test</domain:name>
</domain:check>
</check>
</command>
</epp>
XML
post '/epp/command/check', { 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 '0', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
assert_equal 'Domain is at auction', response_xml.at_xpath('//domain:reason', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
end
def test_idn_unicode_domain_is_unavailable_when_at_auction
@idn_auction.update!(status: Auction.statuses[:started])
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>
<check>
<domain:check xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>püramiid.test</domain:name>
</domain:check>
</check>
</command>
</epp>
XML
post '/epp/command/check', { 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 '0', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
assert_equal 'Domain is at auction', response_xml.at_xpath('//domain:reason', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
end
def test_domain_is_unavailable_when_awaiting_payment
@auction.update!(status: Auction.statuses[:awaiting_payment])