Commit 61a98854 authored by Sean McGivern's avatar Sean McGivern

Merge branch '267489-finding-evidence-details-supmsg-array' into 'master'

Change Finding Evidence Supporting Messages to array

See merge request gitlab-org/gitlab!67620
parents 4a8d23ee 0a290327
......@@ -5,13 +5,32 @@ module Vulnerabilities
class Evidence < ApplicationRecord
self.table_name = 'vulnerability_finding_evidences'
belongs_to :finding, class_name: 'Vulnerabilities::Finding', inverse_of: :evidence, foreign_key: 'vulnerability_occurrence_id', optional: false
belongs_to :finding,
class_name: 'Vulnerabilities::Finding',
inverse_of: :evidence,
foreign_key: 'vulnerability_occurrence_id',
optional: false
has_one :request, class_name: 'Vulnerabilities::Finding::Evidence::Request', inverse_of: :evidence, foreign_key: 'vulnerability_finding_evidence_id'
has_one :response, class_name: 'Vulnerabilities::Finding::Evidence::Response', inverse_of: :evidence, foreign_key: 'vulnerability_finding_evidence_id'
has_one :supporting_message, class_name: 'Vulnerabilities::Finding::Evidence::SupportingMessage', inverse_of: :evidence, foreign_key: 'vulnerability_finding_evidence_id'
has_one :source, class_name: 'Vulnerabilities::Finding::Evidence::Source', inverse_of: :evidence, foreign_key: 'vulnerability_finding_evidence_id'
has_many :assets, class_name: 'Vulnerabilities::Finding::Evidence::Asset', inverse_of: :evidence, foreign_key: 'vulnerability_finding_evidence_id'
has_one :request,
class_name: 'Vulnerabilities::Finding::Evidence::Request',
inverse_of: :evidence,
foreign_key: 'vulnerability_finding_evidence_id'
has_one :response,
class_name: 'Vulnerabilities::Finding::Evidence::Response',
inverse_of: :evidence,
foreign_key: 'vulnerability_finding_evidence_id'
has_one :source,
class_name: 'Vulnerabilities::Finding::Evidence::Source',
inverse_of: :evidence,
foreign_key: 'vulnerability_finding_evidence_id'
has_many :supporting_messages,
class_name: 'Vulnerabilities::Finding::Evidence::SupportingMessage',
inverse_of: :evidence,
foreign_key: 'vulnerability_finding_evidence_id'
has_many :assets,
class_name: 'Vulnerabilities::Finding::Evidence::Asset',
inverse_of: :evidence,
foreign_key: 'vulnerability_finding_evidence_id'
validates :summary, length: { maximum: 8_000_000 }
end
......
......@@ -6,10 +6,20 @@ module Vulnerabilities
class SupportingMessage < ApplicationRecord
self.table_name = 'vulnerability_finding_evidence_supporting_messages'
belongs_to :evidence, class_name: 'Vulnerabilities::Finding::Evidence', inverse_of: :supporting_message, foreign_key: 'vulnerability_finding_evidence_id', optional: false
belongs_to :evidence,
class_name: 'Vulnerabilities::Finding::Evidence',
inverse_of: :supporting_messages,
foreign_key: 'vulnerability_finding_evidence_id',
optional: false
has_one :request, class_name: 'Vulnerabilities::Finding::Evidence::Request', inverse_of: :supporting_message, foreign_key: 'vulnerability_finding_evidence_supporting_message_id'
has_one :response, class_name: 'Vulnerabilities::Finding::Evidence::Response', inverse_of: :supporting_message, foreign_key: 'vulnerability_finding_evidence_supporting_message_id'
has_one :request,
class_name: 'Vulnerabilities::Finding::Evidence::Request',
inverse_of: :supporting_message,
foreign_key: 'vulnerability_finding_evidence_supporting_message_id'
has_one :response,
class_name: 'Vulnerabilities::Finding::Evidence::Response',
inverse_of: :supporting_message,
foreign_key: 'vulnerability_finding_evidence_supporting_message_id'
validates :name, length: { maximum: 2048 }, presence: true
end
......
......@@ -3,9 +3,27 @@
require 'spec_helper'
RSpec.describe Vulnerabilities::Finding::Evidence::SupportingMessage do
it { is_expected.to belong_to(:evidence).class_name('Vulnerabilities::Finding::Evidence').inverse_of(:supporting_message).required }
it { is_expected.to have_one(:request).class_name('Vulnerabilities::Finding::Evidence::Request').with_foreign_key('vulnerability_finding_evidence_supporting_message_id').inverse_of(:supporting_message) }
it { is_expected.to have_one(:response).class_name('Vulnerabilities::Finding::Evidence::Response').with_foreign_key('vulnerability_finding_evidence_supporting_message_id').inverse_of(:supporting_message) }
it {
is_expected
.to belong_to(:evidence)
.class_name('Vulnerabilities::Finding::Evidence')
.inverse_of(:supporting_messages)
.required
}
it {
is_expected
.to have_one(:request)
.class_name('Vulnerabilities::Finding::Evidence::Request')
.with_foreign_key('vulnerability_finding_evidence_supporting_message_id')
.inverse_of(:supporting_message)
}
it {
is_expected
.to have_one(:response)
.class_name('Vulnerabilities::Finding::Evidence::Response')
.with_foreign_key('vulnerability_finding_evidence_supporting_message_id')
.inverse_of(:supporting_message)
}
it { is_expected.to validate_length_of(:name).is_at_most(2048) }
it { is_expected.to validate_presence_of(:name) }
......
......@@ -3,12 +3,47 @@
require 'spec_helper'
RSpec.describe Vulnerabilities::Finding::Evidence do
it { is_expected.to belong_to(:finding).class_name('Vulnerabilities::Finding').required }
it { is_expected.to have_one(:request).class_name('Vulnerabilities::Finding::Evidence::Request').with_foreign_key('vulnerability_finding_evidence_id').inverse_of(:evidence) }
it { is_expected.to have_one(:response).class_name('Vulnerabilities::Finding::Evidence::Response').with_foreign_key('vulnerability_finding_evidence_id').inverse_of(:evidence) }
it { is_expected.to have_one(:supporting_message).class_name('Vulnerabilities::Finding::Evidence::SupportingMessage').with_foreign_key('vulnerability_finding_evidence_id').inverse_of(:evidence) }
it { is_expected.to have_one(:source).class_name('Vulnerabilities::Finding::Evidence::Source').with_foreign_key('vulnerability_finding_evidence_id').inverse_of(:evidence) }
it { is_expected.to have_many(:assets).class_name('Vulnerabilities::Finding::Evidence::Asset').with_foreign_key('vulnerability_finding_evidence_id').inverse_of(:evidence) }
it {
is_expected
.to belong_to(:finding)
.class_name('Vulnerabilities::Finding')
.required
}
it {
is_expected
.to have_one(:request)
.class_name('Vulnerabilities::Finding::Evidence::Request')
.with_foreign_key('vulnerability_finding_evidence_id')
.inverse_of(:evidence)
}
it {
is_expected
.to have_one(:response)
.class_name('Vulnerabilities::Finding::Evidence::Response')
.with_foreign_key('vulnerability_finding_evidence_id')
.inverse_of(:evidence)
}
it {
is_expected
.to have_one(:source)
.class_name('Vulnerabilities::Finding::Evidence::Source')
.with_foreign_key('vulnerability_finding_evidence_id')
.inverse_of(:evidence)
}
it {
is_expected
.to have_many(:supporting_messages)
.class_name('Vulnerabilities::Finding::Evidence::SupportingMessage')
.with_foreign_key('vulnerability_finding_evidence_id')
.inverse_of(:evidence)
}
it {
is_expected
.to have_many(:assets)
.class_name('Vulnerabilities::Finding::Evidence::Asset')
.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
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