Commit a77271f5 authored by Philip Cunningham's avatar Philip Cunningham Committed by Vasilii Iakliushin

Add seeds for DAST Profiles

parent 5e8f3a30
# frozen_string_literal: true
class Gitlab::Seeder::DastProfiles
attr_reader :project
def initialize(project)
@project = project
FactoryBot.definition_file_paths << Rails.root.join('ee', 'spec', 'factories')
FactoryBot.reload # rubocop:disable Cop/ActiveRecordAssociationReload
end
def seed!
3.times { create_profile }
2.times do
token = create_token(create_profile)
create_validation(token)
end
end
private
def create_profile
site_profile = create_site_profile(create_site)
FactoryBot.create(:dast_profile, project: project, dast_site_profile: site_profile)
end
def create_site
FactoryBot.create(:dast_site, project: project, url: "https://#{SecureRandom.hex}.com")
end
def create_site_profile(site)
FactoryBot.create(:dast_site_profile, project: project, dast_site: site)
end
def create_token(profile)
url = profile.dast_site_profile.dast_site.url
FactoryBot.create(:dast_site_token, project: project, url: url)
end
def create_validation(token)
FactoryBot.create(:dast_site_validation, dast_site_token: token)
end
end
Gitlab::Seeder.quiet do
Project.all.each do |project|
next unless project.repo_exists?
seeder = Gitlab::Seeder::DastProfiles.new(project)
seeder.seed!
end
end
......@@ -8,7 +8,7 @@ FactoryBot.define do
dast_scanner_profile { association :dast_scanner_profile, project: project }
sequence :name do |i|
"#{FFaker::Product.product_name.truncate(200)} - #{i}"
"#{FFaker::Product.product_name.truncate(192)} #{SecureRandom.hex(4)} - #{i}"
end
description { FFaker::Product.product_name }
......
......@@ -3,7 +3,7 @@
FactoryBot.define do
factory :dast_scanner_profile do
sequence :name do |i|
"#{FFaker::Product.product_name.truncate(200)} - #{i}"
"#{FFaker::Product.product_name.truncate(192)} #{SecureRandom.hex(4)} - #{i}"
end
before(:create) do |dast_scanner_profile|
......
......@@ -7,7 +7,7 @@ FactoryBot.define do
dast_site { association :dast_site, project: project }
sequence :name do |i|
"#{FFaker::Product.product_name.truncate(200)} - #{i}"
"#{FFaker::Product.product_name.truncate(192)} #{SecureRandom.hex(4)} - #{i}"
end
auth_enabled { true }
......
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