diff --git a/app/controllers/epp/base_controller.rb b/app/controllers/epp/base_controller.rb index 99c0ead35..ff711c490 100644 --- a/app/controllers/epp/base_controller.rb +++ b/app/controllers/epp/base_controller.rb @@ -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 diff --git a/test/integration/epp/domain/create/base_test.rb b/test/integration/epp/domain/create/base_test.rb index fa04fc707..777f01abc 100644 --- a/test/integration/epp/domain/create/base_test.rb +++ b/test/integration/epp/domain/create/base_test.rb @@ -73,7 +73,7 @@ class EppDomainCreateBaseTest < EppTestCase post epp_create_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } end - + assert_epp_response :parameter_value_policy_error end @@ -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 @@ -109,7 +108,7 @@ class EppDomainCreateBaseTest < EppTestCase post epp_create_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } end - + assert_epp_response :parameter_value_policy_error end @@ -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 @@ -139,12 +138,12 @@ class EppDomainCreateBaseTest < EppTestCase XML - + assert_difference 'Domain.count' do post epp_create_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } end - + assert_epp_response :completed_successfully end