spec/request/scrubbed_headers_spec.rb in lhc-15.0.0 vs spec/request/scrubbed_headers_spec.rb in lhc-15.0.1

- old
+ new

@@ -57,45 +57,47 @@ context 'bearer authentication' do let(:bearer_token) { '123456' } let(:authorization_header) { { 'Authorization' => "Bearer #{bearer_token}" } } let(:auth) { { bearer: -> { bearer_token } } } - it 'provides srubbed request headers' do + it 'scrubs only the bearer token' do expect(request.scrubbed_headers).to include('Authorization' => "Bearer #{LHC::Scrubber::SCRUB_DISPLAY}") expect(request.headers).to include(authorization_header) end - context 'when nothing should get scrubbed' do - before :each do - LHC.config.scrubs = {} - end + it 'scrubs whole "Authorization" header' do + LHC.config.scrubs[:headers] << 'Authorization' + expect(request.scrubbed_headers).to include('Authorization' => LHC::Scrubber::SCRUB_DISPLAY) + expect(request.headers).to include(authorization_header) + end - it 'does not filter beaerer auth' do - expect(request.scrubbed_headers).to include(authorization_header) - end + it 'scrubs nothing' do + LHC.config.scrubs = {} + expect(request.scrubbed_headers).to include(authorization_header) end end context 'basic authentication' do let(:username) { 'steve' } let(:password) { 'abcdefg' } let(:credentials_base_64_codiert) { Base64.strict_encode64("#{username}:#{password}").chomp } let(:authorization_header) { { 'Authorization' => "Basic #{credentials_base_64_codiert}" } } let(:auth) { { basic: { username: username, password: password } } } - it 'provides srubbed request headers' do + it 'scrubs only credentials' do expect(request.scrubbed_headers).to include('Authorization' => "Basic #{LHC::Scrubber::SCRUB_DISPLAY}") expect(request.headers).to include(authorization_header) end - context 'when nothing should get scrubbed' do - before :each do - LHC.config.scrubs = {} - end + it 'scrubs whole "Authorization" header' do + LHC.config.scrubs[:headers] << 'Authorization' + expect(request.scrubbed_headers).to include('Authorization' => LHC::Scrubber::SCRUB_DISPLAY) + expect(request.headers).to include(authorization_header) + end - it 'does not filter basic auth' do - expect(request.scrubbed_headers).to include(authorization_header) - end + it 'scrubs nothing' do + LHC.config.scrubs = {} + expect(request.scrubbed_headers).to include(authorization_header) end end end end