scimaenaga 1.0.10 → 2.0.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 +4 -0
- data/app/controllers/scimaenaga/scim_groups_controller.rb +19 -6
- data/app/libraries/scim_patch_operation.rb +4 -1
- data/app/libraries/scim_patch_operation_group.rb +25 -0
- data/app/libraries/scim_patch_operation_user.rb +4 -0
- data/config/initializers/mime_types.rb +3 -3
- data/lib/generators/scimaenaga/templates/initializer.rb +5 -4
- data/lib/scimaenaga/encoder.rb +15 -0
- data/lib/scimaenaga/version.rb +1 -1
- data/spec/controllers/scimaenaga/scim_groups_controller_spec.rb +148 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +291 -0
- data/spec/dummy/log/test.log +4 -11087
- data/spec/lib/scimaenaga/encoder_spec.rb +42 -0
- data/spec/libraries/scim_patch_operation_group_spec.rb +82 -0
- data/spec/libraries/scim_patch_operation_user_spec.rb +23 -0
- data/spec/libraries/scim_patch_spec.rb +6 -0
- metadata +6 -10
|
@@ -27,6 +27,39 @@ describe Scimaenaga::Encoder do
|
|
|
27
27
|
expect(token).to match(/[a-z|A-Z0-9.]{16,}/)
|
|
28
28
|
expect(payload).to contain_exactly(['iat', Integer], %w[subdomain test])
|
|
29
29
|
end
|
|
30
|
+
|
|
31
|
+
it 'raises InvalidConfiguration in production' do
|
|
32
|
+
allow(Rails.env).to receive(:production?).and_return(true)
|
|
33
|
+
|
|
34
|
+
expect do
|
|
35
|
+
Scimaenaga::Encoder.encode(company)
|
|
36
|
+
end.to raise_error Scimaenaga::ExceptionHandler::InvalidConfiguration
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'raises InvalidConfiguration in production for :none and "NONE"' do
|
|
40
|
+
allow(Rails.env).to receive(:production?).and_return(true)
|
|
41
|
+
|
|
42
|
+
[:none, 'NONE'].each do |algorithm|
|
|
43
|
+
allow(Scimaenaga.config).to receive(:signing_algorithm).and_return(algorithm)
|
|
44
|
+
|
|
45
|
+
expect do
|
|
46
|
+
Scimaenaga::Encoder.encode(company)
|
|
47
|
+
end.to raise_error Scimaenaga::ExceptionHandler::InvalidConfiguration
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
context 'with signing configuration in production' do
|
|
53
|
+
before do
|
|
54
|
+
allow(Rails.env).to receive(:production?).and_return(true)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'generates a signed token with the company attribute' do
|
|
58
|
+
token = Scimaenaga::Encoder.encode(company)
|
|
59
|
+
payload = Scimaenaga::Encoder.decode(token)
|
|
60
|
+
|
|
61
|
+
expect(payload).to contain_exactly(['iat', Integer], %w[subdomain test])
|
|
62
|
+
end
|
|
30
63
|
end
|
|
31
64
|
end
|
|
32
65
|
|
|
@@ -59,6 +92,15 @@ describe Scimaenaga::Encoder do
|
|
|
59
92
|
|
|
60
93
|
expect(payload).to contain_exactly(['iat', Integer], %w[subdomain test])
|
|
61
94
|
end
|
|
95
|
+
|
|
96
|
+
it 'decodes an already issued unsigned token in production' do
|
|
97
|
+
issued_token = token
|
|
98
|
+
allow(Rails.env).to receive(:production?).and_return(true)
|
|
99
|
+
|
|
100
|
+
payload = Scimaenaga::Encoder.decode(issued_token)
|
|
101
|
+
|
|
102
|
+
expect(payload).to contain_exactly(['iat', Integer], %w[subdomain test])
|
|
103
|
+
end
|
|
62
104
|
end
|
|
63
105
|
end
|
|
64
106
|
end
|
|
@@ -7,6 +7,7 @@ describe ScimPatchOperationGroup do
|
|
|
7
7
|
let(:path) { 'displayName' }
|
|
8
8
|
let(:value) { 'groupA' }
|
|
9
9
|
let(:mutable_attributes_schema) { { displayName: :name } }
|
|
10
|
+
let(:mutable_attributes) { [:name] }
|
|
10
11
|
let(:group_member_relation_attribute) { :user_ids }
|
|
11
12
|
|
|
12
13
|
let(:user1) { create(:user) }
|
|
@@ -22,6 +23,26 @@ describe ScimPatchOperationGroup do
|
|
|
22
23
|
value
|
|
23
24
|
)
|
|
24
25
|
end
|
|
26
|
+
|
|
27
|
+
before do
|
|
28
|
+
allow(Scimaenaga.config).to(
|
|
29
|
+
receive(:mutable_group_attributes).and_return(mutable_attributes)
|
|
30
|
+
)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context 'attribute in the schema but not in mutable_group_attributes' do
|
|
34
|
+
let(:mutable_attributes_schema) { { displayName: :name, externalId: :external_id } }
|
|
35
|
+
let(:path) { 'externalId' }
|
|
36
|
+
it {
|
|
37
|
+
allow(Scimaenaga.config).to(
|
|
38
|
+
receive(:mutable_group_attributes_schema).and_return(mutable_attributes_schema)
|
|
39
|
+
)
|
|
40
|
+
expect { operation }.to(
|
|
41
|
+
raise_error(Scimaenaga::ExceptionHandler::UnsupportedPatchRequest)
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
end
|
|
45
|
+
|
|
25
46
|
context 'replace displayName' do
|
|
26
47
|
it {
|
|
27
48
|
allow(Scimaenaga.config).to(
|
|
@@ -141,6 +162,67 @@ describe ScimPatchOperationGroup do
|
|
|
141
162
|
}
|
|
142
163
|
end
|
|
143
164
|
|
|
165
|
+
describe '#member_ids_to_assign' do
|
|
166
|
+
let(:path) { 'members' }
|
|
167
|
+
let(:value) { [{ 'value' => user3.id.to_s }, { 'value' => user4.id }] }
|
|
168
|
+
|
|
169
|
+
before do
|
|
170
|
+
allow(Scimaenaga.config).to(
|
|
171
|
+
receive(:mutable_group_attributes_schema).and_return(mutable_attributes_schema)
|
|
172
|
+
)
|
|
173
|
+
allow(Scimaenaga.config).to(
|
|
174
|
+
receive(:group_member_relation_attribute)
|
|
175
|
+
.and_return(group_member_relation_attribute)
|
|
176
|
+
)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
context 'add members' do
|
|
180
|
+
let(:op) { 'add' }
|
|
181
|
+
it { expect(operation.member_ids_to_assign).to eq [user3.id.to_s, user4.id.to_s] }
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
context 'replace members' do
|
|
185
|
+
let(:op) { 'replace' }
|
|
186
|
+
it { expect(operation.member_ids_to_assign).to eq [user3.id.to_s, user4.id.to_s] }
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
context 'remove members' do
|
|
190
|
+
let(:op) { 'remove' }
|
|
191
|
+
it { expect(operation.member_ids_to_assign).to eq [] }
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
context 'path is not members' do
|
|
195
|
+
let(:op) { 'replace' }
|
|
196
|
+
let(:path) { 'displayName' }
|
|
197
|
+
let(:value) { 'groupA' }
|
|
198
|
+
it { expect(operation.member_ids_to_assign).to eq [] }
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
context 'value is nil' do
|
|
202
|
+
let(:op) { 'add' }
|
|
203
|
+
let(:value) { nil }
|
|
204
|
+
it { expect(operation.member_ids_to_assign).to eq [] }
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
context 'value is not an array' do
|
|
208
|
+
let(:op) { 'add' }
|
|
209
|
+
let(:value) { user3.id.to_s }
|
|
210
|
+
it { expect(operation.member_ids_to_assign).to eq [] }
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
context 'value has elements that #save cannot read' do
|
|
214
|
+
let(:op) { 'add' }
|
|
215
|
+
let(:value) { [user3.id, nil, { 'value' => user4.id }] }
|
|
216
|
+
it { expect(operation.member_ids_to_assign).to eq [user4.id.to_s] }
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
context 'value has String elements' do
|
|
220
|
+
let(:op) { 'add' }
|
|
221
|
+
let(:value) { %w[value abc] }
|
|
222
|
+
it { expect(operation.member_ids_to_assign).to eq ['value', ''] }
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
|
|
144
226
|
context 'remove user id (with filter)' do
|
|
145
227
|
let(:op) { 'remove' }
|
|
146
228
|
let(:path) { "members[value eq \"#{user1.id}\"]" }
|
|
@@ -22,6 +22,15 @@ describe ScimPatchOperationUser do
|
|
|
22
22
|
active: :active,
|
|
23
23
|
}
|
|
24
24
|
end
|
|
25
|
+
let(:mutable_attributes) do
|
|
26
|
+
%i[name display_name email family_name given_name active]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
before do
|
|
30
|
+
allow(Scimaenaga.config).to(
|
|
31
|
+
receive(:mutable_user_attributes).and_return(mutable_attributes)
|
|
32
|
+
)
|
|
33
|
+
end
|
|
25
34
|
|
|
26
35
|
let(:operation) do
|
|
27
36
|
described_class.new(
|
|
@@ -97,5 +106,19 @@ describe ScimPatchOperationUser do
|
|
|
97
106
|
expect(operation.value).to eq value
|
|
98
107
|
}
|
|
99
108
|
end
|
|
109
|
+
|
|
110
|
+
context 'attribute in the schema but not in mutable_user_attributes' do
|
|
111
|
+
let(:mutable_attributes) { %i[name display_name email active] }
|
|
112
|
+
let(:path) { 'name.familyName' }
|
|
113
|
+
let(:value) { 'Suzuki' }
|
|
114
|
+
it {
|
|
115
|
+
allow(Scimaenaga.config).to(
|
|
116
|
+
receive(:mutable_user_attributes_schema).and_return(mutable_attributes_schema)
|
|
117
|
+
)
|
|
118
|
+
expect { operation }.to(
|
|
119
|
+
raise_error(Scimaenaga::ExceptionHandler::UnsupportedPatchRequest)
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
end
|
|
100
123
|
end
|
|
101
124
|
end
|
|
@@ -9,6 +9,9 @@ describe ScimPatch do
|
|
|
9
9
|
allow(Scimaenaga.config).to(
|
|
10
10
|
receive(:mutable_user_attributes_schema).and_return(mutable_user_attributes_schema)
|
|
11
11
|
)
|
|
12
|
+
allow(Scimaenaga.config).to(
|
|
13
|
+
receive(:mutable_user_attributes).and_return(%i[name email family_name active])
|
|
14
|
+
)
|
|
12
15
|
|
|
13
16
|
expect(patch.operations[0].op).to eq 'replace'
|
|
14
17
|
expect(patch.operations[0].path_scim).to eq(attribute: 'emails',
|
|
@@ -145,6 +148,9 @@ describe ScimPatch do
|
|
|
145
148
|
allow(Scimaenaga.config).to(
|
|
146
149
|
receive(:mutable_group_attributes_schema).and_return(mutable_group_attributes_schema)
|
|
147
150
|
)
|
|
151
|
+
allow(Scimaenaga.config).to(
|
|
152
|
+
receive(:mutable_group_attributes).and_return([:name])
|
|
153
|
+
)
|
|
148
154
|
|
|
149
155
|
expect(patch.operations[0].op).to eq 'replace'
|
|
150
156
|
expect(patch.operations[0].path_scim).to eq(attribute: 'displayName', rest_path: [])
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: scimaenaga
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Studist Corporation
|
|
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: jwt
|
|
@@ -33,7 +32,7 @@ dependencies:
|
|
|
33
32
|
version: '7.0'
|
|
34
33
|
- - "<"
|
|
35
34
|
- !ruby/object:Gem::Version
|
|
36
|
-
version: '
|
|
35
|
+
version: '9.0'
|
|
37
36
|
type: :runtime
|
|
38
37
|
prerelease: false
|
|
39
38
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -43,7 +42,7 @@ dependencies:
|
|
|
43
42
|
version: '7.0'
|
|
44
43
|
- - "<"
|
|
45
44
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '
|
|
45
|
+
version: '9.0'
|
|
47
46
|
- !ruby/object:Gem::Dependency
|
|
48
47
|
name: bundler
|
|
49
48
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -129,7 +128,6 @@ dependencies:
|
|
|
129
128
|
- !ruby/object:Gem::Version
|
|
130
129
|
version: '0'
|
|
131
130
|
description: SCIM Adapter for Rails.
|
|
132
|
-
email:
|
|
133
131
|
executables: []
|
|
134
132
|
extensions: []
|
|
135
133
|
extra_rdoc_files: []
|
|
@@ -254,7 +252,6 @@ licenses:
|
|
|
254
252
|
- MIT
|
|
255
253
|
metadata:
|
|
256
254
|
rubygems_mfa_required: 'true'
|
|
257
|
-
post_install_message:
|
|
258
255
|
rdoc_options: []
|
|
259
256
|
require_paths:
|
|
260
257
|
- lib
|
|
@@ -269,8 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
269
266
|
- !ruby/object:Gem::Version
|
|
270
267
|
version: '0'
|
|
271
268
|
requirements: []
|
|
272
|
-
rubygems_version: 3.
|
|
273
|
-
signing_key:
|
|
269
|
+
rubygems_version: 3.7.2
|
|
274
270
|
specification_version: 4
|
|
275
271
|
summary: SCIM Adapter for Rails.
|
|
276
272
|
test_files:
|
|
@@ -304,6 +300,7 @@ test_files:
|
|
|
304
300
|
- spec/dummy/bin/rake
|
|
305
301
|
- spec/dummy/bin/setup
|
|
306
302
|
- spec/dummy/bin/update
|
|
303
|
+
- spec/dummy/config.ru
|
|
307
304
|
- spec/dummy/config/application.rb
|
|
308
305
|
- spec/dummy/config/boot.rb
|
|
309
306
|
- spec/dummy/config/cable.yml
|
|
@@ -328,7 +325,6 @@ test_files:
|
|
|
328
325
|
- spec/dummy/config/routes.rb
|
|
329
326
|
- spec/dummy/config/secrets.yml
|
|
330
327
|
- spec/dummy/config/spring.rb
|
|
331
|
-
- spec/dummy/config.ru
|
|
332
328
|
- spec/dummy/db/development.sqlite3
|
|
333
329
|
- spec/dummy/db/migrate/20181206184304_create_users.rb
|
|
334
330
|
- spec/dummy/db/migrate/20181206184313_create_companies.rb
|