-
-
Notifications
You must be signed in to change notification settings - Fork 395
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #692 from splattael/splattael/short-token
Redact short and known private tokens
- Loading branch information
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
RSpec.describe Gitlab::Client do | ||
subject(:client) { described_class.new(options) } | ||
|
||
describe '#inspect' do | ||
subject { client.inspect } | ||
|
||
context 'without private token' do | ||
let(:options) { { private_token: nil } } | ||
|
||
it { is_expected.not_to include('@private_token=') } | ||
end | ||
|
||
context 'with a some lengthy private token' do | ||
let(:options) { { private_token: 'some token' } } | ||
|
||
it { is_expected.to include('@private_token="******oken"') } | ||
end | ||
|
||
context 'with a known private token' do | ||
let(:options) { { private_token: 'endpoint' } } | ||
|
||
it { is_expected.to include('@private_token="****oint"') } | ||
it { is_expected.to include('@endpoint=') } | ||
end | ||
|
||
context 'with empty private token' do | ||
let(:options) { { private_token: '' } } | ||
|
||
it { is_expected.to include('@private_token="****"') } | ||
end | ||
|
||
context 'with short private token' do | ||
let(:options) { { private_token: 'abcd' } } | ||
|
||
it { is_expected.to include('@private_token="****"') } | ||
end | ||
end | ||
end |