mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 20:55:44 +02:00
Fix CC issues
This commit is contained in:
parent
d4dc39bf22
commit
11d97358c1
16 changed files with 78 additions and 60 deletions
|
@ -561,7 +561,7 @@ DEPENDENCIES
|
||||||
puma
|
puma
|
||||||
que
|
que
|
||||||
que-web
|
que-web
|
||||||
rails (~> 6.1)
|
rails (~> 6.0)
|
||||||
ransack (~> 2.3)
|
ransack (~> 2.3)
|
||||||
rest-client
|
rest-client
|
||||||
rexml
|
rexml
|
||||||
|
@ -580,4 +580,4 @@ DEPENDENCIES
|
||||||
wkhtmltopdf-binary (~> 0.12.5.1)
|
wkhtmltopdf-binary (~> 0.12.5.1)
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
2.2.15
|
2.2.16
|
||||||
|
|
|
@ -81,7 +81,9 @@ module Admin
|
||||||
]
|
]
|
||||||
|
|
||||||
allowed = params.require(:price).permit(*allowed_params)
|
allowed = params.require(:price).permit(*allowed_params)
|
||||||
allowed[:duration] = ActiveSupport::Duration.build(allowed[:duration].to_i) if allowed[:duration]
|
if allowed[:duration]
|
||||||
|
allowed[:duration] = ActiveSupport::Duration.build(allowed[:duration].to_i)
|
||||||
|
end
|
||||||
allowed
|
allowed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -163,9 +163,12 @@ module Epp
|
||||||
else
|
else
|
||||||
missing = el.present? ? el.text.blank? : true
|
missing = el.present? ? el.text.blank? : true
|
||||||
end
|
end
|
||||||
|
next unless missing
|
||||||
|
|
||||||
epp_errors.add(:epp_errors,
|
epp_errors.add(:epp_errors,
|
||||||
code: '2003',
|
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
|
end
|
||||||
|
|
||||||
missing ? false : el # return last selector if it was present
|
missing ? false : el # return last selector if it was present
|
||||||
|
@ -185,7 +188,8 @@ module Epp
|
||||||
unless attribute
|
unless attribute
|
||||||
epp_errors.add(:epp_errors,
|
epp_errors.add(:epp_errors,
|
||||||
code: '2003',
|
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
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -221,7 +225,8 @@ module Epp
|
||||||
|
|
||||||
epp_errors.add(:epp_errors,
|
epp_errors.add(:epp_errors,
|
||||||
code: '2306',
|
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
|
end
|
||||||
|
|
||||||
def mutually_exclusive(*selectors)
|
def mutually_exclusive(*selectors)
|
||||||
|
@ -230,7 +235,8 @@ module Epp
|
||||||
|
|
||||||
epp_errors.add(:epp_errors,
|
epp_errors.add(:epp_errors,
|
||||||
code: '2306',
|
code: '2306',
|
||||||
msg: I18n.t(:mutally_exclusive_params, params: full_selectors.join(', ')))
|
msg: I18n.t(:mutally_exclusive_params,
|
||||||
|
params: full_selectors.join(', ')))
|
||||||
end
|
end
|
||||||
|
|
||||||
def optional(selector, *validations)
|
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
|
def xml_attrs_present?(ph, attributes) # TODO: THIS IS DEPRECATED AND WILL BE REMOVED IN FUTURE
|
||||||
attributes.each do |x|
|
attributes.each do |x|
|
||||||
|
next if has_attribute(ph, x)
|
||||||
|
|
||||||
epp_errors.add(:epp_errors,
|
epp_errors.add(:epp_errors,
|
||||||
code: '2003',
|
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
|
end
|
||||||
epp_errors.empty?
|
epp_errors.empty?
|
||||||
end
|
end
|
||||||
|
|
|
@ -173,8 +173,7 @@ module Epp
|
||||||
|
|
||||||
epp_errors.add(:epp_errors,
|
epp_errors.add(:epp_errors,
|
||||||
code: '2306',
|
code: '2306',
|
||||||
msg: "#{I18n.t(:contact_org_error)}: postalInfo > org [org]"
|
msg: "#{I18n.t(:contact_org_error)}: postalInfo > org [org]")
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def fax_disabled
|
def fax_disabled
|
||||||
|
@ -190,8 +189,7 @@ module Epp
|
||||||
return true if params[:parsed_frame].css('status').empty?
|
return true if params[:parsed_frame].css('status').empty?
|
||||||
epp_errors.add(:epp_errors,
|
epp_errors.add(:epp_errors,
|
||||||
code: '2306',
|
code: '2306',
|
||||||
msg: "#{I18n.t(:client_side_status_editing_error)}: status [status]"
|
msg: "#{I18n.t(:client_side_status_editing_error)}: status [status]")
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def address_given?
|
def address_given?
|
||||||
|
|
|
@ -218,8 +218,7 @@ module Epp
|
||||||
return true if params[:parsed_frame].css('status').empty?
|
return true if params[:parsed_frame].css('status').empty?
|
||||||
epp_errors.add(:epp_errors,
|
epp_errors.add(:epp_errors,
|
||||||
code: '2306',
|
code: '2306',
|
||||||
msg: "#{I18n.t(:client_side_status_editing_error)}: status [status]"
|
msg: "#{I18n.t(:client_side_status_editing_error)}: status [status]")
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_client_hold
|
def check_client_hold
|
||||||
|
|
|
@ -3,12 +3,12 @@ module Epp
|
||||||
skip_authorization_check
|
skip_authorization_check
|
||||||
|
|
||||||
def error
|
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'
|
render_epp_response '/epp/error'
|
||||||
end
|
end
|
||||||
|
|
||||||
def command_handler
|
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'
|
render_epp_response '/epp/error'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,8 +20,9 @@ module Epp
|
||||||
|
|
||||||
server_md5 = Certificate.parse_md_from_string(File.read(ENV['cert_path']))
|
server_md5 = Certificate.parse_md_from_string(File.read(ENV['cert_path']))
|
||||||
if client_md5 != server_md5
|
if client_md5 != server_md5
|
||||||
|
msg = 'Authentication error; server closing connection (certificate is not valid)'
|
||||||
epp_errors.add(:epp_errors,
|
epp_errors.add(:epp_errors,
|
||||||
msg: 'Authentication error; server closing connection (certificate is not valid)',
|
msg: msg,
|
||||||
code: '2501')
|
code: '2501')
|
||||||
|
|
||||||
success = false
|
success = false
|
||||||
|
@ -31,8 +32,9 @@ module Epp
|
||||||
if !Rails.env.development? && (!webclient_request && @api_user)
|
if !Rails.env.development? && (!webclient_request && @api_user)
|
||||||
unless @api_user.pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'],
|
unless @api_user.pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'],
|
||||||
request.env['HTTP_SSL_CLIENT_S_DN_CN'])
|
request.env['HTTP_SSL_CLIENT_S_DN_CN'])
|
||||||
|
msg = 'Authentication error; server closing connection (certificate is not valid)'
|
||||||
epp_errors.add(:epp_errors,
|
epp_errors.add(:epp_errors,
|
||||||
msg: 'Authentication error; server closing connection (certificate is not valid)',
|
msg: msg,
|
||||||
code: '2501')
|
code: '2501')
|
||||||
|
|
||||||
success = false
|
success = false
|
||||||
|
@ -40,40 +42,45 @@ module Epp
|
||||||
end
|
end
|
||||||
|
|
||||||
if success && !@api_user
|
if success && !@api_user
|
||||||
|
msg = 'Authentication error; server closing connection (API user not found)'
|
||||||
epp_errors.add(:epp_errors,
|
epp_errors.add(:epp_errors,
|
||||||
msg: 'Authentication error; server closing connection (API user not found)',
|
msg: msg,
|
||||||
code: '2501')
|
code: '2501')
|
||||||
|
|
||||||
success = false
|
success = false
|
||||||
end
|
end
|
||||||
|
|
||||||
if success && !@api_user.try(:active)
|
if success && !@api_user.try(:active)
|
||||||
|
msg = 'Authentication error; server closing connection (API user is not active)'
|
||||||
epp_errors.add(:epp_errors,
|
epp_errors.add(:epp_errors,
|
||||||
msg: 'Authentication error; server closing connection (API user is not active)',
|
msg: msg,
|
||||||
code: '2501')
|
code: '2501')
|
||||||
|
|
||||||
success = false
|
success = false
|
||||||
end
|
end
|
||||||
|
|
||||||
if success && @api_user.cannot?(:create, :epp_login)
|
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,
|
epp_errors.add(:epp_errors,
|
||||||
msg: 'Authentication error; server closing connection (API user does not have epp role)',
|
msg: msg,
|
||||||
code: '2501')
|
code: '2501')
|
||||||
|
|
||||||
success = false
|
success = false
|
||||||
end
|
end
|
||||||
|
|
||||||
if success && !ip_white?
|
if success && !ip_white?
|
||||||
|
msg = 'Authentication error; server closing connection (IP is not whitelisted)'
|
||||||
epp_errors.add(:epp_errors,
|
epp_errors.add(:epp_errors,
|
||||||
msg: 'Authentication error; server closing connection (IP is not whitelisted)',
|
msg: msg,
|
||||||
code: '2501')
|
code: '2501')
|
||||||
|
|
||||||
success = false
|
success = false
|
||||||
end
|
end
|
||||||
|
|
||||||
if success && EppSession.limit_reached?(@api_user.registrar)
|
if success && EppSession.limit_reached?(@api_user.registrar)
|
||||||
|
msg = 'Session limit exceeded; server closing connection (connection limit reached)'
|
||||||
epp_errors.add(:epp_errors,
|
epp_errors.add(:epp_errors,
|
||||||
msg: 'Session limit exceeded; server closing connection (connection limit reached)',
|
msg: msg,
|
||||||
code: '2502')
|
code: '2502')
|
||||||
|
|
||||||
success = false
|
success = false
|
||||||
|
|
|
@ -63,7 +63,7 @@ module Repp
|
||||||
@epp_errors ||= ActiveModel::Errors.new(self)
|
@epp_errors ||= ActiveModel::Errors.new(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_errors(obj = nil, update: false)
|
def handle_errors(obj = nil)
|
||||||
@epp_errors ||= ActiveModel::Errors.new(self)
|
@epp_errors ||= ActiveModel::Errors.new(self)
|
||||||
|
|
||||||
if obj
|
if obj
|
||||||
|
@ -78,8 +78,8 @@ module Repp
|
||||||
@epp_errors ||= ActiveModel::Errors.new(self)
|
@epp_errors ||= ActiveModel::Errors.new(self)
|
||||||
@epp_errors.add(:epp_errors, msg: 'Command failed', code: '2304') if data != {}
|
@epp_errors.add(:epp_errors, msg: 'Command failed', code: '2304') if data != {}
|
||||||
|
|
||||||
error_options = @epp_errors.errors.uniq.
|
error_options = @epp_errors.errors.uniq
|
||||||
select { |error| error.options[:code].present? }[0].options
|
.select { |error| error.options[:code].present? }[0].options
|
||||||
|
|
||||||
@response = { code: error_options[:code].to_i, message: error_options[:msg], data: data }
|
@response = { code: error_options[:code].to_i, message: error_options[:msg], data: data }
|
||||||
render(json: @response, status: status)
|
render(json: @response, status: status)
|
||||||
|
|
|
@ -16,11 +16,11 @@ module Repp
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@epp_errors ||= ActiveModel::Errors.new(self)
|
@epp_errors ||= ActiveModel::Errors.new(self)
|
||||||
if @new_contact.invalid?
|
return unless @new_contact.invalid?
|
||||||
@epp_errors.add(:epp_errors,
|
|
||||||
msg: 'New contact must be valid',
|
@epp_errors.add(:epp_errors,
|
||||||
code: '2304')
|
msg: 'New contact must be valid',
|
||||||
end
|
code: '2304')
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -30,7 +30,7 @@ module Repp
|
||||||
return render_success(data: { updated_domains: @domains.map(&:name) }) if renew.valid?
|
return render_success(data: { updated_domains: @domains.map(&:name) }) if renew.valid?
|
||||||
|
|
||||||
msg = renew.errors.keys.map { |k, _v| renew.errors[k] }.join(', ')
|
msg = renew.errors.keys.map { |k, _v| renew.errors[k] }.join(', ')
|
||||||
@epp_errors.add(:epp_errors, msg: msg , code: '2002')
|
@epp_errors.add(:epp_errors, msg: msg, code: '2002')
|
||||||
handle_errors
|
handle_errors
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ module Repp
|
||||||
periods = Depp::Domain::PERIODS.map { |p| p[1] }
|
periods = Depp::Domain::PERIODS.map { |p| p[1] }
|
||||||
return if periods.include? bulk_renew_params[:renew_period]
|
return if periods.include? bulk_renew_params[:renew_period]
|
||||||
|
|
||||||
@epp_errors.add(:epp_errors, msg: 'Invalid renew period' , code: '2005')
|
@epp_errors.add(:epp_errors, msg: 'Invalid renew period', code: '2005')
|
||||||
end
|
end
|
||||||
|
|
||||||
def select_renewable_domains
|
def select_renewable_domains
|
||||||
|
@ -54,7 +54,7 @@ module Repp
|
||||||
if bulk_renew_params[:domains].instance_of?(Array)
|
if bulk_renew_params[:domains].instance_of?(Array)
|
||||||
@domains = bulk_renew_domains
|
@domains = bulk_renew_domains
|
||||||
else
|
else
|
||||||
@epp_errors.add(:epp_errors, msg: 'Domains attribute must be an array' , code: '2005')
|
@epp_errors.add(:epp_errors, msg: 'Domains attribute must be an array', code: '2005')
|
||||||
end
|
end
|
||||||
|
|
||||||
return handle_errors if @epp_errors.any?
|
return handle_errors if @epp_errors.any?
|
||||||
|
@ -78,11 +78,11 @@ module Repp
|
||||||
bulk_renew_params[:domains].each do |idn|
|
bulk_renew_params[:domains].each do |idn|
|
||||||
domain = Epp::Domain.find_by(name: idn)
|
domain = Epp::Domain.find_by(name: idn)
|
||||||
domains << domain if domain
|
domains << domain if domain
|
||||||
unless domain
|
next if domain
|
||||||
@epp_errors.add(:epp_errors,
|
|
||||||
msg: "Object does not exist: #{idn}",
|
@epp_errors.add(:epp_errors,
|
||||||
code: '2304')
|
msg: "Object does not exist: #{idn}",
|
||||||
end
|
code: '2304')
|
||||||
end
|
end
|
||||||
|
|
||||||
domains
|
domains
|
||||||
|
|
|
@ -194,7 +194,9 @@ module Repp
|
||||||
return if @domain.registrar == current_user.registrar
|
return if @domain.registrar == current_user.registrar
|
||||||
return if @domain.transfer_code.eql?(request.headers['Auth-Code'])
|
return if @domain.transfer_code.eql?(request.headers['Auth-Code'])
|
||||||
|
|
||||||
@epp_errors.add(:epp_errors, code: 2202, msg: I18n.t('errors.messages.epp_authorization_error'))
|
@epp_errors.add(:epp_errors,
|
||||||
|
code: 2202,
|
||||||
|
msg: I18n.t('errors.messages.epp_authorization_error'))
|
||||||
handle_errors
|
handle_errors
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,8 @@ module Domains
|
||||||
def calculate_total_price
|
def calculate_total_price
|
||||||
@total_price = 0
|
@total_price = 0
|
||||||
domains.each do |domain|
|
domains.each do |domain|
|
||||||
task = Domains::CheckBalance::SingleDomain.run(domain: domain,
|
task = Domains::CheckBalance::SingleDomain.run(domain: domain, operation: 'renew',
|
||||||
operation: 'renew',
|
period: period, unit: unit)
|
||||||
period: period,
|
|
||||||
unit: unit)
|
|
||||||
|
|
||||||
if task.valid?
|
if task.valid?
|
||||||
@total_price += task.result
|
@total_price += task.result
|
||||||
|
|
|
@ -30,15 +30,15 @@ module Billing
|
||||||
'6 months' => 6.months,
|
'6 months' => 6.months,
|
||||||
'9 months' => 9.months,
|
'9 months' => 9.months,
|
||||||
'1 year' => 1.year,
|
'1 year' => 1.year,
|
||||||
'2 years'=> 2.years,
|
'2 years' => 2.years,
|
||||||
'3 years'=> 3.years,
|
'3 years' => 3.years,
|
||||||
'4 years'=> 4.years,
|
'4 years' => 4.years,
|
||||||
'5 years'=> 5.years,
|
'5 years' => 5.years,
|
||||||
'6 years'=> 6.years,
|
'6 years' => 6.years,
|
||||||
'7 years'=> 7.years,
|
'7 years' => 7.years,
|
||||||
'8 years'=> 8.years,
|
'8 years' => 8.years,
|
||||||
'9 years'=> 9.years,
|
'9 years' => 9.years,
|
||||||
'10 years'=> 10.years,
|
'10 years' => 10.years,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ module EppErrors
|
||||||
epp_errors.import parent_error
|
epp_errors.import parent_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
epp_errors.each { |epp_error| errors.import epp_error}
|
epp_errors.each { |epp_error| errors.import epp_error }
|
||||||
errors
|
errors
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -49,13 +49,16 @@ module EppErrors
|
||||||
multi = [:has_and_belongs_to_many, :has_many]
|
multi = [:has_and_belongs_to_many, :has_many]
|
||||||
|
|
||||||
epp_errors = ActiveModel::Errors.new(self)
|
epp_errors = ActiveModel::Errors.new(self)
|
||||||
send(attr).each do |x|
|
|
||||||
x.errors.each do |error|
|
if multi.include?(macro)
|
||||||
x.collect_parent_errors(error.attribute, error.message).each do |parent_error|
|
send(attr).each do |x|
|
||||||
epp_errors.import parent_error
|
x.errors.each do |error|
|
||||||
|
x.collect_parent_errors(error.attribute, error.message).each do |parent_error|
|
||||||
|
epp_errors.import parent_error
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end if multi.include?(macro)
|
end
|
||||||
|
|
||||||
epp_errors
|
epp_errors
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@ class Invoice
|
||||||
private
|
private
|
||||||
|
|
||||||
def invoice_html
|
def invoice_html
|
||||||
ApplicationController.render(template: 'invoice/pdf', assigns: { invoice: invoice } )
|
ApplicationController.render(template: 'invoice/pdf', assigns: { invoice: invoice })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,7 @@ xml.epp_head do
|
||||||
@errors.each do |error|
|
@errors.each do |error|
|
||||||
x = error&.options
|
x = error&.options
|
||||||
next if x.empty? || x == { value: nil }
|
next if x.empty? || x == { value: nil }
|
||||||
|
|
||||||
xml.result('code' => x[:code]) do
|
xml.result('code' => x[:code]) do
|
||||||
xml.msg(x[:msg], 'lang' => 'en')
|
xml.msg(x[:msg], 'lang' => 'en')
|
||||||
model_name = resource ? resource.model_name.singular.sub('epp_','') : controller.controller_name.singularize
|
model_name = resource ? resource.model_name.singular.sub('epp_','') : controller.controller_name.singularize
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue