Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-18 18:08:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-18 18:08:51 +0300
commit163a7046ac76eb4109184e82ce0af911633e6626 (patch)
tree9f22bb438db435d518e8f5520b309c6319ae0bd8 /spec/lib/gitlab
parent0637ba1e6e9024f35b2cbf561d9002ec17350bb3 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r--spec/lib/gitlab/ci/templates/templates_spec.rb50
-rw-r--r--spec/lib/gitlab/template/finders/global_template_finder_spec.rb84
2 files changed, 104 insertions, 30 deletions
diff --git a/spec/lib/gitlab/ci/templates/templates_spec.rb b/spec/lib/gitlab/ci/templates/templates_spec.rb
index b52064b3036..bc3d5b89220 100644
--- a/spec/lib/gitlab/ci/templates/templates_spec.rb
+++ b/spec/lib/gitlab/ci/templates/templates_spec.rb
@@ -2,33 +2,43 @@
require 'spec_helper'
-describe "CI YML Templates" do
- using RSpec::Parameterized::TableSyntax
-
+describe 'CI YML Templates' do
subject { Gitlab::Ci::YamlProcessor.new(content) }
- where(:template_name) do
- Gitlab::Template::GitlabCiYmlTemplate.all.map(&:full_name)
- end
-
- with_them do
- let(:content) do
- <<~EOS
- include:
- - template: #{template_name}
+ let(:all_templates) { Gitlab::Template::GitlabCiYmlTemplate.all.map(&:full_name) }
- concrete_build_implemented_by_a_user:
- stage: test
- script: do something
- EOS
+ let(:disabled_templates) do
+ Gitlab::Template::GitlabCiYmlTemplate.disabled_templates.map do |template|
+ template + Gitlab::Template::GitlabCiYmlTemplate.extension
end
+ end
+
+ context 'included in a CI YAML configuration' do
+ using RSpec::Parameterized::TableSyntax
- it 'is valid' do
- expect { subject }.not_to raise_error
+ where(:template_name) do
+ all_templates - disabled_templates
end
- it 'require default stages to be included' do
- expect(subject.stages).to include(*Gitlab::Ci::Config::Entry::Stages.default)
+ with_them do
+ let(:content) do
+ <<~EOS
+ include:
+ - template: #{template_name}
+
+ concrete_build_implemented_by_a_user:
+ stage: test
+ script: do something
+ EOS
+ end
+
+ it 'is valid' do
+ expect { subject }.not_to raise_error
+ end
+
+ it 'require default stages to be included' do
+ expect(subject.stages).to include(*Gitlab::Ci::Config::Entry::Stages.default)
+ end
end
end
end
diff --git a/spec/lib/gitlab/template/finders/global_template_finder_spec.rb b/spec/lib/gitlab/template/finders/global_template_finder_spec.rb
index 082ffa855b7..580da497944 100644
--- a/spec/lib/gitlab/template/finders/global_template_finder_spec.rb
+++ b/spec/lib/gitlab/template/finders/global_template_finder_spec.rb
@@ -15,23 +15,87 @@ describe Gitlab::Template::Finders::GlobalTemplateFinder do
FileUtils.rm_rf(base_dir)
end
- subject(:finder) { described_class.new(base_dir, '', 'Foo' => '', 'Bar' => 'bar') }
+ subject(:finder) { described_class.new(base_dir, '', { 'General' => '', 'Bar' => 'Bar' }, exclusions: exclusions) }
+
+ let(:exclusions) { [] }
describe '.find' do
- it 'finds a template in the Foo category' do
- create_template!('test-template')
+ context 'with a non-prefixed General template' do
+ before do
+ create_template!('test-template')
+ end
- expect(finder.find('test-template')).to be_present
- end
+ it 'finds the template with no prefix' do
+ expect(finder.find('test-template')).to be_present
+ end
+
+ it 'does not find a prefixed template' do
+ expect(finder.find('Bar/test-template')).to be_nil
+ end
+
+ it 'does not permit path traversal requests' do
+ expect { finder.find('../foo') }.to raise_error(/Invalid path/)
+ end
- it 'finds a template in the Bar category' do
- create_template!('bar/test-template')
+ context 'while listed as an exclusion' do
+ let(:exclusions) { %w[test-template] }
- expect(finder.find('test-template')).to be_present
+ it 'does not find the template without a prefix' do
+ expect(finder.find('test-template')).to be_nil
+ end
+
+ it 'does not find the template with a prefix' do
+ expect(finder.find('Bar/test-template')).to be_nil
+ end
+
+ it 'finds another prefixed template with the same name' do
+ create_template!('Bar/test-template')
+
+ expect(finder.find('test-template')).to be_nil
+ expect(finder.find('Bar/test-template')).to be_present
+ end
+ end
end
- it 'does not permit path traversal requests' do
- expect { finder.find('../foo') }.to raise_error(/Invalid path/)
+ context 'with a prefixed template' do
+ before do
+ create_template!('Bar/test-template')
+ end
+
+ it 'finds the template with a prefix' do
+ expect(finder.find('Bar/test-template')).to be_present
+ end
+
+ # NOTE: This spec fails, the template Bar/test-template is found
+ # See Gitlab issue: https://gitlab.com/gitlab-org/gitlab/issues/205719
+ xit 'does not find the template without a prefix' do
+ expect(finder.find('test-template')).to be_nil
+ end
+
+ it 'does not permit path traversal requests' do
+ expect { finder.find('../foo') }.to raise_error(/Invalid path/)
+ end
+
+ context 'while listed as an exclusion' do
+ let(:exclusions) { %w[Bar/test-template] }
+
+ it 'does not find the template with a prefix' do
+ expect(finder.find('Bar/test-template')).to be_nil
+ end
+
+ # NOTE: This spec fails, the template Bar/test-template is found
+ # See Gitlab issue: https://gitlab.com/gitlab-org/gitlab/issues/205719
+ xit 'does not find the template without a prefix' do
+ expect(finder.find('test-template')).to be_nil
+ end
+
+ it 'finds another non-prefixed template with the same name' do
+ create_template!('Bar/test-template')
+
+ expect(finder.find('test-template')).to be_present
+ expect(finder.find('Bar/test-template')).to be_nil
+ end
+ end
end
end
end