diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-08 21:16:37 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-08 21:16:37 +0000 |
commit | 9fe6c95b643c5a2704a8b2a809bd0bd80c5a3307 (patch) | |
tree | eaf1dd550de59c8238d4a1aedb2c1eadab196eca /spec | |
parent | e3bd590af430a430dcbcdd25751c46bbd1ecf56c (diff) | |
download | gitlab-ce-9fe6c95b643c5a2704a8b2a809bd0bd80c5a3307.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
4 files changed, 11 insertions, 46 deletions
diff --git a/spec/lib/security/ci_configuration/sast_build_action_spec.rb b/spec/lib/security/ci_configuration/sast_build_action_spec.rb index 724900aac02..6f702e51b73 100644 --- a/spec/lib/security/ci_configuration/sast_build_action_spec.rb +++ b/spec/lib/security/ci_configuration/sast_build_action_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Security::CiConfiguration::SastBuildAction do let(:default_sast_values) do { 'global' => [ - { 'field' => 'SECURE_ANALYZERS_PREFIX', 'defaultValue' => 'registry.gitlab.com/security-products', 'value' => 'registry.gitlab.com/security-products' } + { 'field' => 'SECURE_ANALYZERS_PREFIX', 'defaultValue' => 'registry.gitlab.com/gitlab-org/security-products/analyzers', 'value' => 'registry.gitlab.com/gitlab-org/security-products/analyzers' } ], 'pipeline' => [ @@ -19,7 +19,7 @@ RSpec.describe Security::CiConfiguration::SastBuildAction do let(:params) do { 'global' => [ - { 'field' => 'SECURE_ANALYZERS_PREFIX', 'defaultValue' => 'registry.gitlab.com/security-products', 'value' => 'new_registry' } + { 'field' => 'SECURE_ANALYZERS_PREFIX', 'defaultValue' => 'registry.gitlab.com/gitlab-org/security-products/analyzers', 'value' => 'new_registry' } ], 'pipeline' => [ @@ -164,7 +164,7 @@ RSpec.describe Security::CiConfiguration::SastBuildAction do let(:params) do { 'global' => [ - { 'field' => 'SECURE_ANALYZERS_PREFIX', 'defaultValue' => 'registry.gitlab.com/security-products', 'value' => 'registry.gitlab.com/security-products' } + { 'field' => 'SECURE_ANALYZERS_PREFIX', 'defaultValue' => 'registry.gitlab.com/gitlab-org/security-products/analyzers', 'value' => 'registry.gitlab.com/gitlab-org/security-products/analyzers' } ], 'pipeline' => [ @@ -219,21 +219,21 @@ RSpec.describe Security::CiConfiguration::SastBuildAction do def existing_gitlab_ci_and_template_array_without_sast { "stages" => %w(test security), - "variables" => { "RANDOM" => "make sure this persists", "SECURE_ANALYZERS_PREFIX" => "localhost:5000" }, + "variables" => { "RANDOM" => "make sure this persists", "SECURE_ANALYZERS_PREFIX" => "localhost:5000/analyzers" }, "sast" => { "variables" => { "SEARCH_MAX_DEPTH" => 1 }, "stage" => "security" }, "include" => [{ "template" => "existing.yml" }] } end def existing_gitlab_ci_and_single_template_with_sast_and_default_stage { "stages" => %w(test), - "variables" => { "SECURE_ANALYZERS_PREFIX" => "localhost:5000" }, + "variables" => { "SECURE_ANALYZERS_PREFIX" => "localhost:5000/analyzers" }, "sast" => { "variables" => { "SEARCH_MAX_DEPTH" => 1 }, "stage" => "test" }, "include" => { "template" => "Security/SAST.gitlab-ci.yml" } } end def existing_gitlab_ci_and_single_template_without_sast { "stages" => %w(test security), - "variables" => { "RANDOM" => "make sure this persists", "SECURE_ANALYZERS_PREFIX" => "localhost:5000" }, + "variables" => { "RANDOM" => "make sure this persists", "SECURE_ANALYZERS_PREFIX" => "localhost:5000/analyzers" }, "sast" => { "variables" => { "SEARCH_MAX_DEPTH" => 1 }, "stage" => "security" }, "include" => { "template" => "existing.yml" } } end @@ -246,13 +246,13 @@ RSpec.describe Security::CiConfiguration::SastBuildAction do def existing_gitlab_ci_with_no_sast_section { "stages" => %w(test security), - "variables" => { "RANDOM" => "make sure this persists", "SECURE_ANALYZERS_PREFIX" => "localhost:5000" }, + "variables" => { "RANDOM" => "make sure this persists", "SECURE_ANALYZERS_PREFIX" => "localhost:5000/analyzers" }, "include" => [{ "template" => "Security/SAST.gitlab-ci.yml" }] } end def existing_gitlab_ci_with_no_sast_variables { "stages" => %w(test security), - "variables" => { "RANDOM" => "make sure this persists", "SECURE_ANALYZERS_PREFIX" => "localhost:5000" }, + "variables" => { "RANDOM" => "make sure this persists", "SECURE_ANALYZERS_PREFIX" => "localhost:5000/analyzers" }, "sast" => { "stage" => "security" }, "include" => [{ "template" => "Security/SAST.gitlab-ci.yml" }] } end @@ -275,7 +275,7 @@ RSpec.describe Security::CiConfiguration::SastBuildAction do let(:params) do { 'global' => [ - { 'field' => 'SECURE_ANALYZERS_PREFIX', 'defaultValue' => 'registry.gitlab.com/security-products', 'value' => '' } + { 'field' => 'SECURE_ANALYZERS_PREFIX', 'defaultValue' => 'registry.gitlab.com/gitlab-org/security-products/analyzers', 'value' => '' } ] } end diff --git a/spec/services/ci/create_pipeline_service/parameter_content_spec.rb b/spec/services/ci/create_pipeline_service/parameter_content_spec.rb index f593707f460..c28bc9d8c13 100644 --- a/spec/services/ci/create_pipeline_service/parameter_content_spec.rb +++ b/spec/services/ci/create_pipeline_service/parameter_content_spec.rb @@ -15,7 +15,7 @@ RSpec.describe Ci::CreatePipelineService do variables: DAST_VERSION: 1 - SECURE_ANALYZERS_PREFIX: "registry.gitlab.com/security-products" + SECURE_ANALYZERS_PREFIX: "registry.gitlab.com/gitlab-org/security-products/analyzers" dast: stage: dast diff --git a/spec/support/helpers/ci/template_helpers.rb b/spec/support/helpers/ci/template_helpers.rb index 598a5a0becc..7bab58a574e 100644 --- a/spec/support/helpers/ci/template_helpers.rb +++ b/spec/support/helpers/ci/template_helpers.rb @@ -3,7 +3,7 @@ module Ci module TemplateHelpers def secure_analyzers_prefix - 'registry.gitlab.com/security-products' + 'registry.gitlab.com/gitlab-org/security-products/analyzers' end end end diff --git a/spec/support/shared_examples/lib/gitlab/ci/templates/security_templates_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/ci/templates/security_templates_shared_examples.rb deleted file mode 100644 index 3136a75f8c9..00000000000 --- a/spec/support/shared_examples/lib/gitlab/ci/templates/security_templates_shared_examples.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.shared_examples 'setting sec analyzer prefix dynamically' do |builds: [], files: { 'README.md' => '' }, variables: {}, namespace: ''| - using RSpec::Parameterized::TableSyntax - - let(:default_analyzer_prefix) { 'registry.gitlab.com/security-products' } - - where(:builds, :files, :analyzer_prefix, :expected_prefix) do - builds | files | nil | "$DEFAULT_SECURE_ANALYZERS_PREFIX#{namespace.present? ? "/#{namespace}" : nil}" - builds | files | 'registry.example.com' | 'registry.example.com' - end - - with_them do - before do - if analyzer_prefix - if analyzer_prefix != default_analyzer_prefix - create(:ci_variable, project: project, key: 'SECURE_ANALYZERS_PREFIX', value: analyzer_prefix) - end - end - - variables.each do |(key, value)| - create(:ci_variable, project: project, key: key, value: value) - end - end - - it 'creates a build with the expected tag' do - expect(build_names).to include(*builds) - - prefixes = pipeline.builds.map { |build| build.variables["SECURE_ANALYZERS_PREFIX"].value } - expect(prefixes.uniq).to match_array(expected_prefix) - end - end -end |