Fix CC issues

This commit is contained in:
Alex Sherman 2021-05-05 17:31:13 +05:00
parent d4dc39bf22
commit 11d97358c1
16 changed files with 78 additions and 60 deletions

View file

@ -163,9 +163,12 @@ module Epp
else
missing = el.present? ? el.text.blank? : true
end
next unless missing
epp_errors.add(:epp_errors,
code: '2003',
message: I18n.t('errors.messages.required_parameter_missing', key: "#{full_selector} [#{attr}]")) if missing
message: I18n.t('errors.messages.required_parameter_missing',
key: "#{full_selector} [#{attr}]"))
end
missing ? false : el # return last selector if it was present
@ -185,7 +188,8 @@ module Epp
unless attribute
epp_errors.add(:epp_errors,
code: '2003',
msg: I18n.t('errors.messages.required_parameter_missing', key: attribute_selector))
msg: I18n.t('errors.messages.required_parameter_missing',
key: attribute_selector))
return
end
@ -221,7 +225,8 @@ module Epp
epp_errors.add(:epp_errors,
code: '2306',
msg: I18n.t(:exactly_one_parameter_required, params: full_selectors.join(' OR ')))
msg: I18n.t(:exactly_one_parameter_required,
params: full_selectors.join(' OR ')))
end
def mutually_exclusive(*selectors)
@ -230,7 +235,8 @@ module Epp
epp_errors.add(:epp_errors,
code: '2306',
msg: I18n.t(:mutally_exclusive_params, params: full_selectors.join(', ')))
msg: I18n.t(:mutally_exclusive_params,
params: full_selectors.join(', ')))
end
def optional(selector, *validations)
@ -273,9 +279,11 @@ module Epp
def xml_attrs_present?(ph, attributes) # TODO: THIS IS DEPRECATED AND WILL BE REMOVED IN FUTURE
attributes.each do |x|
next if has_attribute(ph, x)
epp_errors.add(:epp_errors,
code: '2003',
msg: I18n.t('errors.messages.required_parameter_missing', key: x.last)) unless has_attribute(ph, x)
msg: I18n.t('errors.messages.required_parameter_missing', key: x.last))
end
epp_errors.empty?
end

View file

@ -173,8 +173,7 @@ module Epp
epp_errors.add(:epp_errors,
code: '2306',
msg: "#{I18n.t(:contact_org_error)}: postalInfo > org [org]"
)
msg: "#{I18n.t(:contact_org_error)}: postalInfo > org [org]")
end
def fax_disabled
@ -190,8 +189,7 @@ module Epp
return true if params[:parsed_frame].css('status').empty?
epp_errors.add(:epp_errors,
code: '2306',
msg: "#{I18n.t(:client_side_status_editing_error)}: status [status]"
)
msg: "#{I18n.t(:client_side_status_editing_error)}: status [status]")
end
def address_given?

View file

@ -218,8 +218,7 @@ module Epp
return true if params[:parsed_frame].css('status').empty?
epp_errors.add(:epp_errors,
code: '2306',
msg: "#{I18n.t(:client_side_status_editing_error)}: status [status]"
)
msg: "#{I18n.t(:client_side_status_editing_error)}: status [status]")
end
def check_client_hold

View file

@ -3,12 +3,12 @@ module Epp
skip_authorization_check
def error
epp_errors.add(:epp_errors, code: params[:code], msg: params[:msg] )
epp_errors.add(:epp_errors, code: params[:code], msg: params[:msg])
render_epp_response '/epp/error'
end
def command_handler
epp_errors.add(:epp_errors, code: '2000', msg: 'Unknown command' )
epp_errors.add(:epp_errors, code: '2000', msg: 'Unknown command')
render_epp_response '/epp/error'
end
end

View file

@ -20,8 +20,9 @@ module Epp
server_md5 = Certificate.parse_md_from_string(File.read(ENV['cert_path']))
if client_md5 != server_md5
msg = 'Authentication error; server closing connection (certificate is not valid)'
epp_errors.add(:epp_errors,
msg: 'Authentication error; server closing connection (certificate is not valid)',
msg: msg,
code: '2501')
success = false
@ -31,8 +32,9 @@ module Epp
if !Rails.env.development? && (!webclient_request && @api_user)
unless @api_user.pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'],
request.env['HTTP_SSL_CLIENT_S_DN_CN'])
msg = 'Authentication error; server closing connection (certificate is not valid)'
epp_errors.add(:epp_errors,
msg: 'Authentication error; server closing connection (certificate is not valid)',
msg: msg,
code: '2501')
success = false
@ -40,40 +42,45 @@ module Epp
end
if success && !@api_user
msg = 'Authentication error; server closing connection (API user not found)'
epp_errors.add(:epp_errors,
msg: 'Authentication error; server closing connection (API user not found)',
msg: msg,
code: '2501')
success = false
end
if success && !@api_user.try(:active)
msg = 'Authentication error; server closing connection (API user is not active)'
epp_errors.add(:epp_errors,
msg: 'Authentication error; server closing connection (API user is not active)',
msg: msg,
code: '2501')
success = false
end
if success && @api_user.cannot?(:create, :epp_login)
msg = 'Authentication error; server closing connection (API user does not have epp role)'
epp_errors.add(:epp_errors,
msg: 'Authentication error; server closing connection (API user does not have epp role)',
msg: msg,
code: '2501')
success = false
end
if success && !ip_white?
msg = 'Authentication error; server closing connection (IP is not whitelisted)'
epp_errors.add(:epp_errors,
msg: 'Authentication error; server closing connection (IP is not whitelisted)',
msg: msg,
code: '2501')
success = false
end
if success && EppSession.limit_reached?(@api_user.registrar)
msg = 'Session limit exceeded; server closing connection (connection limit reached)'
epp_errors.add(:epp_errors,
msg: 'Session limit exceeded; server closing connection (connection limit reached)',
msg: msg,
code: '2502')
success = false