mirror of
https://github.com/internetee/registry.git
synced 2025-06-12 07:34:45 +02:00
Fix test to have file at Base64, fix size validation
This commit is contained in:
parent
31a463c587
commit
0f58e47513
4 changed files with 15 additions and 11 deletions
|
@ -62,17 +62,13 @@ 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: error_code(error),
|
code: 2001,
|
||||||
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 > LegalDocument::MAX_BODY_SIZE ? 2306 : 2001
|
|
||||||
end
|
|
||||||
|
|
||||||
def schema
|
def schema
|
||||||
EPP_ALL_SCHEMA
|
EPP_ALL_SCHEMA
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,14 +21,19 @@ class LegalDocument < ApplicationRecord
|
||||||
|
|
||||||
def epp_code_map
|
def epp_code_map
|
||||||
{
|
{
|
||||||
'2306' => [
|
'2306' => [
|
||||||
[:body, :length]
|
%i[body length_more_than],
|
||||||
]
|
%i[body length_less_than],
|
||||||
|
]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def val_body_length
|
def val_body_length
|
||||||
errors.add(:body, :length) if body.nil? || body.size < MIN_BODY_SIZE
|
if body.nil? || body.size < MIN_BODY_SIZE
|
||||||
|
errors.add(:body, :length_more_than)
|
||||||
|
elsif body.size > MAX_BODY_SIZE
|
||||||
|
errors.add(:body, :length_less_than)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_to_filesystem
|
def save_to_filesystem
|
||||||
|
|
|
@ -138,7 +138,8 @@ en:
|
||||||
legal_document:
|
legal_document:
|
||||||
attributes:
|
attributes:
|
||||||
body:
|
body:
|
||||||
length: 'Parameter value policy error: legalDocument size should be more than 3kB'
|
length_more_than: 'Parameter value policy error: legalDocument size should be more than 3kB'
|
||||||
|
length_less_than: 'Parameter value policy error: legalDocument size should be less than 8mB'
|
||||||
|
|
||||||
|
|
||||||
attributes:
|
attributes:
|
||||||
|
|
|
@ -82,7 +82,7 @@ class EppDomainCreateBaseTest < EppTestCase
|
||||||
contact = contacts(:john)
|
contact = contacts(:john)
|
||||||
registrant = contact.becomes(Registrant)
|
registrant = contact.becomes(Registrant)
|
||||||
|
|
||||||
bignum_legaldoc = 't' * (LegalDocument::MAX_BODY_SIZE + 1)
|
bignum_legaldoc = Base64.encode64('t' * (LegalDocument::MAX_BODY_SIZE + 1)).gsub(/\n/,"")
|
||||||
|
|
||||||
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,6 +109,8 @@ class EppDomainCreateBaseTest < EppTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_epp_response :parameter_value_policy_error
|
assert_epp_response :parameter_value_policy_error
|
||||||
|
error_description = 'legalDocument size should be less than 8mB'
|
||||||
|
assert response.body.include? error_description
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_upper_limit_of_value_legal_document
|
def test_upper_limit_of_value_legal_document
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue