airbrake-ruby 2.5.0 → 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/airbrake-ruby/config.rb +1 -1
- data/lib/airbrake-ruby/filters/keys_filter.rb +1 -0
- data/lib/airbrake-ruby/sync_sender.rb +1 -0
- data/lib/airbrake-ruby/version.rb +1 -1
- data/spec/airbrake_spec.rb +1 -3
- data/spec/config_spec.rb +2 -2
- data/spec/notifier_spec.rb +1 -4
- data/spec/notifier_spec/options_spec.rb +23 -3
- data/spec/sync_sender_spec.rb +25 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c824b0d3f9372ab651d5e308df76080b2000f519
|
4
|
+
data.tar.gz: 2fc17c502f0bd474db41d00697a12bcdfeb0ac6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 191e18fafeddbfe6501f5acdf17cd5ec9fd759e41e78b2c3637625b87024561d2ab9599292c420607051b0043079f88490d8470f6caebe6e5e431640a5bdcf43
|
7
|
+
data.tar.gz: 1d16bdffa0fd2c37184b2e95be230b6816e3e9b5d0c2f01b09c9867d70e8d0551f73b9001de35eb0529a0104b7d59b1c86a6fa8236bc7d742bad2101e9844899
|
data/lib/airbrake-ruby/config.rb
CHANGED
@@ -118,7 +118,7 @@ module Airbrake
|
|
118
118
|
@endpoint ||=
|
119
119
|
begin
|
120
120
|
self.host = ('https://' << host) if host !~ %r{\Ahttps?://}
|
121
|
-
api = "api/v3/projects/#{project_id}/notices
|
121
|
+
api = "api/v3/projects/#{project_id}/notices"
|
122
122
|
URI.join(host, api)
|
123
123
|
end
|
124
124
|
end
|
@@ -131,6 +131,7 @@ module Airbrake
|
|
131
131
|
|
132
132
|
def filter_context_key(notice, key)
|
133
133
|
return unless notice[:context][key]
|
134
|
+
return if notice[:context][key] == FILTERED
|
134
135
|
return filter_hash(notice[:context][key]) unless should_filter?(key)
|
135
136
|
|
136
137
|
notice[:context][key] = FILTERED
|
@@ -66,6 +66,7 @@ module Airbrake
|
|
66
66
|
Net::HTTP::Post.new(uri.request_uri).tap do |req|
|
67
67
|
req.body = notice.to_json
|
68
68
|
|
69
|
+
req['Authorization'] = "Bearer #{@config.project_key}"
|
69
70
|
req['Content-Type'] = CONTENT_TYPE
|
70
71
|
req['User-Agent'] =
|
71
72
|
"#{Airbrake::Notice::NOTIFIER[:name]}/#{Airbrake::AIRBRAKE_RUBY_VERSION}" \
|
data/spec/airbrake_spec.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe Airbrake do
|
4
|
-
let(:endpoint)
|
5
|
-
'https://airbrake.io/api/v3/projects/113743/notices?key=fd04e13d806a90f96614ad8e529b2822'
|
6
|
-
end
|
4
|
+
let(:endpoint) { 'https://airbrake.io/api/v3/projects/113743/notices' }
|
7
5
|
|
8
6
|
let!(:notifier) do
|
9
7
|
described_class.configure do |c|
|
data/spec/config_spec.rb
CHANGED
@@ -241,7 +241,7 @@ RSpec.describe Airbrake::Config do
|
|
241
241
|
it "sets the endpoint with the slug" do
|
242
242
|
config.host = 'https://localhost/bingo/'
|
243
243
|
expect(config.endpoint.to_s).
|
244
|
-
to eq('https://localhost/bingo/api/v3/projects/1/notices
|
244
|
+
to eq('https://localhost/bingo/api/v3/projects/1/notices')
|
245
245
|
end
|
246
246
|
end
|
247
247
|
|
@@ -249,7 +249,7 @@ RSpec.describe Airbrake::Config do
|
|
249
249
|
it "sets the endpoint without the slug" do
|
250
250
|
config.host = 'https://localhost/bingo'
|
251
251
|
expect(config.endpoint.to_s).
|
252
|
-
to eq('https://localhost/api/v3/projects/1/notices
|
252
|
+
to eq('https://localhost/api/v3/projects/1/notices')
|
253
253
|
end
|
254
254
|
end
|
255
255
|
end
|
data/spec/notifier_spec.rb
CHANGED
@@ -8,10 +8,7 @@ RSpec.describe Airbrake::Notifier do
|
|
8
8
|
let(:project_id) { 105138 }
|
9
9
|
let(:project_key) { 'fd04e13d806a90f96614ad8e529b2822' }
|
10
10
|
let(:localhost) { 'http://localhost:8080' }
|
11
|
-
|
12
|
-
let(:endpoint) do
|
13
|
-
"https://airbrake.io/api/v3/projects/#{project_id}/notices?key=#{project_key}"
|
14
|
-
end
|
11
|
+
let(:endpoint) { "https://airbrake.io/api/v3/projects/#{project_id}/notices" }
|
15
12
|
|
16
13
|
let(:airbrake_params) do
|
17
14
|
{ project_id: project_id,
|
@@ -10,7 +10,7 @@ RSpec.describe Airbrake::Notifier do
|
|
10
10
|
let(:localhost) { 'http://localhost:8080' }
|
11
11
|
|
12
12
|
let(:endpoint) do
|
13
|
-
"https://airbrake.io/api/v3/projects/#{project_id}/notices
|
13
|
+
"https://airbrake.io/api/v3/projects/#{project_id}/notices"
|
14
14
|
end
|
15
15
|
|
16
16
|
let(:airbrake_params) do
|
@@ -39,7 +39,7 @@ RSpec.describe Airbrake::Notifier do
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
path = '/api/v3/projects/105138/notices
|
42
|
+
path = '/api/v3/projects/105138/notices'
|
43
43
|
|
44
44
|
context "given a full host" do
|
45
45
|
include_examples('endpoint', localhost = 'http://localhost:8080',
|
@@ -150,7 +150,7 @@ RSpec.describe Airbrake::Notifier do
|
|
150
150
|
|
151
151
|
# rubocop:disable Metrics/LineLength
|
152
152
|
expect(proxied_request.request_line).
|
153
|
-
to eq("POST http://localhost:#{proxy.config[:Port]}/api/v3/projects/105138/notices
|
153
|
+
to eq("POST http://localhost:#{proxy.config[:Port]}/api/v3/projects/105138/notices HTTP/1.1\r\n")
|
154
154
|
# rubocop:enable Metrics/LineLength
|
155
155
|
end
|
156
156
|
end
|
@@ -226,5 +226,25 @@ RSpec.describe Airbrake::Notifier do
|
|
226
226
|
include_examples 'sent notice', environment: :development
|
227
227
|
end
|
228
228
|
end
|
229
|
+
|
230
|
+
describe ":blacklist_keys" do
|
231
|
+
# Fixes https://github.com/airbrake/airbrake-ruby/issues/276
|
232
|
+
context "when specified along with :whitelist_keys" do
|
233
|
+
context "and when context payload is present" do
|
234
|
+
it "sends a notice" do
|
235
|
+
params = {
|
236
|
+
blacklist_keys: %i[password password_confirmation],
|
237
|
+
whitelist_keys: [:email, /user/i, 'account_id']
|
238
|
+
}
|
239
|
+
airbrake = described_class.new(airbrake_params.merge(params))
|
240
|
+
notice = airbrake.build_notice(ex)
|
241
|
+
notice[:context][:headers] = 'banana'
|
242
|
+
airbrake.notify_sync(notice)
|
243
|
+
|
244
|
+
expect(a_request(:post, endpoint)).to have_been_made
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|
229
249
|
end
|
230
250
|
end
|
data/spec/sync_sender_spec.rb
CHANGED
@@ -14,7 +14,15 @@ RSpec.describe Airbrake::SyncSender do
|
|
14
14
|
describe "#send" do
|
15
15
|
let(:promise) { Airbrake::Promise.new }
|
16
16
|
let(:stdout) { StringIO.new }
|
17
|
-
|
17
|
+
|
18
|
+
let(:config) do
|
19
|
+
Airbrake::Config.new(
|
20
|
+
project_id: 1,
|
21
|
+
project_key: 'banana',
|
22
|
+
logger: Logger.new(stdout)
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
18
26
|
let(:sender) { described_class.new(config) }
|
19
27
|
let(:notice) { Airbrake::Notice.new(config, AirbrakeTestError.new) }
|
20
28
|
|
@@ -27,6 +35,21 @@ RSpec.describe Airbrake::SyncSender do
|
|
27
35
|
expect(stdout.string).to match(/ERROR -- : .+ HTTP error: foo/)
|
28
36
|
end
|
29
37
|
|
38
|
+
it "passes project key as a token in the Authorization header" do
|
39
|
+
stub_request(:post, 'https://airbrake.io/api/v3/projects/1/notices').
|
40
|
+
to_return(body: '{}')
|
41
|
+
sender.send(notice, promise)
|
42
|
+
|
43
|
+
expect(
|
44
|
+
a_request(:post, 'https://airbrake.io/api/v3/projects/1/notices').with(
|
45
|
+
headers: {
|
46
|
+
'Authorization' => 'Bearer banana',
|
47
|
+
'Content-Type' => 'application/json'
|
48
|
+
}
|
49
|
+
)
|
50
|
+
).to have_been_made.once
|
51
|
+
end
|
52
|
+
|
30
53
|
context "when request body is nil" do
|
31
54
|
it "doesn't send a notice" do
|
32
55
|
expect_any_instance_of(Airbrake::Truncator).
|
@@ -50,7 +73,7 @@ RSpec.describe Airbrake::SyncSender do
|
|
50
73
|
end
|
51
74
|
|
52
75
|
context "when IP is rate limited" do
|
53
|
-
let(:endpoint) { %r{https://airbrake.io/api/v3/projects/notices} }
|
76
|
+
let(:endpoint) { %r{https://airbrake.io/api/v3/projects/1/notices} }
|
54
77
|
|
55
78
|
before do
|
56
79
|
stub_request(:post, endpoint).to_return(
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: airbrake-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Airbrake Technologies, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|