BigW Consortium Gitlab

mask_secret_spec.rb 614 Bytes
Newer Older
1 2 3 4 5 6 7
require 'spec_helper'

describe Ci::MaskSecret, lib: true do
  subject { described_class }

  describe '#mask' do
    it 'masks exact number of characters' do
8
      expect(mask('token', 'oke')).to eq('txxxn')
9 10 11
    end

    it 'masks multiple occurrences' do
12
      expect(mask('token token token', 'oke')).to eq('txxxn txxxn txxxn')
13 14 15
    end

    it 'does not mask if not found' do
16 17 18
      expect(mask('token', 'not')).to eq('token')
    end

19 20 21 22
    it 'does support null token' do
      expect(mask('token', nil)).to eq('token')
    end

23
    def mask(value, token)
24
      subject.mask!(value.dup, token)
25 26 27
    end
  end
end