Commit 47d41fea authored by Gabriel Mazetto's avatar Gabriel Mazetto

Merge branch '230937-remove-vuln-occurrences-alias' into 'master'

Remove vulnerability occurrence factory alias

See merge request gitlab-org/gitlab!46007
parents e13e13c0 0ab60c20
......@@ -67,7 +67,7 @@ class Gitlab::Seeder::Vulnerabilities
def create_occurrence(vulnerability, rank, primary_identifier)
scanner = FactoryBot.create(:vulnerabilities_scanner, project: vulnerability.project)
FactoryBot.create(
:vulnerabilities_occurrence,
:vulnerabilities_finding,
project: project,
vulnerability: vulnerability,
scanner: scanner,
......
......@@ -24,7 +24,7 @@ RSpec.describe Projects::Security::VulnerabilitiesController do
end
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
show_vulnerability
......@@ -42,7 +42,7 @@ RSpec.describe Projects::Security::VulnerabilitiesController do
end
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
show_vulnerability
......
......@@ -25,7 +25,7 @@ FactoryBot.define do
end
end
factory :vulnerabilities_finding, class: 'Vulnerabilities::Finding', aliases: [:vulnerabilities_occurrence] do
factory :vulnerabilities_finding, class: 'Vulnerabilities::Finding' do
name { 'Cipher with no integrity' }
project
sequence(:uuid) { generate(:vulnerability_finding_uuid) }
......
......@@ -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(: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(: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 }
......
......@@ -6,7 +6,7 @@ RSpec.describe VulnerabilitiesHelper do
let_it_be(:user) { create(:user) }
let(:project) { create(:project, :repository, :public) }
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]) }
before do
......
......@@ -34,7 +34,7 @@ RSpec.describe Gitlab::BackgroundMigration::RemoveUndefinedOccurrenceConfidenceL
end
def vuln_params(primary_identifier_id)
attrs = attributes_for(:vulnerabilities_occurrence)
attrs = attributes_for(:vulnerabilities_finding)
{
confidence: 0,
......
......@@ -34,7 +34,7 @@ RSpec.describe Gitlab::BackgroundMigration::RemoveUndefinedOccurrenceSeverityLev
end
def vuln_params(primary_identifier_id)
attrs = attributes_for(:vulnerabilities_occurrence)
attrs = attributes_for(:vulnerabilities_finding)
{
severity: 0,
......
......@@ -36,7 +36,7 @@ RSpec.describe Gitlab::BackgroundMigration::UpdateVulnerabilityConfidence, schem
end
def container_scanning_vuln_params(primary_identifier_id)
attrs = attributes_for(:vulnerabilities_occurrence)
attrs = attributes_for(:vulnerabilities_finding)
{
severity: 2,
......
......@@ -8,8 +8,8 @@ RSpec.describe UpdateCsVulnerabilityConfidenceColumn do
let(:identifiers) { table(:vulnerability_identifiers) }
let(:scanners) { table(:vulnerability_scanners) }
let(:projects) { table(:projects) }
let(:vul1) { attributes_for(:vulnerabilities_occurrence, id: 1, report_type: 2, confidence: 5) }
let(:vul2) { attributes_for(:vulnerabilities_occurrence, id: 2, report_type: 2, confidence: 5) }
let(:vul1) { attributes_for(:vulnerabilities_finding, id: 1, report_type: 2, confidence: 5) }
let(:vul2) { attributes_for(:vulnerabilities_finding, id: 2, report_type: 2, confidence: 5) }
before do
stub_const("#{described_class}::BATCH_SIZE", 2)
......
......@@ -8,8 +8,8 @@ RSpec.describe UpdateOccurrenceSeverityColumn do
let(:identifiers) { table(:vulnerability_identifiers) }
let(:scanners) { table(:vulnerability_scanners) }
let(:projects) { table(:projects) }
let(:vul1) { attributes_for(:vulnerabilities_occurrence, id: 1, report_type: 2, confidence: 5) }
let(:vul2) { attributes_for(:vulnerabilities_occurrence, id: 2, report_type: 2, confidence: 5) }
let(:vul1) { attributes_for(:vulnerabilities_finding, id: 1, report_type: 2, confidence: 5) }
let(:vul2) { attributes_for(:vulnerabilities_finding, id: 2, report_type: 2, confidence: 5) }
before do
stub_const("#{described_class}::BATCH_SIZE", 2)
......
......@@ -8,8 +8,8 @@ RSpec.describe UpdateUndefinedConfidenceFromOccurrences, :migration do
let(:identifiers) { table(:vulnerability_identifiers) }
let(:scanners) { table(:vulnerability_scanners) }
let(:projects) { table(:projects) }
let(:vul1) { attributes_for(:vulnerabilities_occurrence, id: 1, report_type: 2, confidence: 5) }
let(:vul2) { attributes_for(:vulnerabilities_occurrence, id: 2, report_type: 2, confidence: 5) }
let(:vul1) { attributes_for(:vulnerabilities_finding, id: 1, report_type: 2, confidence: 5) }
let(:vul2) { attributes_for(:vulnerabilities_finding, id: 2, report_type: 2, confidence: 5) }
before do
stub_const("#{described_class}::BATCH_SIZE", 2)
......
......@@ -495,8 +495,8 @@ RSpec.describe Vulnerability do
describe '#finding' do
let_it_be(:project) { create(:project, :with_vulnerability) }
let_it_be(:vulnerability) { project.vulnerabilities.first }
let_it_be(:finding1) { create(:vulnerabilities_occurrence, vulnerability: vulnerability) }
let_it_be(:finding2) { create(:vulnerabilities_occurrence, vulnerability: vulnerability) }
let_it_be(:finding1) { create(:vulnerabilities_finding, vulnerability: vulnerability) }
let_it_be(:finding2) { create(:vulnerabilities_finding, vulnerability: vulnerability) }
subject { vulnerability.finding }
......@@ -561,7 +561,7 @@ RSpec.describe Vulnerability do
let_it_be(:project) { create(:project) }
let_it_be(:occurrence) do
create(
:vulnerabilities_occurrence,
:vulnerabilities_finding,
report_type: :dependency_scanning,
project: project
)
......
......@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe Vulnerabilities::FindingPresenter do
let(:presenter) { described_class.new(occurrence) }
let(:occurrence) { build_stubbed(:vulnerabilities_occurrence) }
let(:occurrence) { build_stubbed(:vulnerabilities_finding) }
describe '#blob_path' do
subject { presenter.blob_path }
......
......@@ -90,7 +90,7 @@ RSpec.describe 'Query.vulnerabilities.location' do
let_it_be(:finding) do
create(
:vulnerabilities_occurrence,
:vulnerabilities_finding,
vulnerability: vulnerability,
raw_metadata: metadata.to_json
)
......@@ -128,7 +128,7 @@ RSpec.describe 'Query.vulnerabilities.location' do
let_it_be(:finding) do
create(
:vulnerabilities_occurrence,
:vulnerabilities_finding,
vulnerability: vulnerability,
raw_metadata: metadata.to_json
)
......@@ -163,7 +163,7 @@ RSpec.describe 'Query.vulnerabilities.location' do
let_it_be(:finding) do
create(
:vulnerabilities_occurrence,
:vulnerabilities_finding,
vulnerability: vulnerability,
raw_metadata: metadata.to_json
)
......@@ -200,7 +200,7 @@ RSpec.describe 'Query.vulnerabilities.location' do
let_it_be(:finding) do
create(
:vulnerabilities_occurrence,
:vulnerabilities_finding,
vulnerability: vulnerability,
raw_metadata: metadata.to_json
)
......@@ -236,7 +236,7 @@ RSpec.describe 'Query.vulnerabilities.location' do
let_it_be(:finding) do
create(
:vulnerabilities_occurrence,
:vulnerabilities_finding,
vulnerability: vulnerability,
raw_metadata: metadata.to_json
)
......
......@@ -37,7 +37,7 @@ RSpec.describe 'Query.vulnerabilities.primaryIdentifier' do
let_it_be(:finding) do
create(
:vulnerabilities_occurrence,
:vulnerabilities_finding,
vulnerability: vulnerability,
primary_identifier: primary_identifier
)
......
......@@ -34,7 +34,7 @@ RSpec.describe 'Query.vulnerabilities.scanner' do
let_it_be(:finding) do
create(
:vulnerabilities_occurrence,
:vulnerabilities_finding,
vulnerability: vulnerability,
scanner: vulnerabilities_scanner
)
......
......@@ -61,7 +61,7 @@ RSpec.describe API::Vulnerabilities do
describe 'GET /vulnerabilities/:id' do
let_it_be(:project) { create(:project, :with_vulnerabilities) }
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 }
subject(:get_vulnerability) { get api("/vulnerabilities/#{vulnerability_id}", user) }
......@@ -106,7 +106,7 @@ RSpec.describe API::Vulnerabilities do
describe 'POST /projects/:id/vulnerabilities' do
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(:expected_error_messages) { { 'base' => ['finding is not found or is already attached to a vulnerability'] } }
......@@ -177,7 +177,7 @@ RSpec.describe API::Vulnerabilities do
describe 'POST /vulnerabilities:id/dismiss' do
before do
create_list(:vulnerabilities_occurrence, 2, vulnerability: vulnerability, project: vulnerability.project)
create_list(:vulnerabilities_finding, 2, vulnerability: vulnerability, project: vulnerability.project)
end
let_it_be(:project) { create(:project, :with_vulnerabilities) }
......@@ -378,7 +378,7 @@ RSpec.describe API::Vulnerabilities do
describe 'POST /vulnerabilities:id/revert' do
before do
create_list(:vulnerabilities_occurrence, 2, vulnerability: vulnerability, project: vulnerability.project)
create_list(:vulnerabilities_finding, 2, vulnerability: vulnerability, project: vulnerability.project)
end
let_it_be(:project) { create(:project) }
......
......@@ -19,7 +19,7 @@ RSpec.describe Vulnerabilities::FindingEntity do
let(:occurrence) do
build(
:vulnerabilities_occurrence,
:vulnerabilities_finding,
scanner: scanner,
scan: scan,
project: project,
......
......@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe Vulnerabilities::RequestEntity do
let(:request) { create(:vulnerabilities_occurrence).evidence[:request] }
let(:request) { create(:vulnerabilities_finding).evidence[:request] }
let(:entity) do
described_class.represent(request)
......
......@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe Vulnerabilities::ResponseEntity do
let(:response) { create(:vulnerabilities_occurrence).evidence[:response] }
let(:response) { create(:vulnerabilities_finding).evidence[:response] }
let(:entity) do
described_class.represent(response)
......
......@@ -9,7 +9,7 @@ RSpec.describe Vulnerabilities::CreateService do
let_it_be(:user) { create(:user) }
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(:expected_error_messages) { { base: ['finding is not found or is already attached to a vulnerability'] } }
......@@ -39,7 +39,7 @@ RSpec.describe Vulnerabilities::CreateService do
end
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 }
it 'creates a vulnerability in a dismissed state and sets dismissal information' do
......@@ -67,7 +67,7 @@ RSpec.describe Vulnerabilities::CreateService do
end
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
expect(subject.errors.messages).to eq(expected_error_messages)
......
......@@ -9,7 +9,7 @@ RSpec.describe Vulnerabilities::UpdateService do
let_it_be(:user) { create(:user) }
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(: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