mirror of
https://github.com/internetee/registry.git
synced 2025-05-28 16:39:55 +02:00
Add a new test for domain info query, epp_errors improvement
This commit is contained in:
parent
5b91acb343
commit
28a6b59a55
7 changed files with 34 additions and 3 deletions
|
@ -29,6 +29,8 @@ module Epp::DomainsHelper
|
|||
def info_domain
|
||||
@domain = find_domain
|
||||
|
||||
handle_errors(@domain) and return unless @domain
|
||||
|
||||
render '/epp/domains/info'
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,9 @@ module EppErrors
|
|||
values.each do |err|
|
||||
if err.is_a?(Hash)
|
||||
next unless code = find_epp_code(err[:msg])
|
||||
epp_errors << {code: code, msg: err[:msg], value: {val: err[:val], obj: err[:obj]}}
|
||||
err_msg = {code: code, msg: err[:msg]}
|
||||
err_msg[:value] = {val: err[:val], obj: err[:obj]} if err[:val]
|
||||
epp_errors << err_msg
|
||||
else
|
||||
next unless code = find_epp_code(err)
|
||||
err = {code: code, msg: err}
|
||||
|
|
|
@ -8,7 +8,8 @@ class Domain < ActiveRecord::Base
|
|||
'2302' => ['Domain name already exists', 'Domain name is reserved or restricted'], # Object exists
|
||||
'2306' => ['Registrant is missing', 'Admin contact is missing', 'Given and current expire dates do not match'], # Parameter policy error
|
||||
'2004' => ['Nameservers count must be between 1-13', 'Period must add up to 1, 2 or 3 years'], # Parameter value range error
|
||||
'2303' => ['Registrant not found', 'Contact was not found'] # Object does not exist
|
||||
'2303' => ['Registrant not found', 'Contact was not found'], # Object does not exist
|
||||
'2200' => ['Authentication error']
|
||||
}
|
||||
|
||||
EPP_ATTR_MAP = {
|
||||
|
@ -156,6 +157,14 @@ class Domain < ActiveRecord::Base
|
|||
}) if cur_exp_date.to_date != valid_to
|
||||
end
|
||||
|
||||
## SHARED
|
||||
|
||||
# For domain transfer
|
||||
def authenticate(pw)
|
||||
errors.add(:auth_info, {msg: errors.generate_message(:auth_info, :wrong_pw)}) if pw != auth_info
|
||||
errors.empty?
|
||||
end
|
||||
|
||||
class << self
|
||||
def convert_period_to_time(period, unit)
|
||||
return period.to_i.days if unit == 'd'
|
||||
|
|
|
@ -54,6 +54,8 @@ en:
|
|||
ip_invalid: 'IPv4 is invalid'
|
||||
period:
|
||||
out_of_range: 'Period must add up to 1, 2 or 3 years'
|
||||
auth_info:
|
||||
wrong_pw: 'Authentication error'
|
||||
nameserver:
|
||||
attributes:
|
||||
hostname:
|
||||
|
|
|
@ -234,6 +234,12 @@ describe 'EPP Domain', epp: true do
|
|||
|
||||
expect(inf_data.css('upDate').text).to eq(d.updated_at.to_time.utc.to_s)
|
||||
end
|
||||
|
||||
it 'returns error when domain can not be found' do
|
||||
response = epp_request(domain_info_xml(name_value: 'test.ee'), :xml)
|
||||
expect(response[:results][0][:result_code]).to eq('2303')
|
||||
expect(response[:results][0][:msg]).to eq('Domain not found')
|
||||
end
|
||||
end
|
||||
|
||||
it 'checks a domain' do
|
||||
|
|
|
@ -114,6 +114,9 @@ describe 'EPP Helper', epp: true do
|
|||
<domain:info
|
||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||
<domain:name hosts="all">example.ee</domain:name>
|
||||
<domain:authInfo>
|
||||
<domain:pw>2fooBAR</domain:pw>
|
||||
</domain:authInfo>
|
||||
</domain:info>
|
||||
</info>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
|
@ -132,6 +135,9 @@ describe 'EPP Helper', epp: true do
|
|||
<domain:info
|
||||
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
|
||||
<domain:name hosts="sub">one.ee</domain:name>
|
||||
<domain:authInfo>
|
||||
<domain:pw>b3rafsla</domain:pw>
|
||||
</domain:authInfo>
|
||||
</domain:info>
|
||||
</info>
|
||||
<clTRID>ABC-12345</clTRID>
|
||||
|
@ -140,7 +146,7 @@ describe 'EPP Helper', epp: true do
|
|||
').to_s.squish
|
||||
|
||||
|
||||
generated = Nokogiri::XML(domain_info_xml(name_value: 'one.ee', name_hosts: 'sub')).to_s.squish
|
||||
generated = Nokogiri::XML(domain_info_xml(name_value: 'one.ee', name_hosts: 'sub', pw: 'b3rafsla')).to_s.squish
|
||||
expect(generated).to eq(expected)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -128,6 +128,7 @@ module Epp
|
|||
def domain_info_xml(xml_params={})
|
||||
xml_params[:name_value] = xml_params[:name_value] || 'example.ee'
|
||||
xml_params[:name_hosts] = xml_params[:name_hosts] || 'all'
|
||||
xml_params[:pw] = xml_params[:pw] || '2fooBAR'
|
||||
|
||||
xml = Builder::XmlMarkup.new
|
||||
|
||||
|
@ -137,6 +138,9 @@ module Epp
|
|||
xml.info do
|
||||
xml.tag!('domain:info', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
|
||||
xml.tag!('domain:name', xml_params[:name_value], 'hosts' => xml_params[:name_hosts]) if xml_params[:name] != false
|
||||
xml.tag!('domain:authInfo') do
|
||||
xml.tag!('domain:pw', xml_params[:pw])
|
||||
end
|
||||
end
|
||||
end
|
||||
xml.clTRID 'ABC-12345'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue