rollbar 2.16.2 → 2.22.1

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 (212) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +47 -0
  3. data/.travis.yml +182 -94
  4. data/Appraisals +10 -10
  5. data/Gemfile +45 -13
  6. data/README.md +20 -3
  7. data/Rakefile +0 -0
  8. data/data/rollbar.snippet.js +1 -1
  9. data/docs/configuration.md +15 -0
  10. data/gemfiles/rails30.gemfile +21 -14
  11. data/gemfiles/rails31.gemfile +21 -12
  12. data/gemfiles/rails32.gemfile +18 -8
  13. data/gemfiles/rails40.gemfile +18 -6
  14. data/gemfiles/rails41.gemfile +17 -6
  15. data/gemfiles/rails42.gemfile +24 -14
  16. data/gemfiles/rails50.gemfile +20 -11
  17. data/gemfiles/rails51.gemfile +20 -10
  18. data/gemfiles/rails52.gemfile +65 -0
  19. data/gemfiles/rails60.gemfile +67 -0
  20. data/lib/generators/rollbar/rollbar_generator.rb +1 -1
  21. data/lib/rails/rollbar_runner.rb +17 -2
  22. data/lib/rollbar.rb +2 -3
  23. data/lib/rollbar/capistrano.rb +71 -39
  24. data/lib/rollbar/capistrano3.rb +56 -1
  25. data/lib/rollbar/capistrano_tasks.rb +130 -0
  26. data/lib/rollbar/configuration.rb +95 -7
  27. data/lib/rollbar/delay/active_job.rb +17 -0
  28. data/lib/rollbar/delay/girl_friday.rb +2 -2
  29. data/lib/rollbar/delay/resque.rb +4 -6
  30. data/lib/rollbar/delay/shoryuken.rb +15 -9
  31. data/lib/rollbar/delay/sidekiq.rb +6 -8
  32. data/lib/rollbar/delay/sucker_punch.rb +17 -19
  33. data/lib/rollbar/delay/thread.rb +3 -3
  34. data/lib/rollbar/deploy.rb +90 -0
  35. data/lib/rollbar/encoding/encoder.rb +9 -9
  36. data/lib/rollbar/exception_reporter.rb +19 -5
  37. data/lib/rollbar/item.rb +62 -20
  38. data/lib/rollbar/item/backtrace.rb +4 -4
  39. data/lib/rollbar/item/frame.rb +7 -1
  40. data/lib/rollbar/item/locals.rb +56 -0
  41. data/lib/rollbar/json.rb +5 -51
  42. data/lib/rollbar/language_support.rb +4 -20
  43. data/lib/rollbar/lazy_store.rb +5 -5
  44. data/lib/rollbar/logger.rb +1 -0
  45. data/lib/rollbar/logger_proxy.rb +15 -2
  46. data/lib/rollbar/middleware/js.rb +110 -10
  47. data/lib/rollbar/middleware/js/json_value.rb +26 -0
  48. data/lib/rollbar/middleware/rack.rb +4 -1
  49. data/lib/rollbar/middleware/rails/rollbar.rb +10 -1
  50. data/lib/rollbar/notifier.rb +118 -49
  51. data/lib/rollbar/notifier/trace_with_bindings.rb +65 -0
  52. data/lib/rollbar/plugin.rb +54 -6
  53. data/lib/rollbar/plugins.rb +7 -1
  54. data/lib/rollbar/plugins/active_job.rb +5 -1
  55. data/lib/rollbar/plugins/basic_socket.rb +21 -6
  56. data/lib/rollbar/plugins/delayed_job/job_data.rb +3 -3
  57. data/lib/rollbar/plugins/delayed_job/plugin.rb +3 -3
  58. data/lib/rollbar/plugins/goalie.rb +11 -3
  59. data/lib/rollbar/plugins/rails/controller_methods.rb +17 -4
  60. data/lib/rollbar/plugins/rails/railtie_mixin.rb +7 -3
  61. data/lib/rollbar/plugins/rake.rb +2 -2
  62. data/lib/rollbar/plugins/sidekiq/plugin.rb +10 -6
  63. data/lib/rollbar/rake_tasks.rb +3 -86
  64. data/lib/rollbar/request_data_extractor.rb +35 -21
  65. data/lib/rollbar/rollbar_test.rb +147 -0
  66. data/lib/rollbar/scrubbers.rb +7 -3
  67. data/lib/rollbar/scrubbers/params.rb +38 -20
  68. data/lib/rollbar/scrubbers/url.rb +27 -13
  69. data/lib/rollbar/truncation.rb +9 -2
  70. data/lib/rollbar/truncation/min_body_strategy.rb +2 -3
  71. data/lib/rollbar/truncation/remove_any_key_strategy.rb +123 -0
  72. data/lib/rollbar/truncation/remove_extra_strategy.rb +35 -0
  73. data/lib/rollbar/truncation/remove_request_strategy.rb +21 -0
  74. data/lib/rollbar/truncation/strings_strategy.rb +3 -4
  75. data/lib/rollbar/util.rb +75 -45
  76. data/lib/rollbar/util/hash.rb +30 -6
  77. data/lib/rollbar/util/ip_anonymizer.rb +8 -7
  78. data/lib/rollbar/util/ip_obfuscator.rb +1 -1
  79. data/lib/rollbar/version.rb +1 -1
  80. data/lib/tasks/benchmark.rake +103 -0
  81. data/rollbar.gemspec +14 -8
  82. metadata +25 -277
  83. data/gemfiles/ruby_1_8_and_1_9_2.gemfile +0 -49
  84. data/lib/rollbar/json/default.rb +0 -11
  85. data/lib/rollbar/json/oj.rb +0 -16
  86. data/lib/rollbar/tasks/rollbar.cap +0 -47
  87. data/spec/cacert.pem +0 -3988
  88. data/spec/controllers/home_controller_spec.rb +0 -480
  89. data/spec/delay/sidekiq_spec.rb +0 -61
  90. data/spec/delay/sucker_punch_spec.rb +0 -25
  91. data/spec/delayed/backend/test.rb +0 -140
  92. data/spec/delayed/serialization/test.rb +0 -0
  93. data/spec/dummyapp/.gitignore +0 -73
  94. data/spec/dummyapp/Rakefile +0 -7
  95. data/spec/dummyapp/app/assets/javascripts/application.js +0 -3
  96. data/spec/dummyapp/app/assets/stylesheets/application.css.scss +0 -37
  97. data/spec/dummyapp/app/controllers/application_controller.rb +0 -3
  98. data/spec/dummyapp/app/controllers/home_controller.rb +0 -60
  99. data/spec/dummyapp/app/controllers/users_controller.rb +0 -17
  100. data/spec/dummyapp/app/helpers/.gitkeep +0 -0
  101. data/spec/dummyapp/app/mailers/.gitkeep +0 -0
  102. data/spec/dummyapp/app/models/.gitkeep +0 -0
  103. data/spec/dummyapp/app/models/book.rb +0 -5
  104. data/spec/dummyapp/app/models/post.rb +0 -9
  105. data/spec/dummyapp/app/models/user.rb +0 -9
  106. data/spec/dummyapp/app/views/devise/registrations/edit.html.erb +0 -27
  107. data/spec/dummyapp/app/views/devise/registrations/new.html.erb +0 -20
  108. data/spec/dummyapp/app/views/devise/shared/_links.html.erb +0 -25
  109. data/spec/dummyapp/app/views/home/cause_exception.html.erb +0 -1
  110. data/spec/dummyapp/app/views/home/index.html.erb +0 -4
  111. data/spec/dummyapp/app/views/home/report_exception.html.erb +0 -1
  112. data/spec/dummyapp/app/views/js/test.html.erb +0 -1
  113. data/spec/dummyapp/app/views/layouts/_messages.html.erb +0 -5
  114. data/spec/dummyapp/app/views/layouts/_navigation.html.erb +0 -21
  115. data/spec/dummyapp/app/views/layouts/application.html.erb +0 -25
  116. data/spec/dummyapp/app/views/layouts/simple.html.erb +0 -18
  117. data/spec/dummyapp/app/views/users/index.html.erb +0 -8
  118. data/spec/dummyapp/app/views/users/show.html.erb +0 -3
  119. data/spec/dummyapp/config.ru +0 -4
  120. data/spec/dummyapp/config/application.rb +0 -59
  121. data/spec/dummyapp/config/boot.rb +0 -10
  122. data/spec/dummyapp/config/database.yml +0 -25
  123. data/spec/dummyapp/config/environment.rb +0 -5
  124. data/spec/dummyapp/config/environments/development.rb +0 -37
  125. data/spec/dummyapp/config/environments/production.rb +0 -67
  126. data/spec/dummyapp/config/environments/test.rb +0 -37
  127. data/spec/dummyapp/config/initializers/backtrace_silencers.rb +0 -7
  128. data/spec/dummyapp/config/initializers/inflections.rb +0 -15
  129. data/spec/dummyapp/config/initializers/mime_types.rb +0 -5
  130. data/spec/dummyapp/config/initializers/rollbar.rb +0 -26
  131. data/spec/dummyapp/config/initializers/secret_token.rb +0 -7
  132. data/spec/dummyapp/config/initializers/session_store.rb +0 -8
  133. data/spec/dummyapp/config/initializers/wrap_parameters.rb +0 -16
  134. data/spec/dummyapp/config/locales/devise.en.yml +0 -58
  135. data/spec/dummyapp/config/locales/en.yml +0 -5
  136. data/spec/dummyapp/config/routes.rb +0 -17
  137. data/spec/dummyapp/config/secrets.yml +0 -2
  138. data/spec/dummyapp/db/migrate/20121121184652_devise_create_users.rb +0 -46
  139. data/spec/dummyapp/db/migrate/20121121184654_add_name_to_users.rb +0 -5
  140. data/spec/dummyapp/db/migrate/20161219184410_create_books.rb +0 -10
  141. data/spec/dummyapp/db/migrate/20161219185529_add_username_to_users.rb +0 -5
  142. data/spec/dummyapp/db/schema.rb +0 -41
  143. data/spec/dummyapp/db/seeds.rb +0 -12
  144. data/spec/dummyapp/lib/assets/.gitkeep +0 -0
  145. data/spec/dummyapp/public/404.html +0 -26
  146. data/spec/dummyapp/public/422.html +0 -26
  147. data/spec/dummyapp/public/500.html +0 -25
  148. data/spec/dummyapp/public/favicon.ico +0 -0
  149. data/spec/dummyapp/script/rails +0 -6
  150. data/spec/fixtures/file1 +0 -1
  151. data/spec/fixtures/file2 +0 -1
  152. data/spec/fixtures/payloads/message.json +0 -25
  153. data/spec/fixtures/payloads/sample.trace.json +0 -275
  154. data/spec/fixtures/payloads/sample.trace_chain.json +0 -530
  155. data/spec/fixtures/plugins/dummy1.rb +0 -5
  156. data/spec/fixtures/plugins/dummy2.rb +0 -5
  157. data/spec/generators/rollbar/rollbar_generator_rails30_spec.rb +0 -31
  158. data/spec/generators/rollbar/rollbar_generator_spec.rb +0 -51
  159. data/spec/requests/home_spec.rb +0 -49
  160. data/spec/rollbar/configuration_spec.rb +0 -46
  161. data/spec/rollbar/delay/delayed_job_spec.rb +0 -22
  162. data/spec/rollbar/delay/girl_friday_spec.rb +0 -41
  163. data/spec/rollbar/delay/resque_spec.rb +0 -37
  164. data/spec/rollbar/delay/thread_spec.rb +0 -27
  165. data/spec/rollbar/encoding/encoder_spec.rb +0 -63
  166. data/spec/rollbar/item/backtrace_spec.rb +0 -26
  167. data/spec/rollbar/item/frame_spec.rb +0 -267
  168. data/spec/rollbar/item_spec.rb +0 -736
  169. data/spec/rollbar/json/oj_spec.rb +0 -18
  170. data/spec/rollbar/json_spec.rb +0 -110
  171. data/spec/rollbar/lazy_store_spec.rb +0 -99
  172. data/spec/rollbar/logger_proxy_spec.rb +0 -50
  173. data/spec/rollbar/logger_spec.rb +0 -124
  174. data/spec/rollbar/middleware/js_spec.rb +0 -421
  175. data/spec/rollbar/middleware/sinatra_spec.rb +0 -197
  176. data/spec/rollbar/notifier_spec.rb +0 -56
  177. data/spec/rollbar/plugin_spec.rb +0 -209
  178. data/spec/rollbar/plugins/active_job_spec.rb +0 -38
  179. data/spec/rollbar/plugins/delayed_job/job_data_spec.rb +0 -48
  180. data/spec/rollbar/plugins/delayed_job_spec.rb +0 -129
  181. data/spec/rollbar/plugins/rack_spec.rb +0 -152
  182. data/spec/rollbar/plugins/rails_js_spec.rb +0 -19
  183. data/spec/rollbar/plugins/rake_spec.rb +0 -34
  184. data/spec/rollbar/plugins/resque/failure_spec.rb +0 -36
  185. data/spec/rollbar/plugins/sidekiq_spec.rb +0 -171
  186. data/spec/rollbar/plugins/validations_spec.rb +0 -56
  187. data/spec/rollbar/plugins_spec.rb +0 -68
  188. data/spec/rollbar/request_data_extractor_spec.rb +0 -270
  189. data/spec/rollbar/scrubbers/params_spec.rb +0 -314
  190. data/spec/rollbar/scrubbers/url_spec.rb +0 -136
  191. data/spec/rollbar/scrubbers_spec.rb +0 -31
  192. data/spec/rollbar/sidekig/clear_scope_spec.rb +0 -19
  193. data/spec/rollbar/truncation/frames_strategy_spec.rb +0 -70
  194. data/spec/rollbar/truncation/min_body_strategy_spec.rb +0 -57
  195. data/spec/rollbar/truncation/strings_strategy_spec.rb +0 -89
  196. data/spec/rollbar/truncation_spec.rb +0 -27
  197. data/spec/rollbar/util/hash_spec.rb +0 -22
  198. data/spec/rollbar/util/ip_anonymizer_spec.rb +0 -30
  199. data/spec/rollbar/util_spec.rb +0 -80
  200. data/spec/rollbar_bc_spec.rb +0 -380
  201. data/spec/rollbar_spec.rb +0 -1667
  202. data/spec/spec_helper.rb +0 -84
  203. data/spec/support/cause_exception.rb +0 -1
  204. data/spec/support/encoding_helpers.rb +0 -8
  205. data/spec/support/encodings/iso_8859_9 +0 -1
  206. data/spec/support/fixture_helpers.rb +0 -10
  207. data/spec/support/get_ip_raising.rb +0 -7
  208. data/spec/support/helpers.rb +0 -5
  209. data/spec/support/matchers.rb +0 -23
  210. data/spec/support/notifier_helpers.rb +0 -57
  211. data/spec/support/rollbar_api.rb +0 -57
  212. data/spec/support/shared_contexts.rb +0 -12
@@ -1,314 +0,0 @@
1
- require 'spec_helper'
2
- require 'tempfile'
3
- require 'rollbar/scrubbers/params'
4
-
5
- require 'rspec/expectations'
6
-
7
- describe Rollbar::Scrubbers::Params do
8
- describe '.call' do
9
- it 'calls #call in a new instance' do
10
- arguments = [:foo, :bar]
11
- expect_any_instance_of(described_class).to receive(:call).with(*arguments)
12
-
13
- described_class.call(*arguments)
14
- end
15
- end
16
-
17
- describe '#call' do
18
- let(:options) do
19
- {
20
- :params => params,
21
- :config => scrub_config
22
- }
23
- end
24
-
25
- context 'with scrub fields configured' do
26
- let(:scrub_config) do
27
- [:secret, :password]
28
- end
29
-
30
- context 'with Array object' do
31
- let(:params) do
32
- [
33
- {
34
- :foo => 'bar',
35
- :secret => 'the-secret',
36
- :password => 'the-password',
37
- :password_confirmation => 'the-password'
38
- }
39
- ]
40
- end
41
- let(:result) do
42
- [
43
- {
44
- :foo => 'bar',
45
- :secret => /\*+/,
46
- :password => /\*+/,
47
- :password_confirmation => /\*+/
48
- }
49
- ]
50
- end
51
-
52
- it 'scrubs the required parameters' do
53
- expect(subject.call(options).first).to be_eql_hash_with_regexes(result.first)
54
- end
55
- end
56
-
57
- context 'with simple Hash' do
58
- let(:params) do
59
- {
60
- :foo => 'bar',
61
- :secret => 'the-secret',
62
- :password => 'the-password',
63
- :password_confirmation => 'the-password'
64
- }
65
- end
66
- let(:result) do
67
- {
68
- :foo => 'bar',
69
- :secret => /\*+/,
70
- :password => /\*+/,
71
- :password_confirmation => /\*+/
72
- }
73
- end
74
-
75
- it 'scrubs the required parameters' do
76
- expect(subject.call(options)).to be_eql_hash_with_regexes(result)
77
- end
78
- end
79
-
80
- context 'with nested Hash' do
81
- let(:scrub_config) do
82
- super().push(:other)
83
- end
84
-
85
- let(:params) do
86
- {
87
- :foo => 'bar',
88
- :extra => {
89
- :secret => 'the-secret',
90
- :password => 'the-password',
91
- :password_confirmation => 'the-password'
92
- },
93
- :other => {
94
- :param => 'filtered'
95
- }
96
- }
97
- end
98
- let(:result) do
99
- {
100
- :foo => 'bar',
101
- :extra => {
102
- :secret => /\*+/,
103
- :password => /\*+/,
104
- :password_confirmation => /\*+/
105
- },
106
- :other => /\*+/
107
- }
108
- end
109
-
110
- it 'scrubs the required parameters' do
111
- expect(subject.call(options)).to be_eql_hash_with_regexes(result)
112
- end
113
- end
114
-
115
- context 'with nested Array' do
116
- let(:scrub_config) do
117
- super().push(:other)
118
- end
119
-
120
- let(:params) do
121
- {
122
- :foo => 'bar',
123
- :extra => [{
124
- :secret => 'the-secret',
125
- :password => 'the-password',
126
- :password_confirmation => 'the-password'
127
- }],
128
- :other => [{
129
- :param => 'filtered'
130
- }]
131
- }
132
- end
133
- let(:result) do
134
- {
135
- :foo => 'bar',
136
- :extra => [{
137
- :secret => /\*+/,
138
- :password => /\*+/,
139
- :password_confirmation => /\*+/
140
- }],
141
- :other => /\*+/
142
- }
143
- end
144
-
145
- it 'scrubs the required parameters' do
146
- expect(subject.call(options)).to be_eql_hash_with_regexes(result)
147
- end
148
- end
149
-
150
- context 'with skipped instance' do
151
- let(:tempfile) { Tempfile.new('foo') }
152
- let(:params) do
153
- {
154
- :foo => 'bar',
155
- :extra => [{
156
- :secret => 'the-secret',
157
- :password => 'the-password',
158
- :password_confirmation => 'the-password',
159
- :skipped => tempfile
160
- }]
161
- }
162
- end
163
- let(:result) do
164
- {
165
- :foo => 'bar',
166
- :extra => [{
167
- :secret => /\*+/,
168
- :password => /\*+/,
169
- :password_confirmation => /\*+/,
170
- :skipped => "Skipped value of class 'Tempfile'"
171
- }]
172
- }
173
- end
174
-
175
- after { tempfile.close }
176
-
177
- it 'scrubs the required parameters' do
178
- expect(subject.call(options)).to be_eql_hash_with_regexes(result)
179
- end
180
- end
181
-
182
- context 'with attachment instance' do
183
- let(:tempfile) { double(:size => 100) }
184
- let(:attachment) do
185
- double(:class => double(:name => 'ActionDispatch::Http::UploadedFile'),
186
- :tempfile => tempfile,
187
- :content_type => 'content-type',
188
- 'original_filename' => 'filename')
189
- end
190
- let(:params) do
191
- {
192
- :foo => 'bar',
193
- :extra => [{
194
- :secret => 'the-secret',
195
- :password => 'the-password',
196
- :password_confirmation => 'the-password',
197
- :attachment => attachment
198
- }]
199
- }
200
- end
201
- let(:result) do
202
- {
203
- :foo => 'bar',
204
- :extra => [{
205
- :secret => /\*+/,
206
- :password => /\*+/,
207
- :password_confirmation => /\*+/,
208
- :attachment => {
209
- :content_type => 'content-type',
210
- :original_filename => 'filename',
211
- :size => 100
212
- }
213
- }]
214
- }
215
- end
216
-
217
- it 'scrubs the required parameters' do
218
- expect(subject.call(options)).to be_eql_hash_with_regexes(result)
219
- end
220
-
221
- context 'if getting the attachment values fails' do
222
- let(:tempfile) { Object.new }
223
- let(:attachment) do
224
- double(:class => double(:name => 'ActionDispatch::Http::UploadedFile'),
225
- :tempfile => tempfile,
226
- :content_type => 'content-type',
227
- 'original_filename' => 'filename')
228
- end
229
- let(:params) do
230
- {
231
- :foo => 'bar',
232
- :extra => [{
233
- :secret => 'the-secret',
234
- :password => 'the-password',
235
- :password_confirmation => 'the-password',
236
- :attachment => attachment
237
- }]
238
- }
239
- end
240
- let(:result) do
241
- {
242
- :foo => 'bar',
243
- :extra => [{
244
- :secret => /\*+/,
245
- :password => /\*+/,
246
- :password_confirmation => /\*+/,
247
- :attachment => 'Uploaded file'
248
- }]
249
- }
250
- end
251
-
252
- it 'scrubs the required parameters' do
253
- expect(subject.call(options)).to be_eql_hash_with_regexes(result)
254
- end
255
- end
256
- end
257
-
258
- context 'without params' do
259
- let(:params) do
260
- nil
261
- end
262
- let(:result) do
263
- {}
264
- end
265
-
266
- it 'scrubs the required parameters' do
267
- expect(subject.call(options)).to be_eql_hash_with_regexes(result)
268
- end
269
- end
270
- end
271
-
272
- context 'with :scrub_all option' do
273
- let(:scrub_config) { :scrub_all }
274
- let(:params) do
275
- {
276
- :foo => 'bar',
277
- :password => 'the-password',
278
- :bar => 'foo',
279
- :extra => {
280
- :foo => 'more-foo',
281
- :bar => 'more-bar'
282
- }
283
- }
284
- end
285
- let(:result) do
286
- {
287
- :foo => /\*+/,
288
- :password => /\*+/,
289
- :bar => /\*+/,
290
- :extra => {
291
- :foo => /\*+/,
292
- :bar => /\*+/
293
- }
294
- }
295
- end
296
-
297
- it 'scrubs the required parameters' do
298
- expect(subject.call(options)).to be_eql_hash_with_regexes(result)
299
- end
300
- end
301
- end
302
- end
303
-
304
- describe Rollbar::Scrubbers::Params::ATTACHMENT_CLASSES do
305
- it 'has the correct values' do
306
- expect(described_class).to be_eql(%w(ActionDispatch::Http::UploadedFile Rack::Multipart::UploadedFile).freeze)
307
- end
308
- end
309
-
310
- describe Rollbar::Scrubbers::Params::SKIPPED_CLASSES do
311
- it 'has the correct values' do
312
- expect(described_class).to be_eql([Tempfile])
313
- end
314
- end
@@ -1,136 +0,0 @@
1
- require 'spec_helper'
2
- require 'rollbar/language_support'
3
- require 'rollbar/scrubbers/url'
4
-
5
- describe Rollbar::Scrubbers::URL do
6
- let(:options) do
7
- {
8
- :url => url,
9
- :scrub_fields => [:password, :secret],
10
- :scrub_user => false,
11
- :scrub_password => false,
12
- :randomize_scrub_length => true
13
- }
14
- end
15
-
16
- describe '#call' do
17
- context 'cannot scrub URLs' do
18
- next if Rollbar::LanguageSupport.can_scrub_url?
19
-
20
- let(:url) { 'http://user:password@foo.com/some-interesting-path#fragment' }
21
-
22
- it 'returns the URL without any change' do
23
- expect(subject.call(options)).to be_eql(url)
24
- end
25
- end
26
-
27
- context 'with ruby different from 1.8' do
28
- next unless Rollbar::LanguageSupport.can_scrub_url?
29
-
30
- context 'without data to be scrubbed' do
31
- let(:url) { 'http://user:password@foo.com/some-interesting-path#fragment' }
32
-
33
- it 'returns the URL without any change' do
34
- expect(subject.call(options)).to be_eql(url)
35
- end
36
-
37
- context 'with arrays in params' do
38
- let(:url) { 'http://user:password@foo.com/some-interesting-path?foo[]=1&foo[]=2' }
39
-
40
- it 'returns the URL without any change' do
41
- expect(subject.call(options)).to be_eql(url)
42
- end
43
- end
44
- end
45
-
46
- context 'scrubbing user and password' do
47
- let(:options) do
48
- {
49
- :url => url,
50
- :scrub_fields => [],
51
- :scrub_password => true,
52
- :scrub_user => true
53
- }
54
- end
55
-
56
- let(:url) { 'http://user:password@foo.com/some-interesting-path#fragment' }
57
-
58
- it 'returns the URL without any change' do
59
- expected_url = /http:\/\/\*{3,8}:\*{3,8}@foo.com\/some-interesting\-path#fragment/
60
-
61
- expect(subject.call(options)).to match(expected_url)
62
- end
63
- end
64
-
65
- context 'with params to be filtered' do
66
- let(:url) { 'http://foo.com/some-interesting-path?foo=bar&password=mypassword&secret=somevalue#fragment' }
67
-
68
- it 'returns the URL with some params filtered' do
69
- expected_url = /http:\/\/foo.com\/some-interesting-path\?foo=bar&password=\*{3,8}&secret=\*{3,8}#fragment/
70
-
71
- expect(subject.call(options)).to match(expected_url)
72
- end
73
-
74
- context 'having array params' do
75
- let(:url) { 'http://foo.com/some-interesting-path?foo=bar&password[]=mypassword&password[]=otherpassword&secret=somevalue#fragment' }
76
-
77
- it 'returns the URL with some params filtered' do
78
- expected_url = /http:\/\/foo.com\/some-interesting-path\?foo=bar&password\[\]=\*{3,8}&password\[\]=\*{3,8}&secret=\*{3,8}#fragment/
79
-
80
- expect(subject.call(options)).to match(expected_url)
81
- end
82
- end
83
- end
84
-
85
- context 'with no-random scrub length' do
86
- let(:options) do
87
- {
88
- :url => url,
89
- :scrub_fields => [:password, :secret],
90
- :scrub_user => false,
91
- :scrub_password => false,
92
- :randomize_scrub_length => false
93
- }
94
- end
95
- let(:password) { 'longpasswordishere' }
96
- let(:url) { "http://foo.com/some-interesting-path?foo=bar&password=#{password}#fragment" }
97
-
98
- it 'scrubs with same length than the scrubbed param' do
99
- expected_url = /http:\/\/foo.com\/some-interesting-path\?foo=bar&password=\*{#{password.length}}#fragment/
100
-
101
- expect(subject.call(options)).to match(expected_url)
102
- end
103
- end
104
-
105
- context 'with malformed URL or not able to be parsed' do
106
- let(:url) { '\this\is\not\a\valid\url' }
107
- before { reconfigure_notifier }
108
-
109
- it 'return the same url' do
110
- expect(Rollbar.logger).to receive(:error).and_call_original
111
- expect(subject.call(options)).to be_eql(url)
112
- end
113
- end
114
-
115
- context 'with URL with spaces and arrays' do
116
- let(:url) do
117
- 'https://server.com/api/v1/assignments/4430038?user_id=1&assignable_id=2&starts_at=Wed%20Jul%2013%202016%2000%3A00%3A00%20GMT-0700%20(PDT)&ends_at=Fri%20Jul%2029%202016%2000%3A00%3A00%20GMT-0700%20(PDT)&allocation_mode=hours_per_day&percent=&fixed_hours=&hours_per_day=0&auth=REMOVED&___uidh=2228207862&password[]=mypassword'
118
- end
119
- let(:options) do
120
- {
121
- :url => url,
122
- :scrub_fields => [:passwd, :password, :password_confirmation, :secret, :confirm_password, :secret_token, :api_key, :access_token, :auth, :SAMLResponse, :password, :auth],
123
- :scrub_user => true,
124
- :scrub_password => true,
125
- :randomize_scrub_length => true
126
- }
127
- end
128
-
129
- it 'doesnt logs error' do
130
- expect(Rollbar.logger).not_to receive(:error).and_call_original
131
- subject.call(options)
132
- end
133
- end
134
- end
135
- end
136
- end