mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 17:53:35 +02:00
Strip and downcase domain name before processing
This commit is contained in:
parent
4659aa0cba
commit
35d836531e
6 changed files with 25 additions and 10 deletions
|
@ -167,13 +167,13 @@ module Epp::DomainsHelper
|
||||||
|
|
||||||
## SHARED
|
## SHARED
|
||||||
def find_domain(secure = { secure: true })
|
def find_domain(secure = { secure: true })
|
||||||
domain = Epp::EppDomain.find_by(name: @ph[:name])
|
domain = Epp::EppDomain.find_by(name: @ph[:name].strip.downcase)
|
||||||
|
|
||||||
unless domain
|
unless domain
|
||||||
epp_errors << {
|
epp_errors << {
|
||||||
code: '2303',
|
code: '2303',
|
||||||
msg: I18n.t('errors.messages.epp_domain_not_found'),
|
msg: I18n.t('errors.messages.epp_domain_not_found'),
|
||||||
value: { obj: 'name', val: @ph[:name] }
|
value: { obj: 'name', val: @ph[:name].strip.downcase }
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
@ -182,7 +182,7 @@ module Epp::DomainsHelper
|
||||||
epp_errors << {
|
epp_errors << {
|
||||||
code: '2302',
|
code: '2302',
|
||||||
msg: I18n.t('errors.messages.domain_exists_but_belongs_to_other_registrar'),
|
msg: I18n.t('errors.messages.domain_exists_but_belongs_to_other_registrar'),
|
||||||
value: { obj: 'name', val: @ph[:name] }
|
value: { obj: 'name', val: @ph[:name].strip.downcase }
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -64,6 +64,7 @@ class Domain < ActiveRecord::Base
|
||||||
|
|
||||||
def name=(value)
|
def name=(value)
|
||||||
value.strip!
|
value.strip!
|
||||||
|
value.downcase!
|
||||||
self[:name] = SimpleIDN.to_unicode(value)
|
self[:name] = SimpleIDN.to_unicode(value)
|
||||||
self[:name_puny] = SimpleIDN.to_ascii(value)
|
self[:name_puny] = SimpleIDN.to_ascii(value)
|
||||||
self[:name_dirty] = value
|
self[:name_dirty] = value
|
||||||
|
|
|
@ -477,6 +477,8 @@ class Epp::EppDomain < Domain
|
||||||
|
|
||||||
res = []
|
res = []
|
||||||
domains.each do |x|
|
domains.each do |x|
|
||||||
|
x.strip!
|
||||||
|
x.downcase!
|
||||||
unless DomainNameValidator.validate_format(x)
|
unless DomainNameValidator.validate_format(x)
|
||||||
res << { name: x, avail: 0, reason: 'invalid format' }
|
res << { name: x, avail: 0, reason: 'invalid format' }
|
||||||
next
|
next
|
||||||
|
|
|
@ -36,7 +36,7 @@ xml.epp_head do
|
||||||
|
|
||||||
xml.tag!('domain:clID', @domain.registrar_name)
|
xml.tag!('domain:clID', @domain.registrar_name)
|
||||||
|
|
||||||
xml.tag!('domain:crID', @domain.versions.first.reify.try(:registrar) || @domain.registrar) #TODO Registrar has to be specified
|
xml.tag!('domain:crID', @domain.versions.first.try(:reify).try(:registrar) || @domain.registrar) #TODO Registrar has to be specified
|
||||||
|
|
||||||
xml.tag!('domain:crDate', @domain.created_at)
|
xml.tag!('domain:crDate', @domain.created_at)
|
||||||
|
|
||||||
|
|
|
@ -743,7 +743,9 @@ describe 'EPP Domain', epp: true do
|
||||||
|
|
||||||
d.save
|
d.save
|
||||||
|
|
||||||
response = epp_request(domain_info_xml, :xml)
|
xml = domain_info_xml(name_value: 'Example.ee')
|
||||||
|
|
||||||
|
response = epp_request(xml, :xml)
|
||||||
expect(response[:results][0][:result_code]).to eq('1000')
|
expect(response[:results][0][:result_code]).to eq('1000')
|
||||||
expect(response[:results][0][:msg]).to eq('Command completed successfully')
|
expect(response[:results][0][:msg]).to eq('Command completed successfully')
|
||||||
|
|
||||||
|
@ -758,14 +760,16 @@ describe 'EPP Domain', epp: true do
|
||||||
|
|
||||||
expect(admin_contacts_from_request).to eq(admin_contacts_existing)
|
expect(admin_contacts_from_request).to eq(admin_contacts_existing)
|
||||||
|
|
||||||
hosts_from_request = inf_data.css('hostObj').map(&:text)
|
hosts_from_request = inf_data.css('hostName').map(&:text)
|
||||||
hosts_existing = d.nameservers.where(ipv4: nil).pluck(:hostname)
|
hosts_existing = d.nameservers.pluck(:hostname)
|
||||||
|
|
||||||
expect(hosts_from_request).to eq(hosts_existing)
|
expect(hosts_from_request).to eq(hosts_existing)
|
||||||
|
|
||||||
expect(inf_data.css('hostName').first.text).to eq('ns1.example.com')
|
ns1 = inf_data.css('hostAttr').last
|
||||||
expect(inf_data.css('hostAddr').first.text).to eq('192.168.1.1')
|
|
||||||
expect(inf_data.css('hostAddr').last.text).to eq('1080:0:0:0:8:800:200C:417A')
|
expect(ns1.css('hostName').last.text).to eq('ns1.example.com')
|
||||||
|
expect(ns1.css('hostAddr').first.text).to eq('192.168.1.1')
|
||||||
|
expect(ns1.css('hostAddr').last.text).to eq('1080:0:0:0:8:800:200C:417A')
|
||||||
expect(inf_data.css('crDate').text).to eq(d.created_at.to_time.utc.to_s)
|
expect(inf_data.css('crDate').text).to eq(d.created_at.to_time.utc.to_s)
|
||||||
expect(inf_data.css('exDate').text).to eq(d.valid_to.to_time.utc.to_s)
|
expect(inf_data.css('exDate').text).to eq(d.valid_to.to_time.utc.to_s)
|
||||||
expect(inf_data.css('pw').text).to eq(d.auth_info)
|
expect(inf_data.css('pw').text).to eq(d.auth_info)
|
||||||
|
@ -865,6 +869,7 @@ describe 'EPP Domain', epp: true do
|
||||||
expect(d.dnskeys.count).to eq(2)
|
expect(d.dnskeys.count).to eq(2)
|
||||||
|
|
||||||
response = epp_request(xml, :xml)
|
response = epp_request(xml, :xml)
|
||||||
|
|
||||||
expect(response[:results][0][:result_code]).to eq('2302')
|
expect(response[:results][0][:result_code]).to eq('2302')
|
||||||
expect(response[:results][0][:msg]).to eq('Nameserver already exists on this domain')
|
expect(response[:results][0][:msg]).to eq('Nameserver already exists on this domain')
|
||||||
expect(response[:results][0][:value]).to eq('ns1.example.com')
|
expect(response[:results][0][:value]).to eq('ns1.example.com')
|
||||||
|
|
|
@ -62,6 +62,13 @@ describe Domain do
|
||||||
expect(d.errors.messages[:nameservers]).to eq(['Nameservers count must be between 2-7'])
|
expect(d.errors.messages[:nameservers]).to eq(['Nameservers count must be between 2-7'])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'downcases domain' do
|
||||||
|
d = Domain.new(name: 'TesT.Ee')
|
||||||
|
expect(d.name).to eq('test.ee')
|
||||||
|
expect(d.name_puny).to eq('test.ee')
|
||||||
|
expect(d.name_dirty).to eq('test.ee')
|
||||||
|
end
|
||||||
|
|
||||||
it 'does not create a reserved domain' do
|
it 'does not create a reserved domain' do
|
||||||
Fabricate(:reserved_domain)
|
Fabricate(:reserved_domain)
|
||||||
expect(Fabricate.build(:domain, name: '1162.ee').valid?).to be false
|
expect(Fabricate.build(:domain, name: '1162.ee').valid?).to be false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue