mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 10:45:58 +02:00
More full paths in error messages
This commit is contained in:
parent
01fb195104
commit
7c69783091
3 changed files with 13 additions and 6 deletions
|
@ -119,24 +119,27 @@ class EppController < ApplicationController
|
|||
end
|
||||
|
||||
def exactly_one_of(*selectors)
|
||||
full_selectors = create_full_selectors(*selectors)
|
||||
return if element_count(*selectors) == 1
|
||||
|
||||
epp_errors << {
|
||||
code: '2306',
|
||||
msg: I18n.t(:exactly_one_parameter_required, params: selectors.join(' or '))
|
||||
msg: I18n.t(:exactly_one_parameter_required, params: full_selectors.join(' OR '))
|
||||
}
|
||||
end
|
||||
|
||||
def mutually_exclusive(*selectors)
|
||||
full_selectors = create_full_selectors(*selectors)
|
||||
return if element_count(*selectors) <= 1
|
||||
|
||||
epp_errors << {
|
||||
code: '2306',
|
||||
msg: I18n.t(:mutally_exclusive_params, params: selectors.join(', '))
|
||||
msg: I18n.t(:mutally_exclusive_params, params: full_selectors.join(', '))
|
||||
}
|
||||
end
|
||||
|
||||
def optional(selector, *validations)
|
||||
full_selector = [@prefix, selector].join(' ')
|
||||
full_selector = [@prefix, selector].compact.join(' ')
|
||||
el = params[:parsed_frame].css(full_selector).first
|
||||
return unless el && el.text.present?
|
||||
value = el.text
|
||||
|
@ -151,13 +154,17 @@ class EppController < ApplicationController
|
|||
def element_count(*selectors)
|
||||
present_count = 0
|
||||
selectors.each do |selector|
|
||||
full_selector = [@prefix, selector].join(' ')
|
||||
full_selector = [@prefix, selector].compact.join(' ')
|
||||
el = params[:parsed_frame].css(full_selector).first
|
||||
present_count += 1 if el && el.text.present?
|
||||
end
|
||||
present_count
|
||||
end
|
||||
|
||||
def create_full_selectors(*selectors)
|
||||
selectors.map { |x| [@prefix, x].compact.join(' ') }
|
||||
end
|
||||
|
||||
def xml_attrs_present?(ph, attributes) # TODO: THIS IS DEPRECATED AND WILL BE REMOVED IN FUTURE
|
||||
attributes.each do |x|
|
||||
epp_errors << {
|
||||
|
|
|
@ -629,7 +629,7 @@ describe 'EPP Domain', epp: true do
|
|||
})
|
||||
|
||||
response = epp_plain_request(xml, :xml)
|
||||
response[:msg].should == 'Mutually exclusive parameters: keyData, dsData'
|
||||
response[:msg].should == 'Mutually exclusive parameters: extension > create > keyData, extension > create > dsData'
|
||||
response[:result_code].should == '2306'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -163,7 +163,7 @@ describe 'EPP Keyrelay', epp: true do
|
|||
})
|
||||
|
||||
response = epp_request(xml, :xml, :elkdata)
|
||||
response[:msg].should == 'Exactly one parameter required: expiry > relative or expiry > absolute'
|
||||
response[:msg].should == 'Exactly one parameter required: keyrelay > expiry > relative OR keyrelay > expiry > absolute'
|
||||
|
||||
@zone.messages.queued.count.should == msg_count
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue