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,480 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
|
4
|
-
def wrap_process_args(*args)
|
5
|
-
if ::Gem::Version.new(::Rails.version) >= ::Gem::Version.new('5.0')
|
6
|
-
[{ :params => args[0], :headers => args[1] }]
|
7
|
-
else
|
8
|
-
args
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe HomeController do
|
13
|
-
let(:logger_mock) { double("Rails.logger").as_null_object }
|
14
|
-
let(:notifier) { Rollbar.notifier }
|
15
|
-
|
16
|
-
before do
|
17
|
-
Rollbar.clear_notifier!
|
18
|
-
reset_configuration
|
19
|
-
preconfigure_rails_notifier
|
20
|
-
|
21
|
-
Rollbar.configure do |config|
|
22
|
-
config.access_token = test_access_token
|
23
|
-
config.logger = logger_mock
|
24
|
-
config.open_timeout = 60
|
25
|
-
config.request_timeout = 60
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context "rollbar base_data" do
|
30
|
-
it 'should have the Rails environment' do
|
31
|
-
data = Rollbar.notifier.send(:build_item, 'error', 'message', nil, nil, nil)
|
32
|
-
data['data'][:environment].should == ::Rails.env
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'should have an overridden environment' do
|
36
|
-
Rollbar.configure do |config|
|
37
|
-
config.environment = 'dev'
|
38
|
-
end
|
39
|
-
|
40
|
-
data = Rollbar.notifier.send(:build_item, 'error', 'message', nil, nil, nil)
|
41
|
-
data['data'][:environment].should == 'dev'
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'should use the default "unspecified" environment if rails env ends up being empty' do
|
45
|
-
old_env, ::Rails.env = ::Rails.env, ''
|
46
|
-
preconfigure_rails_notifier
|
47
|
-
|
48
|
-
data = Rollbar.notifier.send(:build_item, 'error', 'message', nil, nil, nil)
|
49
|
-
data['data'][:environment].should == 'unspecified'
|
50
|
-
|
51
|
-
::Rails.env = old_env
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context "rollbar controller methods with %s requests" % (local? ? 'local' : 'non-local') do
|
56
|
-
# TODO run these for a a more-real request
|
57
|
-
it "should build valid request data" do
|
58
|
-
data = @controller.rollbar_request_data
|
59
|
-
data.should have_key(:params)
|
60
|
-
data.should have_key(:url)
|
61
|
-
data.should have_key(:user_ip)
|
62
|
-
data.should have_key(:headers)
|
63
|
-
data.should have_key(:session)
|
64
|
-
data.should have_key(:method)
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should build empty person data when no one is logged-in" do
|
68
|
-
data = @controller.rollbar_person_data
|
69
|
-
data.should == {}
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'rollbar_scrub_headers' do
|
73
|
-
it 'should filter authentication by default' do
|
74
|
-
headers = {
|
75
|
-
'HTTP_AUTHORIZATION' => 'some-user',
|
76
|
-
'HTTP_USER_AGENT' => 'spec'
|
77
|
-
}
|
78
|
-
|
79
|
-
filtered = controller.send( :rollbar_headers, headers )
|
80
|
-
|
81
|
-
expect(filtered['Authorization']).to match(/\**/)
|
82
|
-
expect(filtered['User-Agent']).to be_eql('spec')
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'should filter custom headers' do
|
86
|
-
Rollbar.configure do |config|
|
87
|
-
config.scrub_headers = ['Auth', 'Token']
|
88
|
-
end
|
89
|
-
|
90
|
-
headers = {
|
91
|
-
'HTTP_AUTH' => 'auth-value',
|
92
|
-
'HTTP_TOKEN' => 'token-value',
|
93
|
-
'HTTP_CONTENT_TYPE' => 'text/html'
|
94
|
-
}
|
95
|
-
|
96
|
-
filtered = controller.send( :rollbar_headers, headers )
|
97
|
-
expect(filtered['Auth']).to match(/\**/)
|
98
|
-
expect(filtered['Token']).to match(/\**/)
|
99
|
-
expect(filtered['Content-Type']).to be_eql('text/html')
|
100
|
-
end
|
101
|
-
|
102
|
-
end
|
103
|
-
|
104
|
-
context "rollbar_request_url" do
|
105
|
-
it "should build simple http urls" do
|
106
|
-
req = controller.request
|
107
|
-
req.host = 'rollbar.com'
|
108
|
-
|
109
|
-
controller.send(:rollbar_request_data)[:url].should == 'http://rollbar.com'
|
110
|
-
end
|
111
|
-
|
112
|
-
it "should respect forwarded host" do
|
113
|
-
req = controller.request
|
114
|
-
req.host = '127.0.0.1:8080'
|
115
|
-
req.env['HTTP_X_FORWARDED_HOST'] = 'test.com'
|
116
|
-
|
117
|
-
controller.send(:rollbar_request_data)[:url].should == 'http://test.com'
|
118
|
-
end
|
119
|
-
|
120
|
-
it "should respect forwarded proto" do
|
121
|
-
req = controller.request
|
122
|
-
req.host = 'rollbar.com'
|
123
|
-
req.env['HTTP_X_FORWARDED_PROTO'] = 'https'
|
124
|
-
|
125
|
-
controller.send(:rollbar_request_data)[:url].should == 'https://rollbar.com'
|
126
|
-
end
|
127
|
-
|
128
|
-
it "should respect forwarded port" do
|
129
|
-
req = controller.request
|
130
|
-
req.host = '127.0.0.1:8080'
|
131
|
-
req.env['HTTP_X_FORWARDED_HOST'] = 'test.com'
|
132
|
-
req.env['HTTP_X_FORWARDED_PORT'] = '80'
|
133
|
-
|
134
|
-
controller.send(:rollbar_request_data)[:url].should == 'http://test.com'
|
135
|
-
|
136
|
-
req.env['HTTP_X_FORWARDED_PORT'] = '81'
|
137
|
-
controller.send(:rollbar_request_data)[:url].should == 'http://test.com:81'
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
context "rollbar_user_ip" do
|
142
|
-
it "should use X-Real-Ip when set" do
|
143
|
-
controller.request.env["HTTP_X_REAL_IP"] = '1.1.1.1'
|
144
|
-
controller.request.env["HTTP_X_FORWARDED_FOR"] = '1.2.3.4'
|
145
|
-
controller.send(:rollbar_request_data)[:user_ip].should == '1.1.1.1'
|
146
|
-
end
|
147
|
-
|
148
|
-
it "should use X-Forwarded-For when set" do
|
149
|
-
controller.request.env["HTTP_X_FORWARDED_FOR"] = '1.2.3.4'
|
150
|
-
controller.send(:rollbar_request_data)[:user_ip].should == '1.2.3.4'
|
151
|
-
end
|
152
|
-
|
153
|
-
it "should use the remote_addr when neither is set" do
|
154
|
-
controller.send(:rollbar_request_data)[:user_ip].should == '0.0.0.0'
|
155
|
-
end
|
156
|
-
|
157
|
-
context "rollbar_user_ip obfuscator" do
|
158
|
-
before do
|
159
|
-
Rollbar.configure do |config|
|
160
|
-
config.user_ip_obfuscator_secret = 'secret'
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
it "should obfuscate the ip when user_ip_obfuscator_secret is set" do
|
165
|
-
real_ip = '1.1.1.1'
|
166
|
-
obfuscated_ip = '95.191.35.149'
|
167
|
-
controller.request.env["HTTP_X_REAL_IP"] = real_ip
|
168
|
-
controller.send(:rollbar_request_data)[:user_ip].should == obfuscated_ip
|
169
|
-
end
|
170
|
-
|
171
|
-
it "should clear the ip field when an invalid ip is provided" do
|
172
|
-
invalid_ip = '1.1.1.999'
|
173
|
-
controller.request.env["HTTP_X_REAL_IP"] = invalid_ip
|
174
|
-
controller.send(:rollbar_request_data)[:user_ip].should == nil
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
context "rollbar_route_params", :type => 'request' do
|
180
|
-
it "should save controller and action in the payload body" do
|
181
|
-
post '/report_exception'
|
182
|
-
|
183
|
-
route = controller.send(:rollbar_request_data)[:params]
|
184
|
-
|
185
|
-
route[:controller].should == 'home'
|
186
|
-
route[:action].should == 'report_exception'
|
187
|
-
|
188
|
-
Rollbar.last_report.should_not be_nil
|
189
|
-
Rollbar.last_report[:context].should == 'home#report_exception'
|
190
|
-
end
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
context "param_scrubbing", :type => "request" do
|
195
|
-
it "should scrub the default scrub_fields" do
|
196
|
-
params = {
|
197
|
-
:passwd => "hidden",
|
198
|
-
:password => "hidden",
|
199
|
-
:secret => "hidden",
|
200
|
-
:notpass => "visible",
|
201
|
-
:secret_token => "f6805fea1cae0fb79c5e63bbdcd12bc6",
|
202
|
-
}
|
203
|
-
|
204
|
-
post '/report_exception', *wrap_process_args(params)
|
205
|
-
|
206
|
-
filtered = Rollbar.last_report[:request][:POST]
|
207
|
-
|
208
|
-
expect(filtered["passwd"]).to match(/\**/)
|
209
|
-
expect(filtered["password"]).to match(/\**/)
|
210
|
-
expect(filtered["secret"]).to match(/\**/)
|
211
|
-
expect(filtered["notpass"]).to match(/\**/)
|
212
|
-
expect(filtered["secret_token"]).to match(/\**/)
|
213
|
-
end
|
214
|
-
|
215
|
-
it "should scrub custom scrub_fields" do
|
216
|
-
Rollbar.configure do |config|
|
217
|
-
config.scrub_fields = [:notpass, :secret]
|
218
|
-
end
|
219
|
-
|
220
|
-
params = {
|
221
|
-
:passwd => "visible",
|
222
|
-
:password => "visible",
|
223
|
-
:secret => "hidden",
|
224
|
-
:notpass => "hidden"
|
225
|
-
}
|
226
|
-
|
227
|
-
post '/report_exception', *wrap_process_args(params)
|
228
|
-
|
229
|
-
filtered = Rollbar.last_report[:request][:POST]
|
230
|
-
|
231
|
-
filtered["passwd"].should == "visible"
|
232
|
-
# config.filter_parameters is set to [:password] in
|
233
|
-
# spec/dummyapp/config/application.rb
|
234
|
-
expect(filtered["password"]).to match(/\**/)
|
235
|
-
expect(filtered["secret"]).to match(/\**/)
|
236
|
-
expect(filtered["notpass"]).to match(/\**/)
|
237
|
-
end
|
238
|
-
end
|
239
|
-
|
240
|
-
describe "GET 'index'" do
|
241
|
-
it "should be successful and report two messages" do
|
242
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success').twice
|
243
|
-
get 'index'
|
244
|
-
response.should be_success
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
describe "'report_exception'", :type => "request" do
|
249
|
-
it "should raise a NameError and report an exception after a GET" do
|
250
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success').once
|
251
|
-
|
252
|
-
get '/report_exception'
|
253
|
-
response.should be_success
|
254
|
-
end
|
255
|
-
|
256
|
-
it "should raise a NameError and have PUT params in the reported exception" do
|
257
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success')
|
258
|
-
|
259
|
-
put '/report_exception', *wrap_process_args({ :putparam => "putval" })
|
260
|
-
|
261
|
-
Rollbar.last_report.should_not be_nil
|
262
|
-
Rollbar.last_report[:request][:POST]["putparam"].should == "putval"
|
263
|
-
end
|
264
|
-
|
265
|
-
context 'using deprecated report_exception' do
|
266
|
-
it 'reports the errors successfully' do
|
267
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success')
|
268
|
-
|
269
|
-
put '/deprecated_report_exception', *wrap_process_args({ :putparam => "putval" })
|
270
|
-
|
271
|
-
Rollbar.last_report.should_not be_nil
|
272
|
-
Rollbar.last_report[:request][:POST]["putparam"].should == "putval"
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
it "should raise a NameError and have JSON POST params" do
|
277
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success')
|
278
|
-
@request.env["HTTP_ACCEPT"] = "application/json"
|
279
|
-
|
280
|
-
params = { :jsonparam => 'jsonval' }.to_json
|
281
|
-
post '/report_exception', *wrap_process_args(params, { 'CONTENT_TYPE' => 'application/json' })
|
282
|
-
|
283
|
-
Rollbar.last_report.should_not be_nil
|
284
|
-
expect(Rollbar.last_report[:request][:body]).to be_eql(params)
|
285
|
-
end
|
286
|
-
end
|
287
|
-
|
288
|
-
describe "'cause_exception'", :type => "request" do
|
289
|
-
it "should raise an uncaught exception and report a message" do
|
290
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success').once
|
291
|
-
|
292
|
-
expect { get '/cause_exception' }.to raise_exception(NameError)
|
293
|
-
end
|
294
|
-
|
295
|
-
context 'show_exceptions' do
|
296
|
-
before(:each) do
|
297
|
-
if Dummy::Application.respond_to? :env_config
|
298
|
-
config = Dummy::Application.env_config
|
299
|
-
else
|
300
|
-
config = Dummy::Application.env_defaults
|
301
|
-
end
|
302
|
-
|
303
|
-
config['action_dispatch.show_exceptions'] = true
|
304
|
-
end
|
305
|
-
|
306
|
-
after do
|
307
|
-
if Dummy::Application.respond_to? :env_config
|
308
|
-
config = Dummy::Application.env_config
|
309
|
-
else
|
310
|
-
config = Dummy::Application.env_defaults
|
311
|
-
end
|
312
|
-
|
313
|
-
config['action_dispatch.show_exceptions'] = false
|
314
|
-
end
|
315
|
-
|
316
|
-
it "middleware should catch the exception and only report to rollbar once" do
|
317
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success').once
|
318
|
-
|
319
|
-
get '/cause_exception'
|
320
|
-
end
|
321
|
-
|
322
|
-
it 'should not fail if the controller doesnt contain the person method' do
|
323
|
-
Rollbar.configure do |config|
|
324
|
-
config.person_method = 'invalid_method'
|
325
|
-
end
|
326
|
-
|
327
|
-
get '/cause_exception'
|
328
|
-
end
|
329
|
-
|
330
|
-
context 'with logged user' do
|
331
|
-
let(:user) do
|
332
|
-
User.create(:email => 'foo@bar.com',
|
333
|
-
:username => 'the_username')
|
334
|
-
end
|
335
|
-
|
336
|
-
before { cookies[:session_id] = user.id }
|
337
|
-
|
338
|
-
subject(:person_data) do
|
339
|
-
put '/report_exception', *wrap_process_args('foo' => 'bar')
|
340
|
-
|
341
|
-
Rollbar.last_report[:person]
|
342
|
-
end
|
343
|
-
|
344
|
-
context 'default' do
|
345
|
-
it 'sends the current user data excluding personally identifiable information' do
|
346
|
-
expect(person_data).to eq(:id => user.id,
|
347
|
-
:email => nil,
|
348
|
-
:username => nil)
|
349
|
-
end
|
350
|
-
end
|
351
|
-
|
352
|
-
context 'without EU GDPR subjects' do
|
353
|
-
context 'configured to send email addresses' do
|
354
|
-
before { Rollbar.configure { |config| config.person_email_method = 'email' } }
|
355
|
-
|
356
|
-
it 'sends the current user data including email address' do
|
357
|
-
expect(person_data).to eq(:id => user.id,
|
358
|
-
:email => 'foo@bar.com',
|
359
|
-
:username => nil)
|
360
|
-
end
|
361
|
-
|
362
|
-
context 'configured to send email addresses and username' do
|
363
|
-
before { Rollbar.configure { |config| config.person_username_method = 'username' } }
|
364
|
-
|
365
|
-
it 'sends the current user data including email address and username' do
|
366
|
-
expect(person_data).to eq(:id => user.id,
|
367
|
-
:email => 'foo@bar.com',
|
368
|
-
:username => 'the_username')
|
369
|
-
end
|
370
|
-
end
|
371
|
-
end
|
372
|
-
end
|
373
|
-
end
|
374
|
-
end
|
375
|
-
end
|
376
|
-
|
377
|
-
context 'with routing errors', :type => :request do
|
378
|
-
it 'raises a RoutingError exception' do
|
379
|
-
expect { get '/foo/bar', *wrap_process_args({ :foo => :bar }) }.to raise_exception(ActionController::RoutingError)
|
380
|
-
|
381
|
-
report = Rollbar.last_report
|
382
|
-
expect(report[:request][:GET]['foo']).to be_eql('bar')
|
383
|
-
end
|
384
|
-
end
|
385
|
-
|
386
|
-
context 'with ip parsing raising error' do
|
387
|
-
it 'raise a IpSpoofAttackError exception' do
|
388
|
-
controller.request.env['action_dispatch.remote_ip'] = GetIpRaising.new
|
389
|
-
|
390
|
-
expect do
|
391
|
-
expect(controller.send(:rollbar_request_data)[:user_ip]).to be_nil
|
392
|
-
end.not_to raise_exception
|
393
|
-
end
|
394
|
-
end
|
395
|
-
|
396
|
-
context 'with file uploads',:type => "request" do
|
397
|
-
let(:file1) { fixture_file_upload('spec/fixtures/file1') }
|
398
|
-
let(:file2) { fixture_file_upload('spec/fixtures/file2') }
|
399
|
-
|
400
|
-
context 'with a single upload' do
|
401
|
-
it "saves attachment data" do
|
402
|
-
expect { post '/file_upload', *wrap_process_args({ :upload => file1 }) }.to raise_exception(NameError)
|
403
|
-
|
404
|
-
upload_param = Rollbar.last_report[:request][:POST]['upload']
|
405
|
-
|
406
|
-
expect(upload_param).to have_key(:filename)
|
407
|
-
expect(upload_param).to have_key(:type)
|
408
|
-
expect(upload_param).to have_key(:name)
|
409
|
-
expect(upload_param).to have_key(:head)
|
410
|
-
|
411
|
-
expect(upload_param[:tempfile]).to be_eql("Skipped value of class 'Tempfile'")
|
412
|
-
end
|
413
|
-
end
|
414
|
-
|
415
|
-
context 'with multiple uploads', :type => :request do
|
416
|
-
it "saves attachment data for all uploads" do
|
417
|
-
expect { post '/file_upload', *wrap_process_args({ :upload => [file1, file2] }) }.to raise_exception(NameError)
|
418
|
-
sent_params = Rollbar.last_report[:request][:POST]['upload']
|
419
|
-
|
420
|
-
expect(sent_params).to be_kind_of(Array)
|
421
|
-
expect(sent_params.size).to be(2)
|
422
|
-
end
|
423
|
-
end
|
424
|
-
end
|
425
|
-
|
426
|
-
context 'with session data', :type => :request do
|
427
|
-
before { get '/set_session_data' }
|
428
|
-
|
429
|
-
it 'reports the session data' do
|
430
|
-
expect { get '/use_session_data' }.to raise_exception(NoMethodError)
|
431
|
-
|
432
|
-
session_data = Rollbar.last_report[:request][:session]
|
433
|
-
|
434
|
-
expect(session_data['some_value']).to be_eql('this-is-a-cool-value')
|
435
|
-
end
|
436
|
-
end
|
437
|
-
|
438
|
-
context 'with json ACCEPT header', :type => 'request' do
|
439
|
-
let(:params) { { :foo => :bar } }
|
440
|
-
|
441
|
-
it 'parses the correct headers' do
|
442
|
-
expect do
|
443
|
-
post '/cause_exception', *wrap_process_args(params, { 'ACCEPT' => 'application/vnd.github.v3+json' })
|
444
|
-
end.to raise_exception(NameError)
|
445
|
-
|
446
|
-
expect(Rollbar.last_report[:request][:POST]['foo']).to be_eql('bar')
|
447
|
-
end
|
448
|
-
end
|
449
|
-
|
450
|
-
context 'with params to be scrubed from URL', :type => :request do
|
451
|
-
next unless Rollbar::LanguageSupport.can_scrub_url?
|
452
|
-
|
453
|
-
before do
|
454
|
-
Rollbar.configure do |config|
|
455
|
-
config.scrub_fields = [:password]
|
456
|
-
end
|
457
|
-
end
|
458
|
-
|
459
|
-
let(:headers) do
|
460
|
-
{
|
461
|
-
'ORIGINAL_FULLPATH' => '/cause_exception?password=my-secret-password'
|
462
|
-
}
|
463
|
-
end
|
464
|
-
|
465
|
-
it 'scrubs sensible data from URL' do
|
466
|
-
expect { get '/cause_exception', *wrap_process_args({ :password => 'my-secret-password' }, headers) }.to raise_exception(NameError)
|
467
|
-
|
468
|
-
request_data = Rollbar.last_report[:request]
|
469
|
-
|
470
|
-
expect(request_data[:url]).to match('http:\/\/www.example.com\/cause_exception\?password=\*{3,8}')
|
471
|
-
end
|
472
|
-
end
|
473
|
-
|
474
|
-
after do
|
475
|
-
Rollbar.configure do |config|
|
476
|
-
config.logger = ::Rails.logger
|
477
|
-
end
|
478
|
-
end
|
479
|
-
|
480
|
-
end
|