mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 13:15:40 +02:00
Make domain unavailable when zone with the same origin exists
This commit is contained in:
parent
ee864c807f
commit
d40dc28484
5 changed files with 41 additions and 3 deletions
|
@ -7,7 +7,7 @@ module DNS
|
|||
end
|
||||
|
||||
def unavailable?
|
||||
registered? || blocked?
|
||||
registered? || blocked? || zone_with_same_origin?
|
||||
end
|
||||
|
||||
def unavailability_reason
|
||||
|
@ -15,6 +15,8 @@ module DNS
|
|||
:registered
|
||||
elsif blocked?
|
||||
:blocked
|
||||
elsif zone_with_same_origin?
|
||||
:zone_with_same_origin
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -29,5 +31,9 @@ module DNS
|
|||
def blocked?
|
||||
BlockedDomain.where(name: name).any?
|
||||
end
|
||||
|
||||
def zone_with_same_origin?
|
||||
DNS::Zone.where(origin: name).any?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -805,8 +805,8 @@ class Epp::Domain < Domain
|
|||
domain_name = DNS::DomainName.new(domain_name_as_string)
|
||||
|
||||
if domain_name.unavailable?
|
||||
reason = domain_name.unavailability_reason
|
||||
result << { name: domain_name_as_string, avail: 0, reason: I18n.t("errors.messages.epp_domain_#{reason}") }
|
||||
reason = I18n.t("errors.messages.epp_domain_#{domain_name.unavailability_reason}")
|
||||
result << { name: domain_name_as_string, avail: 0, reason: reason }
|
||||
next
|
||||
end
|
||||
|
||||
|
|
|
@ -198,6 +198,7 @@ en:
|
|||
blank: 'is missing'
|
||||
epp_domain_registered: in use
|
||||
epp_domain_blocked: Blocked
|
||||
epp_domain_zone_with_same_origin: Zone with the same origin exists
|
||||
epp_obj_does_not_exist: 'Object does not exist'
|
||||
epp_authorization_error: 'Authorization error'
|
||||
epp_id_taken: 'Contact id already exists'
|
||||
|
|
|
@ -134,6 +134,29 @@ class EppDomainCheckBaseTest < ApplicationIntegrationTest
|
|||
assert_equal 'Blocked', 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_zone_with_the_same_origin_exists
|
||||
assert_equal 'test', dns_zones(:one).origin
|
||||
|
||||
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>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 '0', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
|
||||
assert_equal 'Zone with the same origin exists', response_xml.at_xpath('//domain:reason', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
|
||||
end
|
||||
|
||||
def test_multiple_domains
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
|
|
@ -16,4 +16,12 @@ class DNS::DomainNameTest < ActiveSupport::TestCase
|
|||
assert domain_name.unavailable?
|
||||
assert_equal :blocked, domain_name.unavailability_reason
|
||||
end
|
||||
|
||||
def test_unavailable_when_zone_with_the_same_origin_exists
|
||||
domain_name = DNS::DomainName.new('test')
|
||||
assert_equal 'test', dns_zones(:one).origin
|
||||
|
||||
assert domain_name.unavailable?
|
||||
assert_equal :zone_with_same_origin, domain_name.unavailability_reason
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue