mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
Validate IPv4 on nameserver when in the same zone with domain
This commit is contained in:
parent
4f780e0c1a
commit
b85420a598
4 changed files with 28 additions and 0 deletions
|
@ -49,6 +49,7 @@ class Domain < ActiveRecord::Base
|
|||
validate :validate_tech_contacts_uniqueness
|
||||
validate :validate_admin_contacts_uniqueness
|
||||
validate :validate_domain_statuses_uniqueness
|
||||
validate :validate_nameserver_ips
|
||||
|
||||
attr_accessor :owner_contact_typeahead
|
||||
|
||||
|
@ -98,6 +99,15 @@ class Domain < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def validate_nameserver_ips
|
||||
nameservers.each do |ns|
|
||||
next if !ns.hostname.end_with?(name)
|
||||
next if ns.ipv4.present?
|
||||
errors.add(:nameservers, :invalid) if errors[:nameservers].blank?
|
||||
ns.errors.add(:ipv4, :blank)
|
||||
end
|
||||
end
|
||||
|
||||
def validate_tech_contacts_uniqueness
|
||||
contacts = domain_contacts.reject(&:marked_for_destruction?).select { |x| x.contact_type == DomainContact::TECH }
|
||||
validate_domain_contacts_uniqueness(contacts)
|
||||
|
|
|
@ -17,6 +17,9 @@ class Nameserver < ActiveRecord::Base
|
|||
[:hostname, :invalid, { value: { obj: 'hostObj', val: hostname } }],
|
||||
[:ipv4, :invalid, { value: { obj: 'hostAddr', val: ipv4 } }],
|
||||
[:ipv6, :invalid, { value: { obj: 'hostAddr', val: ipv6 } }]
|
||||
],
|
||||
'2306' => [
|
||||
[:ipv4, :blank]
|
||||
]
|
||||
}
|
||||
end
|
||||
|
|
|
@ -121,6 +121,7 @@ en:
|
|||
invalid: 'Hostname is invalid'
|
||||
taken: 'Nameserver already exists on this domain'
|
||||
ipv4:
|
||||
blank: 'IPv4 is missing'
|
||||
invalid: 'IPv4 is invalid'
|
||||
ipv6:
|
||||
invalid: 'IPv6 is invalid'
|
||||
|
|
|
@ -203,6 +203,20 @@ describe 'EPP Domain', epp: true do
|
|||
expect(d.auth_info).not_to be_empty
|
||||
end
|
||||
|
||||
it 'validates nameserver ipv4 when in same zone as domain' do
|
||||
xml_params = {
|
||||
nameservers: [
|
||||
{ hostObj: 'ns1.example.ee' },
|
||||
{ hostObj: 'ns2.example.ee' }
|
||||
]
|
||||
}
|
||||
|
||||
response = epp_request(domain_create_xml(xml_params), :xml)
|
||||
|
||||
expect(response[:result_code]).to eq('2306')
|
||||
expect(response[:msg]).to eq('IPv4 is missing')
|
||||
end
|
||||
|
||||
it 'does not create duplicate domain' do
|
||||
epp_request(domain_create_xml, :xml)
|
||||
response = epp_request(domain_create_xml, :xml)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue