Skip to content
Snippets Groups Projects
Commit dadb4891 authored by Andrejs Cunskis's avatar Andrejs Cunskis :flag_lv:
Browse files

Merge branch 'qa-shl-mask-token-resource-values' into 'master'

E2E: Mask api_value in logs if attribute is a token

See merge request !96665
parents 38dc1561 de83a1b5
No related branches found
No related tags found
1 merge request!96665E2E: Mask api_value in logs if attribute is a token
Pipeline #629246212 passed
......@@ -263,6 +263,8 @@ def all_attributes
end
def log_having_both_api_result_and_block(name, api_value)
api_value = "[MASKED]" if name == :token
QA::Runtime::Logger.debug(<<~MSG.strip)
<#{self.class}> Attribute #{name.inspect} has both API response `#{api_value}` and a block. API response will be picked. Block will be ignored.
MSG
......
......@@ -24,6 +24,10 @@ def self.name
'block'
end
attribute :token do
'token_value'
end
attribute :username do
'qa'
end
......@@ -208,6 +212,24 @@ def self.name
.to have_received(:debug).with(/api_with_block/)
end
end
context 'when the attribute is token and has a block' do
let(:api_resource) { { token: 'another_token_value' } }
before do
allow(QA::Runtime::Logger).to receive(:debug)
end
it 'emits a masked debug log entry' do
result = subject.fabricate!(resource: resource)
expect(result).to be_a(described_class)
expect(result.token).to eq('another_token_value')
expect(QA::Runtime::Logger)
.to have_received(:debug).with(/MASKED/)
end
end
end
context 'when the attribute is populated via direct assignment' do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment