lhs 25.2.0 → 26.1.0

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: 22ba3545c4f37d2becb37fbe7efb328a942af240d6a4d03e64fea4890e766969
4
- data.tar.gz: 9cd64f9e1222e7f0f4cb041bdf967c257a2f0fd3ef1564618a65650e23a07ec1
3
+ metadata.gz: abbbaed93b7775580684622aaf8a8dcf7d70825e2105b5ed06f2745f37342d55
4
+ data.tar.gz: 5770ea1e8b270c46e9839b49098515ef36eb396a9ed4fe96af6ce0bfa81d5139
5
5
  SHA512:
6
- metadata.gz: a9c87bfbc21370b89591c0b7a58bf30a24d8123ccbd41280f418afd69a5ebae47d05e0367fabdc7b7a0441a3cdf9729da8fee97b1c2fd5c39fbc757a7c1a0e6e
7
- data.tar.gz: 4ef0c1857ba4983df1c567ea3ffee56ef5348e195e000beed34b4d91d7d372effc9c7fcbeb0d59419aebad7477926ece0e8938b9dfab936827603a8488f051a8
6
+ metadata.gz: '018e106cccf4b3d509472294e6764a1fa8f4c2a966d73884a5291f4c64aa7517fb43891e47a2b7726ec4a80142658987e77514154df08bfca63a80e457657456'
7
+ data.tar.gz: 20ce99451144a5c6de593a325a8b99fb962889c48c27dd682ba70814d196bd26fe73851b4ba9c5137e677186b6bce444f901648a3585a27659afd845874e2e60
data/lhs.gemspec CHANGED
@@ -24,14 +24,14 @@ Gem::Specification.new do |s|
24
24
 
25
25
  s.add_dependency 'activemodel'
26
26
  s.add_dependency 'activesupport', '>= 4.2.11'
27
- s.add_dependency 'lhc', '>= 12.1.1', '< 14'
27
+ s.add_dependency 'lhc', '>= 12.1.1', '< 16'
28
28
  s.add_dependency 'local_uri'
29
29
 
30
30
  s.add_development_dependency 'capybara'
31
31
  s.add_development_dependency 'json', '>= 1.8.2'
32
32
  s.add_development_dependency 'pry'
33
33
  s.add_development_dependency 'pry-byebug'
34
- s.add_development_dependency 'rails', '>= 4.2.11'
34
+ s.add_development_dependency 'rails', '>= 4.2.11', '< 7'
35
35
  s.add_development_dependency 'rollbar', '<= 2.24.0'
36
36
  s.add_development_dependency 'rspec-rails', '>= 3.7.0'
37
37
  s.add_development_dependency 'rubocop', '~> 0.57.1'
@@ -34,7 +34,7 @@ class LHS::Item < LHS::Proxy
34
34
  private
35
35
 
36
36
  def apply_default_creation_options(options, url, data)
37
- options = options.merge(method: :post, url: url, body: data)
37
+ options = options.merge(method: options.fetch(:method, :post), url: url, body: data)
38
38
  options[:headers] ||= {}
39
39
  options
40
40
  end
@@ -10,7 +10,7 @@ module LHS
10
10
  class Interceptor < LHC::Interceptor
11
11
 
12
12
  def before_request
13
- request.options[:auth] = { bearer: token }
13
+ request.options[:auth] ||= { bearer: token }
14
14
  end
15
15
 
16
16
  def tokens
data/lib/lhs/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LHS
4
- VERSION = '25.2.0'
4
+ VERSION = '26.1.0'
5
5
  end
@@ -165,5 +165,46 @@ describe 'Auto OAuth Authentication', type: :request, dummy_models: true do
165
165
  expect(records_request).to have_been_requested
166
166
  end
167
167
  end
168
+
169
+ context 'overriding auth options with provider enabled for auto oauth' do
170
+
171
+ let(:token) { ApplicationController::ACCESS_TOKEN }
172
+ let(:overridden_token) { 'ACCESS_TOKEN' }
173
+
174
+ let(:record_request) do
175
+ stub_request(:get, "http://internalservice/v2/records/1")
176
+ .with(
177
+ headers: { 'Authorization' => "Bearer #{overridden_token}" }
178
+ ).to_return(status: 200, body: { name: 'Record' }.to_json)
179
+ end
180
+
181
+ let(:records_request) do
182
+ stub_request(:get, "http://internalservice/v2/records?color=blue")
183
+ .with(
184
+ headers: { 'Authorization' => "Bearer #{overridden_token}" }
185
+ ).to_return(status: 200, body: { items: [{ name: 'Record' }] }.to_json)
186
+ end
187
+
188
+ before do
189
+ LHS.configure do |config|
190
+ config.auto_oauth = -> { access_token }
191
+ end
192
+ LHC.configure do |config|
193
+ config.interceptors = [LHC::Auth]
194
+ end
195
+ record_request
196
+ records_request
197
+ end
198
+
199
+ after do
200
+ LHC.config.reset
201
+ end
202
+
203
+ it 'applies OAuth credentials for the individual request automatically' do
204
+ get '/automatic_authentication/oauth_with_provider_override', params: { access_token: overridden_token }
205
+ expect(record_request).to have_been_requested
206
+ expect(records_request).to have_been_requested
207
+ end
208
+ end
168
209
  end
169
210
  end
@@ -26,4 +26,11 @@ class AutomaticAuthenticationController < ApplicationController
26
26
  records: DummyRecordWithAutoOauthProvider.where(color: 'blue').as_json
27
27
  }
28
28
  end
29
+
30
+ def o_auth_with_provider_override
31
+ render json: {
32
+ record: DummyRecordWithAutoOauthProvider.options(auth: { bearer: params[:access_token] }).find(1).as_json,
33
+ records: DummyRecordWithAutoOauthProvider.options(auth: { bearer: params[:access_token] }).where(color: 'blue').as_json
34
+ }
35
+ end
29
36
  end
@@ -7,6 +7,7 @@ Rails.application.routes.draw do
7
7
  get 'automatic_authentication/oauth' => 'automatic_authentication#o_auth'
8
8
  get 'automatic_authentication/oauth_with_multiple_providers' => 'automatic_authentication#o_auth_with_multiple_providers'
9
9
  get 'automatic_authentication/oauth_with_provider' => 'automatic_authentication#o_auth_with_provider'
10
+ get 'automatic_authentication/oauth_with_provider_override' => 'automatic_authentication#o_auth_with_provider_override'
10
11
 
11
12
  # Request Cycle Cache
12
13
  get 'request_cycle_cache/simple' => 'request_cycle_cache#simple'
@@ -112,4 +112,14 @@ describe LHS::Item do
112
112
  expect(request).to have_been_requested
113
113
  end
114
114
  end
115
+
116
+ context 'chainable' do
117
+ it 'allows to chain save with options' do
118
+ stub_request(:put, item.href).with(body: item._raw.merge(name: 'Steve').to_json)
119
+ item.name = 'Steve'
120
+ result = item.options(method: :put).save
121
+
122
+ expect(result).to eq true
123
+ end
124
+ end
115
125
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhs
3
3
  version: !ruby/object:Gem::Version
4
- version: 25.2.0
4
+ version: 26.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/local-ch/lhs/graphs/contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-10 00:00:00.000000000 Z
11
+ date: 2022-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -47,7 +47,7 @@ dependencies:
47
47
  version: 12.1.1
48
48
  - - "<"
49
49
  - !ruby/object:Gem::Version
50
- version: '14'
50
+ version: '16'
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
@@ -57,7 +57,7 @@ dependencies:
57
57
  version: 12.1.1
58
58
  - - "<"
59
59
  - !ruby/object:Gem::Version
60
- version: '14'
60
+ version: '16'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: local_uri
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -135,6 +135,9 @@ dependencies:
135
135
  - - ">="
136
136
  - !ruby/object:Gem::Version
137
137
  version: 4.2.11
138
+ - - "<"
139
+ - !ruby/object:Gem::Version
140
+ version: '7'
138
141
  type: :development
139
142
  prerelease: false
140
143
  version_requirements: !ruby/object:Gem::Requirement
@@ -142,6 +145,9 @@ dependencies:
142
145
  - - ">="
143
146
  - !ruby/object:Gem::Version
144
147
  version: 4.2.11
148
+ - - "<"
149
+ - !ruby/object:Gem::Version
150
+ version: '7'
145
151
  - !ruby/object:Gem::Dependency
146
152
  name: rollbar
147
153
  requirement: !ruby/object:Gem::Requirement