oauth2_api_client 3.4.1 → 4.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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71751084c3e42bbdea2ccd3aae3e33716c4cea4d175ef709474de146c94dc7b8
|
4
|
+
data.tar.gz: 78c01d8725a63ad148f3ffa9570f9524a5496bd35c901212cefcbd02f18b4cb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48c6453955a713e5d144e7788c4c970dc3405801410525b9d561c2bc7ede63556dfaf737221f27b38edf37c0342c029c6c17f8c03b2d87ac334d1fa88d125d19
|
7
|
+
data.tar.gz: a62a3aa0814ed3dd096a37ea6ad7ebc7ef304445bbfd7e70fe282e85c060c77607923a08bdbc6f4074bae62e34be56a3731d7e3024f908a61c1f3d14cbff6aba
|
data/.github/workflows/test.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,32 @@
|
|
1
1
|
|
2
2
|
# CHANGELOG
|
3
3
|
|
4
|
+
# v4.0.0
|
5
|
+
|
6
|
+
* [BREAKING] Rescue `HTTP::Error` and raise `Oauth2ApiClient::Error` instead
|
7
|
+
|
8
|
+
In case you currently use:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
begin
|
12
|
+
client = Oauth2ApiClient.new(base_url: "...")
|
13
|
+
client.get("...")
|
14
|
+
rescue HTTP::Error # or HTTP::ConnectionError, etc.
|
15
|
+
# ...
|
16
|
+
end
|
17
|
+
```
|
18
|
+
|
19
|
+
please change it to:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
begin
|
23
|
+
client = Oauth2ApiClient.new(base_url: "...")
|
24
|
+
client.get("...")
|
25
|
+
rescue Oauth2ApiClient::Error
|
26
|
+
# ...
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
4
30
|
# v3.4.1
|
5
31
|
|
6
32
|
* fix duplicate auth calls if NullStore is used
|
@@ -15,7 +15,9 @@ class Oauth2ApiClient
|
|
15
15
|
# # ...
|
16
16
|
# end
|
17
17
|
|
18
|
-
class
|
18
|
+
class Error < StandardError; end
|
19
|
+
|
20
|
+
class ResponseError < Error
|
19
21
|
STATUSES = {
|
20
22
|
400 => "Bad Request",
|
21
23
|
401 => "Unauthorized",
|
@@ -93,7 +95,7 @@ class Oauth2ApiClient
|
|
93
95
|
message.gsub(/[^a-zA-Z0-9]/, "")
|
94
96
|
end
|
95
97
|
|
96
|
-
STATUSES.
|
98
|
+
STATUSES.each_value do |message|
|
97
99
|
const_set(const_name(message), Class.new(self))
|
98
100
|
end
|
99
101
|
end
|
data/lib/oauth2_api_client.rb
CHANGED
@@ -4,7 +4,7 @@ require "http"
|
|
4
4
|
require "active_support"
|
5
5
|
|
6
6
|
require "oauth2_api_client/version"
|
7
|
-
require "oauth2_api_client/
|
7
|
+
require "oauth2_api_client/errors"
|
8
8
|
require "oauth2_api_client/token_provider"
|
9
9
|
|
10
10
|
# The Oauth2ApiClient class is a client wrapped around the oauth2 and http-rb
|
@@ -91,7 +91,12 @@ class Oauth2ApiClient
|
|
91
91
|
opts = options.dup
|
92
92
|
opts[:params] = @params.merge(opts.fetch(:params, {})) if @params
|
93
93
|
|
94
|
-
response =
|
94
|
+
response =
|
95
|
+
begin
|
96
|
+
request.send(verb, "#{@base_url}#{path}", opts)
|
97
|
+
rescue HTTP::Error => e
|
98
|
+
raise Error, e.message
|
99
|
+
end
|
95
100
|
|
96
101
|
return response if response.status.success?
|
97
102
|
|
@@ -222,5 +222,13 @@ RSpec.describe Oauth2ApiClient do
|
|
222
222
|
|
223
223
|
expect { client.get("/path") }.to raise_error("Oauth2ApiClient::ResponseError::Unauthorized (401, http://localhost/api/path): unauthorized")
|
224
224
|
end
|
225
|
+
|
226
|
+
it "rescues HTTP::Error and raises a Oauth2ApiClient::Error instead" do
|
227
|
+
stub_request(:get, "http://localhost/api/path").to_raise(HTTP::Error.new("error"))
|
228
|
+
|
229
|
+
client = described_class.new(base_url: "http://localhost/api", token: "token")
|
230
|
+
|
231
|
+
expect { client.get("/path") }.to raise_error(Oauth2ApiClient::Error, "error")
|
232
|
+
end
|
225
233
|
end
|
226
234
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oauth2_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Vetter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -83,7 +83,7 @@ files:
|
|
83
83
|
- README.md
|
84
84
|
- Rakefile
|
85
85
|
- lib/oauth2_api_client.rb
|
86
|
-
- lib/oauth2_api_client/
|
86
|
+
- lib/oauth2_api_client/errors.rb
|
87
87
|
- lib/oauth2_api_client/token_provider.rb
|
88
88
|
- lib/oauth2_api_client/version.rb
|
89
89
|
- oauth2_api_client.gemspec
|