lhc 15.0.0 → 15.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a34aeee4fa910b8099acfdd73813103beb630400b92b449dbfbf4d87de4e041
4
- data.tar.gz: 846b8cc9e24b9b0b9189b24d38c3e7b485096b4afd970cfc6fe48c8ee3a76d7e
3
+ metadata.gz: d9747364f9001f462e35cdc26b209f078daac57834bb4c1a801866f29abc2ba7
4
+ data.tar.gz: e03286ea873459b7093baef6c47807edb4a1543889e887bf0d708c0144b6a087
5
5
  SHA512:
6
- metadata.gz: 067d2e56385e931f00caa829411888881705ec19a702979332ad5074bf1a6515f0893e09111314b825fa7dd6d559518c997ac309f17e06eee245faffe93fcebd
7
- data.tar.gz: 5284f04c83ca525e774775c41bd88d9f2dc8feeaf8f1fb47d3b9bde5677eeaad9bec6be6213597c4d1f34a2a22f8703b9f8e7fef0a4a09a58f24a6f72b2bf66b
6
+ metadata.gz: bc2238780fe87969d1dea621d44960febb3a19e7b650a5e6ce7939f942e47acd01a825e64c39ab4fb4dbeb5636aef1e0819b3f874b95c22461cee4d63ad44368
7
+ data.tar.gz: cc5a2707f9772cc79a3caa3aa96b3c0ffe1a0984fa06446e48a61a9c08240145d772b35b993f11ec24c278367c9db4d2bf35dafee1aa444818323e2aab3c99b6
@@ -25,14 +25,26 @@ class LHC::HeadersScrubber < LHC::Scrubber
25
25
  end
26
26
 
27
27
  def scrub_basic_authentication_headers!
28
- return if auth_options[:basic].blank? || scrubbed['Authorization'].blank?
28
+ return if !scrub_basic_authentication_headers?
29
29
 
30
30
  scrubbed['Authorization'].gsub!(auth_options[:basic][:base_64_encoded_credentials], SCRUB_DISPLAY)
31
31
  end
32
32
 
33
33
  def scrub_bearer_authentication_headers!
34
- return if auth_options[:bearer].blank? || scrubbed['Authorization'].blank?
34
+ return if !scrub_bearer_authentication_headers?
35
35
 
36
36
  scrubbed['Authorization'].gsub!(auth_options[:bearer_token], SCRUB_DISPLAY)
37
37
  end
38
+
39
+ def scrub_basic_authentication_headers?
40
+ auth_options[:basic].present? &&
41
+ scrubbed['Authorization'].present? &&
42
+ scrubbed['Authorization'].include?(auth_options[:basic][:base_64_encoded_credentials])
43
+ end
44
+
45
+ def scrub_bearer_authentication_headers?
46
+ auth_options[:bearer].present? &&
47
+ scrubbed['Authorization'].present? &&
48
+ scrubbed['Authorization'].include?(auth_options[:bearer_token])
49
+ end
38
50
  end
data/lib/lhc/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LHC
4
- VERSION ||= '15.0.0'
4
+ VERSION ||= '15.0.1'
5
5
  end
@@ -59,19 +59,20 @@ describe LHC::Request do
59
59
  let(:authorization_header) { { 'Authorization' => "Bearer #{bearer_token}" } }
60
60
  let(:auth) { { bearer: -> { bearer_token } } }
61
61
 
62
- it 'provides srubbed request headers' do
62
+ it 'scrubs only the bearer token' do
63
63
  expect(request.scrubbed_headers).to include('Authorization' => "Bearer #{LHC::Scrubber::SCRUB_DISPLAY}")
64
64
  expect(request.headers).to include(authorization_header)
65
65
  end
66
66
 
67
- context 'when nothing should get scrubbed' do
68
- before :each do
69
- LHC.config.scrubs = {}
70
- end
67
+ it 'scrubs whole "Authorization" header' do
68
+ LHC.config.scrubs[:headers] << 'Authorization'
69
+ expect(request.scrubbed_headers).to include('Authorization' => LHC::Scrubber::SCRUB_DISPLAY)
70
+ expect(request.headers).to include(authorization_header)
71
+ end
71
72
 
72
- it 'does not filter beaerer auth' do
73
- expect(request.scrubbed_headers).to include(authorization_header)
74
- end
73
+ it 'scrubs nothing' do
74
+ LHC.config.scrubs = {}
75
+ expect(request.scrubbed_headers).to include(authorization_header)
75
76
  end
76
77
  end
77
78
 
@@ -82,19 +83,20 @@ describe LHC::Request do
82
83
  let(:authorization_header) { { 'Authorization' => "Basic #{credentials_base_64_codiert}" } }
83
84
  let(:auth) { { basic: { username: username, password: password } } }
84
85
 
85
- it 'provides srubbed request headers' do
86
+ it 'scrubs only credentials' do
86
87
  expect(request.scrubbed_headers).to include('Authorization' => "Basic #{LHC::Scrubber::SCRUB_DISPLAY}")
87
88
  expect(request.headers).to include(authorization_header)
88
89
  end
89
90
 
90
- context 'when nothing should get scrubbed' do
91
- before :each do
92
- LHC.config.scrubs = {}
93
- end
91
+ it 'scrubs whole "Authorization" header' do
92
+ LHC.config.scrubs[:headers] << 'Authorization'
93
+ expect(request.scrubbed_headers).to include('Authorization' => LHC::Scrubber::SCRUB_DISPLAY)
94
+ expect(request.headers).to include(authorization_header)
95
+ end
94
96
 
95
- it 'does not filter basic auth' do
96
- expect(request.scrubbed_headers).to include(authorization_header)
97
- end
97
+ it 'scrubs nothing' do
98
+ LHC.config.scrubs = {}
99
+ expect(request.scrubbed_headers).to include(authorization_header)
98
100
  end
99
101
  end
100
102
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhc
3
3
  version: !ruby/object:Gem::Version
4
- version: 15.0.0
4
+ version: 15.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/local-ch/lhc/contributors