diff options
author | Matija Čupić <matteeyah@gmail.com> | 2019-02-26 17:03:42 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2019-02-26 17:03:42 +0300 |
commit | c9125c4786970fc3c3745c7ea7bff45ef7a62e7d (patch) | |
tree | 38bd564113590665646b974dcbdf91f51b3a4b88 /spec/lib | |
parent | c1d8f8a41042ac7abb2916206e8a411e82af442e (diff) |
Add Maskable concern for CI variables
This adds a concern that abstracts the concept of masking a variable,
including the RegEx for validation.
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/ci/variables/collection/item_spec.rb | 20 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/variables/collection_spec.rb | 4 |
2 files changed, 19 insertions, 5 deletions
diff --git a/spec/lib/gitlab/ci/variables/collection/item_spec.rb b/spec/lib/gitlab/ci/variables/collection/item_spec.rb index 8bf44acb228..3ff2fe18c15 100644 --- a/spec/lib/gitlab/ci/variables/collection/item_spec.rb +++ b/spec/lib/gitlab/ci/variables/collection/item_spec.rb @@ -6,7 +6,7 @@ describe Gitlab::Ci::Variables::Collection::Item do let(:expected_value) { variable_value } let(:variable) do - { key: variable_key, value: variable_value, public: true } + { key: variable_key, value: variable_value, public: true, masked: false } end describe '.new' do @@ -88,7 +88,7 @@ describe Gitlab::Ci::Variables::Collection::Item do resource = described_class.fabricate(variable) expect(resource).to be_a(described_class) - expect(resource).to eq(key: 'CI_VAR', value: '123', public: false) + expect(resource).to eq(key: 'CI_VAR', value: '123', public: false, masked: false) end it 'supports using another collection item' do @@ -134,7 +134,21 @@ describe Gitlab::Ci::Variables::Collection::Item do .to_runner_variable expect(runner_variable) - .to eq(key: 'VAR', value: 'value', public: true, file: true) + .to eq(key: 'VAR', value: 'value', public: true, file: true, masked: false) + end + end + + context 'when variable masking is disabled' do + before do + stub_feature_flags(variable_masking: false) + end + + it 'does not expose the masked field to the runner' do + runner_variable = described_class + .new(key: 'VAR', value: 'value', masked: true) + .to_runner_variable + + expect(runner_variable).to eq(key: 'VAR', value: 'value', public: true) end end end diff --git a/spec/lib/gitlab/ci/variables/collection_spec.rb b/spec/lib/gitlab/ci/variables/collection_spec.rb index 5c91816a586..edb209c0cf4 100644 --- a/spec/lib/gitlab/ci/variables/collection_spec.rb +++ b/spec/lib/gitlab/ci/variables/collection_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Gitlab::Ci::Variables::Collection do describe '.new' do it 'can be initialized with an array' do - variable = { key: 'VAR', value: 'value', public: true } + variable = { key: 'VAR', value: 'value', public: true, masked: false } collection = described_class.new([variable]) @@ -93,7 +93,7 @@ describe Gitlab::Ci::Variables::Collection do collection = described_class.new([{ key: 'TEST', value: '1' }]) expect(collection.to_runner_variables) - .to eq [{ key: 'TEST', value: '1', public: true }] + .to eq [{ key: 'TEST', value: '1', public: true, masked: false }] end end |