publishing_platform_sso 0.3.1 → 0.4.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/README.md +20 -0
- data/Rakefile +3 -1
- data/lib/omniauth/strategies/publishing_platform.rb +1 -1
- data/lib/publishing_platform_sso/lint/user_spec.rb +74 -0
- data/lib/publishing_platform_sso/version.rb +1 -1
- data/lib/publishing_platform_sso/warden_config.rb +3 -1
- metadata +89 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5db45f6cf6588fdd48c90f970d1e93c510d9657c95af940a059aa6880f510113
|
4
|
+
data.tar.gz: 6d970b25d32bb7be21c6b7cb4ccc03567672c29770bfdb5e7f71f257d8998f6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75829509bfa165316a74e556d67b0494fb9aa7baf9fbeee633d0499cd5cc65f56ccb39884e855faf3c801a97806bda1286afe58127a4247f8517c7f673607291
|
7
|
+
data.tar.gz: cf00b01c3c82f6a0f1306d702dac5ff468c6652042991320928029f509b492a1e7b71ee2f27602af69a2f027bc1bee802375b6ad536f255f98a58eaaccd9e15d
|
data/README.md
CHANGED
@@ -151,6 +151,26 @@ end
|
|
151
151
|
|
152
152
|
The mock bearer token will then ensure that the dummy api user has the required permission.
|
153
153
|
|
154
|
+
### Testing in your application
|
155
|
+
|
156
|
+
If your app is using `rspec`, there is a [shared examples spec](/lib/publishing_platform_sso/lint/user_spec.rb) compatible with `PublishingPlatform::SSO::User`:
|
157
|
+
|
158
|
+
```ruby
|
159
|
+
require 'publishing_platform_sso/lint/user_spec'
|
160
|
+
|
161
|
+
describe User do
|
162
|
+
it_behaves_like "a publishing_platform_sso user class"
|
163
|
+
end
|
164
|
+
```
|
165
|
+
|
166
|
+
### Running the test suite
|
167
|
+
|
168
|
+
Run the tests with:
|
169
|
+
|
170
|
+
```
|
171
|
+
bundle exec rake
|
172
|
+
```
|
173
|
+
|
154
174
|
## Licence
|
155
175
|
|
156
176
|
[MIT License](LICENSE)
|
data/Rakefile
CHANGED
@@ -0,0 +1,74 @@
|
|
1
|
+
RSpec.shared_examples "a publishing_platform_sso user class" do
|
2
|
+
subject { described_class.new(uid: "12345") }
|
3
|
+
|
4
|
+
it "implements #where" do
|
5
|
+
expect(described_class).to respond_to(:where)
|
6
|
+
|
7
|
+
result = described_class.where(uid: "123")
|
8
|
+
expect(result).to respond_to(:first)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "implements #update_attribute" do
|
12
|
+
expect(subject).to respond_to(:update_attribute)
|
13
|
+
|
14
|
+
subject.update_attribute(:disabled, true)
|
15
|
+
expect(subject).to be_disabled
|
16
|
+
end
|
17
|
+
|
18
|
+
it "implements #update!" do
|
19
|
+
subject.update!(email: "ab@c.com")
|
20
|
+
expect(subject.email).to eq("ab@c.com")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "implements #create!" do
|
24
|
+
expect(described_class).to respond_to(:create!)
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#has_all_permissions?" do
|
28
|
+
it "is false when there are no permissions" do
|
29
|
+
subject.update!(permissions: nil)
|
30
|
+
required_permissions = %w[signin]
|
31
|
+
expect(subject.has_all_permissions?(required_permissions)).to be_falsy
|
32
|
+
end
|
33
|
+
|
34
|
+
it "is false when it does not have all required permissions" do
|
35
|
+
subject.update!(permissions: %w[signin])
|
36
|
+
required_permissions = %w[signin not_granted_permission_one not_granted_permission_two]
|
37
|
+
expect(subject.has_all_permissions?(required_permissions)).to be false
|
38
|
+
end
|
39
|
+
|
40
|
+
it "is true when it has all required permissions" do
|
41
|
+
subject.update!(permissions: %w[signin internal_app])
|
42
|
+
required_permissions = %w[signin internal_app]
|
43
|
+
expect(subject.has_all_permissions?(required_permissions)).to be true
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
specify "the User class and PublishingPlatform::SSO::User mixin work together" do
|
48
|
+
auth_hash = {
|
49
|
+
"uid" => "12345",
|
50
|
+
"info" => {
|
51
|
+
"name" => "Joe Smith",
|
52
|
+
"email" => "joe.smith@example.com",
|
53
|
+
},
|
54
|
+
"extra" => {
|
55
|
+
"user" => {
|
56
|
+
"disabled" => false,
|
57
|
+
"permissions" => %w[signin],
|
58
|
+
"organisation_slug" => "digital-services",
|
59
|
+
"organisation_content_id" => "af07d5a5-df63-4ddc-9383-6a666845ebe9",
|
60
|
+
},
|
61
|
+
},
|
62
|
+
}
|
63
|
+
|
64
|
+
user = described_class.find_for_oauth(auth_hash)
|
65
|
+
expect(user).to be_an_instance_of(described_class)
|
66
|
+
expect(user.uid).to eq("12345")
|
67
|
+
expect(user.name).to eq("Joe Smith")
|
68
|
+
expect(user.email).to eq("joe.smith@example.com")
|
69
|
+
expect(user).not_to be_disabled
|
70
|
+
expect(user.permissions).to eq(%w[signin])
|
71
|
+
expect(user.organisation_slug).to eq("digital-services")
|
72
|
+
expect(user.organisation_content_id).to eq("af07d5a5-df63-4ddc-9383-6a666845ebe9")
|
73
|
+
end
|
74
|
+
end
|
@@ -66,7 +66,7 @@ Warden::Strategies.add(:mock_publishing_platform_sso) do
|
|
66
66
|
logger.warn("Authenticating with mock_publishing_platform_sso strategy")
|
67
67
|
|
68
68
|
test_user = PublishingPlatform::SSO.test_user
|
69
|
-
test_user ||= PublishingPlatform::SSO::Config.user_klass.first
|
69
|
+
test_user ||= ENV["PUBLISHING_PLATFORM_SSO_MOCK_INVALID"].present? ? nil : PublishingPlatform::SSO::Config.user_klass.first
|
70
70
|
if test_user
|
71
71
|
# Brute force ensure test user has correct perms to signin
|
72
72
|
unless test_user.has_permission?("signin")
|
@@ -74,6 +74,8 @@ Warden::Strategies.add(:mock_publishing_platform_sso) do
|
|
74
74
|
test_user.update_attribute(:permissions, permissions << "signin")
|
75
75
|
end
|
76
76
|
success!(test_user)
|
77
|
+
elsif Rails.env.test? && ENV["PUBLISHING_PLATFORM_SSO_MOCK_INVALID"].present?
|
78
|
+
fail!(:invalid)
|
77
79
|
else
|
78
80
|
raise "publishing_platform_sso running in mock mode and no test user found. Normally we'd load the first user in the database. Create a user in the database."
|
79
81
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: publishing_platform_sso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Publishing Platform
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: publishing_platform_location
|
@@ -108,6 +107,34 @@ dependencies:
|
|
108
107
|
- - "~>"
|
109
108
|
- !ruby/object:Gem::Version
|
110
109
|
version: 0.0.1
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: capybara
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '3'
|
117
|
+
type: :development
|
118
|
+
prerelease: false
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '3'
|
124
|
+
- !ruby/object:Gem::Dependency
|
125
|
+
name: combustion
|
126
|
+
requirement: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '1.3'
|
131
|
+
type: :development
|
132
|
+
prerelease: false
|
133
|
+
version_requirements: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '1.3'
|
111
138
|
- !ruby/object:Gem::Dependency
|
112
139
|
name: publishing_platform_rubocop
|
113
140
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,8 +149,63 @@ dependencies:
|
|
122
149
|
- - ">="
|
123
150
|
- !ruby/object:Gem::Version
|
124
151
|
version: '0'
|
152
|
+
- !ruby/object:Gem::Dependency
|
153
|
+
name: rspec-rails
|
154
|
+
requirement: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - "~>"
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '7'
|
159
|
+
type: :development
|
160
|
+
prerelease: false
|
161
|
+
version_requirements: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - "~>"
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '7'
|
166
|
+
- !ruby/object:Gem::Dependency
|
167
|
+
name: sqlite3
|
168
|
+
requirement: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - "~>"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '2.1'
|
173
|
+
type: :development
|
174
|
+
prerelease: false
|
175
|
+
version_requirements: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - "~>"
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '2.1'
|
180
|
+
- !ruby/object:Gem::Dependency
|
181
|
+
name: timecop
|
182
|
+
requirement: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - "~>"
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0.9'
|
187
|
+
type: :development
|
188
|
+
prerelease: false
|
189
|
+
version_requirements: !ruby/object:Gem::Requirement
|
190
|
+
requirements:
|
191
|
+
- - "~>"
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: '0.9'
|
194
|
+
- !ruby/object:Gem::Dependency
|
195
|
+
name: webmock
|
196
|
+
requirement: !ruby/object:Gem::Requirement
|
197
|
+
requirements:
|
198
|
+
- - ">="
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '0'
|
201
|
+
type: :development
|
202
|
+
prerelease: false
|
203
|
+
version_requirements: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - ">="
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '0'
|
125
208
|
description: Client for Publishing Platform's OAuth 2-based SSO.
|
126
|
-
email:
|
127
209
|
executables: []
|
128
210
|
extensions: []
|
129
211
|
extra_rdoc_files: []
|
@@ -144,15 +226,14 @@ files:
|
|
144
226
|
- lib/publishing_platform_sso/controller_methods.rb
|
145
227
|
- lib/publishing_platform_sso/errors.rb
|
146
228
|
- lib/publishing_platform_sso/failure_app.rb
|
229
|
+
- lib/publishing_platform_sso/lint/user_spec.rb
|
147
230
|
- lib/publishing_platform_sso/railtie.rb
|
148
231
|
- lib/publishing_platform_sso/user.rb
|
149
232
|
- lib/publishing_platform_sso/version.rb
|
150
233
|
- lib/publishing_platform_sso/warden_config.rb
|
151
|
-
homepage:
|
152
234
|
licenses:
|
153
235
|
- MIT
|
154
236
|
metadata: {}
|
155
|
-
post_install_message:
|
156
237
|
rdoc_options: []
|
157
238
|
require_paths:
|
158
239
|
- lib
|
@@ -160,15 +241,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
160
241
|
requirements:
|
161
242
|
- - ">="
|
162
243
|
- !ruby/object:Gem::Version
|
163
|
-
version: '3.
|
244
|
+
version: '3.1'
|
164
245
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
246
|
requirements:
|
166
247
|
- - ">="
|
167
248
|
- !ruby/object:Gem::Version
|
168
249
|
version: '0'
|
169
250
|
requirements: []
|
170
|
-
rubygems_version: 3.
|
171
|
-
signing_key:
|
251
|
+
rubygems_version: 3.6.7
|
172
252
|
specification_version: 4
|
173
253
|
summary: Client for Publishing Platform's OAuth 2-based SSO.
|
174
254
|
test_files: []
|