2016-09-29 09:46:39 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
describe Ci::MaskSecret do
|
2016-09-29 09:46:39 +05:30
|
|
|
subject { described_class }
|
|
|
|
|
|
|
|
describe '#mask' do
|
|
|
|
it 'masks exact number of characters' do
|
|
|
|
expect(mask('token', 'oke')).to eq('txxxn')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'masks multiple occurrences' do
|
|
|
|
expect(mask('token token token', 'oke')).to eq('txxxn txxxn txxxn')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not mask if not found' do
|
|
|
|
expect(mask('token', 'not')).to eq('token')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does support null token' do
|
|
|
|
expect(mask('token', nil)).to eq('token')
|
|
|
|
end
|
|
|
|
|
|
|
|
def mask(value, token)
|
|
|
|
subject.mask!(value.dup, token)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|