oauth2_api_client 3.4.0 → 3.4.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 +4 -4
 - data/CHANGELOG.md +4 -0
 - data/lib/oauth2_api_client/version.rb +1 -1
 - data/lib/oauth2_api_client.rb +3 -1
 - data/spec/oauth2_api_client_spec.rb +19 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 9361c724e72de0bbebb82eb1d3a70d62bf9c12488d665eea40ad25c090ab2ed0
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: a025968d9268a17b2fce69056575e48b3133f2621042f0e682d711d9dc4319ad
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: df519ea81f617078eb44f734de18e3543f1d44fcc0db2be030436401c3e504f11b8ed54b5eb5bf0a57af744bec36678bf52f9daa055b51b9ee48e27bc7d340db
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: a2eec2a4d5ad53fcda9386e890d5cf7067410a6e5452a5263206ae6bfe62c8b122c829bee140090e742ba5d151e8a2ce11bae5df0515ca6449605033b248f6d8
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/lib/oauth2_api_client.rb
    CHANGED
    
    | 
         @@ -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 
     | 
    
         
            -
             
     | 
| 
      
 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 
     | 
    
         
            -
               
     | 
| 
      
 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. 
     | 
| 
      
 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- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-04-25 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: activesupport
         
     |