publishing_platform_sso 0.3.1 → 0.3.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 +4 -4
- data/README.md +19 -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
- metadata +89 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c741003970d79722a409247f1c428b44bfd5244db7225767e8d3f3e484677fbd
|
4
|
+
data.tar.gz: e8f167de46211c415cf4639f10c69e187c93d5583cebda3f3d9a7efda993c426
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e608f5c9a129b8065e28a29c0e581fa27379ed721c148d54543294fa2f6469e77f77135bf9143f412e67521dbfb5cc3fed156a2761db79a28c8ef6158eca5e2c
|
7
|
+
data.tar.gz: 8649c2f184d8073799642ff5854008f6cee1a0a1fb8f44a49eb2b042caa9d69df4165e537ec2d9ebea250c00a368333fd85d41c8467d94fc5cb4f8e81611f7d2
|
data/README.md
CHANGED
@@ -151,6 +151,25 @@ 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
|
+
### Running the test suite
|
166
|
+
|
167
|
+
Run the tests with:
|
168
|
+
|
169
|
+
```
|
170
|
+
bundle exec rake
|
171
|
+
```
|
172
|
+
|
154
173
|
## Licence
|
155
174
|
|
156
175
|
[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
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: publishing_platform_sso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Publishing Platform
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: publishing_platform_location
|
@@ -108,6 +108,34 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 0.0.1
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: capybara
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: combustion
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.3'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '1.3'
|
111
139
|
- !ruby/object:Gem::Dependency
|
112
140
|
name: publishing_platform_rubocop
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +150,62 @@ dependencies:
|
|
122
150
|
- - ">="
|
123
151
|
- !ruby/object:Gem::Version
|
124
152
|
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rspec-rails
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '7'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '7'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: sqlite3
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '2.1'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '2.1'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: timecop
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0.9'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0.9'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: webmock
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
125
209
|
description: Client for Publishing Platform's OAuth 2-based SSO.
|
126
210
|
email:
|
127
211
|
executables: []
|
@@ -144,6 +228,7 @@ files:
|
|
144
228
|
- lib/publishing_platform_sso/controller_methods.rb
|
145
229
|
- lib/publishing_platform_sso/errors.rb
|
146
230
|
- lib/publishing_platform_sso/failure_app.rb
|
231
|
+
- lib/publishing_platform_sso/lint/user_spec.rb
|
147
232
|
- lib/publishing_platform_sso/railtie.rb
|
148
233
|
- lib/publishing_platform_sso/user.rb
|
149
234
|
- lib/publishing_platform_sso/version.rb
|
@@ -160,14 +245,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
160
245
|
requirements:
|
161
246
|
- - ">="
|
162
247
|
- !ruby/object:Gem::Version
|
163
|
-
version: '3.
|
248
|
+
version: '3.1'
|
164
249
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
250
|
requirements:
|
166
251
|
- - ">="
|
167
252
|
- !ruby/object:Gem::Version
|
168
253
|
version: '0'
|
169
254
|
requirements: []
|
170
|
-
rubygems_version: 3.
|
255
|
+
rubygems_version: 3.5.23
|
171
256
|
signing_key:
|
172
257
|
specification_version: 4
|
173
258
|
summary: Client for Publishing Platform's OAuth 2-based SSO.
|