lhc 15.2.1 → 16.0.0.pre.pro2162

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: 42aac9f48f10f07bbe4db078524e5b53ac03e8851184d5206a5898f79d2433ff
4
- data.tar.gz: 5446bcfaa0ad5d3d46123326ebd14742b7fad56c32c1658073c3baec94fa41c8
3
+ metadata.gz: 624333537e8e35fa6ece5b46b1748263e023b439060c8e8b6b7ca0572db52ead
4
+ data.tar.gz: 588b9c2328f9ef96fa6709d6d12580083712e863838cb6e3b75b9dfb2e0efe35
5
5
  SHA512:
6
- metadata.gz: 974f22ca22bce0aa13a6c0ee139f8bae16582b2186970259948fb0cf6770191771edc4279c064a93965eca0c54a229ee7bd74da95498dafb9127fd20641c1385
7
- data.tar.gz: 806ccd323810f9bd83cd5b5ee087198d17e88d6b5e8cc04859fa42dd7670c5970273f06d7534052ea3e153f5709eaec8cee8349cc5b8dbc7299034b0bf1dd9d8
6
+ metadata.gz: d038ab78edbddf4f9d3cd8c4f8dd85285448a79498df99f02e9893bf04a68a80fc17fa286555399752452c1e68701307eb2d45112df1bb31df7f96b81c531b23
7
+ data.tar.gz: d45a0a5e8990644c7748527affe7fcee24f481f10043f6368ca90a5bbe8b76ad6e32fbfecc85e65e8f21765799926576ad815f443b34617540b6da8594f66d2b
data/.rubocop.yml CHANGED
@@ -26,9 +26,6 @@ require:
26
26
  Bundler/OrderedGems:
27
27
  Enabled: false
28
28
 
29
- Gemspec/RequireMFA:
30
- Enabled: false
31
-
32
29
  Lint/SuppressedException:
33
30
  Exclude:
34
31
  - spec/**/*
@@ -263,7 +260,7 @@ Style/CaseLikeIf:
263
260
  Enabled: false
264
261
 
265
262
  Style/HashEachMethods:
266
- Enabled: false
263
+ Enabled: false
267
264
 
268
265
  Style/HashConversion: # (new in 1.10)
269
266
  Enabled: false
@@ -271,9 +268,6 @@ Style/HashConversion: # (new in 1.10)
271
268
  Style/NilLambda: # (new in 1.3)
272
269
  Enabled: false
273
270
 
274
- Style/OpenStructUse:
275
- Enabled: false
276
-
277
271
  RSpec/DescribeClass:
278
272
  Exclude:
279
273
  - spec/views/**/*
data/README.md CHANGED
@@ -618,18 +618,12 @@ Adds the following to body of all requests:
618
618
 
619
619
  ##### Reauthenticate
620
620
 
621
- The current implementation offers only reauthentication for _client access tokens_.
622
- Make sure that your interceptors contain `LHC::Auth` and `LHC::Retry`, whereas `LHC::Retry` comes _after_ `LHC::Auth` in the chain.
623
- Provide the refresh token as following:
624
- ```ruby
625
- LHC.get('http://local.ch', auth: { bearer: -> { access_token }, refresh_client_token: -> { TokenRefreshUtil.client_access_token(true) })
626
- ```
627
- Where `TokenRefreshUtil.client_access_token(true)` forces a refresh of the token and returns the new token. It is also expected that this implementation will handle invalidating caches if necessary.
621
+ The current implementation can only offer reauthenticate for _client access tokens_. For this to work the following has to be given:
628
622
 
629
- You can also set a global `refresh_client_token`. This is not recommended for apps with multiple endpoint and different access tokens.
630
- ```ruby
631
- LHC::Auth.refresh_client_token = -> { TokenRefreshUtil.client_access_token(true) }
632
- ```
623
+ * You have configured and implemented `LHC::Auth.refresh_client_token = -> { TokenRefreshUtil.client_access_token(true) }` which when called will force a refresh of the token and return the new value. It is also expected that this implementation will handle invalidating caches if necessary.
624
+ * Your interceptors contain `LHC::Auth` and `LHC::Retry`, whereas `LHC::Retry` comes _after_ `LHC::Auth` in the chain.
625
+
626
+ ##### Bearer Authentication with client access token
633
627
 
634
628
  Reauthentication will be initiated if:
635
629
 
data/lhc.gemspec CHANGED
@@ -15,7 +15,8 @@ Gem::Specification.new do |s|
15
15
  s.summary = 'Advanced HTTP Client for Ruby, fueled with interceptors'
16
16
  s.description = 'LHC is an extended/advanced HTTP client. Implementing basic http-communication enhancements like interceptors, exception handling, format handling, accessing response data, configuring endpoints and placeholders and fully compatible, RFC-compliant URL-template support.'
17
17
 
18
- s.files = `git ls-files`.split("\n")
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- spec/*`.split("\n")
19
20
  s.require_paths = ['lib']
20
21
 
21
22
  s.requirements << 'Ruby >= 2.0.0'
@@ -23,7 +24,6 @@ Gem::Specification.new do |s|
23
24
 
24
25
  s.add_dependency 'activesupport', '>= 5.2'
25
26
  s.add_dependency 'addressable'
26
- s.add_dependency 'local_uri'
27
27
  s.add_dependency 'typhoeus', '>= 0.11'
28
28
 
29
29
  s.add_development_dependency 'geminabox'
@@ -35,7 +35,6 @@ Gem::Specification.new do |s|
35
35
  s.add_development_dependency 'rubocop', '~> 1.0'
36
36
  s.add_development_dependency 'rubocop-performance', '~> 1.0'
37
37
  s.add_development_dependency 'rubocop-rspec', '~> 1.26.0'
38
- s.add_development_dependency 'sprockets-rails'
39
38
  s.add_development_dependency 'timecop'
40
39
  s.add_development_dependency 'webmock'
41
40
 
data/lib/lhc/error.rb CHANGED
@@ -75,7 +75,7 @@ class LHC::Error < StandardError
75
75
  debug << "Options: #{request.scrubbed_options}"
76
76
  debug << "Headers: #{request.scrubbed_headers}"
77
77
  debug << "Response Code: #{response.code} (#{response.options[:return_code]})"
78
- debug << "Response Options: #{response.scrubbed_options}"
78
+ debug << "Response Options: #{response.options}"
79
79
  debug << response.body
80
80
  debug << _message
81
81
  debug.map { |str| self.class.fix_invalid_encoding(str) }.join("\n")
@@ -39,7 +39,7 @@ class LHC::Auth < LHC::Interceptor
39
39
  set_bearer_authorization_header(token)
40
40
  end
41
41
 
42
- # rubocop:disable Naming/AccessorMethodName
42
+ # rubocop:disable Style/AccessorMethodName
43
43
  def set_authorization_header(value)
44
44
  request.headers['Authorization'] = value
45
45
  end
@@ -50,18 +50,20 @@ class LHC::Auth < LHC::Interceptor
50
50
  end
51
51
 
52
52
  def set_bearer_authorization_header(token)
53
- auth_options = request.options[:auth] || {}
54
- auth_options.merge!(bearer_token: token)
55
- request.options[:auth] = auth_options unless request.options.key?(:auth)
56
-
53
+ request.options[:auth].merge!(bearer_token: token)
57
54
  set_authorization_header("Bearer #{token}")
58
55
  end
59
- # rubocop:enable Naming/AccessorMethodName
56
+ # rubocop:enable Style/AccessorMethodName
60
57
 
61
58
  def reauthenticate!
62
- # refresh token and update header
63
- token = refresh_client_token_option.call
64
- set_bearer_authorization_header(token)
59
+ # refresh access_token
60
+ refresh_client_token_option.call
61
+
62
+ # Now as the token is refreshe
63
+ # we need to use the refreshed bearer token
64
+ # in the authorization header
65
+ bearer_authentication! if auth_options[:bearer]
66
+
65
67
  # trigger LHC::Retry and ensure we do not trigger reauthenticate!
66
68
  # again should it fail another time
67
69
  new_options = request.options.dup
@@ -7,8 +7,8 @@ class LHC::Rollbar < LHC::Interceptor
7
7
  include LHC::FixInvalidEncodingConcern
8
8
 
9
9
  def after_response
10
- return unless Object.const_defined?(:Rollbar)
11
- return unless report?
10
+ return unless Object.const_defined?('Rollbar')
11
+ return if response.success?
12
12
 
13
13
  request = response.request
14
14
  additional_params = request.options.fetch(:rollbar, {})
@@ -29,18 +29,9 @@ class LHC::Rollbar < LHC::Interceptor
29
29
  }.merge additional_params
30
30
  begin
31
31
  Rollbar.warning("Status: #{response.code} URL: #{request.url}", data)
32
- rescue JSON::GeneratorError, Encoding::UndefinedConversionError
32
+ rescue Encoding::UndefinedConversionError
33
33
  sanitized_data = data.deep_transform_values { |value| self.class.fix_invalid_encoding(value) }
34
34
  Rollbar.warning("Status: #{response.code} URL: #{request.url}", sanitized_data)
35
35
  end
36
36
  end
37
-
38
- private
39
-
40
- def report?
41
- return false if response.success?
42
- return false if response.request.error_ignored?
43
-
44
- true
45
- end
46
37
  end
data/lib/lhc/request.rb CHANGED
@@ -72,7 +72,6 @@ class LHC::Request
72
72
 
73
73
  def scrubbed_options
74
74
  scrubbed_options = options.deep_dup
75
- scrubbed_options[:cache] = LHC::CacheScrubber.new(scrubbed_options[:cache]).scrubbed
76
75
  scrubbed_options[:params] = LHC::ParamsScrubber.new(scrubbed_options[:params]).scrubbed
77
76
  scrubbed_options[:headers] = LHC::HeadersScrubber.new(scrubbed_options[:headers], scrubbed_options[:auth]).scrubbed
78
77
  scrubbed_options[:auth] = LHC::AuthScrubber.new(scrubbed_options[:auth]).scrubbed
data/lib/lhc/response.rb CHANGED
@@ -54,12 +54,6 @@ class LHC::Response
54
54
  request.format
55
55
  end
56
56
 
57
- def scrubbed_options
58
- scrubbed_options = options.deep_dup
59
- scrubbed_options[:effective_url] = LHC::EffectiveUrlScrubber.new(scrubbed_options[:effective_url]).scrubbed
60
- scrubbed_options
61
- end
62
-
63
57
  private
64
58
 
65
59
  attr_accessor :raw
@@ -44,7 +44,6 @@ class LHC::HeadersScrubber < LHC::Scrubber
44
44
 
45
45
  def scrub_bearer_authentication_headers?
46
46
  auth_options[:bearer].present? &&
47
- auth_options[:bearer_token] &&
48
47
  scrubbed['Authorization'].present? &&
49
48
  scrubbed['Authorization'].include?(auth_options[:bearer_token])
50
49
  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.2.1'
4
+ VERSION ||= '16.0.0-pro2162'
5
5
  end
data/lib/lhc.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'local_uri'
4
3
  require 'typhoeus'
5
4
  require 'active_support/core_ext/object/blank'
6
5
  require 'active_support/core_ext/hash/keys'
@@ -120,10 +119,6 @@ module LHC
120
119
  'lhc/scrubbers/auth_scrubber'
121
120
  autoload :BodyScrubber,
122
121
  'lhc/scrubbers/body_scrubber'
123
- autoload :CacheScrubber,
124
- 'lhc/scrubbers/cache_scrubber'
125
- autoload :EffectiveUrlScrubber,
126
- 'lhc/scrubbers/effective_url_scrubber'
127
122
  autoload :HeadersScrubber,
128
123
  'lhc/scrubbers/headers_scrubber'
129
124
  autoload :ParamsScrubber,
@@ -15,7 +15,7 @@ describe LHC::Error do
15
15
  expect { "#{valid} #{invalid}" }.to raise_error Encoding::CompatibilityError
16
16
  end
17
17
  it 'to_json on an array raises an error' do
18
- expect { [valid, invalid].to_json }.to raise_error JSON::GeneratorError
18
+ expect { [valid, invalid].to_json }.to raise_error Encoding::UndefinedConversionError
19
19
  end
20
20
 
21
21
  it 'to_s on a hash does not raise an error' do
@@ -23,7 +23,7 @@ describe LHC::Error do
23
23
  end
24
24
 
25
25
  it 'to_json on a hash does raise an error' do
26
- expect { { valid: valid, invalid: invalid }.to_json }.to raise_error JSON::GeneratorError
26
+ expect { { valid: valid, invalid: invalid }.to_json }.to raise_error Encoding::UndefinedConversionError
27
27
  end
28
28
  end
29
29
 
@@ -55,12 +55,10 @@ describe LHC::Error do
55
55
  end
56
56
 
57
57
  let(:response) do
58
- options = { return_code: :internal_error, response_headers: "" }
59
58
  double('LHC::Response',
60
59
  request: request,
61
60
  code: 500,
62
- options: options,
63
- scrubbed_options: options,
61
+ options: { return_code: :internal_error, response_headers: "" },
64
62
  body: '{"status":500,"message":"undefined"}')
65
63
  end
66
64
 
@@ -5,7 +5,10 @@ require 'rails_helper'
5
5
  describe LHC::Auth do
6
6
  let(:initial_token) { '123456' }
7
7
  let(:refresh_token) { 'abcdef' }
8
- let(:options) { { bearer: initial_token, refresh_client_token: -> { refresh_token } } }
8
+
9
+ let(:options) do
10
+ { bearer: -> { DummyAuthentication.access_token }, refresh_client_token: -> { DummyAuthentication.refresh_token } }
11
+ end
9
12
  let!(:auth_failing) do
10
13
  stub_request(:get, 'http://local.ch')
11
14
  .with(headers: { 'Authorization' => "Bearer #{initial_token}" })
@@ -17,6 +20,23 @@ describe LHC::Auth do
17
20
  end
18
21
 
19
22
  before(:each) do
23
+ class DummyAuthentication
24
+
25
+ def self.refresh_token
26
+ # updates access_token
27
+ end
28
+
29
+ def self.access_token
30
+ # this is used as bearer token
31
+ end
32
+ end
33
+
34
+ # It does not matter what value this method returns it is not use by LHC.
35
+ # That method needs just to make sure that the value of the access_token
36
+ # is the new valid token
37
+ allow(DummyAuthentication).to receive(:refresh_token).and_return(nil)
38
+
39
+ allow(DummyAuthentication).to receive(:access_token).and_return(initial_token, refresh_token)
20
40
  LHC.config.interceptors = [LHC::Auth, LHC::Retry]
21
41
  end
22
42
 
@@ -27,27 +47,6 @@ describe LHC::Auth do
27
47
  expect(auth_suceeding_after_recovery).to have_been_made.once
28
48
  end
29
49
 
30
- context 'without `auth` options' do
31
- let(:headers) do
32
- { 'Authorization' => "Bearer #{initial_token}" }
33
- end
34
-
35
- before do
36
- LHC::Auth.refresh_client_token = -> { refresh_token }
37
- end
38
-
39
- after do
40
- LHC::Auth.refresh_client_token = -> { nil }
41
- end
42
-
43
- it 'recovery is attempted' do
44
- LHC.config.endpoint(:local, 'http://local.ch')
45
- # the retried request (with updated Bearer), that should work
46
- LHC.get(:local, { headers: headers })
47
- expect(auth_suceeding_after_recovery).to have_been_made.once
48
- end
49
- end
50
-
51
50
  it "recovery is not attempted again when the request has reauthenticated: true " do
52
51
  LHC.config.endpoint(:local, 'http://local.ch', auth: options.merge(reauthenticated: true))
53
52
  expect { LHC.get(:local) }.to raise_error(LHC::Unauthorized)
@@ -9,7 +9,7 @@ describe LHC::Rollbar do
9
9
 
10
10
  context 'Rollbar is undefined' do
11
11
  before(:each) do
12
- Object.send(:remove_const, 'Rollbar') if Object.const_defined?(:Rollbar)
12
+ Object.send(:remove_const, 'Rollbar') if Object.const_defined?('Rollbar')
13
13
  end
14
14
  it 'does not report' do
15
15
  stub_request(:get, 'http://local.ch').to_return(status: 400)
@@ -65,24 +65,5 @@ describe LHC::Rollbar do
65
65
  request: hash_including(url: anything, method: anything, headers: hash_including(private_key: LHC::Scrubber::SCRUB_DISPLAY), params: { api_key: LHC::Scrubber::SCRUB_DISPLAY })
66
66
  )
67
67
  end
68
-
69
- context 'ignored errors' do
70
- it 'does not report to rollbar if the error is ignored' do
71
- stub_request(:get, 'http://local.ch').to_return(status: 404)
72
- LHC.get('http://local.ch', ignore: [LHC::NotFound])
73
- expect(::Rollbar).not_to have_received(:warning)
74
- end
75
-
76
- it 'does report to rollbar' do
77
- stub_request(:get, 'http://local.ch').to_return(status: 400)
78
- expect(-> { LHC.get('http://local.ch', ignore: [LHC::NotFound]) }).to raise_error LHC::BadRequest
79
- expect(::Rollbar).not_to have_received(:warning)
80
- .with(
81
- 'Status: 400 URL: http://local.ch',
82
- response: hash_including(body: anything, code: anything, headers: anything, time: anything, timeout?: anything),
83
- request: hash_including(url: anything, method: anything, headers: hash_including(private_key: LHC::Scrubber::SCRUB_DISPLAY), params: { api_key: LHC::Scrubber::SCRUB_DISPLAY })
84
- )
85
- end
86
- end
87
68
  end
88
69
  end
@@ -74,14 +74,6 @@ describe LHC::Request do
74
74
  LHC.config.scrubs = {}
75
75
  expect(request.scrubbed_headers).to include(authorization_header)
76
76
  end
77
-
78
- context 'when the bearer_token is nil' do
79
- let(:bearer_token) { nil }
80
-
81
- it 'scrubs nothing' do
82
- expect(request.scrubbed_headers).to include(authorization_header)
83
- end
84
- end
85
77
  end
86
78
 
87
79
  context 'basic authentication' do
@@ -18,12 +18,9 @@ describe LHC::Request do
18
18
  let(:params) { { api_key: 'api-key-params' } }
19
19
  let(:headers) { { private_key: 'private-key-header' } }
20
20
  let(:body) { { user_token: 'user-token-body' } }
21
- let(:cache) do
22
- { key: "LHS_REQUEST_CYCLE_CACHE(v1) POST http://local.ch?#{params}" }
23
- end
24
21
 
25
22
  let(:request) do
26
- response = LHC.post(:local, params: params, headers: headers, body: body, cache: cache)
23
+ response = LHC.post(:local, params: params, headers: headers, body: body)
27
24
  response.request
28
25
  end
29
26
 
@@ -33,8 +30,6 @@ describe LHC::Request do
33
30
  expect(request.scrubbed_options[:body]).to include(user_token: LHC::Scrubber::SCRUB_DISPLAY)
34
31
  expect(request.scrubbed_options[:auth][:bearer_token]).to eq(LHC::Scrubber::SCRUB_DISPLAY)
35
32
  expect(request.scrubbed_options[:auth][:basic]).to be nil
36
- expect(request.scrubbed_options[:cache])
37
- .to include(key: "LHS_REQUEST_CYCLE_CACHE(v1) POST http://local.ch?{:api_key=>\"[FILTERED]\"}")
38
33
  end
39
34
 
40
35
  context 'when bearer auth is not a proc' do
@@ -58,19 +53,6 @@ describe LHC::Request do
58
53
  end
59
54
  end
60
55
 
61
- context 'when parameter should not get scrubbed' do
62
- let(:params) { { any_parameter: 'any-parameter' } }
63
-
64
- let(:cache) do
65
- { key: "LHS_REQUEST_CYCLE_CACHE(v1) POST http://local.ch?#{params}" }
66
- end
67
-
68
- it 'does not scrubb the parameter' do
69
- expect(request.scrubbed_options[:cache])
70
- .to include(key: "LHS_REQUEST_CYCLE_CACHE(v1) POST http://local.ch?#{params}")
71
- end
72
- end
73
-
74
56
  context 'when body data is nested' do
75
57
  let(:body) do
76
58
  {
@@ -122,8 +104,6 @@ describe LHC::Request do
122
104
  expect(request.scrubbed_options[:headers]).not_to include(private_key: LHC::Scrubber::SCRUB_DISPLAY)
123
105
  expect(request.scrubbed_options[:body]).not_to include(user_token: LHC::Scrubber::SCRUB_DISPLAY)
124
106
  expect(request.scrubbed_options[:auth][:bearer_token]).not_to eq(LHC::Scrubber::SCRUB_DISPLAY)
125
- expect(request.scrubbed_options[:cache])
126
- .not_to include(key: "LHS_REQUEST_CYCLE_CACHE(v1) POST http://local.ch?{:api_key=>\"[FILTERED]\"}")
127
107
  end
128
108
  end
129
109
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhc
3
3
  version: !ruby/object:Gem::Version
4
- version: 15.2.1
4
+ version: 16.0.0.pre.pro2162
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/local-ch/lhc/contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-01 00:00:00.000000000 Z
11
+ date: 2021-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: local_uri
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: typhoeus
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -192,20 +178,6 @@ dependencies:
192
178
  - - "~>"
193
179
  - !ruby/object:Gem::Version
194
180
  version: 1.26.0
195
- - !ruby/object:Gem::Dependency
196
- name: sprockets-rails
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - ">="
200
- - !ruby/object:Gem::Version
201
- version: '0'
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - ">="
207
- - !ruby/object:Gem::Version
208
- version: '0'
209
181
  - !ruby/object:Gem::Dependency
210
182
  name: timecop
211
183
  requirement: !ruby/object:Gem::Requirement
@@ -301,8 +273,6 @@ files:
301
273
  - lib/lhc/scrubber.rb
302
274
  - lib/lhc/scrubbers/auth_scrubber.rb
303
275
  - lib/lhc/scrubbers/body_scrubber.rb
304
- - lib/lhc/scrubbers/cache_scrubber.rb
305
- - lib/lhc/scrubbers/effective_url_scrubber.rb
306
276
  - lib/lhc/scrubbers/headers_scrubber.rb
307
277
  - lib/lhc/scrubbers/params_scrubber.rb
308
278
  - lib/lhc/test/cache_helper.rb
@@ -431,7 +401,6 @@ files:
431
401
  - spec/response/effective_url_spec.rb
432
402
  - spec/response/headers_spec.rb
433
403
  - spec/response/options_spec.rb
434
- - spec/response/scrubbed_options_spec.rb
435
404
  - spec/response/success_spec.rb
436
405
  - spec/response/time_spec.rb
437
406
  - spec/spec_helper.rb
@@ -458,13 +427,147 @@ required_ruby_version: !ruby/object:Gem::Requirement
458
427
  version: '2.7'
459
428
  required_rubygems_version: !ruby/object:Gem::Requirement
460
429
  requirements:
461
- - - ">="
430
+ - - ">"
462
431
  - !ruby/object:Gem::Version
463
- version: '0'
432
+ version: 1.3.1
464
433
  requirements:
465
434
  - Ruby >= 2.0.0
466
435
  rubygems_version: 3.1.4
467
436
  signing_key:
468
437
  specification_version: 4
469
438
  summary: Advanced HTTP Client for Ruby, fueled with interceptors
470
- test_files: []
439
+ test_files:
440
+ - spec/basic_methods/delete_spec.rb
441
+ - spec/basic_methods/get_spec.rb
442
+ - spec/basic_methods/post_spec.rb
443
+ - spec/basic_methods/put_spec.rb
444
+ - spec/basic_methods/request_spec.rb
445
+ - spec/basic_methods/request_without_rails_spec.rb
446
+ - spec/config/endpoints_spec.rb
447
+ - spec/config/placeholders_spec.rb
448
+ - spec/config/scrubs_spec.rb
449
+ - spec/core_ext/hash/deep_transform_values_spec.rb
450
+ - spec/dummy/README.rdoc
451
+ - spec/dummy/Rakefile
452
+ - spec/dummy/app/assets/config/manifest.js
453
+ - spec/dummy/app/assets/images/.keep
454
+ - spec/dummy/app/assets/javascripts/application.js
455
+ - spec/dummy/app/assets/stylesheets/application.css
456
+ - spec/dummy/app/controllers/application_controller.rb
457
+ - spec/dummy/app/controllers/concerns/.keep
458
+ - spec/dummy/app/helpers/application_helper.rb
459
+ - spec/dummy/app/mailers/.keep
460
+ - spec/dummy/app/models/.keep
461
+ - spec/dummy/app/models/concerns/.keep
462
+ - spec/dummy/app/views/layouts/application.html.erb
463
+ - spec/dummy/bin/bundle
464
+ - spec/dummy/bin/rails
465
+ - spec/dummy/bin/rake
466
+ - spec/dummy/config.ru
467
+ - spec/dummy/config/application.rb
468
+ - spec/dummy/config/boot.rb
469
+ - spec/dummy/config/environment.rb
470
+ - spec/dummy/config/environments/development.rb
471
+ - spec/dummy/config/environments/production.rb
472
+ - spec/dummy/config/environments/test.rb
473
+ - spec/dummy/config/initializers/assets.rb
474
+ - spec/dummy/config/initializers/backtrace_silencers.rb
475
+ - spec/dummy/config/initializers/cookies_serializer.rb
476
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
477
+ - spec/dummy/config/initializers/inflections.rb
478
+ - spec/dummy/config/initializers/mime_types.rb
479
+ - spec/dummy/config/initializers/session_store.rb
480
+ - spec/dummy/config/initializers/wrap_parameters.rb
481
+ - spec/dummy/config/locales/en.yml
482
+ - spec/dummy/config/routes.rb
483
+ - spec/dummy/config/secrets.yml
484
+ - spec/dummy/lib/assets/.keep
485
+ - spec/dummy/log/.keep
486
+ - spec/dummy/public/404.html
487
+ - spec/dummy/public/422.html
488
+ - spec/dummy/public/500.html
489
+ - spec/dummy/public/favicon.ico
490
+ - spec/dummy/tmp/cache/.gitkeep
491
+ - spec/endpoint/compile_spec.rb
492
+ - spec/endpoint/match_spec.rb
493
+ - spec/endpoint/placeholders_spec.rb
494
+ - spec/endpoint/remove_interpolated_params_spec.rb
495
+ - spec/endpoint/values_as_params_spec.rb
496
+ - spec/error/dup_spec.rb
497
+ - spec/error/find_spec.rb
498
+ - spec/error/response_spec.rb
499
+ - spec/error/timeout_spec.rb
500
+ - spec/error/to_s_spec.rb
501
+ - spec/formats/form_spec.rb
502
+ - spec/formats/json_spec.rb
503
+ - spec/formats/multipart_spec.rb
504
+ - spec/formats/plain_spec.rb
505
+ - spec/interceptors/after_request_spec.rb
506
+ - spec/interceptors/after_response_spec.rb
507
+ - spec/interceptors/auth/basic_auth_spec.rb
508
+ - spec/interceptors/auth/bearer_spec.rb
509
+ - spec/interceptors/auth/body_spec.rb
510
+ - spec/interceptors/auth/long_basic_auth_credentials_spec.rb
511
+ - spec/interceptors/auth/no_instance_var_for_options_spec.rb
512
+ - spec/interceptors/auth/reauthentication_configuration_spec.rb
513
+ - spec/interceptors/auth/reauthentication_spec.rb
514
+ - spec/interceptors/before_request_spec.rb
515
+ - spec/interceptors/before_response_spec.rb
516
+ - spec/interceptors/caching/hydra_spec.rb
517
+ - spec/interceptors/caching/main_spec.rb
518
+ - spec/interceptors/caching/methods_spec.rb
519
+ - spec/interceptors/caching/multilevel_cache_spec.rb
520
+ - spec/interceptors/caching/options_spec.rb
521
+ - spec/interceptors/caching/parameters_spec.rb
522
+ - spec/interceptors/caching/response_status_spec.rb
523
+ - spec/interceptors/caching/to_cache_spec.rb
524
+ - spec/interceptors/default_interceptors_spec.rb
525
+ - spec/interceptors/default_timeout/main_spec.rb
526
+ - spec/interceptors/define_spec.rb
527
+ - spec/interceptors/dup_spec.rb
528
+ - spec/interceptors/logging/main_spec.rb
529
+ - spec/interceptors/monitoring/caching_spec.rb
530
+ - spec/interceptors/monitoring/main_spec.rb
531
+ - spec/interceptors/prometheus_spec.rb
532
+ - spec/interceptors/response_competition_spec.rb
533
+ - spec/interceptors/retry/main_spec.rb
534
+ - spec/interceptors/return_response_spec.rb
535
+ - spec/interceptors/rollbar/invalid_encoding_spec.rb
536
+ - spec/interceptors/rollbar/main_spec.rb
537
+ - spec/interceptors/throttle/main_spec.rb
538
+ - spec/interceptors/throttle/reset_track_spec.rb
539
+ - spec/interceptors/zipkin/distributed_tracing_spec.rb
540
+ - spec/rails_helper.rb
541
+ - spec/request/body_spec.rb
542
+ - spec/request/encoding_spec.rb
543
+ - spec/request/error_handling_spec.rb
544
+ - spec/request/headers_spec.rb
545
+ - spec/request/ignore_errors_spec.rb
546
+ - spec/request/option_dup_spec.rb
547
+ - spec/request/parallel_requests_spec.rb
548
+ - spec/request/params_encoding_spec.rb
549
+ - spec/request/request_without_rails_spec.rb
550
+ - spec/request/scrubbed_headers_spec.rb
551
+ - spec/request/scrubbed_options_spec.rb
552
+ - spec/request/scrubbed_params_spec.rb
553
+ - spec/request/url_patterns_spec.rb
554
+ - spec/request/user_agent_spec.rb
555
+ - spec/request/user_agent_without_rails_spec.rb
556
+ - spec/response/body_spec.rb
557
+ - spec/response/code_spec.rb
558
+ - spec/response/data_accessor_spec.rb
559
+ - spec/response/data_spec.rb
560
+ - spec/response/effective_url_spec.rb
561
+ - spec/response/headers_spec.rb
562
+ - spec/response/options_spec.rb
563
+ - spec/response/success_spec.rb
564
+ - spec/response/time_spec.rb
565
+ - spec/spec_helper.rb
566
+ - spec/support/fixtures/json/feedback.json
567
+ - spec/support/fixtures/json/feedbacks.json
568
+ - spec/support/fixtures/json/localina_content_ad.json
569
+ - spec/support/load_json.rb
570
+ - spec/support/reset_config.rb
571
+ - spec/support/zipkin_mock.rb
572
+ - spec/timeouts/no_signal_spec.rb
573
+ - spec/timeouts/timings_spec.rb
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class LHC::CacheScrubber < LHC::Scrubber
4
- def initialize(data)
5
- super(data)
6
- scrub_cache_options!
7
- end
8
-
9
- private
10
-
11
- def scrub_cache_options!
12
- return if scrubbed.blank?
13
- return if scrub_elements.blank?
14
-
15
- scrub_cache_key!
16
- end
17
-
18
- def scrub_cache_key!
19
- return if scrubbed[:key].blank?
20
-
21
- scrub_elements.each do |scrub_element|
22
- matches = scrubbed[:key].match(/:#{scrub_element}=>"(.*?)"/)
23
- next if matches.nil?
24
-
25
- value = matches[-1]
26
- scrubbed[:key].gsub!(value, SCRUB_DISPLAY)
27
- end
28
- end
29
-
30
- def scrub_elements
31
- # The cache key includes the whole request url inklusive params.
32
- # We need to scrub those params from the cache key.
33
- LHC.config.scrubs[:params]
34
- end
35
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class LHC::EffectiveUrlScrubber < LHC::Scrubber
4
- def initialize(data)
5
- super(data)
6
- scrub_effective_url_options!
7
- end
8
-
9
- private
10
-
11
- def scrub_effective_url_options!
12
- return if scrubbed.blank?
13
- return if scrub_elements.blank?
14
-
15
- scrub_effective_url!
16
- end
17
-
18
- def scrub_effective_url!
19
- return if scrubbed.blank?
20
-
21
- scrub_elements.each do |scrub_element|
22
- uri = LocalUri::URI.new(scrubbed)
23
- self.scrubbed = CGI.unescape(uri.query.merge(scrub_element => SCRUB_DISPLAY).to_s)
24
- end
25
- end
26
-
27
- def scrub_elements
28
- # The effective url includes the params of the request
29
- # so we need to scrub those params from the effective url.
30
- LHC.config.scrubs[:params]
31
- end
32
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- describe LHC::Response do
6
- let(:options) do
7
- { effective_url: 'http://local.ch?api_key=api-key' }
8
- end
9
-
10
- let(:raw_response) { OpenStruct.new(options: options) }
11
-
12
- before do
13
- LHC.config.scrubs[:params] << 'api_key'
14
- end
15
-
16
- it 'scrubbes effective url' do
17
- response = LHC::Response.new(raw_response, nil)
18
- expect(response.scrubbed_options[:effective_url]).to eq "http://local.ch?api_key=#{LHC::Scrubber::SCRUB_DISPLAY}"
19
- end
20
- end