Commit 03dd150a authored by Marcos Rocha's avatar Marcos Rocha Committed by Sean McGivern

Fix default Ci config path

When the ci config file it is set to an empty string

This MR adds a blank check to handle the empty string filename

Changelog: fixed
parent 95b17b01
......@@ -6,7 +6,7 @@ module Security
def initialize(auto_devops_enabled, existing_gitlab_ci_content, ci_config_path = ::Ci::Pipeline::DEFAULT_CONFIG_PATH)
@auto_devops_enabled = auto_devops_enabled
@existing_gitlab_ci_content = existing_gitlab_ci_content || {}
@ci_config_path = ci_config_path || ::Ci::Pipeline::DEFAULT_CONFIG_PATH
@ci_config_path = ci_config_path.presence || ::Ci::Pipeline::DEFAULT_CONFIG_PATH
end
def generate
......
......@@ -7,6 +7,7 @@ RSpec.describe Security::CiConfiguration::SastIacBuildAction do
let(:params) { {} }
shared_examples 'existing .gitlab-ci.yml tests' do
context 'with existing .gitlab-ci.yml' do
let(:auto_devops_enabled) { false }
......@@ -104,6 +105,19 @@ RSpec.describe Security::CiConfiguration::SastIacBuildAction do
end
end
end
end
context 'with existing .gitlab-ci.yml and when the ci config file configuration was not set' do
subject(:result) { described_class.new(auto_devops_enabled, gitlab_ci_content).generate }
it_behaves_like 'existing .gitlab-ci.yml tests'
end
context 'with existing .gitlab-ci.yml and when the ci config file configuration was deleted' do
subject(:result) { described_class.new(auto_devops_enabled, gitlab_ci_content, ci_config_path: '').generate }
it_behaves_like 'existing .gitlab-ci.yml tests'
end
context 'with no .gitlab-ci.yml' do
let(:gitlab_ci_content) { nil }
......
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