mirror of
https://github.com/internetee/registry.git
synced 2025-06-12 07:34:45 +02:00
Change error type if legaldoc file is more than 8 MB
This commit is contained in:
parent
3b11f0bc20
commit
9f21b1704c
2 changed files with 14 additions and 9 deletions
|
@ -23,6 +23,8 @@ module Epp
|
||||||
rescue_from ActiveRecord::RecordNotFound, with: :respond_with_object_does_not_exist_error
|
rescue_from ActiveRecord::RecordNotFound, with: :respond_with_object_does_not_exist_error
|
||||||
before_action :set_paper_trail_whodunnit
|
before_action :set_paper_trail_whodunnit
|
||||||
|
|
||||||
|
EIGHT_MEGABYTES = 8_388_608
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def respond_with_command_failed_error(exception)
|
def respond_with_command_failed_error(exception)
|
||||||
|
@ -62,13 +64,17 @@ module Epp
|
||||||
return if %w[hello error].include?(params[:action])
|
return if %w[hello error].include?(params[:action])
|
||||||
schema.validate(params[:nokogiri_frame]).each do |error|
|
schema.validate(params[:nokogiri_frame]).each do |error|
|
||||||
epp_errors << {
|
epp_errors << {
|
||||||
code: 2001,
|
code: error_code(error),
|
||||||
msg: error
|
msg: error
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
handle_errors and return if epp_errors.any?
|
handle_errors and return if epp_errors.any?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def error_code(error)
|
||||||
|
error.str1.present? && error.str1.size > EIGHT_MEGABYTES ? 2306 : 2001
|
||||||
|
end
|
||||||
|
|
||||||
def schema
|
def schema
|
||||||
EPP_ALL_SCHEMA
|
EPP_ALL_SCHEMA
|
||||||
end
|
end
|
||||||
|
|
|
@ -73,7 +73,7 @@ class EppDomainCreateBaseTest < EppTestCase
|
||||||
post epp_create_path, params: { frame: request_xml },
|
post epp_create_path, params: { frame: request_xml },
|
||||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_epp_response :parameter_value_policy_error
|
assert_epp_response :parameter_value_policy_error
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -82,9 +82,8 @@ class EppDomainCreateBaseTest < EppTestCase
|
||||||
contact = contacts(:john)
|
contact = contacts(:john)
|
||||||
registrant = contact.becomes(Registrant)
|
registrant = contact.becomes(Registrant)
|
||||||
|
|
||||||
# 8388608 bites == 8 mb
|
# 8388608 bytes == 8 mb
|
||||||
bignum_legaldoc = 't' * 8388608
|
bignum_legaldoc = 't' * (8388608 + 1)
|
||||||
bignum_legaldoc+= "t"
|
|
||||||
|
|
||||||
request_xml = <<-XML
|
request_xml = <<-XML
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
@ -109,7 +108,7 @@ class EppDomainCreateBaseTest < EppTestCase
|
||||||
post epp_create_path, params: { frame: request_xml },
|
post epp_create_path, params: { frame: request_xml },
|
||||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_epp_response :parameter_value_policy_error
|
assert_epp_response :parameter_value_policy_error
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -118,7 +117,7 @@ class EppDomainCreateBaseTest < EppTestCase
|
||||||
contact = contacts(:john)
|
contact = contacts(:john)
|
||||||
registrant = contact.becomes(Registrant)
|
registrant = contact.becomes(Registrant)
|
||||||
|
|
||||||
# 8388608 bites == 8 mb
|
# 8388608 bytes == 8 mb
|
||||||
bignum_legaldoc = 't' * 8388608
|
bignum_legaldoc = 't' * 8388608
|
||||||
|
|
||||||
request_xml = <<-XML
|
request_xml = <<-XML
|
||||||
|
@ -139,12 +138,12 @@ class EppDomainCreateBaseTest < EppTestCase
|
||||||
</command>
|
</command>
|
||||||
</epp>
|
</epp>
|
||||||
XML
|
XML
|
||||||
|
|
||||||
assert_difference 'Domain.count' do
|
assert_difference 'Domain.count' do
|
||||||
post epp_create_path, params: { frame: request_xml },
|
post epp_create_path, params: { frame: request_xml },
|
||||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_epp_response :completed_successfully
|
assert_epp_response :completed_successfully
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue