Commit e514baf2 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'ajk-integration-models-spec-test-fix' into 'master'

Fix incorrect use of properties

See merge request gitlab-org/gitlab!80027
parents f864b286 1b9c7769
......@@ -392,8 +392,7 @@ class Integration < ApplicationRecord
end
def api_field_names
fields.map { |field| field[:name] }
.reject { |field_name| field_name =~ /(password|token|key|title|description)/ }
fields.pluck(:name).grep_v(/password|token|key|title|description/)
end
def global_fields
......
......@@ -710,30 +710,21 @@ RSpec.describe Integration do
[
{ name: 'token' },
{ name: 'api_token' },
{ name: 'token_api' },
{ name: 'safe_token' },
{ name: 'key' },
{ name: 'api_key' },
{ name: 'password' },
{ name: 'password_field' },
{ name: 'some_safe_field' },
{ name: 'safe_field' }
]
].shuffle
end
end
end
let(:integration) do
fake_integration.new(properties: [
{ token: 'token-value' },
{ api_token: 'api_token-value' },
{ key: 'key-value' },
{ api_key: 'api_key-value' },
{ password: 'password-value' },
{ password_field: 'password_field-value' },
{ safe_field: 'safe_field-value' }
])
end
it 'filters out sensitive fields' do
expect(integration.api_field_names).to eq(['safe_field'])
expect(fake_integration.new).to have_attributes(api_field_names: match_array(%w[some_safe_field safe_field]))
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment