Commit 2e26041e authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'philipcunningham-removed-unused-dast-relations-336195' into 'master'

Remove unused association code from DAST models

See merge request gitlab-org/gitlab!66900
parents 03c1fc6c f515c1dc
......@@ -10,9 +10,6 @@ module Dast
has_many :secret_variables, through: :dast_site_profile, class_name: 'Dast::SiteProfileSecretVariable'
has_many :dast_profiles_pipelines, class_name: 'Dast::ProfilesPipeline', foreign_key: :dast_profile_id, inverse_of: :dast_profile
has_many :ci_pipelines, class_name: 'Ci::Pipeline', through: :dast_profiles_pipelines
has_many :dast_profile_schedules, class_name: 'Dast::ProfileSchedule', foreign_key: :dast_profile_id, inverse_of: :dast_profile
validates :description, length: { maximum: 255 }
......
......@@ -6,7 +6,7 @@ module Dast
self.table_name = 'dast_profiles_pipelines'
belongs_to :ci_pipeline, class_name: 'Ci::Pipeline', optional: false, inverse_of: :dast_profiles_pipeline
belongs_to :dast_profile, class_name: 'Dast::Profile', optional: false, inverse_of: :dast_profiles_pipelines
belongs_to :ci_pipeline, class_name: 'Ci::Pipeline', optional: false
belongs_to :dast_profile, class_name: 'Dast::Profile', optional: false
end
end
......@@ -6,8 +6,8 @@ module Dast
self.table_name = 'dast_scanner_profiles_builds'
belongs_to :ci_build, class_name: 'Ci::Build', optional: false, inverse_of: :dast_scanner_profiles_build
belongs_to :dast_scanner_profile, class_name: 'DastScannerProfile', optional: false, inverse_of: :dast_scanner_profiles_builds
belongs_to :ci_build, class_name: 'Ci::Build', optional: false
belongs_to :dast_scanner_profile, class_name: 'DastScannerProfile', optional: false
validates :ci_build_id, :dast_scanner_profile_id, presence: true
......
......@@ -6,8 +6,8 @@ module Dast
self.table_name = 'dast_site_profiles_builds'
belongs_to :ci_build, class_name: 'Ci::Build', optional: false, inverse_of: :dast_site_profiles_build
belongs_to :dast_site_profile, class_name: 'DastSiteProfile', optional: false, inverse_of: :dast_site_profiles_builds
belongs_to :ci_build, class_name: 'Ci::Build', optional: false
belongs_to :dast_site_profile, class_name: 'DastSiteProfile', optional: false
validates :ci_build_id, :dast_site_profile_id, presence: true
......
......@@ -6,8 +6,8 @@ module Dast
self.table_name = 'dast_site_profiles_pipelines'
belongs_to :ci_pipeline, class_name: 'Ci::Pipeline', optional: false, inverse_of: :dast_site_profiles_pipeline
belongs_to :dast_site_profile, class_name: 'DastSiteProfile', optional: false, inverse_of: :dast_site_profiles_pipelines
belongs_to :ci_pipeline, class_name: 'Ci::Pipeline', optional: false
belongs_to :dast_site_profile, class_name: 'DastSiteProfile', optional: false
validates :ci_pipeline_id, :dast_site_profile_id, presence: true
......
......@@ -3,9 +3,6 @@
class DastScannerProfile < ApplicationRecord
belongs_to :project
has_many :dast_scanner_profiles_builds, class_name: 'Dast::ScannerProfilesBuild', foreign_key: :dast_scanner_profile_id, inverse_of: :dast_scanner_profile
has_many :ci_builds, class_name: 'Ci::Build', through: :dast_scanner_profiles_builds
validates :project_id, presence: true
validates :name, length: { maximum: 255 }, uniqueness: { scope: :project_id }, presence: true
......
......@@ -6,12 +6,6 @@ class DastSiteProfile < ApplicationRecord
has_many :secret_variables, class_name: 'Dast::SiteProfileSecretVariable'
has_many :dast_site_profiles_pipelines, class_name: 'Dast::SiteProfilesPipeline', foreign_key: :dast_site_profile_id, inverse_of: :dast_site_profile
has_many :ci_pipelines, class_name: 'Ci::Pipeline', through: :dast_site_profiles_pipelines
has_many :dast_site_profiles_builds, class_name: 'Dast::SiteProfilesBuild', foreign_key: :dast_site_profile_id, inverse_of: :dast_site_profile
has_many :ci_builds, class_name: 'Ci::Build', through: :dast_site_profiles_builds
validates :excluded_urls, length: { maximum: 25 }
validates :auth_url, addressable_url: true, length: { maximum: 1024 }, allow_nil: true
validates :auth_username_field, :auth_password_field, :auth_username, length: { maximum: 255 }
......
......@@ -32,10 +32,10 @@ module EE
has_many :security_scans, class_name: 'Security::Scan'
has_one :dast_site_profiles_build, class_name: 'Dast::SiteProfilesBuild', foreign_key: :ci_build_id, inverse_of: :ci_build
has_one :dast_site_profiles_build, class_name: 'Dast::SiteProfilesBuild', foreign_key: :ci_build_id
has_one :dast_site_profile, class_name: 'DastSiteProfile', through: :dast_site_profiles_build
has_one :dast_scanner_profiles_build, class_name: 'Dast::ScannerProfilesBuild', foreign_key: :ci_build_id, inverse_of: :ci_build
has_one :dast_scanner_profiles_build, class_name: 'Dast::ScannerProfilesBuild', foreign_key: :ci_build_id
has_one :dast_scanner_profile, class_name: 'DastScannerProfile', through: :dast_scanner_profiles_build
after_commit :track_ci_secrets_management_usage, on: :create
......
......@@ -20,11 +20,11 @@ module EE
has_many :security_scans, class_name: 'Security::Scan', through: :builds
has_many :security_findings, class_name: 'Security::Finding', through: :security_scans, source: :findings
has_one :dast_profiles_pipeline, class_name: 'Dast::ProfilesPipeline', foreign_key: :ci_pipeline_id, inverse_of: :ci_pipeline
has_one :dast_profiles_pipeline, class_name: 'Dast::ProfilesPipeline', foreign_key: :ci_pipeline_id
has_one :dast_profile, class_name: 'Dast::Profile', through: :dast_profiles_pipeline
# Temporary location to be moved in the future. Please see gitlab-org/gitlab#330950 for more info.
has_one :dast_site_profiles_pipeline, class_name: 'Dast::SiteProfilesPipeline', foreign_key: :ci_pipeline_id, inverse_of: :ci_pipeline
has_one :dast_site_profiles_pipeline, class_name: 'Dast::SiteProfilesPipeline', foreign_key: :ci_pipeline_id
has_one :dast_site_profile, class_name: 'DastSiteProfile', through: :dast_site_profiles_pipeline
has_one :source_project, class_name: 'Ci::Sources::Project', foreign_key: :pipeline_id
......
......@@ -41,7 +41,11 @@ RSpec.describe Ci::Build do
end
describe 'associations' do
it { is_expected.to have_many(:security_scans) }
it { is_expected.to have_many(:security_scans).class_name('Security::Scan') }
it { is_expected.to have_one(:dast_site_profiles_build).class_name('Dast::SiteProfilesBuild').with_foreign_key(:ci_build_id) }
it { is_expected.to have_one(:dast_site_profile).class_name('DastSiteProfile').through(:dast_site_profiles_build) }
it { is_expected.to have_one(:dast_scanner_profiles_build).class_name('Dast::ScannerProfilesBuild').with_foreign_key(:ci_build_id) }
it { is_expected.to have_one(:dast_scanner_profile).class_name('DastScannerProfile').through(:dast_scanner_profiles_build) }
end
describe '#shared_runners_minutes_limit_enabled?' do
......
......@@ -18,9 +18,9 @@ RSpec.describe Ci::Pipeline do
it { is_expected.to have_many(:downstream_bridges) }
it { is_expected.to have_many(:vulnerability_findings).through(:vulnerabilities_finding_pipelines).class_name('Vulnerabilities::Finding') }
it { is_expected.to have_many(:vulnerabilities_finding_pipelines).class_name('Vulnerabilities::FindingPipeline') }
it { is_expected.to have_one(:dast_profiles_pipeline).class_name('Dast::ProfilesPipeline').with_foreign_key(:ci_pipeline_id).inverse_of(:ci_pipeline) }
it { is_expected.to have_one(:dast_profiles_pipeline).class_name('Dast::ProfilesPipeline').with_foreign_key(:ci_pipeline_id) }
it { is_expected.to have_one(:dast_profile).class_name('Dast::Profile').through(:dast_profiles_pipeline) }
it { is_expected.to have_one(:dast_site_profiles_pipeline).class_name('Dast::SiteProfilesPipeline').with_foreign_key(:ci_pipeline_id).inverse_of(:ci_pipeline) }
it { is_expected.to have_one(:dast_site_profiles_pipeline).class_name('Dast::SiteProfilesPipeline').with_foreign_key(:ci_pipeline_id) }
it { is_expected.to have_one(:dast_site_profile).class_name('DastSiteProfile').through(:dast_site_profiles_pipeline) }
end
......
......@@ -12,8 +12,6 @@ RSpec.describe Dast::Profile, type: :model do
it { is_expected.to belong_to(:dast_site_profile) }
it { is_expected.to belong_to(:dast_scanner_profile) }
it { is_expected.to have_many(:secret_variables).through(:dast_site_profile).class_name('Dast::SiteProfileSecretVariable') }
it { is_expected.to have_many(:dast_profiles_pipelines).class_name('Dast::ProfilesPipeline').with_foreign_key(:dast_profile_id).inverse_of(:dast_profile) }
it { is_expected.to have_many(:ci_pipelines).through(:dast_profiles_pipelines).class_name('Ci::Pipeline') }
it { is_expected.to have_many(:dast_profile_schedules).class_name('Dast::ProfileSchedule').with_foreign_key(:dast_profile_id).inverse_of(:dast_profile) }
end
......
......@@ -2,11 +2,11 @@
require 'spec_helper'
RSpec.describe Dast::Profile, type: :model do
RSpec.describe Dast::ProfilesPipeline, type: :model do
subject { create(:dast_profiles_pipeline) }
describe 'associations' do
it { is_expected.to belong_to(:ci_pipeline).class_name('Ci::Pipeline').inverse_of(:dast_profiles_pipeline).required }
it { is_expected.to belong_to(:dast_profile).class_name('Dast::Profile').inverse_of(:dast_profiles_pipelines).required }
it { is_expected.to belong_to(:ci_pipeline).class_name('Ci::Pipeline').required }
it { is_expected.to belong_to(:dast_profile).class_name('Dast::Profile').required }
end
end
......@@ -6,8 +6,8 @@ RSpec.describe Dast::ScannerProfilesBuild, type: :model do
subject { create(:dast_scanner_profiles_build) }
describe 'associations' do
it { is_expected.to belong_to(:ci_build).class_name('Ci::Build').inverse_of(:dast_scanner_profiles_build).required }
it { is_expected.to belong_to(:dast_scanner_profile).class_name('DastScannerProfile').inverse_of(:dast_scanner_profiles_builds).required }
it { is_expected.to belong_to(:ci_build).class_name('Ci::Build').required }
it { is_expected.to belong_to(:dast_scanner_profile).class_name('DastScannerProfile').required }
end
describe 'validations' do
......
......@@ -6,8 +6,8 @@ RSpec.describe Dast::SiteProfilesBuild, type: :model do
subject { create(:dast_site_profiles_build) }
describe 'associations' do
it { is_expected.to belong_to(:ci_build).class_name('Ci::Build').inverse_of(:dast_site_profiles_build).required }
it { is_expected.to belong_to(:dast_site_profile).class_name('DastSiteProfile').inverse_of(:dast_site_profiles_builds).required }
it { is_expected.to belong_to(:ci_build).class_name('Ci::Build').required }
it { is_expected.to belong_to(:dast_site_profile).class_name('DastSiteProfile').required }
end
describe 'validations' do
......
......@@ -6,8 +6,8 @@ RSpec.describe Dast::SiteProfilesPipeline, type: :model do
subject { create(:dast_site_profiles_pipeline) }
describe 'associations' do
it { is_expected.to belong_to(:ci_pipeline).class_name('Ci::Pipeline').inverse_of(:dast_site_profiles_pipeline).required }
it { is_expected.to belong_to(:dast_site_profile).class_name('DastSiteProfile').inverse_of(:dast_site_profiles_pipelines).required }
it { is_expected.to belong_to(:ci_pipeline).class_name('Ci::Pipeline').required }
it { is_expected.to belong_to(:dast_site_profile).class_name('DastSiteProfile').required }
end
describe 'validations' do
......
......@@ -7,8 +7,6 @@ RSpec.describe DastScannerProfile, type: :model do
describe 'associations' do
it { is_expected.to belong_to(:project) }
it { is_expected.to have_many(:dast_scanner_profiles_builds).class_name('Dast::ScannerProfilesBuild').with_foreign_key(:dast_scanner_profile_id).inverse_of(:dast_scanner_profile) }
it { is_expected.to have_many(:ci_builds).class_name('Ci::Build').through(:dast_scanner_profiles_builds) }
end
describe 'validations' do
......
......@@ -11,8 +11,6 @@ RSpec.describe DastSiteProfile, type: :model do
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:dast_site) }
it { is_expected.to have_many(:secret_variables).class_name('Dast::SiteProfileSecretVariable') }
it { is_expected.to have_many(:dast_site_profiles_builds).class_name('Dast::SiteProfilesBuild').with_foreign_key(:dast_site_profile_id).inverse_of(:dast_site_profile) }
it { is_expected.to have_many(:ci_builds).class_name('Ci::Build').through(:dast_site_profiles_builds) }
end
describe 'validations' do
......
......@@ -28,7 +28,7 @@ RSpec.shared_examples 'it creates a DAST on-demand scan pipeline' do
it 'creates an association between the dast_profile and the ci_pipeline' do
subject
expect(dast_profile.ci_pipelines).to include(pipeline)
expect(pipeline.dast_profile).to eq(dast_profile)
end
it 'returns the pipeline_url' do
......
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