diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /spec/requests/api/admin/ci/variables_spec.rb | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'spec/requests/api/admin/ci/variables_spec.rb')
-rw-r--r-- | spec/requests/api/admin/ci/variables_spec.rb | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/spec/requests/api/admin/ci/variables_spec.rb b/spec/requests/api/admin/ci/variables_spec.rb index f89964411f8..4bdc44cb583 100644 --- a/spec/requests/api/admin/ci/variables_spec.rb +++ b/spec/requests/api/admin/ci/variables_spec.rb @@ -71,7 +71,8 @@ RSpec.describe ::API::Admin::Ci::Variables do key: 'TEST_VARIABLE_2', value: 'PROTECTED_VALUE_2', protected: true, - masked: true + masked: true, + raw: true } end.to change { ::Ci::InstanceVariable.count }.by(1) @@ -80,9 +81,19 @@ RSpec.describe ::API::Admin::Ci::Variables do expect(json_response['value']).to eq('PROTECTED_VALUE_2') expect(json_response['protected']).to be_truthy expect(json_response['masked']).to be_truthy + expect(json_response['raw']).to be_truthy expect(json_response['variable_type']).to eq('env_var') end + it 'masks the new value when logging' do + masked_params = { 'key' => 'VAR_KEY', 'value' => '[FILTERED]', 'protected' => 'true', 'masked' => 'true' } + + expect(::API::API::LOGGER).to receive(:info).with(include(params: include(masked_params))) + + post api("/admin/ci/variables", user), + params: { key: 'VAR_KEY', value: 'SENSITIVE', protected: true, masked: true } + end + it 'creates variable with optional attributes', :aggregate_failures do expect do post api('/admin/ci/variables', admin), @@ -98,6 +109,7 @@ RSpec.describe ::API::Admin::Ci::Variables do expect(json_response['value']).to eq('VALUE_2') expect(json_response['protected']).to be_falsey expect(json_response['masked']).to be_falsey + expect(json_response['raw']).to be_falsey expect(json_response['variable_type']).to eq('file') end @@ -153,7 +165,8 @@ RSpec.describe ::API::Admin::Ci::Variables do variable_type: 'file', value: 'VALUE_1_UP', protected: true, - masked: true + masked: true, + raw: true } expect(response).to have_gitlab_http_status(:ok) @@ -161,6 +174,16 @@ RSpec.describe ::API::Admin::Ci::Variables do expect(variable.reload).to be_protected expect(json_response['variable_type']).to eq('file') expect(json_response['masked']).to be_truthy + expect(json_response['raw']).to be_truthy + end + + it 'masks the new value when logging' do + masked_params = { 'value' => '[FILTERED]', 'protected' => 'true', 'masked' => 'true' } + + expect(::API::API::LOGGER).to receive(:info).with(include(params: include(masked_params))) + + put api("/admin/ci/variables/#{variable.key}", admin), + params: { value: 'SENSITIVE', protected: true, masked: true } end it 'responds with 404 Not Found if requesting non-existing variable' do |