Commit 41abeb0f authored by Luke Duncalfe's avatar Luke Duncalfe

Merge branch 'philipcunningham-add-new-ci-source-for-dast-site-validation-324990' into 'master'

Add Ci::Pipeline source for DAST site validation

See merge request gitlab-org/gitlab!66991
parents 3ad3f03b e3c9b52b
...@@ -37,7 +37,8 @@ module Enums ...@@ -37,7 +37,8 @@ module Enums
merge_request_event: 10, merge_request_event: 10,
external_pull_request_event: 11, external_pull_request_event: 11,
parent_pipeline: 12, parent_pipeline: 12,
ondemand_dast_scan: 13 ondemand_dast_scan: 13,
ondemand_dast_validation: 14
} }
end end
...@@ -48,8 +49,10 @@ module Enums ...@@ -48,8 +49,10 @@ module Enums
# parent pipeline. It's up to the parent to affect the ref CI status # parent pipeline. It's up to the parent to affect the ref CI status
# - when an ondemand_dast_scan pipeline runs it is for testing purpose and should # - when an ondemand_dast_scan pipeline runs it is for testing purpose and should
# not affect the ref CI status. # not affect the ref CI status.
# - when an ondemand_dast_validation pipeline runs it is for validating a DAST site
# profile and should not affect the ref CI status.
def self.dangling_sources def self.dangling_sources
sources.slice(:webide, :parent_pipeline, :ondemand_dast_scan) sources.slice(:webide, :parent_pipeline, :ondemand_dast_scan, :ondemand_dast_validation)
end end
# CI sources are those pipeline events that affect the CI status of the ref # CI sources are those pipeline events that affect the CI status of the ref
......
...@@ -8,7 +8,7 @@ module AppSec ...@@ -8,7 +8,7 @@ module AppSec
return ServiceResponse.error(message: _('Insufficient permissions')) unless allowed? return ServiceResponse.error(message: _('Insufficient permissions')) unless allowed?
service = Ci::CreatePipelineService.new(project, current_user, ref: project.default_branch_or_main) service = Ci::CreatePipelineService.new(project, current_user, ref: project.default_branch_or_main)
result = service.execute(:ondemand_dast_scan, content: ci_configuration.to_yaml, variables_attributes: dast_site_validation_variables) result = service.execute(:ondemand_dast_validation, content: ci_configuration.to_yaml, variables_attributes: dast_site_validation_variables)
if result.success? if result.success?
ServiceResponse.success(payload: dast_site_validation) ServiceResponse.success(payload: dast_site_validation)
......
...@@ -39,8 +39,10 @@ RSpec.describe AppSec::Dast::SiteValidations::RunnerService do ...@@ -39,8 +39,10 @@ RSpec.describe AppSec::Dast::SiteValidations::RunnerService do
expect(subject).to have_attributes(status: :success, payload: dast_site_validation) expect(subject).to have_attributes(status: :success, payload: dast_site_validation)
end end
it 'creates a ci_pipeline with ci_pipeline_variables' do it 'creates a ci_pipeline with an appropriate source', :aggregate_failures do
expect { subject }.to change { Ci::Pipeline.count }.by(1) expect { subject }.to change { Ci::Pipeline.count }.by(1)
expect(Ci::Pipeline.last.source).to eq('ondemand_dast_validation')
end end
it 'makes the correct variables available to the ci_build' do it 'makes the correct variables available to the ci_build' do
......
...@@ -106,10 +106,6 @@ module Gitlab ...@@ -106,10 +106,6 @@ module Gitlab
metrics.pipeline_failure_reason_counter metrics.pipeline_failure_reason_counter
.increment(reason: (reason || :unknown_failure).to_s) .increment(reason: (reason || :unknown_failure).to_s)
end end
def dangling_build?
%i[ondemand_dast_scan webide].include?(source)
end
end end
end end
end end
......
...@@ -271,31 +271,6 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Command do ...@@ -271,31 +271,6 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Command do
end end
end end
describe '#dangling_build?' do
let(:project) { create(:project, :repository) }
let(:command) { described_class.new(project: project, source: source) }
subject { command.dangling_build? }
context 'when source is :webide' do
let(:source) { :webide }
it { is_expected.to eq(true) }
end
context 'when source is :ondemand_dast_scan' do
let(:source) { :ondemand_dast_scan }
it { is_expected.to eq(true) }
end
context 'when source something else' do
let(:source) { :web }
it { is_expected.to eq(false) }
end
end
describe '#creates_child_pipeline?' do describe '#creates_child_pipeline?' do
let(:command) { described_class.new(bridge: bridge) } let(:command) { described_class.new(bridge: bridge) }
......
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