Commit e7d5b2c6 authored by Jonathan Schafer's avatar Jonathan Schafer Committed by Vasilii Iakliushin

Add limits to ruby to match DB limits

Added tests
parent 74b7bc04
......@@ -9,6 +9,8 @@ module Vulnerabilities
has_one :request, class_name: 'Vulnerabilities::Findings::Evidences::Request', inverse_of: :evidence, foreign_key: 'vulnerability_finding_evidence_id'
has_one :response, class_name: 'Vulnerabilities::Findings::Evidences::Response', inverse_of: :evidence, foreign_key: 'vulnerability_finding_evidence_id'
validates :summary, length: { maximum: 8_000_000 }
end
end
end
......@@ -7,6 +7,10 @@ module Vulnerabilities
self.table_name = 'vulnerability_finding_evidence_requests'
belongs_to :evidence, class_name: 'Vulnerabilities::Findings::Evidence', inverse_of: :request, foreign_key: 'vulnerability_finding_evidence_id', optional: false
validates :method, length: { maximum: 32 }
validates :url, length: { maximum: 2048 }
validates :body, length: { maximum: 2048 }
end
end
end
......
......@@ -7,6 +7,9 @@ module Vulnerabilities
self.table_name = 'vulnerability_finding_evidence_responses'
belongs_to :evidence, class_name: 'Vulnerabilities::Findings::Evidence', inverse_of: :response, foreign_key: 'vulnerability_finding_evidence_id', optional: false
validates :reason_phrase, length: { maximum: 2048 }
validates :body, length: { maximum: 2048 }
end
end
end
......
......@@ -6,4 +6,6 @@ RSpec.describe Vulnerabilities::Findings::Evidence do
it { is_expected.to belong_to(:finding).class_name('Vulnerabilities::Finding').required }
it { is_expected.to have_one(:request).class_name('Vulnerabilities::Findings::Evidences::Request').with_foreign_key('vulnerability_finding_evidence_id').inverse_of(:evidence) }
it { is_expected.to have_one(:response).class_name('Vulnerabilities::Findings::Evidences::Response').with_foreign_key('vulnerability_finding_evidence_id').inverse_of(:evidence) }
it { is_expected.to validate_length_of(:summary).is_at_most(8_000_000) }
end
......@@ -4,4 +4,8 @@ require 'spec_helper'
RSpec.describe Vulnerabilities::Findings::Evidences::Request do
it { is_expected.to belong_to(:evidence).class_name('Vulnerabilities::Findings::Evidence').inverse_of(:request).required }
it { is_expected.to validate_length_of(:method).is_at_most(32) }
it { is_expected.to validate_length_of(:url).is_at_most(2048) }
it { is_expected.to validate_length_of(:body).is_at_most(2048) }
end
......@@ -4,4 +4,7 @@ require 'spec_helper'
RSpec.describe Vulnerabilities::Findings::Evidences::Response do
it { is_expected.to belong_to(:evidence).class_name('Vulnerabilities::Findings::Evidence').inverse_of(:response).required }
it { is_expected.to validate_length_of(:reason_phrase).is_at_most(2048) }
it { is_expected.to validate_length_of(:body).is_at_most(2048) }
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment