mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 19:20:37 +02:00
Merge pull request #1294 from internetee/fix-glue-record-policy
Fix glue record policy
This commit is contained in:
commit
df0e05938b
5 changed files with 35 additions and 49 deletions
1
Gemfile
1
Gemfile
|
@ -93,6 +93,7 @@ gem 'airbrake'
|
|||
gem 'company_register', github: 'internetee/company_register', branch: :master
|
||||
gem 'e_invoice', github: 'internetee/e_invoice', branch: :master
|
||||
gem 'lhv', github: 'internetee/lhv', tag: 'v0.1.0'
|
||||
gem 'domain_name'
|
||||
|
||||
group :development do
|
||||
# deploy
|
||||
|
|
|
@ -475,6 +475,7 @@ DEPENDENCIES
|
|||
database_cleaner
|
||||
devise (~> 4.0)
|
||||
digidoc_client!
|
||||
domain_name
|
||||
e_invoice!
|
||||
epp (= 1.5.0)!
|
||||
epp-xml (= 1.1.0)!
|
||||
|
|
|
@ -81,7 +81,7 @@ class Nameserver < ActiveRecord::Base
|
|||
|
||||
def glue_record_required?
|
||||
return unless hostname? && domain
|
||||
hostname.end_with?(domain.name)
|
||||
DomainName(hostname).domain == domain.name
|
||||
end
|
||||
|
||||
def normalize_attributes
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainCreateNameserversTest < EppTestCase
|
||||
# Glue record requirement
|
||||
def test_nameserver_ip_address_is_required_if_hostname_is_under_the_same_domain
|
||||
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>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>new.test</domain:name>
|
||||
<domain:ns>
|
||||
<domain:hostAttr>
|
||||
<domain:hostName>ns1.new.test</domain:hostName>
|
||||
</domain:hostAttr>
|
||||
</domain:ns>
|
||||
<domain:registrant>john-001</domain:registrant>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">test</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
assert_no_difference 'Domain.count' do
|
||||
post '/epp/command/create', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
assert_epp_response :required_parameter_missing
|
||||
end
|
||||
end
|
|
@ -5,23 +5,42 @@ class NameserverGlueRecordTest < ActiveSupport::TestCase
|
|||
@nameserver = nameservers(:shop_ns1)
|
||||
end
|
||||
|
||||
def test_invalid_without_ip_if_glue_record_is_required
|
||||
@nameserver.hostname = 'ns1.shop.test'
|
||||
@nameserver.ipv4 = @nameserver.ipv6 = ''
|
||||
assert @nameserver.invalid?
|
||||
assert_includes @nameserver.errors.full_messages, 'Either IPv4 or IPv6 is required' \
|
||||
def test_invalid_when_glue_record_is_required_and_no_ip_is_provided
|
||||
domain = Domain.new(name: 'shop.test')
|
||||
nameserver = Nameserver.new(domain: domain, hostname: 'ns1.shop.test')
|
||||
|
||||
assert nameserver.invalid?
|
||||
assert_includes nameserver.errors.full_messages, 'Either IPv4 or IPv6 is required' \
|
||||
' for glue record generation'
|
||||
end
|
||||
|
||||
def test_valid_with_ip_if_glue_record_is_required
|
||||
@nameserver.hostname = 'ns1.shop.test'
|
||||
@nameserver.ipv4 = ['192.0.2.1']
|
||||
@nameserver.ipv6 = ''
|
||||
assert @nameserver.valid?
|
||||
def test_valid_when_glue_record_is_required_and_ipv4_is_provided
|
||||
domain = Domain.new(name: 'shop.test')
|
||||
nameserver = Nameserver.new(domain: domain, hostname: 'ns1.shop.test')
|
||||
nameserver.ipv4 = ['192.0.2.1']
|
||||
|
||||
assert nameserver.valid?
|
||||
end
|
||||
|
||||
def test_valid_without_ip_if_glue_record_is_not_required
|
||||
@nameserver.ipv4 = @nameserver.ipv6 = ''
|
||||
assert @nameserver.valid?
|
||||
def test_valid_when_glue_record_is_required_and_ipv6_is_provided
|
||||
domain = Domain.new(name: 'shop.test')
|
||||
nameserver = Nameserver.new(domain: domain, hostname: 'ns1.shop.test')
|
||||
nameserver.ipv6 = ['2001:db8::1']
|
||||
|
||||
assert nameserver.valid?
|
||||
end
|
||||
|
||||
def test_valid_when_glue_record_is_not_required_and_no_ip_is_provided
|
||||
domain = Domain.new(name: 'shop.test')
|
||||
nameserver = Nameserver.new(domain: domain, hostname: 'ns1.registrar.test')
|
||||
|
||||
assert nameserver.valid?
|
||||
end
|
||||
|
||||
def test_valid_when_glue_record_is_not_required_and_no_ip_is_provided_substring_match
|
||||
domain = Domain.new(name: 'le.test')
|
||||
nameserver = Nameserver.new(domain: domain, hostname: 'ns1.shop.test')
|
||||
|
||||
assert nameserver.valid?
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue