Change error type if legaldoc file is more than 8 MB

This commit is contained in:
Alex Sherman 2021-03-18 15:12:30 +05:00
parent 3b11f0bc20
commit 9f21b1704c
2 changed files with 14 additions and 9 deletions

View file

@ -23,6 +23,8 @@ module Epp
rescue_from ActiveRecord::RecordNotFound, with: :respond_with_object_does_not_exist_error
before_action :set_paper_trail_whodunnit
EIGHT_MEGABYTES = 8_388_608
protected
def respond_with_command_failed_error(exception)
@ -62,13 +64,17 @@ module Epp
return if %w[hello error].include?(params[:action])
schema.validate(params[:nokogiri_frame]).each do |error|
epp_errors << {
code: 2001,
code: error_code(error),
msg: error
}
end
handle_errors and return if epp_errors.any?
end
def error_code(error)
error.str1.present? && error.str1.size > EIGHT_MEGABYTES ? 2306 : 2001
end
def schema
EPP_ALL_SCHEMA
end

View file

@ -82,9 +82,8 @@ class EppDomainCreateBaseTest < EppTestCase
contact = contacts(:john)
registrant = contact.becomes(Registrant)
# 8388608 bites == 8 mb
bignum_legaldoc = 't' * 8388608
bignum_legaldoc+= "t"
# 8388608 bytes == 8 mb
bignum_legaldoc = 't' * (8388608 + 1)
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
@ -118,7 +117,7 @@ class EppDomainCreateBaseTest < EppTestCase
contact = contacts(:john)
registrant = contact.becomes(Registrant)
# 8388608 bites == 8 mb
# 8388608 bytes == 8 mb
bignum_legaldoc = 't' * 8388608
request_xml = <<-XML