mirror of
https://github.com/internetee/registry.git
synced 2025-05-30 09:30:03 +02:00
Start refactoring params_hash out of domains
This commit is contained in:
parent
fe883f4e2e
commit
64183c1dd8
3 changed files with 17 additions and 10 deletions
|
@ -116,23 +116,25 @@ class Epp::DomainsController < EppController
|
||||||
private
|
private
|
||||||
|
|
||||||
def validate_info
|
def validate_info
|
||||||
@ph = params_hash['epp']['command']['info']['info']
|
@prefix = 'info > info >'
|
||||||
xml_attrs_present?(@ph, [['name']])
|
epp_request_valid?('name')
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_check
|
def validate_check
|
||||||
|
@prefix = 'check > check >'
|
||||||
epp_request_valid?('name')
|
epp_request_valid?('name')
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_create
|
def validate_create
|
||||||
# TODO: Verify contact presence if registrant is juridical
|
|
||||||
ret = epp_request_valid?('name', 'ns', 'registrant', 'extension > extdata > legalDocument', 'ns > hostAttr')
|
|
||||||
|
|
||||||
if params[:parsed_frame].css('dsData').count > 0 && params[:parsed_frame].css('create > keyData').count > 0
|
if params[:parsed_frame].css('dsData').count > 0 && params[:parsed_frame].css('create > keyData').count > 0
|
||||||
epp_errors << { code: '2306', msg: I18n.t('ds_data_and_key_data_must_not_exists_together') }
|
epp_errors << { code: '2306', msg: I18n.t('ds_data_and_key_data_must_not_exists_together') }
|
||||||
ret = false
|
|
||||||
end
|
end
|
||||||
ret
|
|
||||||
|
@prefix = 'create > create >'
|
||||||
|
epp_request_valid?('name', 'ns', 'registrant', 'ns > hostAttr')
|
||||||
|
|
||||||
|
@prefix = nil
|
||||||
|
epp_request_valid?('extension > extdata > legalDocument')
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_renew
|
def validate_renew
|
||||||
|
|
|
@ -58,12 +58,14 @@ class EppController < ApplicationController
|
||||||
def validate_request
|
def validate_request
|
||||||
validation_method = "validate_#{params[:action]}"
|
validation_method = "validate_#{params[:action]}"
|
||||||
return unless respond_to?(validation_method, true)
|
return unless respond_to?(validation_method, true)
|
||||||
handle_errors and return unless send(validation_method)
|
send(validation_method)
|
||||||
|
handle_errors and return if epp_errors.any?
|
||||||
end
|
end
|
||||||
|
|
||||||
def epp_request_valid?(*selectors)
|
def epp_request_valid?(*selectors)
|
||||||
selectors.each do |selector|
|
selectors.each do |selector|
|
||||||
el = params[:parsed_frame].css(selector).first
|
full_selector = [@prefix, selector].join(' ')
|
||||||
|
el = params[:parsed_frame].css(full_selector).first
|
||||||
epp_errors << {
|
epp_errors << {
|
||||||
code: '2003',
|
code: '2003',
|
||||||
msg: I18n.t('errors.messages.required_parameter_missing', key: el.try(:name) || selector)
|
msg: I18n.t('errors.messages.required_parameter_missing', key: el.try(:name) || selector)
|
||||||
|
|
|
@ -80,7 +80,10 @@ describe 'EPP Domain', epp: true do
|
||||||
expect(response[:results][1][:msg]).to eq('Required parameter missing: registrant')
|
expect(response[:results][1][:msg]).to eq('Required parameter missing: registrant')
|
||||||
|
|
||||||
expect(response[:results][2][:result_code]).to eq('2003')
|
expect(response[:results][2][:result_code]).to eq('2003')
|
||||||
expect(response[:results][2][:msg]).to eq('Required parameter missing: extension > extdata > legalDocument')
|
expect(response[:results][2][:msg]).to eq('Required parameter missing: ns > hostAttr')
|
||||||
|
|
||||||
|
expect(response[:results][3][:result_code]).to eq('2003')
|
||||||
|
expect(response[:results][3][:msg]).to eq('Required parameter missing: extension > extdata > legalDocument')
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with citizen as an owner' do
|
context 'with citizen as an owner' do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue