mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 09:43:36 +02:00
Use translation file for errors, display reserved domain error through epp
This commit is contained in:
parent
e3c60d51fe
commit
d96b1b5deb
6 changed files with 40 additions and 2 deletions
|
@ -8,7 +8,11 @@ module Epp::DomainsHelper
|
|||
if domain.errors.added?(:name, :taken)
|
||||
@code = '2302'
|
||||
@msg = 'Domain name already exists'
|
||||
elsif domain.errors.added?(:name, :epp_domain_reserved)
|
||||
@code = '2302'
|
||||
@msg = domain.errors[:name].first
|
||||
end
|
||||
|
||||
render '/epp/error'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ class Domain < ActiveRecord::Base
|
|||
end
|
||||
|
||||
if !DomainNameValidator.validate_reservation(x)
|
||||
res << {name: x, avail: 0, reason: 'Domain name is reserved or restricted'}
|
||||
res << {name: x, avail: 0, reason: I18n.t('errors.messages.epp_domain_reserved')}
|
||||
next
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ class DomainNameValidator < ActiveModel::EachValidator
|
|||
if !self.class.validate_format(value)
|
||||
record.errors[attribute] << (options[:message] || 'invalid format')
|
||||
elsif !self.class.validate_reservation(value)
|
||||
record.errors[attribute] << (options[:message] || 'Domain name is reserved or restricted')
|
||||
record.errors[attribute] << (options[:message] || I18n.t('errors.messages.epp_domain_reserved'))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -20,4 +20,7 @@
|
|||
# available at http://guides.rubyonrails.org/i18n.html.
|
||||
|
||||
en:
|
||||
errors:
|
||||
messages:
|
||||
epp_domain_reserved: 'Domain name is reserved or restricted'
|
||||
hello: "Hello world"
|
||||
|
|
|
@ -23,6 +23,14 @@ describe 'EPP Domain', epp: true do
|
|||
expect(response[:clTRID]).to eq('ABC-12345')
|
||||
end
|
||||
|
||||
it 'does not create reserved domain' do
|
||||
Fabricate(:reserved_domain)
|
||||
response = epp_request('domains/create_reserved.xml')
|
||||
expect(response[:result_code]).to eq('2302')
|
||||
expect(response[:msg]).to eq('Domain name is reserved or restricted')
|
||||
expect(response[:clTRID]).to eq('ABC-12345')
|
||||
end
|
||||
|
||||
it 'checks a domain' do
|
||||
response = epp_request('domains/check.xml')
|
||||
expect(response[:result_code]).to eq('1000')
|
||||
|
|
23
spec/epp/requests/domains/create_reserved.xml
Normal file
23
spec/epp/requests/domains/create_reserved.xml
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?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>1162.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:ns>
|
||||
<domain:registrant>jd1234</domain:registrant>
|
||||
<domain:contact type="admin">sh8013</domain:contact>
|
||||
<domain:contact type="tech">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