Welcome to mirror list, hosted at ThFree Co, Russian Federation.

update_default_scan_method_of_dast_site_profile_spec.rb « migrations « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ac7a4171063ca91b7c06c00eb7dead0bd8614107 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# frozen_string_literal: true

require 'spec_helper'
require_migration!

RSpec.describe UpdateDefaultScanMethodOfDastSiteProfile, feature_category: :dynamic_application_security_testing do
  let(:namespaces) { table(:namespaces) }
  let(:projects) { table(:projects) }
  let(:dast_sites) { table(:dast_sites) }
  let(:dast_site_profiles) { table(:dast_site_profiles) }

  before do
    namespace = namespaces.create!(name: 'test', path: 'test')
    project = projects.create!(id: 12, namespace_id: namespace.id, name: 'gitlab', path: 'gitlab')
    dast_site = dast_sites.create!(id: 1, url: 'https://www.gitlab.com', project_id: project.id)

    dast_site_profiles.create!(id: 1, project_id: project.id, dast_site_id: dast_site.id,
                               name: "#{FFaker::Product.product_name.truncate(192)} #{SecureRandom.hex(4)} - 0",
                               scan_method: 0, target_type: 0)

    dast_site_profiles.create!(id: 2, project_id: project.id, dast_site_id: dast_site.id,
                               name: "#{FFaker::Product.product_name.truncate(192)} #{SecureRandom.hex(4)} - 1",
                               scan_method: 0, target_type: 1)
  end

  it 'updates the scan_method to 1 for profiles with target_type 1' do
    migrate!

    expect(dast_site_profiles.where(scan_method: 1).count).to eq 1
    expect(dast_site_profiles.where(scan_method: 0).count).to eq 1
  end
end