diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-04 21:10:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-04 21:10:08 +0300 |
commit | f9ddf689da1edc68c81444a25b3b0d3841382c56 (patch) | |
tree | ecab18b41b8cbca55acfc09b19478e1d7af6160a /spec/lib/gitlab/ci/variables/collection_spec.rb | |
parent | d4194db620cc5b736bb5737ed5e4eab979ccd7ab (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/ci/variables/collection_spec.rb')
-rw-r--r-- | spec/lib/gitlab/ci/variables/collection_spec.rb | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/spec/lib/gitlab/ci/variables/collection_spec.rb b/spec/lib/gitlab/ci/variables/collection_spec.rb index acf5744f566..abda27f0d6e 100644 --- a/spec/lib/gitlab/ci/variables/collection_spec.rb +++ b/spec/lib/gitlab/ci/variables/collection_spec.rb @@ -253,6 +253,11 @@ RSpec.describe Gitlab::Ci::Variables::Collection do value: 'key${MISSING_VAR}-${CI_JOB_NAME}', result: 'key${MISSING_VAR}-test-1', keep_undefined: true + }, + "escaped characters are kept intact": { + value: 'key-$TEST1-%%HOME%%-$${HOME}', + result: 'key-test-3-%%HOME%%-$${HOME}', + keep_undefined: false } } end @@ -315,6 +320,14 @@ RSpec.describe Gitlab::Ci::Variables::Collection do ], keep_undefined: false }, + "escaped characters in complex expansions are kept intact": { + variables: [ + { key: 'variable3', value: 'key_${variable}_$${HOME}_%%HOME%%' }, + { key: 'variable', value: '$variable2' }, + { key: 'variable2', value: 'value2' } + ], + keep_undefined: false + }, "array with cyclic dependency": { variables: [ { key: 'variable', value: '$variable2' }, @@ -415,6 +428,30 @@ RSpec.describe Gitlab::Ci::Variables::Collection do { key: 'variable3', value: 'keyvalueresult' } ] }, + "escaped characters in complex expansions keeping undefined are kept intact": { + variables: [ + { key: 'variable3', value: 'key_${variable}_$${HOME}_%%HOME%%' }, + { key: 'variable', value: '$variable2' }, + { key: 'variable2', value: 'value' } + ], + keep_undefined: true, + result: [ + { key: 'variable', value: 'value' }, + { key: 'variable2', value: 'value' }, + { key: 'variable3', value: 'key_value_$${HOME}_%%HOME%%' } + ] + }, + "escaped characters in complex expansions discarding undefined are kept intact": { + variables: [ + { key: 'variable2', value: 'key_${variable4}_$${HOME}_%%HOME%%' }, + { key: 'variable', value: 'value_$${HOME}_%%HOME%%' } + ], + keep_undefined: false, + result: [ + { key: 'variable', value: 'value_$${HOME}_%%HOME%%' }, + { key: 'variable2', value: 'key__$${HOME}_%%HOME%%' } + ] + }, "out-of-order expansion": { variables: [ { key: 'variable3', value: 'key$variable2$variable' }, @@ -441,7 +478,7 @@ RSpec.describe Gitlab::Ci::Variables::Collection do { key: 'variable3', value: 'keyresultvalue' } ] }, - "missing variable": { + "missing variable discarding original": { variables: [ { key: 'variable2', value: 'key$variable' } ], @@ -485,6 +522,19 @@ RSpec.describe Gitlab::Ci::Variables::Collection do { key: 'variable3', value: 'key_$variable2_value2' } ] }, + "variable value referencing password with special characters": { + variables: [ + { key: 'VAR', value: '$PASSWORD' }, + { key: 'PASSWORD', value: 'my_password$$_%%_$A' }, + { key: 'A', value: 'value' } + ], + keep_undefined: false, + result: [ + { key: 'VAR', value: 'my_password$$_%%_value' }, + { key: 'PASSWORD', value: 'my_password$$_%%_value' }, + { key: 'A', value: 'value' } + ] + }, "cyclic dependency causes original array to be returned": { variables: [ { key: 'variable', value: '$variable2' }, |