Commit a3158aa5 authored by Cameron Swords's avatar Cameron Swords Committed by Stan Hu

Remove stages definitions from the DAST CI template

parent 49e51d0c
......@@ -23,13 +23,15 @@ RSpec.describe "CI YML Templates" do
end
context 'that support autodevops' do
non_autodevops_templates = [
'Security/DAST-API.gitlab-ci.yml',
'Security/API-Fuzzing.gitlab-ci.yml'
exceptions = [
'Security/DAST.gitlab-ci.yml', # DAST stage is defined inside AutoDevops yml
'Security/DAST-API.gitlab-ci.yml', # no auto-devops
'Security/API-Fuzzing.gitlab-ci.yml', # no auto-devops
'Terraform.gitlab-ci.yml'
]
where(:template_name) do
all_templates - non_autodevops_templates - ["Terraform.gitlab-ci.yml"]
all_templates - exceptions
end
with_them do
......
......@@ -13,12 +13,36 @@ RSpec.describe 'DAST.gitlab-ci.yml' do
let(:service) { Ci::CreatePipelineService.new(project, user, ref: pipeline_branch ) }
let(:pipeline) { service.execute!(:push) }
let(:build_names) { pipeline.builds.pluck(:name) }
let(:ci_pipeline_yaml) { "stages: [\"dast\"]\n" }
specify { expect(template).not_to be_nil }
context 'when ci yaml is just template' do
before do
stub_ci_pipeline_yaml_file(template.content)
allow_next_instance_of(Ci::BuildScheduleWorker) do |worker|
allow(worker).to receive(:perform).and_return(true)
end
allow(project).to receive(:default_branch).and_return(default_branch)
end
context 'when project has no license' do
it 'includes no jobs' do
expect(build_names).to be_empty
end
end
end
context 'when stages includes dast' do
before do
stub_ci_pipeline_yaml_file(ci_pipeline_yaml + template.content)
allow_next_instance_of(Ci::BuildScheduleWorker) do |worker|
allow(worker).to receive(:perform).and_return(true)
end
allow(project).to receive(:default_branch).and_return(default_branch)
end
......@@ -139,4 +163,5 @@ RSpec.describe 'DAST.gitlab-ci.yml' do
end
end
end
end
end
# To use this template, add the following to your .gitlab-ci.yml file:
#
# include:
# template: DAST.gitlab-ci.yml
#
# You also need to add a `dast` stage to your `stages:` configuration. A sample configuration for DAST:
#
# stages:
# - build
# - test
# - deploy
# - dast
# Read more about this feature here: https://docs.gitlab.com/ee/user/application_security/dast/
# Configure DAST with CI/CD variables (https://docs.gitlab.com/ee/ci/variables/README.html).
# List of available variables: https://docs.gitlab.com/ee/user/application_security/dast/#available-variables
stages:
- build
- test
- deploy
- dast
variables:
DAST_VERSION: 2
# Setting this variable will affect all Security templates
......
......@@ -27,16 +27,17 @@ RSpec.describe 'CI YML Templates' do
end
context 'that support autodevops' do
non_autodevops_templates = [
'Security/DAST-API.gitlab-ci.yml',
'Security/API-Fuzzing.gitlab-ci.yml'
exceptions = [
'Security/DAST.gitlab-ci.yml', # DAST stage is defined inside AutoDevops yml
'Security/DAST-API.gitlab-ci.yml', # no auto-devops
'Security/API-Fuzzing.gitlab-ci.yml' # no auto-devops
]
context 'when including available templates in a CI YAML configuration' do
using RSpec::Parameterized::TableSyntax
where(:template_name) do
all_templates - excluded_templates - non_autodevops_templates
all_templates - excluded_templates - exceptions
end
with_them 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