diff options
Diffstat (limited to 'spec/migrations/20211116111644_schedule_remove_occurrence_pipelines_and_duplicate_vulnerabilities_findings_spec.rb')
-rw-r--r-- | spec/migrations/20211116111644_schedule_remove_occurrence_pipelines_and_duplicate_vulnerabilities_findings_spec.rb | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/spec/migrations/20211116111644_schedule_remove_occurrence_pipelines_and_duplicate_vulnerabilities_findings_spec.rb b/spec/migrations/20211116111644_schedule_remove_occurrence_pipelines_and_duplicate_vulnerabilities_findings_spec.rb index cf6a033b4b8..18513656029 100644 --- a/spec/migrations/20211116111644_schedule_remove_occurrence_pipelines_and_duplicate_vulnerabilities_findings_spec.rb +++ b/spec/migrations/20211116111644_schedule_remove_occurrence_pipelines_and_duplicate_vulnerabilities_findings_spec.rb @@ -4,23 +4,23 @@ require 'spec_helper' require_migration! RSpec.describe ScheduleRemoveOccurrencePipelinesAndDuplicateVulnerabilitiesFindings, - :suppress_gitlab_schemas_validate_connection, :migration do - let_it_be(:background_migration_jobs) { table(:background_migration_jobs) } - let_it_be(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') } - let_it_be(:users) { table(:users) } - let_it_be(:user) { create_user! } - let_it_be(:project) { table(:projects).create!(id: 14219619, namespace_id: namespace.id) } - let_it_be(:pipelines) { table(:ci_pipelines) } - let_it_be(:scanners) { table(:vulnerability_scanners) } - let_it_be(:scanner1) { scanners.create!(project_id: project.id, external_id: 'test 1', name: 'test scanner 1') } - let_it_be(:scanner2) { scanners.create!(project_id: project.id, external_id: 'test 2', name: 'test scanner 2') } - let_it_be(:scanner3) { scanners.create!(project_id: project.id, external_id: 'test 3', name: 'test scanner 3') } - let_it_be(:unrelated_scanner) { scanners.create!(project_id: project.id, external_id: 'unreleated_scanner', name: 'unrelated scanner') } - let_it_be(:vulnerabilities) { table(:vulnerabilities) } - let_it_be(:vulnerability_findings) { table(:vulnerability_occurrences) } - let_it_be(:vulnerability_finding_pipelines) { table(:vulnerability_occurrence_pipelines) } - let_it_be(:vulnerability_identifiers) { table(:vulnerability_identifiers) } - let_it_be(:vulnerability_identifier) do + :suppress_gitlab_schemas_validate_connection, :migration, feature_category: :vulnerability_management do + let!(:background_migration_jobs) { table(:background_migration_jobs) } + let!(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') } + let!(:users) { table(:users) } + let!(:user) { create_user! } + let!(:project) { table(:projects).create!(id: 14219619, namespace_id: namespace.id) } + let!(:pipelines) { table(:ci_pipelines) } + let!(:scanners) { table(:vulnerability_scanners) } + let!(:scanner1) { scanners.create!(project_id: project.id, external_id: 'test 1', name: 'test scanner 1') } + let!(:scanner2) { scanners.create!(project_id: project.id, external_id: 'test 2', name: 'test scanner 2') } + let!(:scanner3) { scanners.create!(project_id: project.id, external_id: 'test 3', name: 'test scanner 3') } + let!(:unrelated_scanner) { scanners.create!(project_id: project.id, external_id: 'unreleated_scanner', name: 'unrelated scanner') } + let!(:vulnerabilities) { table(:vulnerabilities) } + let!(:vulnerability_findings) { table(:vulnerability_occurrences) } + let!(:vulnerability_finding_pipelines) { table(:vulnerability_occurrence_pipelines) } + let!(:vulnerability_identifiers) { table(:vulnerability_identifiers) } + let!(:vulnerability_identifier) do vulnerability_identifiers.create!( id: 1244459, project_id: project.id, @@ -30,14 +30,14 @@ RSpec.describe ScheduleRemoveOccurrencePipelinesAndDuplicateVulnerabilitiesFindi name: 'vulnerability identifier') end - let_it_be(:vulnerability_for_first_duplicate) do + let!(:vulnerability_for_first_duplicate) do create_vulnerability!( project_id: project.id, author_id: user.id ) end - let_it_be(:first_finding_duplicate) do + let!(:first_finding_duplicate) do create_finding!( id: 5606961, uuid: "bd95c085-71aa-51d7-9bb6-08ae669c262e", @@ -50,14 +50,14 @@ RSpec.describe ScheduleRemoveOccurrencePipelinesAndDuplicateVulnerabilitiesFindi ) end - let_it_be(:vulnerability_for_second_duplicate) do + let!(:vulnerability_for_second_duplicate) do create_vulnerability!( project_id: project.id, author_id: user.id ) end - let_it_be(:second_finding_duplicate) do + let!(:second_finding_duplicate) do create_finding!( id: 8765432, uuid: "5b714f58-1176-5b26-8fd5-e11dfcb031b5", @@ -70,14 +70,14 @@ RSpec.describe ScheduleRemoveOccurrencePipelinesAndDuplicateVulnerabilitiesFindi ) end - let_it_be(:vulnerability_for_third_duplicate) do + let!(:vulnerability_for_third_duplicate) do create_vulnerability!( project_id: project.id, author_id: user.id ) end - let_it_be(:third_finding_duplicate) do + let!(:third_finding_duplicate) do create_finding!( id: 8832995, uuid: "cfe435fa-b25b-5199-a56d-7b007cc9e2d4", @@ -90,10 +90,9 @@ RSpec.describe ScheduleRemoveOccurrencePipelinesAndDuplicateVulnerabilitiesFindi ) end - let_it_be(:unrelated_finding) do + let!(:unrelated_finding) do create_finding!( id: 9999999, - uuid: "unreleated_finding", vulnerability_id: nil, report_type: 1, location_fingerprint: 'random_location_fingerprint', @@ -149,11 +148,10 @@ RSpec.describe ScheduleRemoveOccurrencePipelinesAndDuplicateVulnerabilitiesFindi # rubocop:disable Metrics/ParameterLists def create_finding!( - id: nil, - vulnerability_id:, project_id:, scanner_id:, primary_identifier_id:, + vulnerability_id:, project_id:, scanner_id:, primary_identifier_id:, id: nil, name: "test", severity: 7, confidence: 7, report_type: 0, project_fingerprint: '123qweasdzxc', location_fingerprint: 'test', - metadata_version: 'test', raw_metadata: 'test', uuid: 'test') + metadata_version: 'test', raw_metadata: 'test', uuid: SecureRandom.uuid) params = { vulnerability_id: vulnerability_id, project_id: project_id, |