rdstation-ruby-client 2.8.0 → 2.8.1

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: f9c55a165bdad7cd10471e913f2f531d429e4200c7180b291d55695e5370c585
4
- data.tar.gz: f88b126bc80b46bb3b7ffd5f5d424190251f8d93f3c787aeefb291c6ccdec544
3
+ metadata.gz: 440807bc5aafd6c15cb69ad4c7ef4b50fbdcbddfac9e3441f4fff97675cf4ee3
4
+ data.tar.gz: 3c419ba39fd059e44d072c19b595147099f90295e69a946c02da95e4e856103e
5
5
  SHA512:
6
- metadata.gz: bc9a5c11adcc7d45451b2b069b3634c08bb3a47a9af4b473f7d2a39222969764cf80cd746d4d74cf723a6ff46b03f3983a1257f72f5a6a6f88085d2bc7929785
7
- data.tar.gz: 17df3fc0b5abaa008377680764ef12a9fadb99a1d44a1fdbc3d76ea656776f07a51da3a348c00fc2982691b517f89d596d0d6e1fd1ca553bb5fd8e007c80ccac
6
+ metadata.gz: c75f8c5d1957ccef3016093d1768e64b27e71ff7e47274efc9c6ee013cecb88befebfd2c38a476d4aecf68f1d92709747b882542ce9ea5bcd16cbc0faa7eee85
7
+ data.tar.gz: b66553b5cf10bc85f3f6c40704ebc999b3bd61ece59ef431bd903803e60cd29f27f88ea55750f4b650016c0173c88001ead4f305cfc313338fc1849d4b1fc05b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.8.1
2
+
3
+ - Makes the retryable_request method also retry when a `RDStation::Error::Unauthorized` error happen
4
+
1
5
  ## 2.8.0
2
6
 
3
7
  ### Additions
@@ -7,7 +7,7 @@ module RDStation
7
7
  retries = 0
8
8
  begin
9
9
  yield authorization
10
- rescue ::RDStation::Error::ExpiredAccessToken => e
10
+ rescue ::RDStation::Error::ExpiredAccessToken, ::RDStation::Error::Unauthorized => e
11
11
  raise if !retry_possible?(authorization) || retries >= MAX_RETRIES
12
12
 
13
13
  retries += 1
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RDStation
4
- VERSION = '2.8.0'
4
+ VERSION = '2.8.1'
5
5
  end
@@ -56,7 +56,7 @@ RSpec.describe RDStation::RetryableRequest do
56
56
  and_return(new_credentials)
57
57
  end
58
58
 
59
- it 'refreshes the access_token and retries the request' do
59
+ it 'refreshes the access_token and retries the request when an ExpiredAccessToken error happen' do
60
60
  dummy_request = double("dummy_request")
61
61
  expect(dummy_request).to receive(:call).twice do |auth|
62
62
  expired_token = ::RDStation::Error::ExpiredAccessToken.new({'error_message' => 'x'})
@@ -74,6 +74,24 @@ RSpec.describe RDStation::RetryableRequest do
74
74
  end.not_to raise_error
75
75
  end
76
76
 
77
+ it 'refreshes the access_token and retries the request an Unauthorized error happen' do
78
+ dummy_request = double("dummy_request")
79
+ expect(dummy_request).to receive(:call).twice do |auth|
80
+ expired_token = ::RDStation::Error::Unauthorized.new({'error_message' => 'x'})
81
+ raise expired_token unless auth.access_token == new_access_token
82
+ end
83
+
84
+ expect(RDStation.configuration.access_token_refresh_callback)
85
+ .to receive(:call)
86
+ .once do |authorization|
87
+ expect(authorization.access_token).to eq new_access_token
88
+ end
89
+
90
+ expect do
91
+ subject.retryable_request(auth) { |yielded_auth| dummy_request.call(yielded_auth) }
92
+ end.not_to raise_error
93
+ end
94
+
77
95
  context 'and keeps raising retryable exception event after token refreshed' do
78
96
  it 'retries only once' do
79
97
  dummy_request = double("dummy_request")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdstation-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.0
4
+ version: 2.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paulo L F Casaretto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-18 00:00:00.000000000 Z
11
+ date: 2022-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler