raygun4ruby 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +48 -2
- data/lib/generators/raygun/install_generator.rb +3 -0
- data/lib/raygun/client.rb +53 -10
- data/lib/raygun/configuration.rb +10 -1
- data/lib/raygun/railtie.rb +1 -1
- data/lib/raygun/version.rb +1 -1
- data/raygun4ruby.gemspec +1 -0
- data/test/test_helper.rb +3 -1
- data/test/unit/client_test.rb +114 -29
- data/test/unit/configuration_test.rb +12 -0
- metadata +45 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7305d4c71a9380e59cb3dbb72a80ddc92eef5159
|
4
|
+
data.tar.gz: a7d9832f4983245ab09a21900b1c28f016f1a823
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7d0eeffeacca83f3e415369887d2e48ad8b142863a032f531b48a335acf1363776c138f482dd4efd7403059780c7d64d2ecf11e6cc62018872d7eb19c94d769
|
7
|
+
data.tar.gz: 1dfecde6867df5367dbc42dc0d07808df0234469bd8f321e53a36d729ddb1671d4431b12157e356f8cef96a4ec46c756e066540a40f932af09f3dba8ea20b8f0
|
data/README.md
CHANGED
@@ -37,10 +37,24 @@ NB: Raygun4Ruby currently requires Ruby >= 1.9
|
|
37
37
|
|
38
38
|
Note that the generator will create a file in `config/initializers` called "raygun.rb". If you need to do any further configuration or customization of Raygun, that's the place to do it!
|
39
39
|
|
40
|
+
By default the Rails integration is set to only report Exceptions in Production. To change this behaviour, set `config.enable_reporting` to something else in `config/initializers/raygun.rb`.
|
41
|
+
|
40
42
|
### Rails 2
|
41
43
|
|
42
44
|
Raygun4Ruby doesn't currently support Rails 2. If you'd like Rails 2 support, [drop us a line](http://raygun.io/forums).
|
43
45
|
|
46
|
+
### Sinatra
|
47
|
+
|
48
|
+
To enable exception tracking in Sinatra, just add configure Raygun and use the Rack middleware in your app:
|
49
|
+
|
50
|
+
```
|
51
|
+
require 'raygun4ruby'
|
52
|
+
Raygun.setup do |config|
|
53
|
+
config.api_key = "YOUR_API_KEY_HERE"
|
54
|
+
end
|
55
|
+
use Raygun::Middleware::RackExceptionInterceptor
|
56
|
+
```
|
57
|
+
|
44
58
|
###Standalone / Manual Exception Tracking
|
45
59
|
|
46
60
|
```ruby
|
@@ -51,6 +65,7 @@ require 'raygun4ruby'
|
|
51
65
|
Raygun.setup do |config|
|
52
66
|
config.api_key = "YOUR_RAYGUN_API_KEY"
|
53
67
|
config.filter_parameters = [ :password, :card_number, :cvv ] # don't forget to filter out sensitive parameters
|
68
|
+
config.enable_reporting = Rails.env.production? # true to send errors, false to not log
|
54
69
|
end
|
55
70
|
|
56
71
|
begin
|
@@ -61,7 +76,20 @@ end
|
|
61
76
|
|
62
77
|
```
|
63
78
|
|
64
|
-
|
79
|
+
You can also pass a Hash as the second parameter to `track_exception`. It should look like a [Rack Env Hash](http://rack.rubyforge.org/doc/SPEC.html)
|
80
|
+
|
81
|
+
### Customising Paremter Filtering
|
82
|
+
|
83
|
+
If you'd like to customize how parameters are filtered, you can pass a `Proc` to `filter_parameters`. Raygun4Ruby will yield the params hash to the block, and the return value will be sent along with your error.
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
Raygun.setup do |config|
|
87
|
+
config.api_key = "YOUR_RAYGUN_API_KEY"
|
88
|
+
config.filter_parameters do |params|
|
89
|
+
params.slice("only", "a", "few", "keys") # note that Hash#slice is in ActiveSupport
|
90
|
+
end
|
91
|
+
end
|
92
|
+
```
|
65
93
|
|
66
94
|
###Custom User Data
|
67
95
|
Custom data can be added to `track_exception` by passing a custom_data key in the second parameter hash.
|
@@ -87,7 +115,25 @@ Raygun.setup do |config|
|
|
87
115
|
end
|
88
116
|
```
|
89
117
|
|
90
|
-
You can also check which [exceptions are ignored by default](https://github.com/MindscapeHQ/raygun4ruby/blob/master/lib/raygun/configuration.rb#L26)
|
118
|
+
You can also check which [exceptions are ignored by default](https://github.com/MindscapeHQ/raygun4ruby/blob/master/lib/raygun/configuration.rb#L26) and unignore them if needed by doing the following:
|
119
|
+
|
120
|
+
```ruby
|
121
|
+
Raygun.setup do |config|
|
122
|
+
config.api_key = "MY_SWEET_API_KEY"
|
123
|
+
config.ignore.delete('ActionController::InvalidAuthenticityToken')
|
124
|
+
end
|
125
|
+
```
|
126
|
+
|
127
|
+
###Using a Proxy
|
128
|
+
|
129
|
+
You can pass proxy settings using the `proxy_settings` config option.
|
130
|
+
|
131
|
+
```ruby
|
132
|
+
Raygun.setup do |config|
|
133
|
+
config.api_key = "MY_SWEET_API_KEY"
|
134
|
+
config.proxy_settings = { host: "localhost", port: 8888 }
|
135
|
+
end
|
136
|
+
```
|
91
137
|
|
92
138
|
###Affected User Tracking
|
93
139
|
|
data/lib/raygun/client.rb
CHANGED
@@ -15,6 +15,8 @@ module Raygun
|
|
15
15
|
@headers = {
|
16
16
|
"X-ApiKey" => @api_key
|
17
17
|
}
|
18
|
+
|
19
|
+
enable_http_proxy if Raygun.configuration.proxy_settings[:address]
|
18
20
|
end
|
19
21
|
|
20
22
|
def require_api_key!
|
@@ -27,6 +29,13 @@ module Raygun
|
|
27
29
|
|
28
30
|
private
|
29
31
|
|
32
|
+
def enable_http_proxy
|
33
|
+
self.class.http_proxy(Raygun.configuration.proxy_settings[:address],
|
34
|
+
Raygun.configuration.proxy_settings[:port] || "80",
|
35
|
+
Raygun.configuration.proxy_settings[:username],
|
36
|
+
Raygun.configuration.proxy_settings[:password])
|
37
|
+
end
|
38
|
+
|
30
39
|
def client_details
|
31
40
|
{
|
32
41
|
name: Raygun::CLIENT_NAME,
|
@@ -38,7 +47,7 @@ module Raygun
|
|
38
47
|
def error_details(exception)
|
39
48
|
{
|
40
49
|
className: exception.class.to_s,
|
41
|
-
message: exception.message.encode('UTF-16', :undef => :replace, :invalid => :replace).encode('UTF-8'),
|
50
|
+
message: exception.message.to_s.encode('UTF-16', :undef => :replace, :invalid => :replace).encode('UTF-8'),
|
42
51
|
stackTrace: (exception.backtrace || []).map { |line| stack_trace_for(line) }
|
43
52
|
}
|
44
53
|
end
|
@@ -69,18 +78,25 @@ module Raygun
|
|
69
78
|
!!env["raygun.affected_user"]
|
70
79
|
end
|
71
80
|
|
81
|
+
def error_tags
|
82
|
+
[ENV["RACK_ENV"]]
|
83
|
+
end
|
84
|
+
|
85
|
+
def error_tags_present?
|
86
|
+
!!ENV["RACK_ENV"]
|
87
|
+
end
|
88
|
+
|
72
89
|
def request_information(env)
|
73
90
|
return {} if env.nil? || env.empty?
|
74
|
-
|
75
91
|
{
|
76
92
|
hostName: env["SERVER_NAME"],
|
77
93
|
url: env["PATH_INFO"],
|
78
94
|
httpMethod: env["REQUEST_METHOD"],
|
79
95
|
iPAddress: "#{ip_address_from(env)}",
|
80
96
|
queryString: Rack::Utils.parse_nested_query(env["QUERY_STRING"]),
|
81
|
-
form: form_data(env),
|
82
97
|
headers: headers(env),
|
83
|
-
|
98
|
+
form: form_params(env),
|
99
|
+
rawData: raw_data(env)
|
84
100
|
}
|
85
101
|
end
|
86
102
|
|
@@ -98,10 +114,24 @@ module Raygun
|
|
98
114
|
.sub(/ /, '-')
|
99
115
|
end
|
100
116
|
|
101
|
-
def
|
117
|
+
def form_params(env)
|
118
|
+
params = action_dispatch_params(env) || rack_params(env) || {}
|
119
|
+
filter_params(params, env["action_dispatch.parameter_filter"])
|
120
|
+
end
|
121
|
+
|
122
|
+
def action_dispatch_params(env)
|
123
|
+
env["action_dispatch.request.parameters"]
|
124
|
+
end
|
125
|
+
|
126
|
+
def rack_params(env)
|
127
|
+
request = Rack::Request.new(env)
|
128
|
+
request.params if env["rack.input"]
|
129
|
+
end
|
130
|
+
|
131
|
+
def raw_data(rack_env)
|
102
132
|
request = Rack::Request.new(rack_env)
|
103
|
-
|
104
|
-
|
133
|
+
unless request.form_data?
|
134
|
+
form_params(rack_env)
|
105
135
|
end
|
106
136
|
end
|
107
137
|
|
@@ -118,6 +148,7 @@ module Raygun
|
|
118
148
|
request: request_information(env)
|
119
149
|
}
|
120
150
|
|
151
|
+
error_details.merge!(tags: error_tags) if error_tags_present?
|
121
152
|
error_details.merge!(user: user_information(env)) if affected_user_present?(env)
|
122
153
|
|
123
154
|
{
|
@@ -131,13 +162,24 @@ module Raygun
|
|
131
162
|
end
|
132
163
|
|
133
164
|
def filter_params(params_hash, extra_filter_keys = nil)
|
134
|
-
|
165
|
+
if Raygun.configuration.filter_parameters.is_a?(Proc)
|
166
|
+
filter_params_with_proc(params_hash, Raygun.configuration.filter_parameters)
|
167
|
+
else
|
168
|
+
filter_keys = (Array(extra_filter_keys) + Raygun.configuration.filter_parameters).map(&:to_s)
|
169
|
+
filter_params_with_array(params_hash, filter_keys)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def filter_params_with_proc(params_hash, proc)
|
174
|
+
proc.call(params_hash)
|
175
|
+
end
|
135
176
|
|
177
|
+
def filter_params_with_array(params_hash, filter_keys)
|
136
178
|
# Recursive filtering of (nested) hashes
|
137
|
-
params_hash.inject({}) do |result, (k, v)|
|
179
|
+
(params_hash || {}).inject({}) do |result, (k, v)|
|
138
180
|
result[k] = case v
|
139
181
|
when Hash
|
140
|
-
|
182
|
+
filter_params_with_array(v, filter_keys)
|
141
183
|
else
|
142
184
|
filter_keys.include?(k) ? "[FILTERED]" : v
|
143
185
|
end
|
@@ -149,6 +191,7 @@ module Raygun
|
|
149
191
|
ENV_IP_ADDRESS_KEYS.each do |key_to_try|
|
150
192
|
return env_hash[key_to_try] unless env_hash[key_to_try].nil? || env_hash[key_to_try] == ""
|
151
193
|
end
|
194
|
+
"(Not Available)"
|
152
195
|
end
|
153
196
|
|
154
197
|
end
|
data/lib/raygun/configuration.rb
CHANGED
@@ -41,6 +41,9 @@ module Raygun
|
|
41
41
|
# Which parameter keys should we filter out by default?
|
42
42
|
config_option :filter_parameters
|
43
43
|
|
44
|
+
# Hash of proxy settings - :address, :port (defaults to 80), :username and :password (both default to nil)
|
45
|
+
config_option :proxy_settings
|
46
|
+
|
44
47
|
# Exception classes to ignore by default
|
45
48
|
IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
|
46
49
|
'ActionController::RoutingError',
|
@@ -64,7 +67,8 @@ module Raygun
|
|
64
67
|
enable_reporting: true,
|
65
68
|
affected_user_method: :current_user,
|
66
69
|
affected_user_identifier_methods: [ :email, :username, :id ],
|
67
|
-
filter_parameters: DEFAULT_FILTER_PARAMETERS
|
70
|
+
filter_parameters: DEFAULT_FILTER_PARAMETERS,
|
71
|
+
proxy_settings: {}
|
68
72
|
})
|
69
73
|
end
|
70
74
|
|
@@ -84,6 +88,11 @@ module Raygun
|
|
84
88
|
self.enable_reporting = !value
|
85
89
|
end
|
86
90
|
|
91
|
+
def filter_parameters(&filter_proc)
|
92
|
+
set_value(:filter_parameters, filter_proc) if block_given?
|
93
|
+
read_value(:filter_parameters)
|
94
|
+
end
|
95
|
+
|
87
96
|
private
|
88
97
|
|
89
98
|
def read_value(name)
|
data/lib/raygun/railtie.rb
CHANGED
@@ -15,7 +15,7 @@ class Raygun::Railtie < Rails::Railtie
|
|
15
15
|
|
16
16
|
# Affected User tracking
|
17
17
|
require "raygun/middleware/rails_insert_affected_user"
|
18
|
-
app.config.middleware.
|
18
|
+
app.config.middleware.insert_before Raygun::Middleware::RackExceptionInterceptor, "Raygun::Middleware::RailsInsertAffectedUser"
|
19
19
|
end
|
20
20
|
|
21
21
|
config.to_prepare do
|
data/lib/raygun/version.rb
CHANGED
data/raygun4ruby.gemspec
CHANGED
data/test/test_helper.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
ENV['RACK_ENV'] = 'test'
|
1
2
|
require_relative "../lib/raygun.rb"
|
2
3
|
require "minitest/autorun"
|
3
4
|
require "minitest/pride"
|
4
5
|
require "fakeweb"
|
5
6
|
require "timecop"
|
7
|
+
require "mocha/mini_test"
|
6
8
|
|
7
9
|
class NoApiKey < StandardError; end
|
8
10
|
|
@@ -44,4 +46,4 @@ class Raygun::UnitTest < MiniTest::Unit::TestCase
|
|
44
46
|
Raygun.configuration = Raygun::Configuration.new
|
45
47
|
end
|
46
48
|
|
47
|
-
end
|
49
|
+
end
|
data/test/unit/client_test.rb
CHANGED
@@ -5,6 +5,11 @@ require 'stringio'
|
|
5
5
|
class ClientTest < Raygun::UnitTest
|
6
6
|
|
7
7
|
class TestException < StandardError; end
|
8
|
+
class NilMessageError < StandardError
|
9
|
+
def message
|
10
|
+
nil
|
11
|
+
end
|
12
|
+
end
|
8
13
|
|
9
14
|
class FakeActionDispatcherIp
|
10
15
|
attr_reader :ip
|
@@ -55,6 +60,12 @@ class ClientTest < Raygun::UnitTest
|
|
55
60
|
assert_equal expected_hash, @client.send(:error_details, e)
|
56
61
|
end
|
57
62
|
|
63
|
+
def test_error_details_with_nil_message
|
64
|
+
e = NilMessageError.new
|
65
|
+
expected_message = ""
|
66
|
+
assert_equal expected_message, @client.send(:error_details, e)[:message]
|
67
|
+
end
|
68
|
+
|
58
69
|
def test_client_details
|
59
70
|
expected_hash = {
|
60
71
|
name: Raygun::CLIENT_NAME,
|
@@ -138,6 +149,7 @@ class ClientTest < Raygun::UnitTest
|
|
138
149
|
]
|
139
150
|
},
|
140
151
|
userCustomData: {},
|
152
|
+
tags: ["test"],
|
141
153
|
request: {}
|
142
154
|
}
|
143
155
|
}
|
@@ -176,9 +188,9 @@ class ClientTest < Raygun::UnitTest
|
|
176
188
|
httpMethod: "GET",
|
177
189
|
iPAddress: "127.0.0.1",
|
178
190
|
queryString: { "a" => "b", "c" => "4945438" },
|
179
|
-
form: nil,
|
180
191
|
headers: { "Version"=>"HTTP/1.1", "Host"=>"localhost:3000", "Connection"=>"keep-alive", "Cache-Control"=>"max-age=0", "Accept"=>"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "User-Agent"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.22 Safari/537.36", "Accept-Encoding"=>"gzip,deflate,sdch", "Accept-Language"=>"en-US,en;q=0.8", "Cookie"=>"cookieval" },
|
181
|
-
|
192
|
+
form: {},
|
193
|
+
rawData: {}
|
182
194
|
}
|
183
195
|
|
184
196
|
assert_equal expected_hash, @client.send(:request_information, sample_env_hash)
|
@@ -188,10 +200,10 @@ class ClientTest < Raygun::UnitTest
|
|
188
200
|
assert_equal({}, @client.send(:request_information, nil))
|
189
201
|
end
|
190
202
|
|
191
|
-
def
|
192
|
-
|
203
|
+
def test_non_form_parameters
|
204
|
+
put_body_env_hash = {
|
193
205
|
"SERVER_NAME"=>"localhost",
|
194
|
-
"REQUEST_METHOD"=>"
|
206
|
+
"REQUEST_METHOD"=>"PUT",
|
195
207
|
"REQUEST_PATH"=>"/",
|
196
208
|
"PATH_INFO"=>"/",
|
197
209
|
"QUERY_STRING"=>"",
|
@@ -210,44 +222,56 @@ class ClientTest < Raygun::UnitTest
|
|
210
222
|
"SERVER_PROTOCOL"=>"HTTP/1.1",
|
211
223
|
"SCRIPT_NAME"=>"",
|
212
224
|
"REMOTE_ADDR"=>"127.0.0.1",
|
213
|
-
"
|
225
|
+
"action_dispatch.request.parameters"=> { "a" => "b", "c" => "4945438", "password" => "swordfish" }
|
214
226
|
}
|
215
227
|
|
216
228
|
expected_form_hash = { "a" => "b", "c" => "4945438", "password" => "[FILTERED]" }
|
217
229
|
|
230
|
+
assert_equal expected_form_hash, @client.send(:request_information, put_body_env_hash)[:rawData]
|
231
|
+
end
|
232
|
+
|
233
|
+
def test_filtering_parameters
|
234
|
+
post_body_env_hash = sample_env_hash.merge(
|
235
|
+
"rack.input"=>StringIO.new("a=b&c=4945438&password=swordfish")
|
236
|
+
)
|
237
|
+
|
238
|
+
expected_form_hash = { "a" => "b", "c" => "4945438", "password" => "[FILTERED]" }
|
239
|
+
|
218
240
|
assert_equal expected_form_hash, @client.send(:request_information, post_body_env_hash)[:form]
|
219
241
|
end
|
220
242
|
|
221
243
|
def test_filtering_nested_params
|
222
|
-
post_body_env_hash =
|
223
|
-
"
|
224
|
-
|
225
|
-
"REQUEST_PATH"=>"/",
|
226
|
-
"PATH_INFO"=>"/",
|
227
|
-
"QUERY_STRING"=>"",
|
228
|
-
"REQUEST_URI"=>"/",
|
229
|
-
"HTTP_VERSION"=>"HTTP/1.1",
|
230
|
-
"HTTP_HOST"=>"localhost:3000",
|
231
|
-
"HTTP_CONNECTION"=>"keep-alive",
|
232
|
-
"HTTP_CACHE_CONTROL"=>"max-age=0",
|
233
|
-
"HTTP_ACCEPT"=>"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
234
|
-
"HTTP_USER_AGENT"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.22 Safari/537.36",
|
235
|
-
"HTTP_ACCEPT_ENCODING"=>"gzip,deflate,sdch",
|
236
|
-
"HTTP_ACCEPT_LANGUAGE"=>"en-US,en;q=0.8",
|
237
|
-
"HTTP_COOKIE"=>"cookieval",
|
238
|
-
"GATEWAY_INTERFACE"=>"CGI/1.2",
|
239
|
-
"SERVER_PORT"=>"3000",
|
240
|
-
"SERVER_PROTOCOL"=>"HTTP/1.1",
|
241
|
-
"SCRIPT_NAME"=>"",
|
242
|
-
"REMOTE_ADDR"=>"127.0.0.1",
|
243
|
-
"rack.input"=>StringIO.new("a=b&bank%5Bcredit_card%5D%5Bcard_number%5D=my_secret_bank_number&bank%5Bname%5D=something&c=123456&user%5Bpassword%5D=my_fancy_password")
|
244
|
-
}
|
244
|
+
post_body_env_hash = sample_env_hash.merge(
|
245
|
+
"rack.input" => StringIO.new("a=b&bank%5Bcredit_card%5D%5Bcard_number%5D=my_secret_bank_number&bank%5Bname%5D=something&c=123456&user%5Bpassword%5D=my_fancy_password")
|
246
|
+
)
|
245
247
|
|
246
248
|
expected_form_hash = { "a" => "b", "bank" => { "credit_card" => { "card_number" => "[FILTERED]" }, "name" => "something" }, "c" => "123456", "user" => { "password" => "[FILTERED]" } }
|
247
249
|
|
248
250
|
assert_equal expected_form_hash, @client.send(:request_information, post_body_env_hash)[:form]
|
249
251
|
end
|
250
252
|
|
253
|
+
def test_filter_parameters_using_proc
|
254
|
+
# filter any parameters that start with "nsa_only"
|
255
|
+
Raygun.configuration.filter_parameters do |hash|
|
256
|
+
hash.inject({}) do |sanitized_hash, pair|
|
257
|
+
k, v = pair
|
258
|
+
v = "[OUREYESONLY]" if k[0...8] == "nsa_only"
|
259
|
+
sanitized_hash[k] = v
|
260
|
+
sanitized_hash
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
post_body_env_hash = sample_env_hash.merge(
|
265
|
+
"rack.input" => StringIO.new("nsa_only_info=123&nsa_only_metadata=seekrit&something_normal=hello")
|
266
|
+
)
|
267
|
+
|
268
|
+
expected_form_hash = { "nsa_only_info" => "[OUREYESONLY]", "nsa_only_metadata" => "[OUREYESONLY]", "something_normal" => "hello" }
|
269
|
+
|
270
|
+
assert_equal expected_form_hash, @client.send(:request_information, post_body_env_hash)[:form]
|
271
|
+
ensure
|
272
|
+
Raygun.configuration.filter_parameters = nil
|
273
|
+
end
|
274
|
+
|
251
275
|
def test_ip_address_from_action_dispatch
|
252
276
|
sample_env_hash = {
|
253
277
|
"HTTP_VERSION"=>"HTTP/1.1",
|
@@ -270,6 +294,7 @@ class ClientTest < Raygun::UnitTest
|
|
270
294
|
assert_equal "123.456.789.012", @client.send(:ip_address_from, sample_env_hash)
|
271
295
|
assert_equal "123.456.789.012", @client.send(:request_information, sample_env_hash)[:iPAddress]
|
272
296
|
end
|
297
|
+
|
273
298
|
def test_ip_address_from_old_action_dispatch
|
274
299
|
old_action_dispatch_ip = FakeActionDispatcherIp.new("123.456.789.012")
|
275
300
|
sample_env_hash = {
|
@@ -317,4 +342,64 @@ class ClientTest < Raygun::UnitTest
|
|
317
342
|
assert_equal "123.456.789.012", @client.send(:request_information, sample_env_hash)[:iPAddress]
|
318
343
|
end
|
319
344
|
|
345
|
+
def test_ip_address_returns_not_available_if_not_set
|
346
|
+
sample_env_hash = {
|
347
|
+
"HTTP_VERSION"=>"HTTP/1.1",
|
348
|
+
"HTTP_HOST"=>"localhost:3000",
|
349
|
+
"HTTP_CONNECTION"=>"keep-alive",
|
350
|
+
"HTTP_CACHE_CONTROL"=>"max-age=0",
|
351
|
+
"HTTP_ACCEPT"=>"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
352
|
+
"HTTP_USER_AGENT"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.22 Safari/537.36",
|
353
|
+
"HTTP_ACCEPT_ENCODING"=>"gzip,deflate,sdch",
|
354
|
+
"HTTP_ACCEPT_LANGUAGE"=>"en-US,en;q=0.8",
|
355
|
+
"HTTP_COOKIE"=>"cookieval",
|
356
|
+
"GATEWAY_INTERFACE"=>"CGI/1.2",
|
357
|
+
"SERVER_PORT"=>"3000",
|
358
|
+
"SERVER_PROTOCOL"=>"HTTP/1.1",
|
359
|
+
"SCRIPT_NAME"=>""
|
360
|
+
}
|
361
|
+
|
362
|
+
assert_equal "(Not Available)", @client.send(:ip_address_from, sample_env_hash)
|
363
|
+
end
|
364
|
+
|
365
|
+
def test_setting_up_http_proxy
|
366
|
+
begin
|
367
|
+
Raygun.configuration.proxy_settings[:address] = "http://proxy.com"
|
368
|
+
Raygun::Client.expects(:http_proxy).with("http://proxy.com", "80", nil, nil)
|
369
|
+
|
370
|
+
Raygun.track_exceptions do
|
371
|
+
raise TestException.new
|
372
|
+
end
|
373
|
+
ensure
|
374
|
+
Raygun.configuration.proxy_settings = {}
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
private
|
379
|
+
|
380
|
+
def sample_env_hash
|
381
|
+
{
|
382
|
+
"SERVER_NAME"=>"localhost",
|
383
|
+
"REQUEST_METHOD"=>"POST",
|
384
|
+
"REQUEST_PATH"=>"/",
|
385
|
+
"PATH_INFO"=>"/",
|
386
|
+
"QUERY_STRING"=>"",
|
387
|
+
"REQUEST_URI"=>"/",
|
388
|
+
"HTTP_VERSION"=>"HTTP/1.1",
|
389
|
+
"HTTP_HOST"=>"localhost:3000",
|
390
|
+
"HTTP_CONNECTION"=>"keep-alive",
|
391
|
+
"HTTP_CACHE_CONTROL"=>"max-age=0",
|
392
|
+
"HTTP_ACCEPT"=>"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
393
|
+
"HTTP_USER_AGENT"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.22 Safari/537.36",
|
394
|
+
"HTTP_ACCEPT_ENCODING"=>"gzip,deflate,sdch",
|
395
|
+
"HTTP_ACCEPT_LANGUAGE"=>"en-US,en;q=0.8",
|
396
|
+
"HTTP_COOKIE"=>"cookieval",
|
397
|
+
"GATEWAY_INTERFACE"=>"CGI/1.2",
|
398
|
+
"SERVER_PORT"=>"3000",
|
399
|
+
"SERVER_PROTOCOL"=>"HTTP/1.1",
|
400
|
+
"SCRIPT_NAME"=>"",
|
401
|
+
"REMOTE_ADDR"=>"127.0.0.1"
|
402
|
+
}
|
403
|
+
end
|
404
|
+
|
320
405
|
end
|
@@ -60,4 +60,16 @@ class ConfigurationTest < Raygun::UnitTest
|
|
60
60
|
assert_equal({ sally: "stegosaurus" }, Raygun.configuration.custom_data)
|
61
61
|
end
|
62
62
|
|
63
|
+
def test_setting_filter_paramters_to_proc
|
64
|
+
Raygun.setup do |config|
|
65
|
+
config.filter_parameters do |hash|
|
66
|
+
# Don't need to do anything :)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
assert Raygun.configuration.filter_parameters.is_a?(Proc)
|
71
|
+
ensure
|
72
|
+
Raygun.configuration.filter_parameters = nil
|
73
|
+
end
|
74
|
+
|
63
75
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: raygun4ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mindscape
|
@@ -9,168 +9,182 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-01-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - ~>
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0.11'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - ~>
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0.11'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: json
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rack
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: bundler
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '1.1'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '1.1'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: rake
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- -
|
81
|
+
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: fakeweb
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- - ~>
|
88
|
+
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '1.3'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- - ~>
|
95
|
+
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '1.3'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: timecop
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- -
|
102
|
+
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
type: :development
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- -
|
109
|
+
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: minitest
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
|
-
- - ~>
|
116
|
+
- - "~>"
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: '4.2'
|
119
119
|
type: :development
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- - ~>
|
123
|
+
- - "~>"
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '4.2'
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: redis-namespace
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
|
-
- -
|
130
|
+
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
132
|
version: 1.3.1
|
133
133
|
type: :development
|
134
134
|
prerelease: false
|
135
135
|
version_requirements: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
|
-
- -
|
137
|
+
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: 1.3.1
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
141
|
name: resque
|
142
142
|
requirement: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
|
-
- -
|
144
|
+
- - ">="
|
145
145
|
- !ruby/object:Gem::Version
|
146
146
|
version: '0'
|
147
147
|
type: :development
|
148
148
|
prerelease: false
|
149
149
|
version_requirements: !ruby/object:Gem::Requirement
|
150
150
|
requirements:
|
151
|
-
- -
|
151
|
+
- - ">="
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: '0'
|
154
154
|
- !ruby/object:Gem::Dependency
|
155
155
|
name: sidekiq
|
156
156
|
requirement: !ruby/object:Gem::Requirement
|
157
157
|
requirements:
|
158
|
-
- -
|
158
|
+
- - ">="
|
159
159
|
- !ruby/object:Gem::Version
|
160
160
|
version: '3'
|
161
|
-
- - <
|
161
|
+
- - "<"
|
162
162
|
- !ruby/object:Gem::Version
|
163
163
|
version: 3.2.2
|
164
164
|
type: :development
|
165
165
|
prerelease: false
|
166
166
|
version_requirements: !ruby/object:Gem::Requirement
|
167
167
|
requirements:
|
168
|
-
- -
|
168
|
+
- - ">="
|
169
169
|
- !ruby/object:Gem::Version
|
170
170
|
version: '3'
|
171
|
-
- - <
|
171
|
+
- - "<"
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: 3.2.2
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: mocha
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
type: :development
|
182
|
+
prerelease: false
|
183
|
+
version_requirements: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
174
188
|
description: Ruby Adapter for Raygun.io
|
175
189
|
email:
|
176
190
|
- hello@raygun.io
|
@@ -178,8 +192,8 @@ executables: []
|
|
178
192
|
extensions: []
|
179
193
|
extra_rdoc_files: []
|
180
194
|
files:
|
181
|
-
- .gitignore
|
182
|
-
- .travis.yml
|
195
|
+
- ".gitignore"
|
196
|
+
- ".travis.yml"
|
183
197
|
- Gemfile
|
184
198
|
- LICENSE.txt
|
185
199
|
- README.md
|
@@ -215,17 +229,17 @@ require_paths:
|
|
215
229
|
- lib
|
216
230
|
required_ruby_version: !ruby/object:Gem::Requirement
|
217
231
|
requirements:
|
218
|
-
- -
|
232
|
+
- - ">="
|
219
233
|
- !ruby/object:Gem::Version
|
220
234
|
version: '0'
|
221
235
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
222
236
|
requirements:
|
223
|
-
- -
|
237
|
+
- - ">="
|
224
238
|
- !ruby/object:Gem::Version
|
225
239
|
version: '0'
|
226
240
|
requirements: []
|
227
241
|
rubyforge_project:
|
228
|
-
rubygems_version: 2.
|
242
|
+
rubygems_version: 2.2.2
|
229
243
|
signing_key:
|
230
244
|
specification_version: 4
|
231
245
|
summary: This gem provides support for Ruby and Ruby on Rails for the Raygun.io error
|