airbrake 4.3.8 → 5.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 (134) hide show
  1. checksums.yaml +4 -4
  2. data/lib/airbrake/capistrano/tasks.rb +64 -0
  3. data/lib/airbrake/delayed_job/plugin.rb +48 -0
  4. data/lib/airbrake/rack/middleware.rb +45 -0
  5. data/lib/airbrake/rack/notice_builder.rb +80 -0
  6. data/lib/airbrake/rack/user.rb +51 -0
  7. data/lib/airbrake/rails/action_controller.rb +35 -0
  8. data/lib/airbrake/rails/active_job.rb +23 -0
  9. data/lib/airbrake/rails/active_record.rb +40 -0
  10. data/lib/airbrake/rails/railtie.rb +61 -0
  11. data/lib/airbrake/rake/task_ext.rb +61 -0
  12. data/lib/airbrake/rake/tasks.rb +93 -0
  13. data/lib/airbrake/resque/failure.rb +19 -0
  14. data/lib/airbrake/sidekiq/error_handler.rb +35 -0
  15. data/lib/airbrake/version.rb +4 -1
  16. data/lib/airbrake.rb +16 -185
  17. data/lib/generators/airbrake_generator.rb +25 -0
  18. data/lib/generators/airbrake_initializer.rb.erb +55 -0
  19. data/spec/airbrake_spec.rb +0 -0
  20. data/spec/apps/rack/dummy_app.rb +17 -0
  21. data/spec/apps/rails/dummy_app.rb +150 -0
  22. data/spec/apps/rails/dummy_task.rake +20 -0
  23. data/spec/apps/rails/logs/32.log +13358 -0
  24. data/spec/apps/rails/logs/40.log +6854 -0
  25. data/spec/apps/rails/logs/41.log +3170 -0
  26. data/spec/apps/rails/logs/42.log +23919 -0
  27. data/spec/apps/rails/logs/50.log +10976 -0
  28. data/spec/apps/sinatra/dummy_app.rb +12 -0
  29. data/spec/integration/rack/rack_spec.rb +17 -0
  30. data/spec/integration/rails/rails_spec.rb +135 -0
  31. data/spec/integration/rails/rake_spec.rb +160 -0
  32. data/spec/integration/shared_examples/rack_examples.rb +106 -0
  33. data/spec/integration/sinatra/sinatra_spec.rb +15 -0
  34. data/spec/spec_helper.rb +127 -0
  35. data/spec/unit/rack/middleware_spec.rb +80 -0
  36. data/spec/unit/rack/notice_builder_spec.rb +35 -0
  37. data/spec/unit/rack/user_spec.rb +78 -0
  38. data/spec/unit/rake/tasks_spec.rb +40 -0
  39. data/spec/unit/sidekiq/error_handler_spec.rb +29 -0
  40. metadata +108 -323
  41. data/CHANGELOG +0 -1716
  42. data/Gemfile +0 -3
  43. data/Guardfile +0 -6
  44. data/INSTALL +0 -20
  45. data/LICENSE +0 -61
  46. data/README.md +0 -148
  47. data/README_FOR_HEROKU_ADDON.md +0 -102
  48. data/Rakefile +0 -179
  49. data/TESTED_AGAINST +0 -7
  50. data/airbrake.gemspec +0 -41
  51. data/bin/airbrake +0 -12
  52. data/features/metal.feature +0 -34
  53. data/features/rack.feature +0 -60
  54. data/features/rails.feature +0 -324
  55. data/features/rake.feature +0 -33
  56. data/features/sinatra.feature +0 -126
  57. data/features/step_definitions/file_steps.rb +0 -14
  58. data/features/step_definitions/rack_steps.rb +0 -27
  59. data/features/step_definitions/rails_application_steps.rb +0 -267
  60. data/features/step_definitions/rake_steps.rb +0 -22
  61. data/features/support/airbrake_shim.rb.template +0 -11
  62. data/features/support/aruba.rb +0 -5
  63. data/features/support/env.rb +0 -39
  64. data/features/support/matchers.rb +0 -35
  65. data/features/support/rails.rb +0 -156
  66. data/features/support/rake/Rakefile +0 -77
  67. data/features/user_informer.feature +0 -57
  68. data/generators/airbrake/airbrake_generator.rb +0 -94
  69. data/generators/airbrake/lib/insert_commands.rb +0 -34
  70. data/generators/airbrake/lib/rake_commands.rb +0 -24
  71. data/generators/airbrake/templates/airbrake_tasks.rake +0 -25
  72. data/generators/airbrake/templates/capistrano_hook.rb +0 -6
  73. data/generators/airbrake/templates/initializer.rb +0 -4
  74. data/install.rb +0 -1
  75. data/lib/airbrake/backtrace.rb +0 -103
  76. data/lib/airbrake/capistrano.rb +0 -103
  77. data/lib/airbrake/capistrano3.rb +0 -3
  78. data/lib/airbrake/cli/client.rb +0 -76
  79. data/lib/airbrake/cli/options.rb +0 -45
  80. data/lib/airbrake/cli/printer.rb +0 -33
  81. data/lib/airbrake/cli/project.rb +0 -17
  82. data/lib/airbrake/cli/project_factory.rb +0 -33
  83. data/lib/airbrake/cli/runner.rb +0 -49
  84. data/lib/airbrake/cli/validator.rb +0 -8
  85. data/lib/airbrake/configuration.rb +0 -366
  86. data/lib/airbrake/jobs/send_job.rb +0 -7
  87. data/lib/airbrake/notice.rb +0 -411
  88. data/lib/airbrake/rack.rb +0 -64
  89. data/lib/airbrake/rails/action_controller_catcher.rb +0 -32
  90. data/lib/airbrake/rails/controller_methods.rb +0 -146
  91. data/lib/airbrake/rails/error_lookup.rb +0 -35
  92. data/lib/airbrake/rails/middleware.rb +0 -63
  93. data/lib/airbrake/rails.rb +0 -45
  94. data/lib/airbrake/rails3_tasks.rb +0 -126
  95. data/lib/airbrake/railtie.rb +0 -46
  96. data/lib/airbrake/rake_handler.rb +0 -75
  97. data/lib/airbrake/response.rb +0 -29
  98. data/lib/airbrake/sender.rb +0 -213
  99. data/lib/airbrake/shared_tasks.rb +0 -59
  100. data/lib/airbrake/sidekiq.rb +0 -8
  101. data/lib/airbrake/sinatra.rb +0 -40
  102. data/lib/airbrake/tasks/airbrake.cap +0 -28
  103. data/lib/airbrake/tasks.rb +0 -81
  104. data/lib/airbrake/user_informer.rb +0 -36
  105. data/lib/airbrake/utils/params_cleaner.rb +0 -141
  106. data/lib/airbrake/utils/rack_filters.rb +0 -45
  107. data/lib/airbrake_tasks.rb +0 -62
  108. data/lib/rails/generators/airbrake/airbrake_generator.rb +0 -155
  109. data/lib/templates/rescue.erb +0 -91
  110. data/rails/init.rb +0 -1
  111. data/resources/README.md +0 -34
  112. data/resources/airbrake_2_4.xsd +0 -89
  113. data/resources/airbrake_3_0.json +0 -52
  114. data/resources/ca-bundle.crt +0 -3376
  115. data/script/integration_test.rb +0 -35
  116. data/test/airbrake_tasks_test.rb +0 -161
  117. data/test/backtrace_test.rb +0 -215
  118. data/test/capistrano_test.rb +0 -44
  119. data/test/configuration_test.rb +0 -303
  120. data/test/controller_methods_test.rb +0 -230
  121. data/test/helper.rb +0 -233
  122. data/test/integration/catcher_test.rb +0 -371
  123. data/test/integration.rb +0 -13
  124. data/test/logger_test.rb +0 -79
  125. data/test/notice_test.rb +0 -494
  126. data/test/notifier_test.rb +0 -288
  127. data/test/params_cleaner_test.rb +0 -204
  128. data/test/rack_test.rb +0 -62
  129. data/test/rails_initializer_test.rb +0 -36
  130. data/test/recursion_test.rb +0 -10
  131. data/test/response_test.rb +0 -18
  132. data/test/sender_test.rb +0 -335
  133. data/test/support/response_shim.xml +0 -4
  134. data/test/user_informer_test.rb +0 -29
@@ -1,288 +0,0 @@
1
- require File.expand_path '../helper', __FILE__
2
-
3
- class NotifierTest < Test::Unit::TestCase
4
-
5
- class OriginalException < Exception
6
- end
7
-
8
- class ContinuedException < Exception
9
- end
10
-
11
- include DefinesConstants
12
-
13
- def setup
14
- super
15
- reset_config
16
- end
17
-
18
- def assert_sent(notice, notice_args)
19
- assert_received(Airbrake::Notice, :new) {|expect| expect.with(has_entries(notice_args)) }
20
- assert_received(Airbrake.sender, :send_to_airbrake) {|expect| expect.with(notice) }
21
- end
22
-
23
- def set_public_env
24
- Airbrake.configure { |config| config.environment_name = 'production' }
25
- end
26
-
27
- def set_development_env
28
- Airbrake.configure { |config| config.environment_name = 'development' }
29
- end
30
-
31
- should "yield and save a configuration when configuring" do
32
- yielded_configuration = nil
33
- Airbrake.configure do |config|
34
- yielded_configuration = config
35
- end
36
-
37
- assert_kind_of Airbrake::Configuration, yielded_configuration
38
- assert_equal yielded_configuration, Airbrake.configuration
39
- end
40
-
41
- should "not remove existing config options when configuring twice" do
42
- first_config = nil
43
- Airbrake.configure do |config|
44
- first_config = config
45
- end
46
- Airbrake.configure do |config|
47
- assert_equal first_config, config
48
- end
49
- end
50
-
51
- should "configure the sender" do
52
- sender = stub_sender
53
- Airbrake::Sender.stubs(:new => sender)
54
- configuration = nil
55
-
56
- Airbrake.configure { |yielded_config| configuration = yielded_config }
57
-
58
- assert_received(Airbrake::Sender, :new) { |expect| expect.with(configuration) }
59
- assert_equal sender, Airbrake.sender
60
- end
61
-
62
- should "create and send a notice for an exception" do
63
- set_public_env
64
- exception = build_exception
65
- stub_sender!
66
- notice = stub_notice!
67
-
68
- Airbrake.notify(exception)
69
-
70
- assert_sent notice, :exception => exception
71
- end
72
-
73
- should "create and send a notice for a hash" do
74
- set_public_env
75
- notice = stub_notice!
76
- notice_args = { :error_message => 'uh oh' }
77
- stub_sender!
78
-
79
- Airbrake.notify(notice_args)
80
-
81
- assert_sent(notice, notice_args)
82
- end
83
-
84
- should "not pass the hash as an exception when sending a notice for it" do
85
- set_public_env
86
- stub_notice!
87
- notice_args = { :error_message => 'uh oh' }
88
- stub_sender!
89
-
90
- Airbrake.notify(notice_args)
91
-
92
- assert_received(Airbrake::Notice, :new) {|expect| expect.with(Not(has_key(:exception))) }
93
- end
94
-
95
- should "create and send a notice for an exception that responds to to_hash" do
96
- set_public_env
97
- exception = build_exception
98
- notice = stub_notice!
99
- notice_args = { :error_message => 'uh oh' }
100
- exception.stubs(:to_hash).returns(notice_args)
101
- stub_sender!
102
-
103
- Airbrake.notify(exception)
104
-
105
- assert_sent(notice, notice_args.merge(:exception => exception))
106
- end
107
-
108
- should "create and sent a notice for an exception and hash" do
109
- set_public_env
110
- exception = build_exception
111
- notice = stub_notice!
112
- notice_args = { :error_message => 'uh oh' }
113
- stub_sender!
114
-
115
- Airbrake.notify(exception, notice_args)
116
-
117
- assert_sent(notice, notice_args.merge(:exception => exception))
118
- end
119
-
120
- should "not create a notice in a development environment" do
121
- set_development_env
122
- sender = stub_sender!
123
-
124
- Airbrake.notify(build_exception)
125
- Airbrake.notify_or_ignore(build_exception)
126
-
127
- assert_received(sender, :send_to_airbrake) {|expect| expect.never }
128
- end
129
-
130
- should "not deliver an ignored exception when notifying implicitly" do
131
- set_public_env
132
- exception = build_exception
133
- sender = stub_sender!
134
- notice = stub_notice!
135
- notice.stubs(:ignore? => true)
136
-
137
- Airbrake.notify_or_ignore(exception)
138
-
139
- assert_received(sender, :send_to_airbrake) {|expect| expect.never }
140
- end
141
-
142
- should "deliver exception in async-mode" do
143
- Airbrake.configure do |config|
144
- config.environment_name = 'production'
145
- config.async do |notice|
146
- Airbrake.sender.send_to_airbrake(notice)
147
- end
148
- end
149
- exception = build_exception
150
- stub_sender!
151
- notice = stub_notice!
152
-
153
- Airbrake.notify(exception)
154
-
155
- assert_sent(notice, :exception => exception)
156
- end
157
-
158
- should "pass notice in async-mode" do
159
- received_notice = nil
160
- Airbrake.configure do |config|
161
- config.environment_name = 'production'
162
- config.async {|notice| received_notice = notice}
163
- end
164
- exception = build_exception
165
- stub_sender!
166
- notice = stub_notice!
167
-
168
- Airbrake.notify(exception)
169
-
170
- assert_equal received_notice, notice
171
- end
172
-
173
- should "deliver an ignored exception when notifying manually" do
174
- set_public_env
175
- exception = build_exception
176
- stub_sender!
177
- notice = stub_notice!
178
- notice.stubs(:ignore? => true)
179
-
180
- Airbrake.notify(exception)
181
-
182
- assert_sent(notice, :exception => exception)
183
- end
184
-
185
- should "pass config to created notices" do
186
- exception = build_exception
187
- config_opts = { 'one' => 'two', 'three' => 'four' }
188
- stub_notice!
189
- stub_sender!
190
- Airbrake.configuration = stub('config', :merge => config_opts, :configured? => true, :public? => true,:async? => nil)
191
-
192
- Airbrake.notify(exception)
193
-
194
- assert_received(Airbrake::Notice, :new) do |expect|
195
- expect.with(has_entries(config_opts))
196
- end
197
- end
198
-
199
- context "building notice JSON for an exception" do
200
- setup do
201
- @params = { :controller => "users", :action => "create" }
202
- @exception = build_exception
203
- @hash = Airbrake.build_lookup_hash_for(@exception, @params)
204
- end
205
-
206
- should "set action" do
207
- assert_equal @params[:action], @hash[:action]
208
- end
209
-
210
- should "set controller" do
211
- assert_equal @params[:controller], @hash[:component]
212
- end
213
-
214
- should "set line number" do
215
- assert @hash[:line_number] =~ /\d+/
216
- end
217
-
218
- should "set file" do
219
- assert_match(/test\/helper\.rb$/, @hash[:file])
220
- end
221
-
222
- should "set rails_env to production" do
223
- assert_equal 'production', @hash[:environment_name]
224
- end
225
-
226
- should "set error class" do
227
- assert_equal @exception.class.to_s, @hash[:error_class]
228
- end
229
-
230
- should "not set file or line number with no backtrace" do
231
- @exception.stubs(:backtrace).returns([])
232
-
233
- @hash = Airbrake.build_lookup_hash_for(@exception)
234
-
235
- assert_nil @hash[:line_number]
236
- assert_nil @hash[:file]
237
- end
238
-
239
- should "not set action or controller when not provided" do
240
- @hash = Airbrake.build_lookup_hash_for(@exception)
241
-
242
- assert_nil @hash[:action]
243
- assert_nil @hash[:controller]
244
- end
245
-
246
- context "when an exception that provides #original_exception is raised" do
247
- setup do
248
- @exception.stubs(:original_exception).returns(begin
249
- raise NotifierTest::OriginalException.new
250
- rescue Exception => e
251
- e
252
- end)
253
- end
254
-
255
- should "unwrap exceptions that provide #original_exception" do
256
- @hash = Airbrake.build_lookup_hash_for(@exception)
257
- assert_equal "NotifierTest::OriginalException", @hash[:error_class]
258
- end
259
-
260
- should "keep exception if #original_exception is nil" do
261
- @exception.stubs(:original_exception).returns(nil)
262
- @hash = Airbrake.build_lookup_hash_for(@exception)
263
- assert_equal "BacktracedException", @hash[:error_class]
264
- end
265
- end
266
-
267
- context "when an exception that provides #continued_exception is raised" do
268
- setup do
269
- @exception.stubs(:continued_exception).returns(begin
270
- raise NotifierTest::ContinuedException.new
271
- rescue Exception => e
272
- e
273
- end)
274
- end
275
-
276
- should "unwrap exceptions that provide #continued_exception" do
277
- @hash = Airbrake.build_lookup_hash_for(@exception)
278
- assert_equal "NotifierTest::ContinuedException", @hash[:error_class]
279
- end
280
-
281
- should "keep exception if #continued_exception is nil" do
282
- @exception.stubs(:continued_exception).returns(nil)
283
- @hash = Airbrake.build_lookup_hash_for(@exception)
284
- assert_equal "BacktracedException", @hash[:error_class]
285
- end
286
- end
287
- end
288
- end
@@ -1,204 +0,0 @@
1
- require File.expand_path '../helper', __FILE__
2
-
3
- class ParamsCleanerTest < Test::Unit::TestCase
4
-
5
- def clean(opts = {})
6
- cleaner = Airbrake::Utils::ParamsCleaner.new(:blacklist_filters => opts.delete(:params_filters) || [],
7
- :whitelist_filters => opts.delete(:whitelist_params_filters) || [],
8
- :to_clean => opts)
9
- cleaner.clean
10
- end
11
-
12
- def assert_serializes_hash(attribute)
13
- [File.open(__FILE__), Proc.new { puts "boo!" }, Module.new, nil].each do |object|
14
- hash = {
15
- :strange_object => object,
16
- :sub_hash => {
17
- :sub_object => object
18
- },
19
- :array => [object]
20
- }
21
- clean_params = clean(attribute => hash)
22
- hash = clean_params.send(attribute)
23
- object_serialized = object.nil? ? nil : object.to_s
24
- assert_equal object_serialized, hash[:strange_object], "objects should be serialized"
25
- assert_kind_of Hash, hash[:sub_hash], "subhashes should be kept"
26
- assert_equal object_serialized, hash[:sub_hash][:sub_object], "subhash members should be serialized"
27
- assert_kind_of Array, hash[:array], "arrays should be kept"
28
- assert_equal object_serialized, hash[:array].first, "array members should be serialized"
29
- end
30
- end
31
-
32
- def assert_filters_hash(attribute)
33
- filters = ['abc', :def]
34
- original = {
35
- 'abc' => '123',
36
- 'def' => '456',
37
- 'ghi' => '789',
38
- 'something_with_abc' => 'match the entire string',
39
- 'nested_hash' => { 'abc' => '100', 'ghi' => '789' },
40
- 'nested_array' => [{ 'abc' => '100' }, { 'ghi' => '789' }, 'xyz', [['asd', []]]]
41
- }
42
- filtered = {
43
- 'abc' => '[FILTERED]',
44
- 'def' => '[FILTERED]',
45
- 'ghi' => '789',
46
- 'something_with_abc' => 'match the entire string',
47
- 'nested_hash' => { 'abc' => '[FILTERED]', 'ghi' => '789' },
48
- 'nested_array' => [{ 'abc' => '[FILTERED]' }, { 'ghi' => '789' }, 'xyz', [['asd', []]]]
49
- }
50
-
51
- clean_params = clean(:params_filters => filters, attribute => original)
52
-
53
- assert_equal(filtered, clean_params.send(attribute))
54
- end
55
-
56
- should "should always remove a Rails application's secret token" do
57
- original = {
58
- "action_dispatch.secret_token" => "abc123xyz456",
59
- "abc" => "123"
60
- }
61
- clean_params = clean(:cgi_data => original)
62
- assert_equal({"abc" => "123"}, clean_params.cgi_data)
63
- end
64
-
65
- should "remove sensitive rack vars" do
66
- original = {
67
- "HTTP_X_CSRF_TOKEN" => "remove_me",
68
- "HTTP_COOKIE" => "remove_me",
69
- "HTTP_AUTHORIZATION" => "remove_me",
70
- "action_dispatch.request.unsigned_session_cookie" => "remove_me",
71
- "action_dispatch.cookies" => "remove_me",
72
- "action_dispatch.unsigned_session_cookie" => "remove_me",
73
- "action_dispatch.secret_key_base" => "remove_me",
74
- "action_dispatch.signed_cookie_salt" => "remove_me",
75
- "action_dispatch.encrypted_cookie_salt" => "remove_me",
76
- "action_dispatch.encrypted_signed_cookie_salt" => "remove_me",
77
- "action_dispatch.http_auth_salt" => "remove_me",
78
- "action_dispatch.secret_token" => "remove_me",
79
- "rack.request.cookie_hash" => "remove_me",
80
- "rack.request.cookie_string" => "remove_me",
81
- "rack.request.form_vars" => "remove_me",
82
- "rack.session" => "remove_me",
83
- "rack.session.options" => "remove_me",
84
- "rack.request.form_vars" => "story%5Btitle%5D=The+TODO+label",
85
- "abc" => "123"
86
- }
87
-
88
- clean_params = clean(:cgi_data => original)
89
- assert_equal({"abc" => "123"}, clean_params.cgi_data)
90
- end
91
-
92
- should "remove secrets from cgi_data" do
93
- original = {
94
- "aws_secret_key" => "secret",
95
- "service_password" => "password",
96
- "abc" => "123"
97
- }
98
-
99
- clean_params = clean(:cgi_data => original)
100
- assert_equal({"abc" => "123"}, clean_params.cgi_data)
101
- end
102
-
103
- should "handle frozen objects" do
104
- params = {
105
- 'filter_me' => ['a', 'b', 'c', 'd'].freeze
106
- }
107
-
108
- clean_params = clean({:params_filters => ['filter_me'], :parameters => params})
109
- assert_equal({'filter_me' => '[FILTERED]'}, clean_params.parameters)
110
- end
111
-
112
- should "filter parameters" do
113
- assert_filters_hash(:parameters)
114
- end
115
-
116
- should "whitelist filter parameters" do
117
- whitelist_filters = ["abc", :def]
118
- original = { 'abc' => "123", 'def' => "456", 'ghi' => "789", 'nested' => { 'abc' => '100' },
119
- 'something_with_abc' => 'match the entire string'}
120
- filtered = { 'abc' => "123",
121
- 'def' => "456",
122
- 'something_with_abc' => "[FILTERED]",
123
- 'ghi' => "[FILTERED]",
124
- 'nested' => "[FILTERED]" }
125
-
126
- clean_params = clean(:whitelist_params_filters => whitelist_filters,
127
- :parameters => original)
128
-
129
- assert_equal(filtered,
130
- clean_params.send(:parameters))
131
- end
132
-
133
- should "not filter everything if whitelist filters are empty" do
134
- whitelist_filters = []
135
- original = { 'abc' => '123' }
136
- clean_params = clean(:whitelist_params_filters => whitelist_filters,
137
- :parameters => original)
138
- assert_equal(original, clean_params.send(:parameters))
139
- end
140
-
141
- should "not care if filters are defined in nested array" do
142
- filters = [[/crazy/, :foo, ["bar", ["too"]]]]
143
- original = {
144
- 'this_is_crazy' => 'yes_it_is',
145
- 'I_am_good' => 'yes_you_are',
146
- 'foo' => '1212',
147
- 'too' => '2121',
148
- 'bar' => 'secret'
149
- }
150
- filtered = {
151
- 'this_is_crazy' => '[FILTERED]',
152
- 'I_am_good' => 'yes_you_are',
153
- 'foo' => '[FILTERED]',
154
- 'too' => '[FILTERED]',
155
- 'bar' => '[FILTERED]'
156
- }
157
- clean_params = clean(:params_filters => filters,
158
- :parameters => original)
159
- assert_equal(filtered, clean_params.send(:parameters))
160
- end
161
-
162
- should "filter key if it is defined as blacklist and whitelist" do
163
- original = { 'filter_me' => 'secret' }
164
- filtered = { 'filter_me' => '[FILTERED]' }
165
- clean_params = clean(:params_filters => [:filter_me],
166
- :params_whitelist_filters => [:filter_me],
167
- :parameters => original)
168
- assert_equal(filtered, clean_params.send(:parameters))
169
- end
170
-
171
- should "filter cgi data" do
172
- assert_filters_hash(:cgi_data)
173
- end
174
-
175
- should "filter session" do
176
- assert_filters_hash(:session_data)
177
- end
178
-
179
- should "convert unserializable objects to strings" do
180
- assert_serializes_hash(:parameters)
181
- assert_serializes_hash(:cgi_data)
182
- assert_serializes_hash(:session_data)
183
- end
184
-
185
- should "handle closed IO objects by converting them to strings" do
186
- params = {
187
- :files => [Tempfile.new('a').tap(&:close), IO.new(0).tap(&:close)]
188
- }
189
- clean_params = clean(:params_filters => ['files'], :parameters => params)
190
- assert_match(/\A#<(Temp)?[Ff]ile:0x.+>\z/, clean_params.parameters[:files][0])
191
- assert_match(/\A#<IO:0x.+>\z/, clean_params.parameters[:files][1])
192
- end
193
-
194
- should "not break on filtering multi-dimensional array as possible in action_dispatch.cookies" do
195
- original = { 'cgi_cookies_to_filter' => [['any_cookie_key', 'some_cookie_value'], ['secret', 'some_secret_value']] }
196
- clean_params = clean(:params_filters => [:secret],
197
- :params_whitelist_filters => [:secret],
198
- :parameters => original)
199
- assert_nothing_raised do
200
- clean_params.send(:parameters)
201
- end
202
- end
203
-
204
- end
data/test/rack_test.rb DELETED
@@ -1,62 +0,0 @@
1
- require File.expand_path '../helper', __FILE__
2
-
3
- class RackTest < Test::Unit::TestCase
4
-
5
- should "call the upstream app with the environment" do
6
- environment = { 'key' => 'value' }
7
- app = lambda { |env| ['response', {}, env] }
8
- stack = Airbrake::Rack.new(app)
9
-
10
- response = stack.call(environment)
11
-
12
- assert_equal ['response', {}, environment], response
13
- end
14
-
15
- should "deliver an exception raised while calling an upstream app" do
16
- Airbrake.stubs(:notify_or_ignore)
17
-
18
- exception = build_exception
19
- environment = { 'key' => 'value' }
20
- app = lambda do |env|
21
- raise exception
22
- end
23
-
24
- begin
25
- stack = Airbrake::Rack.new(app)
26
- stack.call(environment)
27
- rescue Exception => raised
28
- assert_equal exception, raised
29
- else
30
- flunk "Didn't raise an exception"
31
- end
32
-
33
- assert_received(Airbrake, :notify_or_ignore) do |expect|
34
- expect.with(exception, :rack_env => environment)
35
- end
36
- end
37
-
38
- %w(rack.exception sinatra.error).each do |ex|
39
-
40
- should "deliver an exception in #{ex}" do
41
- Airbrake.stubs(:notify_or_ignore)
42
- exception = build_exception
43
- environment = { 'key' => 'value' }
44
-
45
- response = [200, {}, ['okay']]
46
- app = lambda do |env|
47
- env[ex] = exception
48
- response
49
- end
50
- stack = Airbrake::Rack.new(app)
51
-
52
- actual_response = stack.call(environment)
53
-
54
- assert_equal response, actual_response
55
- assert_received(Airbrake, :notify_or_ignore) do |expect|
56
- expect.with(exception, :rack_env => environment)
57
- end
58
- end
59
-
60
- end
61
-
62
- end
@@ -1,36 +0,0 @@
1
- require File.expand_path '../helper', __FILE__
2
-
3
- require 'airbrake/rails'
4
-
5
- class RailsInitializerTest < Test::Unit::TestCase
6
- include DefinesConstants
7
-
8
- should "trigger use of Rails' logger if logger isn't set and Rails' logger exists" do
9
- rails = Module.new do
10
- def self.logger
11
- "RAILS LOGGER"
12
- end
13
- end
14
- define_constant("Rails", rails)
15
- Airbrake::Rails.initialize
16
- assert_equal "RAILS LOGGER", Airbrake.logger
17
- end
18
-
19
- should "trigger use of Rails' default logger if logger isn't set and Rails.logger doesn't exist" do
20
- define_constant("RAILS_DEFAULT_LOGGER", "RAILS DEFAULT LOGGER")
21
-
22
- Airbrake::Rails.initialize
23
- assert_equal "RAILS DEFAULT LOGGER", Airbrake.logger
24
- end
25
-
26
- should "allow overriding of the logger if already assigned" do
27
- define_constant("RAILS_DEFAULT_LOGGER", "RAILS DEFAULT LOGGER")
28
- Airbrake::Rails.initialize
29
-
30
- Airbrake.configure(true) do |config|
31
- config.logger = "OVERRIDDEN LOGGER"
32
- end
33
-
34
- assert_equal "OVERRIDDEN LOGGER", Airbrake.logger
35
- end
36
- end
@@ -1,10 +0,0 @@
1
- require File.expand_path '../helper', __FILE__
2
-
3
- class RecursionTest < Test::Unit::TestCase
4
- should "not allow infinite recursion" do
5
- hash = {:a => :a}
6
- hash[:hash] = hash
7
- notice = Airbrake::Notice.new(:parameters => hash)
8
- assert_equal "[possible infinite recursion halted]", notice.parameters[:hash]
9
- end
10
- end
@@ -1,18 +0,0 @@
1
- require File.expand_path '../helper', __FILE__
2
-
3
- class ResponseTest < Test::Unit::TestCase
4
- include DefinesConstants
5
-
6
- def response_body
7
- File.read File.expand_path('../support/response_shim.xml', __FILE__)
8
- end
9
-
10
- should "output a nicely formatted notice details" do
11
- output = Airbrake::Response.pretty_format(response_body)
12
-
13
- assert %r{ID: b6817316-9c45-ed26-45eb-780dbb86aadb}, "#{output}"
14
- assert %r{URL: http://airbrake.io/locate/b6817316-9c45-ed26-45eb-780dbb86aadb},
15
- "#{output}"
16
-
17
- end
18
- end