omniauth-shopify-oauth2 2.2.1 → 2.2.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f79e7c2eb47cf4f303c1f8cb850da4bd9796f5b303b0a4ef52819460d353c4f
|
4
|
+
data.tar.gz: 1bb889fe7e031d419f7b11f49404ffcfbd4767f0c92295af679faed935555850
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e94434e74dd9f35eb13127b5e5bf44c5471280bf9b783fc170f7168529be5bc18a2b29ef422df77622e6e879dc505b434ef0cb83f32986e3476c72c7f0cf5d8
|
7
|
+
data.tar.gz: 76ae229909c8a01b1bcc6ba2832ca9b4a3cf2d3f0d1bc86fd84781b54e460e6638d59f2046a58e590fc70bf7719d5ee2a967cc1f0bd693fc598bb88d871b3e1b
|
@@ -94,7 +94,12 @@ module OmniAuth
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def valid_permissions?(token)
|
97
|
-
|
97
|
+
return false unless token
|
98
|
+
|
99
|
+
return true if options[:per_user_permissions] && token['associated_user']
|
100
|
+
return true if !options[:per_user_permissions] && !token['associated_user']
|
101
|
+
|
102
|
+
false
|
98
103
|
end
|
99
104
|
|
100
105
|
def fix_https
|
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_runtime_dependency 'activesupport'
|
22
22
|
|
23
23
|
s.add_development_dependency 'minitest', '~> 5.6'
|
24
|
+
s.add_development_dependency 'rspec', '~> 3.9.0'
|
24
25
|
s.add_development_dependency 'fakeweb', '~> 1.3'
|
25
26
|
s.add_development_dependency 'rake'
|
26
27
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'spec_helper'
|
2
1
|
require 'omniauth-shopify-oauth2'
|
3
2
|
require 'base64'
|
4
3
|
|
@@ -141,4 +140,80 @@ describe OmniAuth::Strategies::Shopify do
|
|
141
140
|
subject.valid_site?.should eq(true)
|
142
141
|
end
|
143
142
|
end
|
143
|
+
|
144
|
+
describe '#valid_permissions?' do
|
145
|
+
let(:associated_user) do
|
146
|
+
{}
|
147
|
+
end
|
148
|
+
|
149
|
+
let(:token) do
|
150
|
+
{
|
151
|
+
'associated_user' => associated_user,
|
152
|
+
}
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'returns false if there is no token' do
|
156
|
+
expect(subject.valid_permissions?(nil)).to be_falsey
|
157
|
+
end
|
158
|
+
|
159
|
+
context 'with per_user_permissions is present' do
|
160
|
+
before do
|
161
|
+
@options = @options.merge(per_user_permissions: true)
|
162
|
+
end
|
163
|
+
|
164
|
+
context 'when token does not have associated user' do
|
165
|
+
let(:associated_user) { nil }
|
166
|
+
|
167
|
+
it 'return false' do
|
168
|
+
expect(subject.valid_permissions?(token)).to be_falsey
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
context 'when token has associated user' do
|
173
|
+
it 'return true' do
|
174
|
+
expect(subject.valid_permissions?(token)).to be_truthy
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
context 'with per_user_permissions is false' do
|
180
|
+
before do
|
181
|
+
@options = @options.merge(per_user_permissions: false)
|
182
|
+
end
|
183
|
+
|
184
|
+
context 'when token does not have associated user' do
|
185
|
+
let(:associated_user) { nil }
|
186
|
+
|
187
|
+
it 'return true' do
|
188
|
+
expect(subject.valid_permissions?(token)).to be_truthy
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
context 'when token has associated user' do
|
193
|
+
it 'return false' do
|
194
|
+
expect(subject.valid_permissions?(token)).to be_falsey
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
context 'with per_user_permissions is nil' do
|
200
|
+
before do
|
201
|
+
@options = @options.merge(per_user_permissions: nil)
|
202
|
+
end
|
203
|
+
|
204
|
+
context 'when token does not have associated user' do
|
205
|
+
let(:associated_user) { nil }
|
206
|
+
|
207
|
+
it 'return true' do
|
208
|
+
expect(subject.valid_permissions?(token)).to be_truthy
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
context 'when token has associated user' do
|
213
|
+
it 'return false' do
|
214
|
+
expect(subject.valid_permissions?(token)).to be_falsey
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
144
219
|
end
|
data/test/integration_test.rb
CHANGED
@@ -280,6 +280,18 @@ class IntegrationTest < Minitest::Test
|
|
280
280
|
assert_equal '/auth/failure?message=invalid_permissions&strategy=shopify', response.location
|
281
281
|
end
|
282
282
|
|
283
|
+
def test_callback_when_per_user_permissions_are_not_present_and_options_is_nil
|
284
|
+
build_app(scope: 'scope', per_user_permissions: nil)
|
285
|
+
|
286
|
+
access_token = SecureRandom.hex(16)
|
287
|
+
code = SecureRandom.hex(16)
|
288
|
+
expect_access_token_request(access_token, 'scope', nil)
|
289
|
+
|
290
|
+
response = callback(sign_with_new_secret(shop: 'snowdevil.myshopify.com', code: code, state: opts["rack.session"]["omniauth.state"]))
|
291
|
+
|
292
|
+
assert_callback_success(response, access_token, code)
|
293
|
+
end
|
294
|
+
|
283
295
|
def test_callback_when_per_user_permissions_are_not_present_but_requested
|
284
296
|
build_app(scope: 'scope', per_user_permissions: true)
|
285
297
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-shopify-oauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Odorcic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth-oauth2
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.9.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.9.0
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: fakeweb
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|