diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 09:45:46 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 09:45:46 +0000 |
commit | a7b3560714b4d9cc4ab32dffcd1f74a284b93580 (patch) | |
tree | 7452bd5c3545c2fa67a28aa013835fb4fa071baf /spec/lib/gitlab/ci/yaml_processor_spec.rb | |
parent | ee9173579ae56a3dbfe5afe9f9410c65bb327ca7 (diff) | |
download | gitlab-ce-a7b3560714b4d9cc4ab32dffcd1f74a284b93580.tar.gz |
Add latest changes from gitlab-org/gitlab@14-8-stable-eev14.8.0-rc42
Diffstat (limited to 'spec/lib/gitlab/ci/yaml_processor_spec.rb')
-rw-r--r-- | spec/lib/gitlab/ci/yaml_processor_spec.rb | 58 |
1 files changed, 19 insertions, 39 deletions
diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index 20af84ce648..5f46607b042 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -9,6 +9,10 @@ module Gitlab subject { described_class.new(config, user: nil).execute } + before do + stub_feature_flags(allow_unsafe_ruby_regexp: false) + end + shared_examples 'returns errors' do |error_message| it 'adds a message when an error is encountered' do expect(subject.errors).to include(error_message) @@ -609,13 +613,13 @@ module Gitlab context 'when it is an array of integers' do let(:only) { [1, 1] } - it_behaves_like 'returns errors', 'jobs:rspec:only config should be an array of strings or regexps' + it_behaves_like 'returns errors', 'jobs:rspec:only config should be an array of strings or regular expressions using re2 syntax' end context 'when it is invalid regex' do let(:only) { ["/*invalid/"] } - it_behaves_like 'returns errors', 'jobs:rspec:only config should be an array of strings or regexps' + it_behaves_like 'returns errors', 'jobs:rspec:only config should be an array of strings or regular expressions using re2 syntax' end end @@ -633,13 +637,13 @@ module Gitlab context 'when it is an array of integers' do let(:except) { [1, 1] } - it_behaves_like 'returns errors', 'jobs:rspec:except config should be an array of strings or regexps' + it_behaves_like 'returns errors', 'jobs:rspec:except config should be an array of strings or regular expressions using re2 syntax' end context 'when it is invalid regex' do let(:except) { ["/*invalid/"] } - it_behaves_like 'returns errors', 'jobs:rspec:except config should be an array of strings or regexps' + it_behaves_like 'returns errors', 'jobs:rspec:except config should be an array of strings or regular expressions using re2 syntax' end end end @@ -710,16 +714,16 @@ module Gitlab end end - context 'when script is array of arrays of strings' do + context 'when script is nested arrays of strings' do let(:config) do { - before_script: [["global script", "echo 1"], ["ls"], "pwd"], + before_script: [[["global script"], "echo 1"], "echo 2", ["ls"], "pwd"], test: { script: ["script"] } } end it "return commands with scripts concatenated" do - expect(subject[:options][:before_script]).to eq(["global script", "echo 1", "ls", "pwd"]) + expect(subject[:options][:before_script]).to eq(["global script", "echo 1", "echo 2", "ls", "pwd"]) end end end @@ -737,15 +741,15 @@ module Gitlab end end - context 'when script is array of arrays of strings' do + context 'when script is nested arrays of strings' do let(:config) do { - test: { script: [["script"], ["echo 1"], "ls"] } + test: { script: [[["script"], "echo 1", "echo 2"], "ls"] } } end it "return commands with scripts concatenated" do - expect(subject[:options][:script]).to eq(["script", "echo 1", "ls"]) + expect(subject[:options][:script]).to eq(["script", "echo 1", "echo 2", "ls"]) end end end @@ -790,16 +794,16 @@ module Gitlab end end - context 'when script is array of arrays of strings' do + context 'when script is nested arrays of strings' do let(:config) do { - after_script: [["global script", "echo 1"], ["ls"], "pwd"], + after_script: [[["global script"], "echo 1"], "echo 2", ["ls"], "pwd"], test: { script: ["script"] } } end it "return after_script in options" do - expect(subject[:options][:after_script]).to eq(["global script", "echo 1", "ls", "pwd"]) + expect(subject[:options][:after_script]).to eq(["global script", "echo 1", "echo 2", "ls", "pwd"]) end end end @@ -2469,40 +2473,16 @@ module Gitlab it_behaves_like 'returns errors', 'jobs:rspec:tags config should be an array of strings' end - context 'returns errors if before_script parameter is invalid' do - let(:config) { YAML.dump({ before_script: "bundle update", rspec: { script: "test" } }) } - - it_behaves_like 'returns errors', 'before_script config should be an array containing strings and arrays of strings' - end - context 'returns errors if job before_script parameter is not an array of strings' do let(:config) { YAML.dump({ rspec: { script: "test", before_script: [10, "test"] } }) } - it_behaves_like 'returns errors', 'jobs:rspec:before_script config should be an array containing strings and arrays of strings' - end - - context 'returns errors if job before_script parameter is multi-level nested array of strings' do - let(:config) { YAML.dump({ rspec: { script: "test", before_script: [["ls", ["pwd"]], "test"] } }) } - - it_behaves_like 'returns errors', 'jobs:rspec:before_script config should be an array containing strings and arrays of strings' - end - - context 'returns errors if after_script parameter is invalid' do - let(:config) { YAML.dump({ after_script: "bundle update", rspec: { script: "test" } }) } - - it_behaves_like 'returns errors', 'after_script config should be an array containing strings and arrays of strings' + it_behaves_like 'returns errors', 'jobs:rspec:before_script config should be a string or a nested array of strings up to 10 levels deep' end context 'returns errors if job after_script parameter is not an array of strings' do let(:config) { YAML.dump({ rspec: { script: "test", after_script: [10, "test"] } }) } - it_behaves_like 'returns errors', 'jobs:rspec:after_script config should be an array containing strings and arrays of strings' - end - - context 'returns errors if job after_script parameter is multi-level nested array of strings' do - let(:config) { YAML.dump({ rspec: { script: "test", after_script: [["ls", ["pwd"]], "test"] } }) } - - it_behaves_like 'returns errors', 'jobs:rspec:after_script config should be an array containing strings and arrays of strings' + it_behaves_like 'returns errors', 'jobs:rspec:after_script config should be a string or a nested array of strings up to 10 levels deep' end context 'returns errors if image parameter is invalid' do |