summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab
diff options
context:
space:
mode:
authorMaxim Rydkin <maks.rydkin@gmail.com>2017-09-06 14:26:15 +0300
committerMaxim Rydkin <maks.rydkin@gmail.com>2017-09-12 22:32:02 +0300
commit5b296f81e2f49fc7dc2d3b091340a9a8b86eae97 (patch)
treef2a1681807ed6cb937ce41d038f435a949f363f4 /spec/lib/gitlab
parentc45ace8972f18af1f232f9074d6e4104fc4f0c14 (diff)
downloadgitlab-ce-5b296f81e2f49fc7dc2d3b091340a9a8b86eae97.tar.gz
move `lib/ci/mask_secret.rb` into `lib/gitlab/ci/mask_secret.rb`
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r--spec/lib/gitlab/ci/mask_secret_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/mask_secret_spec.rb b/spec/lib/gitlab/ci/mask_secret_spec.rb
new file mode 100644
index 00000000000..3789a142248
--- /dev/null
+++ b/spec/lib/gitlab/ci/mask_secret_spec.rb
@@ -0,0 +1,27 @@
+require 'spec_helper'
+
+describe Gitlab::Ci::MaskSecret do
+ 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