lhc 13.0.0 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rubocop.yml +15 -0
  3. data/.github/workflows/test.yml +15 -0
  4. data/.rubocop.yml +344 -19
  5. data/.ruby-version +1 -1
  6. data/README.md +89 -0
  7. data/Rakefile +3 -3
  8. data/lhc.gemspec +3 -1
  9. data/lib/lhc.rb +70 -59
  10. data/lib/lhc/concerns/lhc/fix_invalid_encoding_concern.rb +1 -0
  11. data/lib/lhc/config.rb +16 -0
  12. data/lib/lhc/endpoint.rb +3 -0
  13. data/lib/lhc/error.rb +7 -4
  14. data/lib/lhc/interceptor.rb +4 -0
  15. data/lib/lhc/interceptors.rb +1 -0
  16. data/lib/lhc/interceptors/auth.rb +10 -5
  17. data/lib/lhc/interceptors/caching.rb +14 -3
  18. data/lib/lhc/interceptors/logging.rb +4 -2
  19. data/lib/lhc/interceptors/monitoring.rb +46 -11
  20. data/lib/lhc/interceptors/retry.rb +2 -0
  21. data/lib/lhc/interceptors/rollbar.rb +3 -2
  22. data/lib/lhc/interceptors/throttle.rb +7 -2
  23. data/lib/lhc/interceptors/zipkin.rb +2 -0
  24. data/lib/lhc/request.rb +37 -4
  25. data/lib/lhc/response.rb +1 -0
  26. data/lib/lhc/response/data.rb +1 -1
  27. data/lib/lhc/scrubber.rb +45 -0
  28. data/lib/lhc/scrubbers/auth_scrubber.rb +33 -0
  29. data/lib/lhc/scrubbers/body_scrubber.rb +28 -0
  30. data/lib/lhc/scrubbers/headers_scrubber.rb +38 -0
  31. data/lib/lhc/scrubbers/params_scrubber.rb +14 -0
  32. data/lib/lhc/version.rb +1 -1
  33. data/spec/config/scrubs_spec.rb +108 -0
  34. data/spec/error/to_s_spec.rb +13 -8
  35. data/spec/formats/multipart_spec.rb +2 -2
  36. data/spec/formats/plain_spec.rb +1 -1
  37. data/spec/interceptors/after_response_spec.rb +1 -1
  38. data/spec/interceptors/caching/main_spec.rb +2 -2
  39. data/spec/interceptors/caching/multilevel_cache_spec.rb +2 -1
  40. data/spec/interceptors/define_spec.rb +1 -0
  41. data/spec/interceptors/logging/main_spec.rb +21 -1
  42. data/spec/interceptors/monitoring/caching_spec.rb +66 -0
  43. data/spec/interceptors/response_competition_spec.rb +2 -2
  44. data/spec/interceptors/return_response_spec.rb +2 -2
  45. data/spec/interceptors/rollbar/main_spec.rb +27 -15
  46. data/spec/request/scrubbed_headers_spec.rb +101 -0
  47. data/spec/request/scrubbed_options_spec.rb +194 -0
  48. data/spec/request/scrubbed_params_spec.rb +35 -0
  49. data/spec/response/data_spec.rb +2 -2
  50. data/spec/support/zipkin_mock.rb +1 -0
  51. metadata +40 -21
  52. data/.rubocop.localch.yml +0 -325
  53. data/cider-ci.yml +0 -5
  54. data/cider-ci/bin/bundle +0 -51
  55. data/cider-ci/bin/ruby_install +0 -8
  56. data/cider-ci/bin/ruby_version +0 -25
  57. data/cider-ci/jobs/rspec-activesupport-5.yml +0 -27
  58. data/cider-ci/jobs/rspec-activesupport-6.yml +0 -28
  59. data/cider-ci/jobs/rubocop.yml +0 -18
  60. data/cider-ci/task_components/bundle.yml +0 -22
  61. data/cider-ci/task_components/rspec.yml +0 -36
  62. data/cider-ci/task_components/rubocop.yml +0 -29
  63. data/cider-ci/task_components/ruby.yml +0 -15
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_helper'
4
+
5
+ describe LHC::Request do
6
+ let(:params) { { api_key: 'xyz-123', secret_key: '123-xyz' } }
7
+ let(:response) { LHC.get(:local, params: params) }
8
+
9
+ before :each do
10
+ LHC.config.endpoint(:local, 'http://local.ch')
11
+ stub_request(:get, "http://local.ch?#{params.to_query}")
12
+ end
13
+
14
+ it 'scrubs "api_key"' do
15
+ LHC.config.scrubs[:params] << 'api_key'
16
+ expect(response.request.scrubbed_params).to include(api_key: LHC::Scrubber::SCRUB_DISPLAY)
17
+ expect(response.request.scrubbed_params).to include(secret_key: '123-xyz')
18
+ end
19
+
20
+ it 'scrubs "api_key" and "secret_key"' do
21
+ LHC.config.scrubs[:params].push('api_key', 'secret_key')
22
+ expect(response.request.scrubbed_params).to include(api_key: LHC::Scrubber::SCRUB_DISPLAY)
23
+ expect(response.request.scrubbed_params).to include(secret_key: LHC::Scrubber::SCRUB_DISPLAY)
24
+ end
25
+
26
+ context 'when value is empty' do
27
+ let(:params) { { api_key: nil, secret_key: '' } }
28
+
29
+ it 'does not filter the value' do
30
+ LHC.config.scrubs[:params].push('api_key', 'secret_key')
31
+ expect(response.request.scrubbed_params).to include(api_key: nil)
32
+ expect(response.request.scrubbed_params).to include(secret_key: '')
33
+ end
34
+ end
35
+ end
@@ -75,9 +75,9 @@ describe LHC::Response do
75
75
  it 'does not throw a stack level to deep issue when accessing data in a rescue context' do
76
76
  begin
77
77
  LHC.get('http://listings')
78
- rescue LHC::Error => error
78
+ rescue LHC::Error => e
79
79
  expect(
80
- error.response.request.response.data.meta.errors.detect { |item| item.code == 2000 }.msg
80
+ e.response.request.response.data.meta.errors.detect { |item| item.code == 2000 }.msg
81
81
  ).to eq 'I like to hide error messages (this is meta).'
82
82
  end
83
83
  end
@@ -3,6 +3,7 @@
3
3
  module ZipkinTracer
4
4
  class TraceContainer
5
5
  attr_reader :trace_id, :parent_id, :span_id, :sampled, :flags
6
+
6
7
  class << self
7
8
  attr_accessor :current
8
9
 
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: 13.0.0
4
+ version: 15.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/local-ch/lhc/contributors
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-28 00:00:00.000000000 Z
11
+ date: 2021-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -142,14 +142,28 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 0.57.1
145
+ version: '1.0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 0.57.1
152
+ version: '1.0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop-performance
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '1.0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '1.0'
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: rubocop-rspec
155
169
  requirement: !ruby/object:Gem::Requirement
@@ -202,8 +216,9 @@ executables: []
202
216
  extensions: []
203
217
  extra_rdoc_files: []
204
218
  files:
219
+ - ".github/workflows/rubocop.yml"
220
+ - ".github/workflows/test.yml"
205
221
  - ".gitignore"
206
- - ".rubocop.localch.yml"
207
222
  - ".rubocop.yml"
208
223
  - ".ruby-version"
209
224
  - Gemfile
@@ -212,17 +227,6 @@ files:
212
227
  - LICENSE
213
228
  - README.md
214
229
  - Rakefile
215
- - cider-ci.yml
216
- - cider-ci/bin/bundle
217
- - cider-ci/bin/ruby_install
218
- - cider-ci/bin/ruby_version
219
- - cider-ci/jobs/rspec-activesupport-5.yml
220
- - cider-ci/jobs/rspec-activesupport-6.yml
221
- - cider-ci/jobs/rubocop.yml
222
- - cider-ci/task_components/bundle.yml
223
- - cider-ci/task_components/rspec.yml
224
- - cider-ci/task_components/rubocop.yml
225
- - cider-ci/task_components/ruby.yml
226
230
  - friday.yml
227
231
  - lhc.gemspec
228
232
  - lib/core_ext/hash/deep_transform_values.rb
@@ -266,6 +270,11 @@ files:
266
270
  - lib/lhc/response/data/collection.rb
267
271
  - lib/lhc/response/data/item.rb
268
272
  - lib/lhc/rspec.rb
273
+ - lib/lhc/scrubber.rb
274
+ - lib/lhc/scrubbers/auth_scrubber.rb
275
+ - lib/lhc/scrubbers/body_scrubber.rb
276
+ - lib/lhc/scrubbers/headers_scrubber.rb
277
+ - lib/lhc/scrubbers/params_scrubber.rb
269
278
  - lib/lhc/test/cache_helper.rb
270
279
  - lib/lhc/version.rb
271
280
  - script/ci/build.sh
@@ -277,6 +286,7 @@ files:
277
286
  - spec/basic_methods/request_without_rails_spec.rb
278
287
  - spec/config/endpoints_spec.rb
279
288
  - spec/config/placeholders_spec.rb
289
+ - spec/config/scrubs_spec.rb
280
290
  - spec/core_ext/hash/deep_transform_values_spec.rb
281
291
  - spec/dummy/README.rdoc
282
292
  - spec/dummy/Rakefile
@@ -357,6 +367,7 @@ files:
357
367
  - spec/interceptors/define_spec.rb
358
368
  - spec/interceptors/dup_spec.rb
359
369
  - spec/interceptors/logging/main_spec.rb
370
+ - spec/interceptors/monitoring/caching_spec.rb
360
371
  - spec/interceptors/monitoring/main_spec.rb
361
372
  - spec/interceptors/prometheus_spec.rb
362
373
  - spec/interceptors/response_competition_spec.rb
@@ -377,6 +388,9 @@ files:
377
388
  - spec/request/parallel_requests_spec.rb
378
389
  - spec/request/params_encoding_spec.rb
379
390
  - spec/request/request_without_rails_spec.rb
391
+ - spec/request/scrubbed_headers_spec.rb
392
+ - spec/request/scrubbed_options_spec.rb
393
+ - spec/request/scrubbed_params_spec.rb
380
394
  - spec/request/url_patterns_spec.rb
381
395
  - spec/request/user_agent_spec.rb
382
396
  - spec/request/user_agent_without_rails_spec.rb
@@ -402,7 +416,7 @@ homepage: https://github.com/local-ch/lhc
402
416
  licenses:
403
417
  - GPL-3.0
404
418
  metadata: {}
405
- post_install_message:
419
+ post_install_message:
406
420
  rdoc_options: []
407
421
  require_paths:
408
422
  - lib
@@ -410,7 +424,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
410
424
  requirements:
411
425
  - - ">="
412
426
  - !ruby/object:Gem::Version
413
- version: '0'
427
+ version: '2.7'
414
428
  required_rubygems_version: !ruby/object:Gem::Requirement
415
429
  requirements:
416
430
  - - ">="
@@ -418,8 +432,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
418
432
  version: '0'
419
433
  requirements:
420
434
  - Ruby >= 2.0.0
421
- rubygems_version: 3.0.6
422
- signing_key:
435
+ rubygems_version: 3.1.4
436
+ signing_key:
423
437
  specification_version: 4
424
438
  summary: Advanced HTTP Client for Ruby, fueled with interceptors
425
439
  test_files:
@@ -431,6 +445,7 @@ test_files:
431
445
  - spec/basic_methods/request_without_rails_spec.rb
432
446
  - spec/config/endpoints_spec.rb
433
447
  - spec/config/placeholders_spec.rb
448
+ - spec/config/scrubs_spec.rb
434
449
  - spec/core_ext/hash/deep_transform_values_spec.rb
435
450
  - spec/dummy/README.rdoc
436
451
  - spec/dummy/Rakefile
@@ -511,6 +526,7 @@ test_files:
511
526
  - spec/interceptors/define_spec.rb
512
527
  - spec/interceptors/dup_spec.rb
513
528
  - spec/interceptors/logging/main_spec.rb
529
+ - spec/interceptors/monitoring/caching_spec.rb
514
530
  - spec/interceptors/monitoring/main_spec.rb
515
531
  - spec/interceptors/prometheus_spec.rb
516
532
  - spec/interceptors/response_competition_spec.rb
@@ -531,6 +547,9 @@ test_files:
531
547
  - spec/request/parallel_requests_spec.rb
532
548
  - spec/request/params_encoding_spec.rb
533
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
534
553
  - spec/request/url_patterns_spec.rb
535
554
  - spec/request/user_agent_spec.rb
536
555
  - spec/request/user_agent_without_rails_spec.rb
data/.rubocop.localch.yml DELETED
@@ -1,325 +0,0 @@
1
- # This is master rubocop configuration.
2
- # DO NOT EDIT THIS FILE - it WILL be overwriten on every config update
3
- AllCops:
4
- TargetRubyVersion: 2.3
5
- DisplayCopNames: true
6
- DisplayStyleGuide: true
7
- Exclude:
8
- - 'db/**/*'
9
- - 'script/**/*'
10
- - 'vendor/bundle/**/*'
11
- - 'vendor/assets/**/*'
12
- - 'bin/**/*'
13
- - 'config/unicorn.rb'
14
- - 'config/compass.rb'
15
- - 'Rakefile'
16
- - 'app/controllers/error_trap_controller.rb'
17
- - 'app/controllers/hsts_controller.rb'
18
- - 'spec/lib/util_spec.rb'
19
-
20
- Rails:
21
- Enabled: true
22
-
23
- require:
24
- - rubocop-rspec
25
-
26
- Bundler/OrderedGems:
27
- Enabled: false
28
-
29
- Lint/HandleExceptions:
30
- Exclude:
31
- - spec/**/*
32
-
33
- Lint/UriEscapeUnescape:
34
- Enabled: false
35
-
36
- Style/RescueStandardError:
37
- Enabled: false
38
-
39
- Metrics/LineLength:
40
- Enabled: false
41
-
42
- Metrics/AbcSize:
43
- Enabled: false
44
-
45
- Metrics/MethodLength:
46
- Enabled: false
47
-
48
- Metrics/CyclomaticComplexity:
49
- Enabled: false
50
-
51
- Metrics/PerceivedComplexity:
52
- Enabled: false
53
-
54
- Metrics/ClassLength:
55
- Enabled: false
56
-
57
- Metrics/ModuleLength:
58
- Enabled: false
59
-
60
- Metrics/BlockLength:
61
- Enabled: false
62
-
63
- Metrics/ParameterLists:
64
- Enabled: false
65
-
66
- Metrics/BlockNesting:
67
- Enabled: false
68
-
69
- Performance/StringReplacement:
70
- Enabled: false
71
-
72
- Performance/TimesMap:
73
- Enabled: false
74
-
75
- Performance/RedundantBlockCall:
76
- Enabled: false
77
-
78
- Performance/RedundantMatch:
79
- Enabled: false
80
-
81
- Performance/RedundantMerge:
82
- Enabled: false
83
-
84
- Performance/Casecmp:
85
- Enabled: false
86
-
87
- Layout/MultilineOperationIndentation:
88
- EnforcedStyle: indented
89
-
90
- Layout/DotPosition:
91
- EnforcedStyle: leading
92
-
93
- Layout/AlignParameters:
94
- Enabled: false
95
-
96
- Layout/EmptyLinesAroundClassBody:
97
- Enabled: false
98
-
99
- Layout/IndentArray:
100
- EnforcedStyle: consistent
101
-
102
- Layout/MultilineMethodCallIndentation:
103
- EnforcedStyle: indented
104
-
105
- Layout/MultilineMethodCallBraceLayout:
106
- EnforcedStyle: symmetrical
107
-
108
- Layout/EmptyLinesAroundBlockBody:
109
- EnforcedStyle: no_empty_lines
110
-
111
- Layout/IndentHeredoc:
112
- Enabled: false
113
-
114
- Layout/MultilineArrayBraceLayout:
115
- EnforcedStyle: symmetrical
116
-
117
- Layout/MultilineHashBraceLayout:
118
- EnforcedStyle: symmetrical
119
-
120
- Style/StringLiterals:
121
- Enabled: false
122
-
123
- Style/RegexpLiteral:
124
- Exclude:
125
- - spec/**/*
126
-
127
- Style/NumericLiterals:
128
- Enabled: false
129
-
130
- Style/WordArray:
131
- Enabled: false
132
-
133
- Style/Next:
134
- Enabled: false
135
-
136
- Style/PercentLiteralDelimiters:
137
- Enabled: false
138
-
139
- Style/GlobalVars:
140
- Enabled: false
141
-
142
- Style/CommentAnnotation:
143
- Enabled: false
144
-
145
- Style/SymbolProc:
146
- Enabled: false
147
-
148
- Style/DoubleNegation:
149
- Enabled: false
150
-
151
- Style/FormatString:
152
- Enabled: false
153
-
154
- Style/AsciiComments:
155
- Enabled: false
156
-
157
- Style/BarePercentLiterals:
158
- Enabled: false
159
-
160
- Style/SingleLineBlockParams:
161
- Enabled: false
162
-
163
- Style/MultilineBlockChain:
164
- Enabled: false
165
-
166
- Style/UnneededCapitalW:
167
- Enabled: false
168
-
169
- Style/UnneededPercentQ:
170
- Enabled: false
171
-
172
- Style/BlockDelimiters:
173
- Exclude:
174
- - spec/**/*
175
-
176
- Style/BracesAroundHashParameters:
177
- EnforcedStyle: context_dependent
178
-
179
- Style/IfUnlessModifier:
180
- Enabled: false
181
-
182
- Style/ClassAndModuleChildren:
183
- Enabled: false
184
-
185
- Style/Documentation:
186
- Enabled: false
187
-
188
- Style/GuardClause:
189
- Enabled: false
190
-
191
- Naming/AccessorMethodName:
192
- Exclude:
193
- - spec/support/pages/**/*
194
-
195
- Style/NegatedIf:
196
- Enabled: false
197
-
198
- Style/MutableConstant:
199
- Enabled: false
200
-
201
- Style/ConditionalAssignment:
202
- Enabled: false
203
-
204
- Style/Lambda:
205
- Enabled: false
206
-
207
- Style/FrozenStringLiteralComment:
208
- Enabled: false
209
-
210
- Style/SymbolArray:
211
- Enabled: false
212
-
213
- Style/HashSyntax:
214
- EnforcedStyle: ruby19
215
-
216
- Style/FormatStringToken:
217
- Enabled: false
218
-
219
- Style/EmptyMethod:
220
- EnforcedStyle: expanded
221
-
222
- Style/TernaryParentheses:
223
- EnforcedStyle: require_parentheses_when_complex
224
-
225
- Naming/VariableNumber:
226
- Enabled: false
227
-
228
- Style/PerlBackrefs:
229
- Enabled: false
230
-
231
- Style/RegexpLiteral:
232
- AllowInnerSlashes: false
233
-
234
- Style/BlockComments:
235
- Enabled: false
236
-
237
- Style/RedundantParentheses:
238
- Enabled: false
239
-
240
- Naming/FileName:
241
- Exclude:
242
- - Gemfile
243
- - Brewfile
244
- - Guardfile
245
-
246
- Style/NumericPredicate:
247
- Enabled: false
248
-
249
- RSpec/DescribeClass:
250
- Exclude:
251
- - spec/views/**/*
252
- - spec/routing/**/*
253
- - spec/requests/**/*
254
- - spec/features/**/*
255
-
256
- RSpec/FilePath:
257
- Enabled: false
258
-
259
- RSpec/NamedSubject:
260
- Enabled: false
261
-
262
- RSpec/MultipleExpectations:
263
- Enabled: false
264
-
265
- RSpec/ExampleLength:
266
- Enabled: false
267
-
268
- RSpec/HookArgument:
269
- EnforcedStyle: implicit
270
-
271
- RSpec/MessageSpies:
272
- EnforcedStyle: receive
273
-
274
- RSpec/NestedGroups:
275
- Enabled: false
276
-
277
- RSpec/VerifiedDoubles:
278
- Enabled: false
279
-
280
- RSpec/LeadingSubject:
281
- Enabled: false
282
-
283
- RSpec/ExpectInHook:
284
- Enabled: false
285
-
286
- RSpec/ReturnFromStub:
287
- Enabled: false
288
-
289
- RSpec/SubjectStub:
290
- Enabled: false
291
-
292
- RSpec/EmptyLineAfterSubject:
293
- Enabled: false
294
-
295
- RSpec/LetSetup:
296
- Enabled: false
297
-
298
- RSpec/ImplicitExpect:
299
- EnforcedStyle: is_expected
300
-
301
- RSpec/ScatteredLet:
302
- Enabled: false
303
-
304
- RSpec/ContextWording:
305
- Enabled: false
306
-
307
- Rails/Output:
308
- Exclude:
309
- - 'config/application.rb'
310
- - 'config/initializers/asset_manifest_warning.rb'
311
-
312
- Rails/DynamicFindBy:
313
- Enabled: false
314
-
315
- Rails/Presence:
316
- Enabled: false
317
-
318
- Capybara/CurrentPathExpectation:
319
- Enabled: false
320
-
321
- Naming/UncommunicativeMethodParamName:
322
- Enabled: false
323
-
324
- Style/ExpandPathArguments:
325
- Enabled: false