rollbar 2.18.2 → 2.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +15 -0
- data/.travis.yml +155 -93
- data/Gemfile +19 -13
- data/README.md +12 -0
- data/gemfiles/rails30.gemfile +17 -10
- data/gemfiles/rails31.gemfile +20 -12
- data/gemfiles/rails32.gemfile +16 -7
- data/gemfiles/rails40.gemfile +16 -5
- data/gemfiles/rails41.gemfile +15 -5
- data/gemfiles/rails42.gemfile +25 -14
- data/gemfiles/rails50.gemfile +15 -8
- data/gemfiles/rails51.gemfile +15 -8
- data/gemfiles/rails52.gemfile +62 -0
- data/gemfiles/ruby_1_8_and_1_9_2.gemfile +2 -2
- data/lib/rails/rollbar_runner.rb +16 -1
- data/lib/rollbar/capistrano.rb +71 -39
- data/lib/rollbar/capistrano3.rb +53 -1
- data/lib/rollbar/capistrano_tasks.rb +131 -0
- data/lib/rollbar/configuration.rb +13 -4
- data/lib/rollbar/delay/active_job.rb +17 -0
- data/lib/rollbar/delay/sidekiq.rb +3 -1
- data/lib/rollbar/delay/thread.rb +1 -1
- data/lib/rollbar/deploy.rb +69 -0
- data/lib/rollbar/item.rb +17 -6
- data/lib/rollbar/middleware/js.rb +25 -3
- data/lib/rollbar/middleware/js/json_value.rb +26 -0
- data/lib/rollbar/notifier.rb +32 -13
- data/lib/rollbar/plugins/active_job.rb +3 -0
- data/lib/rollbar/plugins/rails/controller_methods.rb +2 -1
- data/lib/rollbar/plugins/rails/railtie_mixin.rb +7 -1
- data/lib/rollbar/rake_tasks.rb +126 -67
- data/lib/rollbar/scrubbers/params.rb +6 -0
- data/lib/rollbar/util.rb +75 -45
- data/lib/rollbar/util/hash.rb +15 -6
- data/lib/rollbar/version.rb +1 -1
- data/rollbar.gemspec +2 -3
- metadata +9 -261
- data/lib/rollbar/tasks/rollbar.cap +0 -47
- data/spec/cacert.pem +0 -3988
- data/spec/controllers/home_controller_spec.rb +0 -480
- data/spec/delay/sidekiq_spec.rb +0 -61
- data/spec/delay/sucker_punch_spec.rb +0 -25
- data/spec/delayed/backend/test.rb +0 -140
- data/spec/delayed/serialization/test.rb +0 -0
- data/spec/dummyapp/.gitignore +0 -73
- data/spec/dummyapp/Rakefile +0 -7
- data/spec/dummyapp/app/assets/javascripts/application.js +0 -3
- data/spec/dummyapp/app/assets/stylesheets/application.css.scss +0 -37
- data/spec/dummyapp/app/controllers/application_controller.rb +0 -3
- data/spec/dummyapp/app/controllers/home_controller.rb +0 -60
- data/spec/dummyapp/app/controllers/users_controller.rb +0 -17
- data/spec/dummyapp/app/helpers/.gitkeep +0 -0
- data/spec/dummyapp/app/mailers/.gitkeep +0 -0
- data/spec/dummyapp/app/models/.gitkeep +0 -0
- data/spec/dummyapp/app/models/book.rb +0 -5
- data/spec/dummyapp/app/models/post.rb +0 -9
- data/spec/dummyapp/app/models/user.rb +0 -9
- data/spec/dummyapp/app/views/devise/registrations/edit.html.erb +0 -27
- data/spec/dummyapp/app/views/devise/registrations/new.html.erb +0 -20
- data/spec/dummyapp/app/views/devise/shared/_links.html.erb +0 -25
- data/spec/dummyapp/app/views/home/cause_exception.html.erb +0 -1
- data/spec/dummyapp/app/views/home/index.html.erb +0 -4
- data/spec/dummyapp/app/views/home/report_exception.html.erb +0 -1
- data/spec/dummyapp/app/views/js/test.html.erb +0 -1
- data/spec/dummyapp/app/views/layouts/_messages.html.erb +0 -5
- data/spec/dummyapp/app/views/layouts/_navigation.html.erb +0 -21
- data/spec/dummyapp/app/views/layouts/application.html.erb +0 -25
- data/spec/dummyapp/app/views/layouts/simple.html.erb +0 -18
- data/spec/dummyapp/app/views/users/index.html.erb +0 -8
- data/spec/dummyapp/app/views/users/show.html.erb +0 -3
- data/spec/dummyapp/config.ru +0 -4
- data/spec/dummyapp/config/application.rb +0 -59
- data/spec/dummyapp/config/boot.rb +0 -10
- data/spec/dummyapp/config/database.yml +0 -25
- data/spec/dummyapp/config/environment.rb +0 -5
- data/spec/dummyapp/config/environments/development.rb +0 -37
- data/spec/dummyapp/config/environments/production.rb +0 -67
- data/spec/dummyapp/config/environments/test.rb +0 -37
- data/spec/dummyapp/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummyapp/config/initializers/inflections.rb +0 -15
- data/spec/dummyapp/config/initializers/mime_types.rb +0 -5
- data/spec/dummyapp/config/initializers/rollbar.rb +0 -26
- data/spec/dummyapp/config/initializers/secret_token.rb +0 -7
- data/spec/dummyapp/config/initializers/session_store.rb +0 -8
- data/spec/dummyapp/config/initializers/wrap_parameters.rb +0 -16
- data/spec/dummyapp/config/locales/devise.en.yml +0 -58
- data/spec/dummyapp/config/locales/en.yml +0 -5
- data/spec/dummyapp/config/routes.rb +0 -17
- data/spec/dummyapp/config/secrets.yml +0 -2
- data/spec/dummyapp/db/migrate/20121121184652_devise_create_users.rb +0 -46
- data/spec/dummyapp/db/migrate/20121121184654_add_name_to_users.rb +0 -5
- data/spec/dummyapp/db/migrate/20161219184410_create_books.rb +0 -10
- data/spec/dummyapp/db/migrate/20161219185529_add_username_to_users.rb +0 -5
- data/spec/dummyapp/db/schema.rb +0 -41
- data/spec/dummyapp/db/seeds.rb +0 -12
- data/spec/dummyapp/lib/assets/.gitkeep +0 -0
- data/spec/dummyapp/public/404.html +0 -26
- data/spec/dummyapp/public/422.html +0 -26
- data/spec/dummyapp/public/500.html +0 -25
- data/spec/dummyapp/public/favicon.ico +0 -0
- data/spec/dummyapp/script/rails +0 -6
- data/spec/fixtures/file1 +0 -1
- data/spec/fixtures/file2 +0 -1
- data/spec/fixtures/payloads/message.json +0 -25
- data/spec/fixtures/payloads/sample.trace.json +0 -275
- data/spec/fixtures/payloads/sample.trace_chain.json +0 -530
- data/spec/fixtures/plugins/dummy1.rb +0 -5
- data/spec/fixtures/plugins/dummy2.rb +0 -5
- data/spec/generators/rollbar/rollbar_generator_rails30_spec.rb +0 -31
- data/spec/generators/rollbar/rollbar_generator_spec.rb +0 -51
- data/spec/requests/home_spec.rb +0 -49
- data/spec/rollbar/configuration_spec.rb +0 -74
- data/spec/rollbar/delay/delayed_job_spec.rb +0 -22
- data/spec/rollbar/delay/girl_friday_spec.rb +0 -41
- data/spec/rollbar/delay/resque_spec.rb +0 -37
- data/spec/rollbar/delay/shoryuken_spec.rb +0 -44
- data/spec/rollbar/delay/thread_spec.rb +0 -27
- data/spec/rollbar/encoding/encoder_spec.rb +0 -63
- data/spec/rollbar/item/backtrace_spec.rb +0 -26
- data/spec/rollbar/item/frame_spec.rb +0 -267
- data/spec/rollbar/item_spec.rb +0 -736
- data/spec/rollbar/json/oj_spec.rb +0 -18
- data/spec/rollbar/json_spec.rb +0 -110
- data/spec/rollbar/lazy_store_spec.rb +0 -99
- data/spec/rollbar/logger_proxy_spec.rb +0 -69
- data/spec/rollbar/logger_spec.rb +0 -124
- data/spec/rollbar/middleware/js_spec.rb +0 -428
- data/spec/rollbar/middleware/sinatra_spec.rb +0 -197
- data/spec/rollbar/notifier_spec.rb +0 -67
- data/spec/rollbar/plugin_spec.rb +0 -209
- data/spec/rollbar/plugins/active_job_spec.rb +0 -45
- data/spec/rollbar/plugins/delayed_job/job_data_spec.rb +0 -48
- data/spec/rollbar/plugins/delayed_job_spec.rb +0 -129
- data/spec/rollbar/plugins/rack_spec.rb +0 -152
- data/spec/rollbar/plugins/rails_js_spec.rb +0 -19
- data/spec/rollbar/plugins/rake_spec.rb +0 -34
- data/spec/rollbar/plugins/resque/failure_spec.rb +0 -36
- data/spec/rollbar/plugins/sidekiq_spec.rb +0 -169
- data/spec/rollbar/plugins/validations_spec.rb +0 -56
- data/spec/rollbar/plugins_spec.rb +0 -68
- data/spec/rollbar/request_data_extractor_spec.rb +0 -321
- data/spec/rollbar/scrubbers/params_spec.rb +0 -598
- data/spec/rollbar/scrubbers/url_spec.rb +0 -240
- data/spec/rollbar/scrubbers_spec.rb +0 -31
- data/spec/rollbar/sidekig/clear_scope_spec.rb +0 -19
- data/spec/rollbar/truncation/frames_strategy_spec.rb +0 -70
- data/spec/rollbar/truncation/min_body_strategy_spec.rb +0 -57
- data/spec/rollbar/truncation/strings_strategy_spec.rb +0 -89
- data/spec/rollbar/truncation_spec.rb +0 -27
- data/spec/rollbar/util/hash_spec.rb +0 -22
- data/spec/rollbar/util/ip_anonymizer_spec.rb +0 -30
- data/spec/rollbar/util_spec.rb +0 -80
- data/spec/rollbar_bc_spec.rb +0 -380
- data/spec/rollbar_spec.rb +0 -1737
- data/spec/spec_helper.rb +0 -84
- data/spec/support/cause_exception.rb +0 -1
- data/spec/support/encoding_helpers.rb +0 -8
- data/spec/support/encodings/iso_8859_9 +0 -1
- data/spec/support/fixture_helpers.rb +0 -10
- data/spec/support/get_ip_raising.rb +0 -7
- data/spec/support/helpers.rb +0 -5
- data/spec/support/matchers.rb +0 -23
- data/spec/support/notifier_helpers.rb +0 -57
- data/spec/support/rollbar_api.rb +0 -57
- data/spec/support/secure_headers_mocks.rb +0 -83
- data/spec/support/shared_contexts.rb +0 -12
@@ -1,240 +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
|
-
options = {
|
8
|
-
:url => url,
|
9
|
-
:scrub_fields => [:password, :secret],
|
10
|
-
:scrub_user => false,
|
11
|
-
:scrub_password => false,
|
12
|
-
:randomize_scrub_length => true
|
13
|
-
}
|
14
|
-
|
15
|
-
if defined? whitelist
|
16
|
-
options[:whitelist] = whitelist
|
17
|
-
end
|
18
|
-
|
19
|
-
options
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#call' do
|
23
|
-
context 'cannot scrub URLs' do
|
24
|
-
next if Rollbar::LanguageSupport.can_scrub_url?
|
25
|
-
|
26
|
-
let(:url) { 'http://user:password@foo.com/some-interesting-path#fragment' }
|
27
|
-
|
28
|
-
it 'returns the URL without any change' do
|
29
|
-
expect(subject.call(options)).to be_eql(url)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'with ruby different from 1.8' do
|
34
|
-
next unless Rollbar::LanguageSupport.can_scrub_url?
|
35
|
-
|
36
|
-
context 'without data to be scrubbed' do
|
37
|
-
let(:url) { 'http://user:password@foo.com/some-interesting-path#fragment' }
|
38
|
-
|
39
|
-
it 'returns the URL without any change' do
|
40
|
-
expect(subject.call(options)).to be_eql(url)
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'with arrays in params' do
|
44
|
-
let(:url) { 'http://user:password@foo.com/some-interesting-path?foo[]=1&foo[]=2' }
|
45
|
-
|
46
|
-
it 'returns the URL without any change' do
|
47
|
-
expect(subject.call(options)).to be_eql(url)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context 'scrubbing user and password' do
|
53
|
-
let(:options) do
|
54
|
-
{
|
55
|
-
:url => url,
|
56
|
-
:scrub_fields => [],
|
57
|
-
:scrub_password => true,
|
58
|
-
:scrub_user => true
|
59
|
-
}
|
60
|
-
end
|
61
|
-
|
62
|
-
let(:url) { 'http://user:password@foo.com/some-interesting-path#fragment' }
|
63
|
-
|
64
|
-
it 'returns the URL without any change' do
|
65
|
-
expected_url = /http:\/\/\*{3,8}:\*{3,8}@foo.com\/some-interesting\-path#fragment/
|
66
|
-
|
67
|
-
expect(subject.call(options)).to match(expected_url)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
context 'with params to be filtered' do
|
72
|
-
let(:url) { 'http://foo.com/some-interesting-path?foo=bar&password=mypassword&secret=somevalue#fragment' }
|
73
|
-
|
74
|
-
it 'returns the URL with some params filtered' do
|
75
|
-
expected_url = /http:\/\/foo.com\/some-interesting-path\?foo=bar&password=\*{3,8}&secret=\*{3,8}#fragment/
|
76
|
-
|
77
|
-
expect(subject.call(options)).to match(expected_url)
|
78
|
-
end
|
79
|
-
|
80
|
-
context 'having array params' do
|
81
|
-
let(:url) { 'http://foo.com/some-interesting-path?foo=bar&password[]=mypassword&password[]=otherpassword&secret=somevalue#fragment' }
|
82
|
-
|
83
|
-
it 'returns the URL with some params filtered' do
|
84
|
-
expected_url = /http:\/\/foo.com\/some-interesting-path\?foo=bar&password\[\]=\*{3,8}&password\[\]=\*{3,8}&secret=\*{3,8}#fragment/
|
85
|
-
|
86
|
-
expect(subject.call(options)).to match(expected_url)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
context 'with no-random scrub length' do
|
92
|
-
let(:options) do
|
93
|
-
{
|
94
|
-
:url => url,
|
95
|
-
:scrub_fields => [:password, :secret],
|
96
|
-
:scrub_user => false,
|
97
|
-
:scrub_password => false,
|
98
|
-
:randomize_scrub_length => false
|
99
|
-
}
|
100
|
-
end
|
101
|
-
let(:password) { 'longpasswordishere' }
|
102
|
-
let(:url) { "http://foo.com/some-interesting-path?foo=bar&password=#{password}#fragment" }
|
103
|
-
|
104
|
-
it 'scrubs with same length than the scrubbed param' do
|
105
|
-
expected_url = /http:\/\/foo.com\/some-interesting-path\?foo=bar&password=\*{#{password.length}}#fragment/
|
106
|
-
|
107
|
-
expect(subject.call(options)).to match(expected_url)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
context 'with malformed URL or not able to be parsed' do
|
112
|
-
let(:url) { '\this\is\not\a\valid\url' }
|
113
|
-
before { reconfigure_notifier }
|
114
|
-
|
115
|
-
it 'return the same url' do
|
116
|
-
expect(Rollbar.logger).to receive(:error).and_call_original
|
117
|
-
expect(subject.call(options)).to be_eql(url)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
context 'with URL with spaces and arrays' do
|
122
|
-
let(:url) do
|
123
|
-
'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'
|
124
|
-
end
|
125
|
-
let(:options) do
|
126
|
-
{
|
127
|
-
:url => url,
|
128
|
-
:scrub_fields => [:passwd, :password, :password_confirmation, :secret, :confirm_password, :secret_token, :api_key, :access_token, :auth, :SAMLResponse, :password, :auth],
|
129
|
-
:scrub_user => true,
|
130
|
-
:scrub_password => true,
|
131
|
-
:randomize_scrub_length => true
|
132
|
-
}
|
133
|
-
end
|
134
|
-
|
135
|
-
it 'doesnt logs error' do
|
136
|
-
expect(Rollbar.logger).not_to receive(:error).and_call_original
|
137
|
-
subject.call(options)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
context 'in whitelist mode' do
|
143
|
-
|
144
|
-
let(:whitelist) { [:user, :secret] }
|
145
|
-
|
146
|
-
context 'with ruby different from 1.8' do
|
147
|
-
next unless Rollbar::LanguageSupport.can_scrub_url?
|
148
|
-
|
149
|
-
context 'cannot scrub URLs' do
|
150
|
-
|
151
|
-
let(:url) { 'http://user:password@foo.com/some-interesting-path#fragment' }
|
152
|
-
|
153
|
-
it 'returns the URL without any change' do
|
154
|
-
expect(subject.call(options)).to be_eql(url)
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
context 'scrubbing user and password' do
|
159
|
-
|
160
|
-
let(:options) do
|
161
|
-
{
|
162
|
-
:url => url,
|
163
|
-
:scrub_fields => [],
|
164
|
-
:scrub_password => true,
|
165
|
-
:scrub_user => true,
|
166
|
-
:whitelist => whitelist
|
167
|
-
}
|
168
|
-
end
|
169
|
-
|
170
|
-
let(:url) { 'http://user:password@foo.com/some-interesting-path#fragment' }
|
171
|
-
|
172
|
-
it 'returns the URL without any change' do
|
173
|
-
expected_url = /http:\/\/\*{3,8}:\*{3,8}@foo.com\/some-interesting\-path#fragment/
|
174
|
-
|
175
|
-
expect(subject.call(options)).to match(expected_url)
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
context 'with scrub_all' do
|
180
|
-
let(:options) do
|
181
|
-
{
|
182
|
-
:url => url,
|
183
|
-
:scrub_fields => [:scrub_all],
|
184
|
-
:scrub_password => false,
|
185
|
-
:scrub_user => false,
|
186
|
-
:whitelist => whitelist
|
187
|
-
}
|
188
|
-
end
|
189
|
-
let(:url) { 'http://foo.com/some-interesting-path?foo=bar&password=mypassword&secret=somevalue&dont_scrub=foo#fragment' }
|
190
|
-
|
191
|
-
it 'returns the URL with some params filtered' do
|
192
|
-
expected_url = /http:\/\/foo.com\/some-interesting-path\?foo=\*{3,8}&password=\*{3,8}&secret=somevalue&dont_scrub=\*{3,8}#fragment/
|
193
|
-
|
194
|
-
expect(subject.call(options)).to match(expected_url)
|
195
|
-
end
|
196
|
-
|
197
|
-
context 'having array params' do
|
198
|
-
let(:url) { 'http://foo.com/some-interesting-path?foo=bar&password[]=mypassword&password[]=otherpassword&secret=somevalue&dont_scrub=foo#fragment' }
|
199
|
-
|
200
|
-
it 'returns the URL with some params filtered' do
|
201
|
-
expected_url = /http:\/\/foo.com\/some-interesting-path\?foo=\*{3,8}&password\[\]=\*{3,8}&password\[\]=\*{3,8}&secret=somevalue&dont_scrub=\*{3,8}#fragment/
|
202
|
-
|
203
|
-
expect(subject.call(options)).to match(expected_url)
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
context 'with params to be filtered' do
|
209
|
-
let(:options) do
|
210
|
-
{
|
211
|
-
:url => url,
|
212
|
-
:scrub_fields => [:dont_scrub, :secret, :password, :foo],
|
213
|
-
:scrub_password => false,
|
214
|
-
:scrub_user => false,
|
215
|
-
:whitelist => whitelist
|
216
|
-
}
|
217
|
-
end
|
218
|
-
|
219
|
-
let(:url) { 'http://foo.com/some-interesting-path?foo=bar&password=mypassword&secret=somevalue&dont_scrub=foo#fragment' }
|
220
|
-
|
221
|
-
it 'returns the URL with some params filtered' do
|
222
|
-
expected_url = /http:\/\/foo.com\/some-interesting-path\?foo=\*{3,8}&password=\*{3,8}&secret=somevalue&dont_scrub=\*{3,8}#fragment/
|
223
|
-
|
224
|
-
expect(subject.call(options)).to match(expected_url)
|
225
|
-
end
|
226
|
-
|
227
|
-
context 'having array params' do
|
228
|
-
let(:url) { 'http://foo.com/some-interesting-path?foo=bar&password[]=mypassword&password[]=otherpassword&secret=somevalue&dont_scrub=foo#fragment' }
|
229
|
-
|
230
|
-
it 'returns the URL with some params filtered' do
|
231
|
-
expected_url = /http:\/\/foo.com\/some-interesting-path\?foo=\*{3,8}&password\[\]=\*{3,8}&password\[\]=\*{3,8}&secret=somevalue&dont_scrub=\*{3,8}#fragment/
|
232
|
-
|
233
|
-
expect(subject.call(options)).to match(expected_url)
|
234
|
-
end
|
235
|
-
end
|
236
|
-
end
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
240
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'rollbar/scrubbers'
|
4
|
-
|
5
|
-
describe Rollbar::Scrubbers do
|
6
|
-
describe '.scrub_value' do
|
7
|
-
context 'with random scrub length' do
|
8
|
-
before do
|
9
|
-
allow(Rollbar.configuration).to receive(:randomize_scrub_length).and_return(true)
|
10
|
-
end
|
11
|
-
|
12
|
-
let(:value) { 'herecomesaverylongvalue' }
|
13
|
-
|
14
|
-
it 'randomizes the scrubbed string' do
|
15
|
-
expect(described_class.scrub_value(value)).to match(/\*{3,8}/)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'with no-random scrub length' do
|
20
|
-
before do
|
21
|
-
allow(Rollbar.configuration).to receive(:randomize_scrub_length).and_return(false)
|
22
|
-
end
|
23
|
-
|
24
|
-
let(:value) { 'herecomesaverylongvalue' }
|
25
|
-
|
26
|
-
it 'randomizes the scrubbed string' do
|
27
|
-
expect(described_class.scrub_value(value)).to match(/\*{#{value.length}}/)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
unless RUBY_VERSION == '1.8.7'
|
4
|
-
require 'sidekiq'
|
5
|
-
end
|
6
|
-
|
7
|
-
Rollbar.plugins.load!
|
8
|
-
|
9
|
-
describe Rollbar::Sidekiq::ClearScope, :reconfigure_notifier => false do
|
10
|
-
describe '#call' do
|
11
|
-
let(:middleware_block) { proc{} }
|
12
|
-
|
13
|
-
it 'sends the error to Rollbar::Sidekiq.handle_exception' do
|
14
|
-
expect(Rollbar).to receive(:reset_notifier!)
|
15
|
-
|
16
|
-
subject.call(nil, nil, nil, &middleware_block)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end unless RUBY_VERSION == '1.8.7'
|
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rollbar/truncation/frames_strategy'
|
3
|
-
|
4
|
-
describe Rollbar::Truncation::FramesStrategy do
|
5
|
-
def expand_frames(frames)
|
6
|
-
frames * (1 + 300 / frames.count)
|
7
|
-
end
|
8
|
-
|
9
|
-
describe '.call', :fixture => :payload do
|
10
|
-
context 'with trace key' do
|
11
|
-
let(:payload_fixture) { 'payloads/sample.trace.json' }
|
12
|
-
let(:frames) { payload['data']['body']['trace']['frames'].clone }
|
13
|
-
|
14
|
-
before do
|
15
|
-
payload['data']['body']['trace']['frames'] = expand_frames(frames)
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'returns a new payload with 300 frames' do
|
19
|
-
result = Rollbar::JSON.load(described_class.call(payload))
|
20
|
-
|
21
|
-
new_frames = result['data']['body']['trace']['frames']
|
22
|
-
|
23
|
-
expect(new_frames.count).to be_eql(300)
|
24
|
-
expect(new_frames.first).to be_eql(frames.first)
|
25
|
-
expect(new_frames.last).to be_eql(frames.last)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'with trace_chain key' do
|
30
|
-
let(:payload_fixture) { 'payloads/sample.trace_chain.json' }
|
31
|
-
|
32
|
-
let(:frames1) { payload['data']['body']['trace_chain'][0]['frames'].clone }
|
33
|
-
let(:frames2) { payload['data']['body']['trace_chain'][1]['frames'].clone }
|
34
|
-
|
35
|
-
before do
|
36
|
-
payload['data']['body']['trace_chain'][0]['frames'] = expand_frames(frames1)
|
37
|
-
payload['data']['body']['trace_chain'][1]['frames'] = expand_frames(frames2)
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'returns a new payload with 300 frames for each chain item' do
|
41
|
-
result = Rollbar::JSON.load(described_class.call(payload))
|
42
|
-
|
43
|
-
new_frames1 = result['data']['body']['trace_chain'][0]['frames']
|
44
|
-
new_frames2 = result['data']['body']['trace_chain'][1]['frames']
|
45
|
-
|
46
|
-
expect(new_frames1.count).to be_eql(300)
|
47
|
-
expect(new_frames1.first).to be_eql(frames1.first)
|
48
|
-
expect(new_frames1.last).to be_eql(frames1.last)
|
49
|
-
|
50
|
-
expect(new_frames2.count).to be_eql(300)
|
51
|
-
expect(new_frames2.first).to be_eql(frames2.first)
|
52
|
-
expect(new_frames2.last).to be_eql(frames2.last)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'without trace or trace_chain', :fixture => :payload do
|
57
|
-
let(:payload_fixture) { 'payloads/sample.trace.json' }
|
58
|
-
|
59
|
-
before do
|
60
|
-
payload['data']['body'].delete('trace')
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'returns the original payload' do
|
64
|
-
result = Rollbar::JSON.load(described_class.call(payload))
|
65
|
-
|
66
|
-
expect(result).to be_eql(payload)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rollbar/truncation/frames_strategy'
|
3
|
-
|
4
|
-
describe Rollbar::Truncation::MinBodyStrategy do
|
5
|
-
describe '.call', :fixture => :payload do
|
6
|
-
let(:message) { 'a' * 1_000 }
|
7
|
-
|
8
|
-
context 'with trace key ' do
|
9
|
-
let(:payload_fixture) { 'payloads/sample.trace.json' }
|
10
|
-
let!(:frames) { payload['data']['body']['trace']['frames'].clone }
|
11
|
-
|
12
|
-
before do
|
13
|
-
payload['data']['body']['trace']['exception']['message'] = message
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'truncates the exception message and frames array' do
|
17
|
-
result = Rollbar::JSON.load(described_class.call(payload))
|
18
|
-
|
19
|
-
trace = result['data']['body']['trace']
|
20
|
-
expect(trace['frames'].count).to eq 2
|
21
|
-
expect(trace['exception']['message']).to be_eql('a' * 255)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'with trace_chain key ' do
|
26
|
-
let(:payload_fixture) { 'payloads/sample.trace_chain.json' }
|
27
|
-
let!(:frames1) { payload['data']['body']['trace_chain'][0]['frames'].clone }
|
28
|
-
let!(:frames2) { payload['data']['body']['trace_chain'][1]['frames'].clone }
|
29
|
-
|
30
|
-
before do
|
31
|
-
payload['data']['body']['trace_chain'][0]['exception']['message'] = message
|
32
|
-
payload['data']['body']['trace_chain'][1]['exception']['message'] = message
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'truncates the exception message and frames array' do
|
36
|
-
result = Rollbar::JSON.load(described_class.call(payload))
|
37
|
-
|
38
|
-
traces = result['data']['body']['trace_chain']
|
39
|
-
expect(traces[0]['frames'].count).to eq 2
|
40
|
-
expect(traces[0]['exception']['message']).to be_eql('a' * 255)
|
41
|
-
|
42
|
-
expect(traces[1]['frames'].count).to eq 2
|
43
|
-
expect(traces[1]['exception']['message']).to be_eql('a' * 255)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context 'with a message payload' do
|
48
|
-
let(:payload_fixture) { 'payloads/message.json' }
|
49
|
-
|
50
|
-
it "doesn't truncate anything and returns same payload" do
|
51
|
-
result = Rollbar::JSON.load(described_class.call(payload))
|
52
|
-
|
53
|
-
expect(result).to be_eql(payload)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'rollbar/truncation/frames_strategy'
|
5
|
-
|
6
|
-
describe Rollbar::Truncation::StringsStrategy do
|
7
|
-
describe '.call' do
|
8
|
-
let(:long_message) { 'a' * 2000 }
|
9
|
-
let(:payload) do
|
10
|
-
{
|
11
|
-
'truncated' => long_message,
|
12
|
-
'not_truncated' => '123456',
|
13
|
-
'hash' => {
|
14
|
-
'inner_truncated' => long_message,
|
15
|
-
'inner_not_truncated' => '567',
|
16
|
-
'array' => ['12345678', '12', { 'inner_inner' => long_message }]
|
17
|
-
}
|
18
|
-
}
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should truncate all nested strings in the payload' do
|
22
|
-
result = Rollbar::JSON.load(described_class.call(payload))
|
23
|
-
|
24
|
-
expect(result['truncated'].size).to be_eql(1024)
|
25
|
-
expect(result['hash']['inner_truncated'].size).to be_eql(1024)
|
26
|
-
expect(result['hash']['array'][2]['inner_inner'].size).to be_eql(1024)
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'with utf8 strings' do
|
30
|
-
let(:long_message) { 'Ŝǻмρļẻ śţяịņģ' + 'a' * 2000 }
|
31
|
-
let(:payload) do
|
32
|
-
{
|
33
|
-
'truncated' => long_message,
|
34
|
-
'not_truncated' => '123456',
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should truncate utf8 strings properly' do
|
39
|
-
result = Rollbar::JSON.load(described_class.call(payload))
|
40
|
-
expect(result['truncated']).to match(/^Ŝǻмρļẻ śţяịņģa*\.{3}/)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'when first threshold is not enough' do
|
45
|
-
let(:payload) do
|
46
|
-
512.times.to_enum.reduce({}) do |hash, i|
|
47
|
-
hash[i.to_s] = 'a' * 1024
|
48
|
-
hash
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'truncates to 512 size strings' do
|
53
|
-
result = Rollbar::JSON.load(described_class.call(payload))
|
54
|
-
|
55
|
-
expect(result['0'].size).to be_eql(512)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'when second threshold is still not enough' do
|
60
|
-
let(:payload) do
|
61
|
-
1024.times.to_enum.reduce({}) do |hash, i|
|
62
|
-
hash[i.to_s] = 'a' * 1024
|
63
|
-
hash
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'truncates to 256 size strings, the third threshold' do
|
68
|
-
result = Rollbar::JSON.load(described_class.call(payload))
|
69
|
-
|
70
|
-
expect(result['0'].size).to be_eql(256)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
context 'when third threshold is still not enough' do
|
75
|
-
let(:payload) do
|
76
|
-
1024.times.to_enum.reduce({}) do |hash, i|
|
77
|
-
hash[i.to_s] = 'a' * 1024
|
78
|
-
hash
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'just return the value for third threshold' do
|
83
|
-
result = Rollbar::JSON.load(described_class.call(payload))
|
84
|
-
|
85
|
-
expect(result['0'].size).to be_eql(256)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|