airbrake-ruby 5.0.0.rc.1-java → 5.0.0.rc.2-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a60c7ee3f35357ecbe72d0bdedb89a61b248101ac58d866166e5daa1e2f79eb
4
- data.tar.gz: 53a68e1f1bab4158d773593ad201dce948a0df60c0fd1b80a27451a96dc5596c
3
+ metadata.gz: c5c1a171bc9b89ed604ee96683863915d95d13823f004234902d95036576d101
4
+ data.tar.gz: bcc5563ebce4151570184bf9ed9248eb21684fbc4cf5911fbea687f47e4587e4
5
5
  SHA512:
6
- metadata.gz: 8d14d8843ea3d8c8923b654d5c1110fbefb83b40b63a15c930b5243de81f5ecd594d8e08be64a8242884793a6203f535d16088ebbbef3328d519f8cfd440d19e
7
- data.tar.gz: '08fdf62186815e85696acd66641f60bfeca556c2a3e30c0b7d7c49c3f02bdd208d795aceee9af65a4683773580682f8efa96a61434a716118a8a85346432d41f'
6
+ metadata.gz: eb1e4f7df43de3905ebe1fdded4066009043fc5f82a6f47aa7ea827ced8a0ba77432eb5413c8481456e5348a7ea673e1a880ecbf15aefb5a94d37eb0df7b91a2
7
+ data.tar.gz: 9967e9fa9ddef2d7a3be67aa0fc1cc44eca5a0c89945b0fa69bf4510733e827f164a70c7a12e36426d4a5b6f239fdd072a64de886aca42d93355ad18b5d96b66
@@ -4,19 +4,12 @@ module Airbrake
4
4
  #
5
5
  # @since v1.0.0
6
6
  class Notice
7
- # @return [Hash{Symbol=>String}] the information about the notifier library
8
- NOTIFIER = {
9
- name: 'airbrake-ruby'.freeze,
10
- version: Airbrake::AIRBRAKE_RUBY_VERSION,
11
- url: 'https://github.com/airbrake/airbrake-ruby'.freeze,
12
- }.freeze
13
-
14
7
  # @return [Hash{Symbol=>String,Hash}] the information to be displayed in the
15
8
  # Context tab in the dashboard
16
9
  CONTEXT = {
17
10
  os: RUBY_PLATFORM,
18
11
  language: "#{RUBY_ENGINE}/#{RUBY_VERSION}".freeze,
19
- notifier: NOTIFIER,
12
+ notifier: Airbrake::NOTIFIER_INFO,
20
13
  }.freeze
21
14
 
22
15
  # @return [Integer] the maxium size of the JSON payload in bytes
@@ -24,6 +24,15 @@ module Airbrake
24
24
  '../../config/config.json',
25
25
  ).freeze
26
26
 
27
+ # @return [Hash{Symbol=>String}] metadata to be attached to every GET
28
+ # request
29
+ QUERY_PARAMS = URI.encode_www_form(
30
+ notifier_name: Airbrake::NOTIFIER_INFO[:name],
31
+ notifier_version: Airbrake::NOTIFIER_INFO[:version],
32
+ os: RUBY_PLATFORM,
33
+ language: "#{RUBY_ENGINE}/#{RUBY_VERSION}".freeze,
34
+ ).freeze
35
+
27
36
  # Polls remote config of the given project.
28
37
  #
29
38
  # @param [Integer] project_id
@@ -84,7 +93,7 @@ module Airbrake
84
93
  def fetch_config
85
94
  response = nil
86
95
  begin
87
- response = Net::HTTP.get(URI(@data.config_route))
96
+ response = Net::HTTP.get(build_config_uri)
88
97
  rescue StandardError => ex
89
98
  logger.error(ex)
90
99
  return {}
@@ -108,6 +117,12 @@ module Airbrake
108
117
  json
109
118
  end
110
119
 
120
+ def build_config_uri
121
+ uri = URI(@data.config_route)
122
+ uri.query = QUERY_PARAMS
123
+ uri
124
+ end
125
+
111
126
  def load_config
112
127
  config_dir = File.dirname(CONFIG_DUMP_PATH)
113
128
  Dir.mkdir(config_dir) unless File.directory?(config_dir)
@@ -22,7 +22,7 @@ module Airbrake
22
22
 
23
23
  # @return [String] what URL to poll
24
24
  CONFIG_ROUTE_PATTERN =
25
- 'https://%<bucket>s.s3.amazonaws.com/' \
25
+ 'https://v1-%<bucket>s.s3.amazonaws.com/' \
26
26
  "#{API_VER}/config/%<project_id>s/config.json".freeze
27
27
 
28
28
  # @return [Hash{Symbol=>String}] the hash of all supported settings where
@@ -79,7 +79,7 @@ module Airbrake
79
79
  req['Authorization'] = "Bearer #{@config.project_key}"
80
80
  req['Content-Type'] = CONTENT_TYPE
81
81
  req['User-Agent'] =
82
- "#{Airbrake::Notice::NOTIFIER[:name]}/#{Airbrake::AIRBRAKE_RUBY_VERSION}" \
82
+ "#{Airbrake::NOTIFIER_INFO[:name]}/#{Airbrake::AIRBRAKE_RUBY_VERSION}" \
83
83
  " Ruby/#{RUBY_VERSION}"
84
84
 
85
85
  req
@@ -2,5 +2,15 @@
2
2
  # More information: http://semver.org/
3
3
  module Airbrake
4
4
  # @return [String] the library version
5
- AIRBRAKE_RUBY_VERSION = '5.0.0.rc.1'.freeze
5
+ # @api public
6
+ AIRBRAKE_RUBY_VERSION = '5.0.0.rc.2'.freeze
7
+
8
+ # @return [Hash{Symbol=>String}] the information about the notifier library
9
+ # @since ?.?.?
10
+ # @api public
11
+ NOTIFIER_INFO = {
12
+ name: 'airbrake-ruby'.freeze,
13
+ version: Airbrake::AIRBRAKE_RUBY_VERSION,
14
+ url: 'https://github.com/airbrake/airbrake-ruby'.freeze,
15
+ }.freeze
6
16
  end
@@ -79,7 +79,7 @@ RSpec.describe Airbrake::RemoteSettings::SettingsData do
79
79
 
80
80
  it "returns the default pathname" do
81
81
  expect(described_class.new(project_id, data).config_route).to eq(
82
- 'https://staging-notifier-configs.s3.amazonaws.com/' \
82
+ 'https://v1-staging-notifier-configs.s3.amazonaws.com/' \
83
83
  "2020-06-18/config/#{project_id}/config.json",
84
84
  )
85
85
  end
@@ -2,7 +2,7 @@ RSpec.describe Airbrake::RemoteSettings do
2
2
  let(:project_id) { 123 }
3
3
 
4
4
  let(:endpoint) do
5
- "https://staging-notifier-configs.s3.amazonaws.com/2020-06-18/config/" \
5
+ "https://v1-staging-notifier-configs.s3.amazonaws.com/2020-06-18/config/" \
6
6
  "#{project_id}/config.json"
7
7
  end
8
8
 
@@ -25,9 +25,12 @@ RSpec.describe Airbrake::RemoteSettings do
25
25
  let(:config_path) { described_class::CONFIG_DUMP_PATH }
26
26
  let(:config_dir) { File.dirname(config_path) }
27
27
 
28
- before do
29
- stub_request(:get, endpoint).to_return(status: 200, body: body.to_json)
28
+ let!(:stub) do
29
+ stub_request(:get, Regexp.new(endpoint))
30
+ .to_return(status: 200, body: body.to_json)
31
+ end
30
32
 
33
+ before do
31
34
  # Do not create config dumps on disk.
32
35
  allow(Dir).to receive(:mkdir).with(config_dir)
33
36
  allow(File).to receive(:write).with(config_path, anything)
@@ -52,7 +55,7 @@ RSpec.describe Airbrake::RemoteSettings do
52
55
  sleep(0.2)
53
56
  remote_settings.stop_polling
54
57
 
55
- expect(a_request(:get, endpoint)).to have_been_made.once
58
+ expect(stub).to have_been_requested.once
56
59
  end
57
60
 
58
61
  it "yields the config to the block twice" do
@@ -63,7 +66,7 @@ RSpec.describe Airbrake::RemoteSettings do
63
66
  sleep(0.2)
64
67
  remote_settings.stop_polling
65
68
 
66
- expect(a_request(:get, endpoint)).to have_been_made.once
69
+ expect(stub).to have_been_requested.once
67
70
  end
68
71
 
69
72
  context "when config loading fails" do
@@ -77,7 +80,7 @@ RSpec.describe Airbrake::RemoteSettings do
77
80
  sleep(0.2)
78
81
  remote_settings.stop_polling
79
82
 
80
- expect(a_request(:get, endpoint)).to have_been_made.once
83
+ expect(stub).to have_been_requested.once
81
84
  end
82
85
  end
83
86
  end
@@ -88,7 +91,18 @@ RSpec.describe Airbrake::RemoteSettings do
88
91
  sleep(0.1)
89
92
  remote_settings.stop_polling
90
93
 
91
- expect(a_request(:get, endpoint)).to have_been_made.at_least_once
94
+ expect(stub).to have_been_requested.at_least_once
95
+ end
96
+
97
+ it "sends params about the environment with the request" do
98
+ remote_settings = described_class.poll(project_id) {}
99
+ sleep(0.1)
100
+ remote_settings.stop_polling
101
+
102
+ stub_with_query_params = stub.with(
103
+ query: URI.decode_www_form(described_class::QUERY_PARAMS).to_h,
104
+ )
105
+ expect(stub_with_query_params).to have_been_requested.at_least_once
92
106
  end
93
107
 
94
108
  it "fetches remote settings" do
@@ -118,7 +132,7 @@ RSpec.describe Airbrake::RemoteSettings do
118
132
  sleep(0.1)
119
133
  remote_settings.stop_polling
120
134
 
121
- expect(a_request(:get, endpoint)).not_to have_been_made
135
+ expect(stub).not_to have_been_requested
122
136
  expect(settings.interval).to eq(600)
123
137
  end
124
138
  end
@@ -136,14 +150,15 @@ RSpec.describe Airbrake::RemoteSettings do
136
150
  sleep(0.1)
137
151
  remote_settings.stop_polling
138
152
 
139
- expect(a_request(:get, endpoint)).to have_been_made.once
153
+ expect(stub).to have_been_requested.once
140
154
  expect(settings.interval).to eq(600)
141
155
  end
142
156
  end
143
157
 
144
158
  context "when API returns an XML response" do
145
- before do
146
- stub_request(:get, endpoint).to_return(status: 200, body: '<?xml ...')
159
+ let!(:stub) do
160
+ stub_request(:get, Regexp.new(endpoint))
161
+ .to_return(status: 200, body: '<?xml ...')
147
162
  end
148
163
 
149
164
  it "doesn't update settings data" do
@@ -154,20 +169,23 @@ RSpec.describe Airbrake::RemoteSettings do
154
169
  sleep(0.1)
155
170
  remote_settings.stop_polling
156
171
 
157
- expect(a_request(:get, endpoint)).to have_been_made.once
172
+ expect(stub).to have_been_requested.once
158
173
  expect(settings.interval).to eq(600)
159
174
  end
160
175
  end
161
176
 
162
177
  context "when a config route is specified in the returned data" do
163
- let(:new_endpoint) { 'http://example.com' }
178
+ let(:new_endpoint) do
179
+ "http://example.com"
180
+ end
164
181
 
165
182
  let(:body) do
166
183
  { 'config_route' => new_endpoint, 'poll_sec' => 0.1 }
167
184
  end
168
185
 
169
- before do
170
- stub_request(:get, new_endpoint).to_return(status: 200, body: body.to_json)
186
+ let!(:new_stub) do
187
+ stub_request(:get, Regexp.new(new_endpoint))
188
+ .to_return(status: 200, body: body.to_json)
171
189
  end
172
190
 
173
191
  it "makes the next request to the specified config route" do
@@ -176,8 +194,8 @@ RSpec.describe Airbrake::RemoteSettings do
176
194
 
177
195
  remote_settings.stop_polling
178
196
 
179
- expect(a_request(:get, endpoint)).to have_been_made.once
180
- expect(a_request(:get, new_endpoint)).to have_been_made.once
197
+ expect(stub).to have_been_requested.once
198
+ expect(new_stub).to have_been_requested.once
181
199
  end
182
200
  end
183
201
  end
@@ -191,7 +209,7 @@ RSpec.describe Airbrake::RemoteSettings do
191
209
  sleep(0.2)
192
210
  remote_settings.stop_polling
193
211
 
194
- expect(a_request(:get, endpoint)).to have_been_made.once
212
+ expect(stub).to have_been_requested.once
195
213
  end
196
214
 
197
215
  context "when config dumping fails" do
@@ -205,7 +223,7 @@ RSpec.describe Airbrake::RemoteSettings do
205
223
  sleep(0.2)
206
224
  remote_settings.stop_polling
207
225
 
208
- expect(a_request(:get, endpoint)).to have_been_made.once
226
+ expect(stub).to have_been_requested.once
209
227
  end
210
228
  end
211
229
  end
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: 5.0.0.rc.1
4
+ version: 5.0.0.rc.2
5
5
  platform: java
6
6
  authors:
7
7
  - Airbrake Technologies, Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-13 00:00:00.000000000 Z
11
+ date: 2020-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbtree-jruby
@@ -152,7 +152,7 @@ homepage: https://airbrake.io
152
152
  licenses:
153
153
  - MIT
154
154
  metadata: {}
155
- post_install_message:
155
+ post_install_message:
156
156
  rdoc_options: []
157
157
  require_paths:
158
158
  - lib
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
168
  version: 1.3.1
169
169
  requirements: []
170
170
  rubygems_version: 3.1.2
171
- signing_key:
171
+ signing_key:
172
172
  specification_version: 4
173
173
  summary: Ruby notifier for https://airbrake.io
174
174
  test_files: