mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 10:16:01 +02:00
Nameserver count validation 1
This commit is contained in:
parent
d01944fe21
commit
86dc8321c6
6 changed files with 82 additions and 1 deletions
|
@ -52,6 +52,7 @@ module Epp::DomainsHelper
|
||||||
|
|
||||||
def domain_nameservers
|
def domain_nameservers
|
||||||
ph = params_hash['epp']['command']['create']['create']['ns']
|
ph = params_hash['epp']['command']['create']['create']['ns']
|
||||||
|
return [] unless ph
|
||||||
ph[:hostObj]
|
ph[:hostObj]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,18 @@ class Domain < ActiveRecord::Base
|
||||||
self.nameservers << Nameserver.find_or_create_by(hostname: x)
|
self.nameservers << Nameserver.find_or_create_by(hostname: x)
|
||||||
end
|
end
|
||||||
save!
|
save!
|
||||||
|
|
||||||
|
validate_nameservers_count
|
||||||
|
|
||||||
|
errors.empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_nameservers_count
|
||||||
|
errors.add(:nameservers, :blank) if nameservers.empty?
|
||||||
|
|
||||||
|
if nameservers.count <= 1 || nameservers.count > 13
|
||||||
|
errors.add(:nameservers, I18n.t('errors.messages.epp_nameservers_range_fail', min: 1, max: 13))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_admin_contacts_count
|
def validate_admin_contacts_count
|
||||||
|
|
|
@ -43,7 +43,8 @@ en:
|
||||||
blank: 'Required parameter missing - registrant'
|
blank: 'Required parameter missing - registrant'
|
||||||
admin_contacts:
|
admin_contacts:
|
||||||
blank: 'Required parameter missing - admin contact'
|
blank: 'Required parameter missing - admin contact'
|
||||||
|
nameservers:
|
||||||
|
blank: 'Required parameter missing - nameserver'
|
||||||
|
|
||||||
errors:
|
errors:
|
||||||
messages:
|
messages:
|
||||||
|
@ -52,3 +53,4 @@ en:
|
||||||
epp_obj_does_not_exist: 'Object does not exist'
|
epp_obj_does_not_exist: 'Object does not exist'
|
||||||
epp_command_failed: 'Command failed'
|
epp_command_failed: 'Command failed'
|
||||||
epp_contact_not_found: 'Contact was not found'
|
epp_contact_not_found: 'Contact was not found'
|
||||||
|
epp_nameservers_range_fail: 'Domain must have %{min}-%{max} nameservers'
|
||||||
|
|
|
@ -66,6 +66,18 @@ describe 'EPP Domain', epp: true do
|
||||||
expect(response[:result_code]).to eq('2306')
|
expect(response[:result_code]).to eq('2306')
|
||||||
expect(response[:msg]).to eq('Required parameter missing - registrant')
|
expect(response[:msg]).to eq('Required parameter missing - registrant')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'does not create domain without nameservers' do
|
||||||
|
response = epp_request('domains/create_wo_nameservers.xml')
|
||||||
|
expect(response[:result_code]).to eq('2306')
|
||||||
|
expect(response[:msg]).to eq('Required parameter missing - nameserver')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not create domain with too many nameservers', pending: true do
|
||||||
|
response = epp_request('domains/create_w_too_many_nameservers.xml')
|
||||||
|
expect(response[:result_code]).to eq('2306')
|
||||||
|
expect(response[:msg]).to eq('Domain must have 1-13 nameservers')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with juridical persion as an owner' do
|
context 'with juridical persion as an owner' do
|
||||||
|
|
36
spec/epp/requests/domains/create_w_too_many_nameservers.xml
Normal file
36
spec/epp/requests/domains/create_w_too_many_nameservers.xml
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||||
|
<command>
|
||||||
|
<create>
|
||||||
|
<domain:create
|
||||||
|
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||||
|
<domain:name>example.ee</domain:name>
|
||||||
|
<domain:period unit="y">1</domain:period>
|
||||||
|
<domain:ns>
|
||||||
|
<domain:hostObj>ns1.example.net</domain:hostObj>
|
||||||
|
<domain:hostObj>ns2.example.net</domain:hostObj>
|
||||||
|
<domain:hostObj>ns3.example.net</domain:hostObj>
|
||||||
|
<domain:hostObj>ns4.example.net</domain:hostObj>
|
||||||
|
<domain:hostObj>ns5.example.net</domain:hostObj>
|
||||||
|
<domain:hostObj>ns6.example.net</domain:hostObj>
|
||||||
|
<domain:hostObj>ns7.example.net</domain:hostObj>
|
||||||
|
<domain:hostObj>ns8.example.net</domain:hostObj>
|
||||||
|
<domain:hostObj>ns9.example.net</domain:hostObj>
|
||||||
|
<domain:hostObj>ns10.example.net</domain:hostObj>
|
||||||
|
<domain:hostObj>ns11.example.net</domain:hostObj>
|
||||||
|
<domain:hostObj>ns12.example.net</domain:hostObj>
|
||||||
|
<domain:hostObj>ns13.example.net</domain:hostObj>
|
||||||
|
<domain:hostObj>ns14.example.net</domain:hostObj>
|
||||||
|
</domain:ns>
|
||||||
|
<domain:registrant>jd1234</domain:registrant>
|
||||||
|
<domain:contact type="admin">sh8013</domain:contact>
|
||||||
|
<domain:contact type="tech">sh8013</domain:contact>
|
||||||
|
<domain:contact type="tech">sh801333</domain:contact>
|
||||||
|
<domain:authInfo>
|
||||||
|
<domain:pw>2fooBAR</domain:pw>
|
||||||
|
</domain:authInfo>
|
||||||
|
</domain:create>
|
||||||
|
</create>
|
||||||
|
<clTRID>ABC-12345</clTRID>
|
||||||
|
</command>
|
||||||
|
</epp>
|
18
spec/epp/requests/domains/create_wo_nameservers.xml
Normal file
18
spec/epp/requests/domains/create_wo_nameservers.xml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
|
||||||
|
<command>
|
||||||
|
<create>
|
||||||
|
<domain:create
|
||||||
|
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||||
|
<domain:name>example.ee</domain:name>
|
||||||
|
<domain:period unit="y">1</domain:period>
|
||||||
|
<domain:registrant>jd1234</domain:registrant>
|
||||||
|
<domain:contact type="admin">sh8013</domain:contact>
|
||||||
|
<domain:authInfo>
|
||||||
|
<domain:pw>2fooBAR</domain:pw>
|
||||||
|
</domain:authInfo>
|
||||||
|
</domain:create>
|
||||||
|
</create>
|
||||||
|
<clTRID>ABC-12345</clTRID>
|
||||||
|
</command>
|
||||||
|
</epp>
|
Loading…
Add table
Add a link
Reference in a new issue