debian-mirror-gitlab/spec/lib/gitlab/ci/mask_secret_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
781 B
Ruby
Raw Permalink Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2022-10-11 01:57:18 +05:30
require 'fast_spec_helper'
2016-09-29 09:46:39 +05:30
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::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
2021-02-22 17:27:13 +05:30
it 'does not change a bytesize of a value' do
expect(mask('token-ü/unicode', 'token-ü').bytesize).to eq 16
end
2016-09-29 09:46:39 +05:30
def mask(value, token)
subject.mask!(value.dup, token)
end
end
end