lhs 25.2.0 → 26.1.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 +4 -4
- data/lhs.gemspec +2 -2
- data/lib/lhs/concerns/item/save.rb +1 -1
- data/lib/lhs/interceptors/auto_oauth/interceptor.rb +1 -1
- data/lib/lhs/version.rb +1 -1
- data/spec/auto_oauth_spec.rb +41 -0
- data/spec/dummy/app/controllers/automatic_authentication_controller.rb +7 -0
- data/spec/dummy/config/routes.rb +1 -0
- data/spec/item/save_spec.rb +10 -0
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abbbaed93b7775580684622aaf8a8dcf7d70825e2105b5ed06f2745f37342d55
|
4
|
+
data.tar.gz: 5770ea1e8b270c46e9839b49098515ef36eb396a9ed4fe96af6ce0bfa81d5139
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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', '<
|
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
|
data/lib/lhs/version.rb
CHANGED
data/spec/auto_oauth_spec.rb
CHANGED
@@ -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
|
data/spec/dummy/config/routes.rb
CHANGED
@@ -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'
|
data/spec/item/save_spec.rb
CHANGED
@@ -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:
|
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:
|
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: '
|
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: '
|
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
|