Commit ff6a7e96 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'philipcunningham-on-demand-branch-selection' into 'master'

Fix issue not passing Dast::Profile branch

See merge request gitlab-org/gitlab!58830
parents d21f12c0 b313d625
...@@ -25,12 +25,6 @@ module DastOnDemandScans ...@@ -25,12 +25,6 @@ module DastOnDemandScans
).execute.present? ).execute.present?
end end
def branch
strong_memoize(:branch) do
params[:branch] || container.default_branch
end
end
def dast_profile def dast_profile
strong_memoize(:dast_profile) do strong_memoize(:dast_profile) do
params[:dast_profile] params[:dast_profile]
...@@ -55,6 +49,12 @@ module DastOnDemandScans ...@@ -55,6 +49,12 @@ module DastOnDemandScans
end end
end end
def branch
strong_memoize(:branch) do
dast_profile&.branch_name || params[:branch] || container.default_branch
end
end
def url_base def url_base
strong_memoize(:url_base) do strong_memoize(:url_base) do
DastSiteValidation.get_normalized_url_base(dast_site&.url) DastSiteValidation.get_normalized_url_base(dast_site&.url)
......
...@@ -28,7 +28,7 @@ RSpec.describe Mutations::Dast::Profiles::Create do ...@@ -28,7 +28,7 @@ RSpec.describe Mutations::Dast::Profiles::Create do
full_path: project.full_path, full_path: project.full_path,
name: name, name: name,
description: description, description: description,
branch_name: 'orphaned-branch', branch_name: project.default_branch,
dast_site_profile_id: dast_site_profile.to_global_id.to_s, dast_site_profile_id: dast_site_profile.to_global_id.to_s,
dast_scanner_profile_id: dast_scanner_profile.to_global_id.to_s, dast_scanner_profile_id: dast_scanner_profile.to_global_id.to_s,
run_after_create: run_after_create run_after_create: run_after_create
...@@ -62,7 +62,7 @@ RSpec.describe Mutations::Dast::Profiles::Create do ...@@ -62,7 +62,7 @@ RSpec.describe Mutations::Dast::Profiles::Create do
context 'when the feature flag dast_branch_selection is enabled' do context 'when the feature flag dast_branch_selection is enabled' do
it 'sets the branch_name' do it 'sets the branch_name' do
expect(subject[:dast_profile].branch_name).to eq('orphaned-branch') expect(subject[:dast_profile].branch_name).to eq(project.default_branch)
end end
end end
end end
......
...@@ -6,7 +6,7 @@ RSpec.describe Mutations::Dast::Profiles::Run do ...@@ -6,7 +6,7 @@ RSpec.describe Mutations::Dast::Profiles::Run do
let_it_be_with_refind(:project) { create(:project, :repository) } let_it_be_with_refind(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:dast_profile) { create(:dast_profile, project: project, branch_name: 'orphaned-branch') } let_it_be(:dast_profile) { create(:dast_profile, project: project, branch_name: project.default_branch) }
let(:full_path) { project.full_path } let(:full_path) { project.full_path }
let(:dast_profile_id) { dast_profile.to_global_id } let(:dast_profile_id) { dast_profile.to_global_id }
......
...@@ -17,7 +17,7 @@ RSpec.describe Mutations::Dast::Profiles::Update do ...@@ -17,7 +17,7 @@ RSpec.describe Mutations::Dast::Profiles::Update do
id: dast_profile_gid, id: dast_profile_gid,
name: SecureRandom.hex, name: SecureRandom.hex,
description: SecureRandom.hex, description: SecureRandom.hex,
branch_name: 'orphaned-branch', branch_name: project.default_branch,
dast_site_profile_id: global_id_of(create(:dast_site_profile, project: project)), dast_site_profile_id: global_id_of(create(:dast_site_profile, project: project)),
dast_scanner_profile_id: global_id_of(create(:dast_scanner_profile, project: project)), dast_scanner_profile_id: global_id_of(create(:dast_scanner_profile, project: project)),
run_after_update: run_after_update run_after_update: run_after_update
......
...@@ -92,7 +92,7 @@ RSpec.describe DastOnDemandScans::ParamsCreateService do ...@@ -92,7 +92,7 @@ RSpec.describe DastOnDemandScans::ParamsCreateService do
end end
context 'when the dast_profile is provided' do context 'when the dast_profile is provided' do
let_it_be(:dast_profile) { create(:dast_profile, project: project, dast_site_profile: dast_site_profile, dast_scanner_profile: dast_scanner_profile) } let_it_be(:dast_profile) { create(:dast_profile, project: project, dast_site_profile: dast_site_profile, dast_scanner_profile: dast_scanner_profile, branch_name: 'hello-world') }
let(:params) { { dast_profile: dast_profile } } let(:params) { { dast_profile: dast_profile } }
...@@ -101,7 +101,7 @@ RSpec.describe DastOnDemandScans::ParamsCreateService do ...@@ -101,7 +101,7 @@ RSpec.describe DastOnDemandScans::ParamsCreateService do
auth_password_field: dast_site_profile.auth_password_field, auth_password_field: dast_site_profile.auth_password_field,
auth_username: dast_site_profile.auth_username, auth_username: dast_site_profile.auth_username,
auth_username_field: dast_site_profile.auth_username_field, auth_username_field: dast_site_profile.auth_username_field,
branch: project.default_branch, branch: dast_profile.branch_name,
dast_profile: dast_profile, dast_profile: dast_profile,
excluded_urls: dast_site_profile.excluded_urls.join(','), excluded_urls: dast_site_profile.excluded_urls.join(','),
full_scan_enabled: false, full_scan_enabled: 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