Commit 0ab60c20 authored by Alan Paruszewski's avatar Alan Paruszewski

Remove vulnerability occurrence factory alias

This change removes vulnerabilities_occurrence alias from finding
factory and updates all specs to use new name.
parent cf605972
...@@ -67,7 +67,7 @@ class Gitlab::Seeder::Vulnerabilities ...@@ -67,7 +67,7 @@ class Gitlab::Seeder::Vulnerabilities
def create_occurrence(vulnerability, rank, primary_identifier) def create_occurrence(vulnerability, rank, primary_identifier)
scanner = FactoryBot.create(:vulnerabilities_scanner, project: vulnerability.project) scanner = FactoryBot.create(:vulnerabilities_scanner, project: vulnerability.project)
FactoryBot.create( FactoryBot.create(
:vulnerabilities_occurrence, :vulnerabilities_finding,
project: project, project: project,
vulnerability: vulnerability, vulnerability: vulnerability,
scanner: scanner, scanner: scanner,
......
...@@ -24,7 +24,7 @@ RSpec.describe Projects::Security::VulnerabilitiesController do ...@@ -24,7 +24,7 @@ RSpec.describe Projects::Security::VulnerabilitiesController do
end end
context "when there's an attached pipeline" do context "when there's an attached pipeline" do
let_it_be(:finding) { create(:vulnerabilities_occurrence, vulnerability: vulnerability, pipelines: [pipeline]) } let_it_be(:finding) { create(:vulnerabilities_finding, vulnerability: vulnerability, pipelines: [pipeline]) }
it 'renders the vulnerability page' do it 'renders the vulnerability page' do
show_vulnerability show_vulnerability
...@@ -42,7 +42,7 @@ RSpec.describe Projects::Security::VulnerabilitiesController do ...@@ -42,7 +42,7 @@ RSpec.describe Projects::Security::VulnerabilitiesController do
end end
context "when there's no attached pipeline" do context "when there's no attached pipeline" do
let_it_be(:finding) { create(:vulnerabilities_occurrence, vulnerability: vulnerability) } let_it_be(:finding) { create(:vulnerabilities_finding, vulnerability: vulnerability) }
it 'renders the vulnerability page' do it 'renders the vulnerability page' do
show_vulnerability show_vulnerability
......
...@@ -25,7 +25,7 @@ FactoryBot.define do ...@@ -25,7 +25,7 @@ FactoryBot.define do
end end
end end
factory :vulnerabilities_finding, class: 'Vulnerabilities::Finding', aliases: [:vulnerabilities_occurrence] do factory :vulnerabilities_finding, class: 'Vulnerabilities::Finding' do
name { 'Cipher with no integrity' } name { 'Cipher with no integrity' }
project project
sequence(:uuid) { generate(:vulnerability_finding_uuid) } sequence(:uuid) { generate(:vulnerability_finding_uuid) }
......
...@@ -15,10 +15,10 @@ RSpec.describe Resolvers::Vulnerabilities::ScannersResolver do ...@@ -15,10 +15,10 @@ RSpec.describe Resolvers::Vulnerabilities::ScannersResolver do
let_it_be(:user) { create(:user, security_dashboard_projects: [project_with_no_group]) } let_it_be(:user) { create(:user, security_dashboard_projects: [project_with_no_group]) }
let_it_be(:vulnerability_scanner_1) { create(:vulnerabilities_scanner, project: project) } let_it_be(:vulnerability_scanner_1) { create(:vulnerabilities_scanner, project: project) }
let_it_be(:finding_1) { create(:vulnerabilities_occurrence, project: project, scanner: vulnerability_scanner_1) } let_it_be(:finding_1) { create(:vulnerabilities_finding, project: project, scanner: vulnerability_scanner_1) }
let_it_be(:vulnerability_scanner_2) { create(:vulnerabilities_scanner, project: project_with_no_group) } let_it_be(:vulnerability_scanner_2) { create(:vulnerabilities_scanner, project: project_with_no_group) }
let_it_be(:finding_2) { create(:vulnerabilities_occurrence, project: project_with_no_group, scanner: vulnerability_scanner_2) } let_it_be(:finding_2) { create(:vulnerabilities_finding, project: project_with_no_group, scanner: vulnerability_scanner_2) }
let(:current_user) { user } let(:current_user) { user }
......
...@@ -6,7 +6,7 @@ RSpec.describe VulnerabilitiesHelper do ...@@ -6,7 +6,7 @@ RSpec.describe VulnerabilitiesHelper do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let(:project) { create(:project, :repository, :public) } let(:project) { create(:project, :repository, :public) }
let(:pipeline) { create(:ci_pipeline, :success, project: project) } let(:pipeline) { create(:ci_pipeline, :success, project: project) }
let(:finding) { create(:vulnerabilities_occurrence, pipelines: [pipeline], project: project, severity: :high) } let(:finding) { create(:vulnerabilities_finding, pipelines: [pipeline], project: project, severity: :high) }
let(:vulnerability) { create(:vulnerability, title: "My vulnerability", project: project, findings: [finding]) } let(:vulnerability) { create(:vulnerability, title: "My vulnerability", project: project, findings: [finding]) }
before do before do
......
...@@ -34,7 +34,7 @@ RSpec.describe Gitlab::BackgroundMigration::RemoveUndefinedOccurrenceConfidenceL ...@@ -34,7 +34,7 @@ RSpec.describe Gitlab::BackgroundMigration::RemoveUndefinedOccurrenceConfidenceL
end end
def vuln_params(primary_identifier_id) def vuln_params(primary_identifier_id)
attrs = attributes_for(:vulnerabilities_occurrence) attrs = attributes_for(:vulnerabilities_finding)
{ {
confidence: 0, confidence: 0,
......
...@@ -34,7 +34,7 @@ RSpec.describe Gitlab::BackgroundMigration::RemoveUndefinedOccurrenceSeverityLev ...@@ -34,7 +34,7 @@ RSpec.describe Gitlab::BackgroundMigration::RemoveUndefinedOccurrenceSeverityLev
end end
def vuln_params(primary_identifier_id) def vuln_params(primary_identifier_id)
attrs = attributes_for(:vulnerabilities_occurrence) attrs = attributes_for(:vulnerabilities_finding)
{ {
severity: 0, severity: 0,
......
...@@ -36,7 +36,7 @@ RSpec.describe Gitlab::BackgroundMigration::UpdateVulnerabilityConfidence, schem ...@@ -36,7 +36,7 @@ RSpec.describe Gitlab::BackgroundMigration::UpdateVulnerabilityConfidence, schem
end end
def container_scanning_vuln_params(primary_identifier_id) def container_scanning_vuln_params(primary_identifier_id)
attrs = attributes_for(:vulnerabilities_occurrence) attrs = attributes_for(:vulnerabilities_finding)
{ {
severity: 2, severity: 2,
......
...@@ -8,8 +8,8 @@ RSpec.describe UpdateCsVulnerabilityConfidenceColumn do ...@@ -8,8 +8,8 @@ RSpec.describe UpdateCsVulnerabilityConfidenceColumn do
let(:identifiers) { table(:vulnerability_identifiers) } let(:identifiers) { table(:vulnerability_identifiers) }
let(:scanners) { table(:vulnerability_scanners) } let(:scanners) { table(:vulnerability_scanners) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:vul1) { attributes_for(:vulnerabilities_occurrence, id: 1, report_type: 2, confidence: 5) } let(:vul1) { attributes_for(:vulnerabilities_finding, id: 1, report_type: 2, confidence: 5) }
let(:vul2) { attributes_for(:vulnerabilities_occurrence, id: 2, report_type: 2, confidence: 5) } let(:vul2) { attributes_for(:vulnerabilities_finding, id: 2, report_type: 2, confidence: 5) }
before do before do
stub_const("#{described_class}::BATCH_SIZE", 2) stub_const("#{described_class}::BATCH_SIZE", 2)
......
...@@ -8,8 +8,8 @@ RSpec.describe UpdateOccurrenceSeverityColumn do ...@@ -8,8 +8,8 @@ RSpec.describe UpdateOccurrenceSeverityColumn do
let(:identifiers) { table(:vulnerability_identifiers) } let(:identifiers) { table(:vulnerability_identifiers) }
let(:scanners) { table(:vulnerability_scanners) } let(:scanners) { table(:vulnerability_scanners) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:vul1) { attributes_for(:vulnerabilities_occurrence, id: 1, report_type: 2, confidence: 5) } let(:vul1) { attributes_for(:vulnerabilities_finding, id: 1, report_type: 2, confidence: 5) }
let(:vul2) { attributes_for(:vulnerabilities_occurrence, id: 2, report_type: 2, confidence: 5) } let(:vul2) { attributes_for(:vulnerabilities_finding, id: 2, report_type: 2, confidence: 5) }
before do before do
stub_const("#{described_class}::BATCH_SIZE", 2) stub_const("#{described_class}::BATCH_SIZE", 2)
......
...@@ -8,8 +8,8 @@ RSpec.describe UpdateUndefinedConfidenceFromOccurrences, :migration do ...@@ -8,8 +8,8 @@ RSpec.describe UpdateUndefinedConfidenceFromOccurrences, :migration do
let(:identifiers) { table(:vulnerability_identifiers) } let(:identifiers) { table(:vulnerability_identifiers) }
let(:scanners) { table(:vulnerability_scanners) } let(:scanners) { table(:vulnerability_scanners) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:vul1) { attributes_for(:vulnerabilities_occurrence, id: 1, report_type: 2, confidence: 5) } let(:vul1) { attributes_for(:vulnerabilities_finding, id: 1, report_type: 2, confidence: 5) }
let(:vul2) { attributes_for(:vulnerabilities_occurrence, id: 2, report_type: 2, confidence: 5) } let(:vul2) { attributes_for(:vulnerabilities_finding, id: 2, report_type: 2, confidence: 5) }
before do before do
stub_const("#{described_class}::BATCH_SIZE", 2) stub_const("#{described_class}::BATCH_SIZE", 2)
......
...@@ -495,8 +495,8 @@ RSpec.describe Vulnerability do ...@@ -495,8 +495,8 @@ RSpec.describe Vulnerability do
describe '#finding' do describe '#finding' do
let_it_be(:project) { create(:project, :with_vulnerability) } let_it_be(:project) { create(:project, :with_vulnerability) }
let_it_be(:vulnerability) { project.vulnerabilities.first } let_it_be(:vulnerability) { project.vulnerabilities.first }
let_it_be(:finding1) { create(:vulnerabilities_occurrence, vulnerability: vulnerability) } let_it_be(:finding1) { create(:vulnerabilities_finding, vulnerability: vulnerability) }
let_it_be(:finding2) { create(:vulnerabilities_occurrence, vulnerability: vulnerability) } let_it_be(:finding2) { create(:vulnerabilities_finding, vulnerability: vulnerability) }
subject { vulnerability.finding } subject { vulnerability.finding }
...@@ -561,7 +561,7 @@ RSpec.describe Vulnerability do ...@@ -561,7 +561,7 @@ RSpec.describe Vulnerability do
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let_it_be(:occurrence) do let_it_be(:occurrence) do
create( create(
:vulnerabilities_occurrence, :vulnerabilities_finding,
report_type: :dependency_scanning, report_type: :dependency_scanning,
project: project project: project
) )
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe Vulnerabilities::FindingPresenter do RSpec.describe Vulnerabilities::FindingPresenter do
let(:presenter) { described_class.new(occurrence) } let(:presenter) { described_class.new(occurrence) }
let(:occurrence) { build_stubbed(:vulnerabilities_occurrence) } let(:occurrence) { build_stubbed(:vulnerabilities_finding) }
describe '#blob_path' do describe '#blob_path' do
subject { presenter.blob_path } subject { presenter.blob_path }
......
...@@ -90,7 +90,7 @@ RSpec.describe 'Query.vulnerabilities.location' do ...@@ -90,7 +90,7 @@ RSpec.describe 'Query.vulnerabilities.location' do
let_it_be(:finding) do let_it_be(:finding) do
create( create(
:vulnerabilities_occurrence, :vulnerabilities_finding,
vulnerability: vulnerability, vulnerability: vulnerability,
raw_metadata: metadata.to_json raw_metadata: metadata.to_json
) )
...@@ -128,7 +128,7 @@ RSpec.describe 'Query.vulnerabilities.location' do ...@@ -128,7 +128,7 @@ RSpec.describe 'Query.vulnerabilities.location' do
let_it_be(:finding) do let_it_be(:finding) do
create( create(
:vulnerabilities_occurrence, :vulnerabilities_finding,
vulnerability: vulnerability, vulnerability: vulnerability,
raw_metadata: metadata.to_json raw_metadata: metadata.to_json
) )
...@@ -163,7 +163,7 @@ RSpec.describe 'Query.vulnerabilities.location' do ...@@ -163,7 +163,7 @@ RSpec.describe 'Query.vulnerabilities.location' do
let_it_be(:finding) do let_it_be(:finding) do
create( create(
:vulnerabilities_occurrence, :vulnerabilities_finding,
vulnerability: vulnerability, vulnerability: vulnerability,
raw_metadata: metadata.to_json raw_metadata: metadata.to_json
) )
...@@ -200,7 +200,7 @@ RSpec.describe 'Query.vulnerabilities.location' do ...@@ -200,7 +200,7 @@ RSpec.describe 'Query.vulnerabilities.location' do
let_it_be(:finding) do let_it_be(:finding) do
create( create(
:vulnerabilities_occurrence, :vulnerabilities_finding,
vulnerability: vulnerability, vulnerability: vulnerability,
raw_metadata: metadata.to_json raw_metadata: metadata.to_json
) )
...@@ -236,7 +236,7 @@ RSpec.describe 'Query.vulnerabilities.location' do ...@@ -236,7 +236,7 @@ RSpec.describe 'Query.vulnerabilities.location' do
let_it_be(:finding) do let_it_be(:finding) do
create( create(
:vulnerabilities_occurrence, :vulnerabilities_finding,
vulnerability: vulnerability, vulnerability: vulnerability,
raw_metadata: metadata.to_json raw_metadata: metadata.to_json
) )
......
...@@ -37,7 +37,7 @@ RSpec.describe 'Query.vulnerabilities.primaryIdentifier' do ...@@ -37,7 +37,7 @@ RSpec.describe 'Query.vulnerabilities.primaryIdentifier' do
let_it_be(:finding) do let_it_be(:finding) do
create( create(
:vulnerabilities_occurrence, :vulnerabilities_finding,
vulnerability: vulnerability, vulnerability: vulnerability,
primary_identifier: primary_identifier primary_identifier: primary_identifier
) )
......
...@@ -34,7 +34,7 @@ RSpec.describe 'Query.vulnerabilities.scanner' do ...@@ -34,7 +34,7 @@ RSpec.describe 'Query.vulnerabilities.scanner' do
let_it_be(:finding) do let_it_be(:finding) do
create( create(
:vulnerabilities_occurrence, :vulnerabilities_finding,
vulnerability: vulnerability, vulnerability: vulnerability,
scanner: vulnerabilities_scanner scanner: vulnerabilities_scanner
) )
......
...@@ -61,7 +61,7 @@ RSpec.describe API::Vulnerabilities do ...@@ -61,7 +61,7 @@ RSpec.describe API::Vulnerabilities do
describe 'GET /vulnerabilities/:id' do describe 'GET /vulnerabilities/:id' do
let_it_be(:project) { create(:project, :with_vulnerabilities) } let_it_be(:project) { create(:project, :with_vulnerabilities) }
let_it_be(:vulnerability) { project.vulnerabilities.first } let_it_be(:vulnerability) { project.vulnerabilities.first }
let_it_be(:finding) { create(:vulnerabilities_occurrence, vulnerability: vulnerability) } let_it_be(:finding) { create(:vulnerabilities_finding, vulnerability: vulnerability) }
let(:vulnerability_id) { vulnerability.id } let(:vulnerability_id) { vulnerability.id }
subject(:get_vulnerability) { get api("/vulnerabilities/#{vulnerability_id}", user) } subject(:get_vulnerability) { get api("/vulnerabilities/#{vulnerability_id}", user) }
...@@ -106,7 +106,7 @@ RSpec.describe API::Vulnerabilities do ...@@ -106,7 +106,7 @@ RSpec.describe API::Vulnerabilities do
describe 'POST /projects/:id/vulnerabilities' do describe 'POST /projects/:id/vulnerabilities' do
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let(:finding) { create(:vulnerabilities_occurrence, project: project) } let(:finding) { create(:vulnerabilities_finding, project: project) }
let(:finding_id) { finding.id } let(:finding_id) { finding.id }
let(:expected_error_messages) { { 'base' => ['finding is not found or is already attached to a vulnerability'] } } let(:expected_error_messages) { { 'base' => ['finding is not found or is already attached to a vulnerability'] } }
...@@ -177,7 +177,7 @@ RSpec.describe API::Vulnerabilities do ...@@ -177,7 +177,7 @@ RSpec.describe API::Vulnerabilities do
describe 'POST /vulnerabilities:id/dismiss' do describe 'POST /vulnerabilities:id/dismiss' do
before do before do
create_list(:vulnerabilities_occurrence, 2, vulnerability: vulnerability, project: vulnerability.project) create_list(:vulnerabilities_finding, 2, vulnerability: vulnerability, project: vulnerability.project)
end end
let_it_be(:project) { create(:project, :with_vulnerabilities) } let_it_be(:project) { create(:project, :with_vulnerabilities) }
...@@ -378,7 +378,7 @@ RSpec.describe API::Vulnerabilities do ...@@ -378,7 +378,7 @@ RSpec.describe API::Vulnerabilities do
describe 'POST /vulnerabilities:id/revert' do describe 'POST /vulnerabilities:id/revert' do
before do before do
create_list(:vulnerabilities_occurrence, 2, vulnerability: vulnerability, project: vulnerability.project) create_list(:vulnerabilities_finding, 2, vulnerability: vulnerability, project: vulnerability.project)
end end
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
......
...@@ -19,7 +19,7 @@ RSpec.describe Vulnerabilities::FindingEntity do ...@@ -19,7 +19,7 @@ RSpec.describe Vulnerabilities::FindingEntity do
let(:occurrence) do let(:occurrence) do
build( build(
:vulnerabilities_occurrence, :vulnerabilities_finding,
scanner: scanner, scanner: scanner,
scan: scan, scan: scan,
project: project, project: project,
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Vulnerabilities::RequestEntity do RSpec.describe Vulnerabilities::RequestEntity do
let(:request) { create(:vulnerabilities_occurrence).evidence[:request] } let(:request) { create(:vulnerabilities_finding).evidence[:request] }
let(:entity) do let(:entity) do
described_class.represent(request) described_class.represent(request)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Vulnerabilities::ResponseEntity do RSpec.describe Vulnerabilities::ResponseEntity do
let(:response) { create(:vulnerabilities_occurrence).evidence[:response] } let(:response) { create(:vulnerabilities_finding).evidence[:response] }
let(:entity) do let(:entity) do
described_class.represent(response) described_class.represent(response)
......
...@@ -9,7 +9,7 @@ RSpec.describe Vulnerabilities::CreateService do ...@@ -9,7 +9,7 @@ RSpec.describe Vulnerabilities::CreateService do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let(:project) { create(:project) } # cannot use let_it_be here: caching causes problems with permission-related tests let(:project) { create(:project) } # cannot use let_it_be here: caching causes problems with permission-related tests
let(:finding) { create(:vulnerabilities_occurrence, project: project) } let(:finding) { create(:vulnerabilities_finding, project: project) }
let(:finding_id) { finding.id } let(:finding_id) { finding.id }
let(:expected_error_messages) { { base: ['finding is not found or is already attached to a vulnerability'] } } let(:expected_error_messages) { { base: ['finding is not found or is already attached to a vulnerability'] } }
...@@ -39,7 +39,7 @@ RSpec.describe Vulnerabilities::CreateService do ...@@ -39,7 +39,7 @@ RSpec.describe Vulnerabilities::CreateService do
end end
context 'and finding is dismissed' do context 'and finding is dismissed' do
let(:finding) { create(:vulnerabilities_occurrence, :with_dismissal_feedback, project: project) } let(:finding) { create(:vulnerabilities_finding, :with_dismissal_feedback, project: project) }
let(:vulnerability) { project.vulnerabilities.last } let(:vulnerability) { project.vulnerabilities.last }
it 'creates a vulnerability in a dismissed state and sets dismissal information' do it 'creates a vulnerability in a dismissed state and sets dismissal information' do
...@@ -67,7 +67,7 @@ RSpec.describe Vulnerabilities::CreateService do ...@@ -67,7 +67,7 @@ RSpec.describe Vulnerabilities::CreateService do
end end
context 'when finding does not belong to the vulnerability project' do context 'when finding does not belong to the vulnerability project' do
let(:finding) { create(:vulnerabilities_occurrence) } let(:finding) { create(:vulnerabilities_finding) }
it 'adds expected error to the response' do it 'adds expected error to the response' do
expect(subject.errors.messages).to eq(expected_error_messages) expect(subject.errors.messages).to eq(expected_error_messages)
......
...@@ -9,7 +9,7 @@ RSpec.describe Vulnerabilities::UpdateService do ...@@ -9,7 +9,7 @@ RSpec.describe Vulnerabilities::UpdateService do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let!(:project) { create(:project) } # cannot use let_it_be here: caching causes problems with permission-related tests let!(:project) { create(:project) } # cannot use let_it_be here: caching causes problems with permission-related tests
let!(:updated_finding) { create(:vulnerabilities_occurrence, project: project, name: 'New title', severity: :critical, confidence: :confirmed, vulnerability: vulnerability) } let!(:updated_finding) { create(:vulnerabilities_finding, project: project, name: 'New title', severity: :critical, confidence: :confirmed, vulnerability: vulnerability) }
let!(:vulnerability) { create(:vulnerability, project: project, severity: :low, severity_overridden: severity_overridden, confidence: :ignore, confidence_overridden: confidence_overridden) } let!(:vulnerability) { create(:vulnerability, project: project, severity: :low, severity_overridden: severity_overridden, confidence: :ignore, confidence_overridden: confidence_overridden) }
let(:severity_overridden) { false } let(:severity_overridden) { false }
......
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