summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-09-19 12:38:03 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2016-09-19 12:38:10 +0200
commitb51ededc5fef05f94a632aa7651b5a1f7395bd4e (patch)
tree74a4e49d7c005d67823ec206c65ab75fed5e62d6 /spec/lib
parent0ca43b1b86edea69656582b2a8febb0d41f7ef01 (diff)
downloadgitlab-ce-b51ededc5fef05f94a632aa7651b5a1f7395bd4e.tar.gz
Don't leak build tokens in build logs
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/ci/mask_secret_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/lib/ci/mask_secret_spec.rb b/spec/lib/ci/mask_secret_spec.rb
new file mode 100644
index 00000000000..518de76911c
--- /dev/null
+++ b/spec/lib/ci/mask_secret_spec.rb
@@ -0,0 +1,19 @@
+require 'spec_helper'
+
+describe Ci::MaskSecret, lib: true do
+ subject { described_class }
+
+ describe '#mask' do
+ it 'masks exact number of characters' do
+ expect(subject.mask('token', 'oke')).to eq('txxxn')
+ end
+
+ it 'masks multiple occurrences' do
+ expect(subject.mask('token token token', 'oke')).to eq('txxxn txxxn txxxn')
+ end
+
+ it 'does not mask if not found' do
+ expect(subject.mask('token', 'not')).to eq('token')
+ end
+ end
+end