oauth2_api_client 3.4.0 → 3.4.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: bf92b6840d7440d512d8d0b7586acfe9751c38e6c99e4ab9f83cd9893cf9f13e
4
- data.tar.gz: 2e79b922b01af914adef3bacc2f415af62d26e3c8ad95b699daa63147842410a
3
+ metadata.gz: 9361c724e72de0bbebb82eb1d3a70d62bf9c12488d665eea40ad25c090ab2ed0
4
+ data.tar.gz: a025968d9268a17b2fce69056575e48b3133f2621042f0e682d711d9dc4319ad
5
5
  SHA512:
6
- metadata.gz: 0b782f564cde4d121868f274946df14af27ab13d7e1d501367451b571ada534696027c8ae51e8705315ad35a5a43b04d800d3209a6c70a6eaedf0a1a5f077ca1
7
- data.tar.gz: f2c3a469a6a189c6a0c986182ab2a53eb268a851882406d1d7de00cc32556f5a7ebb9e9dcc6732fd370ff9ce905a90a714ddea0649e33ada8eeea2dcb7a74be7
6
+ metadata.gz: df519ea81f617078eb44f734de18e3543f1d44fcc0db2be030436401c3e504f11b8ed54b5eb5bf0a57af744bec36678bf52f9daa055b51b9ee48e27bc7d340db
7
+ data.tar.gz: a2eec2a4d5ad53fcda9386e890d5cf7067410a6e5452a5263206ae6bfe62c8b122c829bee140090e742ba5d151e8a2ce11bae5df0515ca6449605033b248f6d8
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
 
2
2
  # CHANGELOG
3
3
 
4
+ # v3.4.1
5
+
6
+ * fix duplicate auth calls if NullStore is used
7
+
4
8
  # v3.4.0
5
9
 
6
10
  * Add PATCH method
@@ -1,3 +1,3 @@
1
1
  class Oauth2ApiClient
2
- VERSION = "3.4.0"
2
+ VERSION = "3.4.1"
3
3
  end
@@ -84,7 +84,9 @@ class Oauth2ApiClient
84
84
  with_retry do
85
85
  request = @request
86
86
  request = request.headers({}) # Prevent thread-safety issue of http-rb: https://github.com/httprb/http/issues/558
87
- request = request.auth("Bearer #{token}") if token
87
+
88
+ current_token = token
89
+ request = request.auth("Bearer #{current_token}") if current_token
88
90
 
89
91
  opts = options.dup
90
92
  opts[:params] = @params.merge(opts.fetch(:params, {})) if @params
@@ -17,7 +17,7 @@ class HttpTestRequest
17
17
  end
18
18
 
19
19
  RSpec.describe Oauth2ApiClient do
20
- before do
20
+ let!(:auth_request_stub) do
21
21
  token_response = {
22
22
  access_token: "access_token",
23
23
  token_type: "bearer",
@@ -173,6 +173,24 @@ RSpec.describe Oauth2ApiClient do
173
173
  expect(client.get("/path").to_s).to eq("ok")
174
174
  end
175
175
 
176
+ it "calls token provider once if NullStore is set as cache" do
177
+ stub_request(:get, "http://localhost/api/path")
178
+ .to_return(status: 200, body: "ok")
179
+
180
+ client = described_class.new(
181
+ base_url: "http://localhost/api",
182
+ token: described_class::TokenProvider.new(
183
+ client_id: "client_id",
184
+ client_secret: "client_secret",
185
+ token_url: "http://localhost/oauth2/token",
186
+ cache: ActiveSupport::Cache::NullStore.new
187
+ )
188
+ )
189
+
190
+ expect(client.get("/path").to_s).to eq("ok")
191
+ expect(auth_request_stub).to have_been_requested.once
192
+ end
193
+
176
194
  it "retries the request when an http unauthorized status is returned" do
177
195
  stub_request(:get, "http://localhost/api/path")
178
196
  .to_return({ status: 401, body: "unauthorized" }, { status: 200, body: "ok" })
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: 3.4.0
4
+ version: 3.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Vetter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-22 00:00:00.000000000 Z
11
+ date: 2023-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport