Merge pull request #1881 from internetee/1880-returns-command-failed-for-transfer-request-with-invalid-legaldoc

Fix error message on too big LegalDoc size in epp
This commit is contained in:
Timo Võhmar 2021-04-30 18:15:19 +03:00 committed by GitHub
commit 51e5439fa0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 114 additions and 5 deletions

View file

@ -1,6 +1,7 @@
class LegalDocument < ApplicationRecord
include EppErrors
MIN_BODY_SIZE = (1.37 * 3.kilobytes).ceil
MAX_BODY_SIZE = 8.megabytes
if ENV['legal_document_types'].present?
TYPES = ENV['legal_document_types'].split(',').map(&:strip)
@ -20,14 +21,19 @@ class LegalDocument < ApplicationRecord
def epp_code_map
{
'2306' => [
[:body, :length]
]
'2308' => [
%i[body length_more_than],
%i[body length_less_than],
]
}
end
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
def save_to_filesystem