Commit 347ae433 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'edit-scan-schedules' into 'master'

Make DAST scan schedules editable

See merge request gitlab-org/gitlab!69894
parents 998dbda5 614bd2c5
...@@ -33,6 +33,15 @@ module Projects ...@@ -33,6 +33,15 @@ module Projects
branch { name } branch { name }
dastSiteProfile { id } dastSiteProfile { id }
dastScannerProfile { id } dastScannerProfile { id }
dastProfileSchedule {
active
cadence {
duration
unit
}
startsAt
timezone
}
} }
} }
} }
......
# frozen_string_literal: true
module Projects::Security::DastProfilesHelper
def dast_profiles_list_data(project)
{
'new_dast_saved_scan_path' => new_project_on_demand_scan_path(project),
'new_dast_site_profile_path' => new_project_security_configuration_dast_scans_dast_site_profile_path(project),
'new_dast_scanner_profile_path' => new_project_security_configuration_dast_scans_dast_scanner_profile_path(project),
'project_full_path' => project.path_with_namespace
}
end
end
...@@ -2,7 +2,4 @@ ...@@ -2,7 +2,4 @@
- breadcrumb_title s_('DastProfiles|Manage DAST scans') - breadcrumb_title s_('DastProfiles|Manage DAST scans')
- page_title s_('DastProfiles|Manage DAST scans') - page_title s_('DastProfiles|Manage DAST scans')
.js-dast-profiles{ data: { new_dast_saved_scan_path: new_project_on_demand_scan_path(@project), .js-dast-profiles{ data: dast_profiles_list_data(@project) }
new_dast_site_profile_path: new_project_security_configuration_dast_scans_dast_site_profile_path(@project),
new_dast_scanner_profile_path: new_project_security_configuration_dast_scans_dast_scanner_profile_path(@project),
project_full_path: @project.path_with_namespace } }
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::Security::DastProfilesHelper do
describe '#dast_profiles_list_data' do
let(:project) { create(:project) }
it 'returns proper data' do
expect(helper.dast_profiles_list_data(project)).to match(
{
'new_dast_saved_scan_path' => new_project_on_demand_scan_path(project),
'new_dast_site_profile_path' => new_project_security_configuration_dast_scans_dast_site_profile_path(project),
'new_dast_scanner_profile_path' => new_project_security_configuration_dast_scans_dast_scanner_profile_path(project),
'project_full_path' => project.path_with_namespace
}
)
end
end
end
...@@ -83,6 +83,7 @@ RSpec.describe Projects::OnDemandScansController, type: :request do ...@@ -83,6 +83,7 @@ RSpec.describe Projects::OnDemandScansController, type: :request do
describe 'GET #edit' do describe 'GET #edit' do
let_it_be(:dast_profile) { create(:dast_profile, project: project, branch_name: project.default_branch_or_main) } let_it_be(:dast_profile) { create(:dast_profile, project: project, branch_name: project.default_branch_or_main) }
let_it_be(:dast_profile_schedule) { create(:dast_profile_schedule, project: project, dast_profile: dast_profile) }
let(:dast_profile_id) { dast_profile.id } let(:dast_profile_id) { dast_profile.id }
let(:edit_path) { edit_project_on_demand_scan_path(project, id: dast_profile_id) } let(:edit_path) { edit_project_on_demand_scan_path(project, id: dast_profile_id) }
...@@ -110,7 +111,16 @@ RSpec.describe Projects::OnDemandScansController, type: :request do ...@@ -110,7 +111,16 @@ RSpec.describe Projects::OnDemandScansController, type: :request do
description: dast_profile.description, description: dast_profile.description,
branch: { name: project.default_branch_or_main }, branch: { name: project.default_branch_or_main },
dastSiteProfile: { id: global_id_of(DastSiteProfile.new(id: dast_profile.dast_site_profile_id)) }, dastSiteProfile: { id: global_id_of(DastSiteProfile.new(id: dast_profile.dast_site_profile_id)) },
dastScannerProfile: { id: global_id_of(DastScannerProfile.new(id: dast_profile.dast_scanner_profile_id)) } dastScannerProfile: { id: global_id_of(DastScannerProfile.new(id: dast_profile.dast_scanner_profile_id)) },
dastProfileSchedule: {
active: dast_profile_schedule.active,
cadence: {
duration: dast_profile_schedule.cadence[:duration],
unit: dast_profile_schedule.cadence[:unit]&.upcase
},
startsAt: dast_profile_schedule.starts_at.in_time_zone(dast_profile_schedule.timezone).iso8601,
timezone: dast_profile_schedule.timezone
}
}.to_json }.to_json
on_demand_div = Nokogiri::HTML.parse(response.body).at_css('div#js-on-demand-scans-app') on_demand_div = Nokogiri::HTML.parse(response.body).at_css('div#js-on-demand-scans-app')
......
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