airbrake-ruby 5.1.0 → 5.1.1

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: 249098c5348f018ea17258df9ff7bbc4bde71c8e3f0a75c8e6fc00c5f30446b7
4
- data.tar.gz: 1936144cbf286ab6e43fbd8874d4093357ee4f7c2a7c43f0d7e507290e081d53
3
+ metadata.gz: a9438fdfe9308d48989fc04e1f9873c4cab46f7c22487ae1bd3d22e917d73f60
4
+ data.tar.gz: '08e6b8f6af0fd1ff980e642d9ce540c6c407844d34249bb921b9a15cd5f74ad7'
5
5
  SHA512:
6
- metadata.gz: 16fadd2ad3df2deb38208b463fe0df57790e07a47db70d48a01094efc58f5937429042208be4fb2413a91d28ea7e71ab046a898079d9b74060f226de80cdcbc2
7
- data.tar.gz: 371aea04d52fef881b2b74c9781f0788b536711e1cfeecfd328ee6778f629e7f19eab793a557f42f6fa1603709ae7e20b1ec1abba527f26149acb3581a633f6c
6
+ metadata.gz: e6e892017febffa214ab8ea921fa8c09b1a27e6c2b0874d669e0dd64004b21fa27bd13ea65b750505e9c702c7248314e8d77ca6b57cb1ec4332c9157712d866d
7
+ data.tar.gz: c1ebc53b428eca54eb4c85e4fc094819c9c2972308b97069c6234502159d57c2b5977203fb8a60dd3865e7f8dca2f0430dd0f1500ef2df89f8f059a881433740
@@ -126,6 +126,8 @@ module Airbrake
126
126
 
127
127
  # @return [String] the host such as which should be used for fetching remote
128
128
  # configuration options (example: "https://bucket-name.s3.amazonaws.com")
129
+ # @api private
130
+ # @since 5.0.0
129
131
  attr_accessor :remote_config_host
130
132
 
131
133
  class << self
@@ -151,7 +153,7 @@ module Airbrake
151
153
  self.project_key = user_config[:project_key]
152
154
  self.error_host = 'https://api.airbrake.io'
153
155
  self.apm_host = 'https://api.airbrake.io'
154
- self.remote_config_host = 'https://v1-production-notifier-configs.s3.amazonaws.com'
156
+ self.remote_config_host = 'https://notifier-configs.airbrake.io'
155
157
 
156
158
  self.ignore_environments = []
157
159
 
@@ -22,6 +22,9 @@ module Airbrake
22
22
  language: "#{RUBY_ENGINE}/#{RUBY_VERSION}".freeze,
23
23
  ).freeze
24
24
 
25
+ # @return [String]
26
+ HTTP_OK = '200'.freeze
27
+
25
28
  # Polls remote config of the given project.
26
29
  #
27
30
  # @param [Integer] project_id
@@ -71,22 +74,20 @@ module Airbrake
71
74
  def fetch_config
72
75
  response = nil
73
76
  begin
74
- response = Net::HTTP.get(build_config_uri)
77
+ response = Net::HTTP.get_response(build_config_uri)
75
78
  rescue StandardError => ex
76
79
  logger.error(ex)
77
80
  return {}
78
81
  end
79
82
 
80
- # AWS S3 API returns XML when request is not valid. In this case we just
81
- # print the returned body and exit the method.
82
- if response.start_with?('<?xml ')
83
- logger.error(response)
83
+ unless response.code == HTTP_OK
84
+ logger.error(response.body)
84
85
  return {}
85
86
  end
86
87
 
87
88
  json = nil
88
89
  begin
89
- json = JSON.parse(response)
90
+ json = JSON.parse(response.body)
90
91
  rescue JSON::ParserError => ex
91
92
  logger.error(ex)
92
93
  return {}
@@ -3,7 +3,7 @@
3
3
  module Airbrake
4
4
  # @return [String] the library version
5
5
  # @api public
6
- AIRBRAKE_RUBY_VERSION = '5.1.0'.freeze
6
+ AIRBRAKE_RUBY_VERSION = '5.1.1'.freeze
7
7
 
8
8
  # @return [Hash{Symbol=>String}] the information about the notifier library
9
9
  # @since 5.0.0
@@ -28,7 +28,7 @@ RSpec.describe Airbrake::Config do
28
28
  its(:error_notifications) { is_expected.to eq(true) }
29
29
 
30
30
  its(:remote_config_host) do
31
- is_expected.to eq('https://v1-production-notifier-configs.s3.amazonaws.com')
31
+ is_expected.to eq('https://notifier-configs.airbrake.io')
32
32
  end
33
33
 
34
34
  describe "#new" do
@@ -83,7 +83,7 @@ RSpec.describe Airbrake::RemoteSettings do
83
83
 
84
84
  context "when an error is raised while making a HTTP request" do
85
85
  before do
86
- allow(Net::HTTP).to receive(:get).and_raise(StandardError)
86
+ allow(Net::HTTP).to receive(:get_response).and_raise(StandardError)
87
87
  end
88
88
 
89
89
  it "doesn't fetch remote settings" do
@@ -117,10 +117,10 @@ RSpec.describe Airbrake::RemoteSettings do
117
117
  end
118
118
  end
119
119
 
120
- context "when API returns an XML response" do
120
+ context "when API returns a non-200 response" do
121
121
  let!(:stub) do
122
122
  stub_request(:get, Regexp.new(endpoint))
123
- .to_return(status: 200, body: '<?xml ...')
123
+ .to_return(status: 201, body: body.to_json)
124
124
  end
125
125
 
126
126
  it "doesn't update settings data" do
@@ -134,6 +134,29 @@ RSpec.describe Airbrake::RemoteSettings do
134
134
  expect(stub).to have_been_requested.once
135
135
  expect(settings.interval).to eq(600)
136
136
  end
137
+
138
+ it "logs error" do
139
+ expect(Airbrake::Loggable.instance).to receive(:error).with(body.to_json)
140
+
141
+ remote_settings = described_class.poll(project_id, host) {}
142
+ sleep(0.1)
143
+ remote_settings.stop_polling
144
+ end
145
+ end
146
+
147
+ context "when API returns a 200 response" do
148
+ let!(:stub) do
149
+ stub_request(:get, Regexp.new(endpoint))
150
+ .to_return(status: 200, body: body.to_json)
151
+ end
152
+
153
+ it "doesn't log errors" do
154
+ expect(Airbrake::Loggable.instance).not_to receive(:error)
155
+
156
+ remote_settings = described_class.poll(project_id, host) {}
157
+ sleep(0.1)
158
+ remote_settings.stop_polling
159
+ end
137
160
  end
138
161
 
139
162
  context "when a config route is specified in the returned data" do
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.1.0
4
+ version: 5.1.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: 2020-10-20 00:00:00.000000000 Z
11
+ date: 2020-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbtree3