Commit 1a7b43b6 authored by Nick Thomas's avatar Nick Thomas

Merge branch '239179-new-model-for-finding-evidences-response' into 'master'

Add FindingEvidenceResponse model

See merge request gitlab-org/gitlab!59563
parents 3ca18ac9 788b4ce3
---
title: Add VulnerabiltyFindingEvidenceResponse model
merge_request: 59563
author:
type: changed
# frozen_string_literal: true
class CreateVulnerabilityFindingEvidenceResponses < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
create_table_with_constraints :vulnerability_finding_evidence_responses do |t|
t.timestamps_with_timezone null: false
t.references :vulnerability_finding_evidence, index: { name: 'finding_evidence_responses_on_finding_evidences_id' }, null: false, foreign_key: { on_delete: :cascade }
t.integer :status_code
t.text :reason_phrase
t.text_limit :reason_phrase, 2048
end
end
def down
with_lock_retries do
drop_table :vulnerability_finding_evidence_responses
end
end
end
26f3978600808eae8396e0d5292bae95feca52ff3e44a019c04bd9708f27cc84
\ No newline at end of file
......@@ -18601,6 +18601,25 @@ CREATE SEQUENCE vulnerability_finding_evidence_requests_id_seq
ALTER SEQUENCE vulnerability_finding_evidence_requests_id_seq OWNED BY vulnerability_finding_evidence_requests.id;
CREATE TABLE vulnerability_finding_evidence_responses (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
vulnerability_finding_evidence_id bigint NOT NULL,
status_code integer,
reason_phrase text,
CONSTRAINT check_58b124ab48 CHECK ((char_length(reason_phrase) <= 2048))
);
CREATE SEQUENCE vulnerability_finding_evidence_responses_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE vulnerability_finding_evidence_responses_id_seq OWNED BY vulnerability_finding_evidence_responses.id;
CREATE TABLE vulnerability_finding_evidences (
id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
......@@ -19908,6 +19927,8 @@ ALTER TABLE ONLY vulnerability_feedback ALTER COLUMN id SET DEFAULT nextval('vul
ALTER TABLE ONLY vulnerability_finding_evidence_requests ALTER COLUMN id SET DEFAULT nextval('vulnerability_finding_evidence_requests_id_seq'::regclass);
ALTER TABLE ONLY vulnerability_finding_evidence_responses ALTER COLUMN id SET DEFAULT nextval('vulnerability_finding_evidence_responses_id_seq'::regclass);
ALTER TABLE ONLY vulnerability_finding_evidences ALTER COLUMN id SET DEFAULT nextval('vulnerability_finding_evidences_id_seq'::regclass);
ALTER TABLE ONLY vulnerability_finding_links ALTER COLUMN id SET DEFAULT nextval('vulnerability_finding_links_id_seq'::regclass);
......@@ -21541,6 +21562,9 @@ ALTER TABLE ONLY vulnerability_feedback
ALTER TABLE ONLY vulnerability_finding_evidence_requests
ADD CONSTRAINT vulnerability_finding_evidence_requests_pkey PRIMARY KEY (id);
ALTER TABLE ONLY vulnerability_finding_evidence_responses
ADD CONSTRAINT vulnerability_finding_evidence_responses_pkey PRIMARY KEY (id);
ALTER TABLE ONLY vulnerability_finding_evidences
ADD CONSTRAINT vulnerability_finding_evidences_pkey PRIMARY KEY (id);
......@@ -21779,6 +21803,8 @@ CREATE INDEX expired_artifacts_temp_index ON ci_job_artifacts USING btree (id, c
CREATE INDEX finding_evidence_requests_on_finding_evidence_id ON vulnerability_finding_evidence_requests USING btree (vulnerability_finding_evidence_id);
CREATE INDEX finding_evidence_responses_on_finding_evidences_id ON vulnerability_finding_evidence_responses USING btree (vulnerability_finding_evidence_id);
CREATE INDEX finding_evidences_on_vulnerability_occurrence_id ON vulnerability_finding_evidences USING btree (vulnerability_occurrence_id);
CREATE INDEX finding_links_on_vulnerability_occurrence_id ON vulnerability_finding_links USING btree (vulnerability_occurrence_id);
......@@ -25691,6 +25717,9 @@ ALTER TABLE ONLY service_desk_settings
ALTER TABLE ONLY saml_group_links
ADD CONSTRAINT fk_rails_22e312c530 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
ALTER TABLE ONLY vulnerability_finding_evidence_responses
ADD CONSTRAINT fk_rails_2390a09723 FOREIGN KEY (vulnerability_finding_evidence_id) REFERENCES vulnerability_finding_evidences(id) ON DELETE CASCADE;
ALTER TABLE ONLY dast_profiles
ADD CONSTRAINT fk_rails_23cae5abe1 FOREIGN KEY (dast_scanner_profile_id) REFERENCES dast_scanner_profiles(id) ON DELETE CASCADE;
......@@ -7,5 +7,6 @@ module Vulnerabilities
belongs_to :finding, class_name: 'Vulnerabilities::Finding', inverse_of: :finding_evidences, foreign_key: 'vulnerability_occurrence_id', optional: false
has_many :requests, class_name: 'Vulnerabilities::FindingEvidenceRequest', inverse_of: :finding_evidence, foreign_key: 'vulnerability_finding_evidence_id'
has_many :responses, class_name: 'Vulnerabilities::FindingEvidenceResponse', inverse_of: :finding_evidence, foreign_key: 'vulnerability_finding_evidence_id'
end
end
# frozen_string_literal: true
module Vulnerabilities
class FindingEvidenceResponse < ApplicationRecord
self.table_name = 'vulnerability_finding_evidence_responses'
belongs_to :finding_evidence, class_name: 'Vulnerabilities::FindingEvidence', inverse_of: :responses, foreign_key: 'vulnerability_finding_evidence_id', optional: false
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Vulnerabilities::FindingEvidenceResponse do
it { is_expected.to belong_to(:finding_evidence).class_name('Vulnerabilities::FindingEvidence').inverse_of(:responses).required }
end
......@@ -5,4 +5,5 @@ require 'spec_helper'
RSpec.describe Vulnerabilities::FindingEvidence do
it { is_expected.to belong_to(:finding).class_name('Vulnerabilities::Finding').required }
it { is_expected.to have_many(:requests).class_name('Vulnerabilities::FindingEvidenceRequest').with_foreign_key('vulnerability_finding_evidence_id').inverse_of(:finding_evidence) }
it { is_expected.to have_many(:responses).class_name('Vulnerabilities::FindingEvidenceResponse').with_foreign_key('vulnerability_finding_evidence_id').inverse_of(:finding_evidence) }
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