scimaenaga 0.7.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +22 -7
  3. data/Rakefile +6 -8
  4. data/app/controllers/concerns/{scim_rails → scimaenaga}/exception_handler.rb +47 -37
  5. data/app/controllers/concerns/scimaenaga/response.rb +94 -0
  6. data/app/controllers/scimaenaga/application_controller.rb +72 -0
  7. data/app/controllers/{scim_rails → scimaenaga}/scim_groups_controller.rb +26 -26
  8. data/app/controllers/scimaenaga/scim_schemas_controller.rb +42 -0
  9. data/app/controllers/scimaenaga/scim_users_controller.rb +104 -0
  10. data/app/helpers/{scim_rails → scimaenaga}/application_helper.rb +1 -1
  11. data/app/libraries/scim_patch.rb +16 -9
  12. data/app/libraries/scim_patch_operation.rb +51 -141
  13. data/app/libraries/scim_patch_operation_converter.rb +90 -0
  14. data/app/libraries/scim_patch_operation_group.rb +100 -0
  15. data/app/libraries/scim_patch_operation_user.rb +53 -0
  16. data/app/models/{scim_rails → scimaenaga}/application_record.rb +1 -1
  17. data/app/models/scimaenaga/authorize_api_request.rb +39 -0
  18. data/app/models/{scim_rails → scimaenaga}/scim_count.rb +8 -4
  19. data/app/models/scimaenaga/scim_query_parser.rb +49 -0
  20. data/config/routes.rb +15 -13
  21. data/lib/generators/scimaenaga/USAGE +8 -0
  22. data/lib/generators/scimaenaga/scimaenaga_generator.rb +7 -0
  23. data/lib/generators/{scim_rails → scimaenaga}/templates/initializer.rb +128 -22
  24. data/lib/{scim_rails → scimaenaga}/config.rb +9 -7
  25. data/lib/scimaenaga/encoder.rb +27 -0
  26. data/lib/scimaenaga/engine.rb +12 -0
  27. data/lib/scimaenaga/version.rb +5 -0
  28. data/lib/scimaenaga.rb +6 -0
  29. data/lib/tasks/{scim_rails_tasks.rake → scimaenaga_tasks.rake} +1 -1
  30. data/spec/controllers/{scim_rails → scimaenaga}/scim_groups_controller_spec.rb +8 -8
  31. data/spec/controllers/{scim_rails → scimaenaga}/scim_groups_request_spec.rb +18 -18
  32. data/spec/controllers/scimaenaga/scim_schemas_controller_spec.rb +238 -0
  33. data/spec/controllers/scimaenaga/scim_schemas_request_spec.rb +39 -0
  34. data/spec/controllers/{scim_rails → scimaenaga}/scim_users_controller_spec.rb +14 -15
  35. data/spec/controllers/{scim_rails → scimaenaga}/scim_users_request_spec.rb +20 -20
  36. data/spec/dummy/app/assets/config/manifest.js +1 -1
  37. data/spec/dummy/config/application.rb +1 -2
  38. data/spec/dummy/config/initializers/{scim_rails_config.rb → scimaenaga_config.rb} +25 -25
  39. data/spec/dummy/config/routes.rb +1 -1
  40. data/spec/factories/company.rb +3 -3
  41. data/spec/lib/scimaenaga/encoder_spec.rb +64 -0
  42. data/spec/libraries/scim_patch_operation_group_spec.rb +165 -0
  43. data/spec/libraries/scim_patch_operation_user_spec.rb +101 -0
  44. data/spec/libraries/scim_patch_spec.rb +129 -45
  45. data/spec/models/scim_query_parser_spec.rb +5 -6
  46. metadata +107 -108
  47. data/app/controllers/concerns/scim_rails/response.rb +0 -94
  48. data/app/controllers/scim_rails/application_controller.rb +0 -72
  49. data/app/controllers/scim_rails/scim_users_controller.rb +0 -107
  50. data/app/models/scim_rails/authorize_api_request.rb +0 -40
  51. data/app/models/scim_rails/scim_query_parser.rb +0 -49
  52. data/lib/generators/scim_rails/USAGE +0 -8
  53. data/lib/generators/scim_rails/scim_rails_generator.rb +0 -7
  54. data/lib/scim_rails/encoder.rb +0 -25
  55. data/lib/scim_rails/engine.rb +0 -12
  56. data/lib/scim_rails/version.rb +0 -5
  57. data/lib/scim_rails.rb +0 -6
  58. data/spec/dummy/db/development.sqlite3 +0 -0
  59. data/spec/dummy/db/test.sqlite3 +0 -0
  60. data/spec/dummy/log/development.log +0 -0
  61. data/spec/dummy/log/test.log +0 -5770
  62. data/spec/dummy/put_group.http +0 -5
  63. data/spec/dummy/tmp/restart.txt +0 -0
  64. data/spec/lib/scim_rails/encoder_spec.rb +0 -62
  65. data/spec/libraries/scim_patch_operation_spec.rb +0 -116
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe Scimaenaga::Encoder do
4
+ let(:company) { Company.new(subdomain: 'test') }
5
+
6
+ describe '::encode' do
7
+ context 'with signing configuration' do
8
+ it 'generates a signed token with the company attribute' do
9
+ token = Scimaenaga::Encoder.encode(company)
10
+ payload = Scimaenaga::Encoder.decode(token)
11
+
12
+ expect(token).to match(/[a-z|A-Z0-9.]{16,}\.[a-z|A-Z0-9.]{16,}/)
13
+ expect(payload).to contain_exactly(['iat', Integer], %w[subdomain test])
14
+ end
15
+ end
16
+
17
+ context 'without signing configuration' do
18
+ before do
19
+ allow(Scimaenaga.config).to receive(:signing_secret).and_return(nil)
20
+ allow(Scimaenaga.config).to receive(:signing_algorithm).and_return(Scimaenaga::Config::ALGO_NONE)
21
+ end
22
+
23
+ it 'generates an unsigned token with the company attribute' do
24
+ token = Scimaenaga::Encoder.encode(company)
25
+ payload = Scimaenaga::Encoder.decode(token)
26
+
27
+ expect(token).to match(/[a-z|A-Z0-9.]{16,}/)
28
+ expect(payload).to contain_exactly(['iat', Integer], %w[subdomain test])
29
+ end
30
+ end
31
+ end
32
+
33
+ describe '::decode' do
34
+ let(:token) { Scimaenaga::Encoder.encode(company) }
35
+
36
+ it 'raises InvalidCredentials error for an invalid token' do
37
+ token = 'f487bf84bfub4f74fj4894fnh483f4h4u8f'
38
+ expect do
39
+ Scimaenaga::Encoder.decode(token)
40
+ end.to raise_error Scimaenaga::ExceptionHandler::InvalidCredentials
41
+ end
42
+
43
+ context 'with signing configuration' do
44
+ it 'decodes a signed token, returning the company attributes' do
45
+ payload = Scimaenaga::Encoder.decode(token)
46
+
47
+ expect(payload).to contain_exactly(['iat', Integer], %w[subdomain test])
48
+ end
49
+ end
50
+
51
+ context 'without signing configuration' do
52
+ before do
53
+ allow(Scimaenaga.config).to receive(:signing_secret).and_return(nil)
54
+ allow(Scimaenaga.config).to receive(:signing_algorithm).and_return(Scimaenaga::Config::ALGO_NONE)
55
+ end
56
+
57
+ it 'decodes an unsigned token, returning the company attributes' do
58
+ payload = Scimaenaga::Encoder.decode(token)
59
+
60
+ expect(payload).to contain_exactly(['iat', Integer], %w[subdomain test])
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,165 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe ScimPatchOperationGroup do
6
+ let(:op) { 'replace' }
7
+ let(:path) { 'displayName' }
8
+ let(:value) { 'groupA' }
9
+ let(:mutable_attributes_schema) { { displayName: :name } }
10
+ let(:group_member_relation_attribute) { :user_ids }
11
+
12
+ let(:user1) { create(:user) }
13
+ let(:user2) { create(:user) }
14
+ let(:user3) { create(:user) }
15
+ let(:user4) { create(:user) }
16
+ let(:group) { create(:group, users: [user1, user2]) }
17
+
18
+ let(:operation) do
19
+ described_class.new(
20
+ op,
21
+ path,
22
+ value
23
+ )
24
+ end
25
+ context 'replace displayName' do
26
+ it {
27
+ allow(Scimaenaga.config).to(
28
+ receive(:mutable_group_attributes_schema).and_return(mutable_attributes_schema)
29
+ )
30
+ allow(Scimaenaga.config).to(
31
+ receive(:group_member_relation_attribute).and_return(group_member_relation_attribute)
32
+ )
33
+ expect(operation.op).to eq 'replace'
34
+ expect(operation.path_scim).to eq(attribute: path, rest_path: [])
35
+ expect(operation.path_sp).to eq :name
36
+ expect(operation.value).to eq value
37
+
38
+ operation.save(group)
39
+ expect(group.name).to eq value
40
+ }
41
+ end
42
+
43
+ context 'add displayName' do
44
+ let(:op) { 'add' }
45
+ it {
46
+ allow(Scimaenaga.config).to(
47
+ receive(:mutable_group_attributes_schema).and_return(mutable_attributes_schema)
48
+ )
49
+ allow(Scimaenaga.config).to(
50
+ receive(:group_member_relation_attribute).and_return(group_member_relation_attribute)
51
+ )
52
+ expect(operation.op).to eq 'add'
53
+ expect(operation.path_scim).to eq(attribute: path, rest_path: [])
54
+ expect(operation.path_sp).to eq :name
55
+ expect(operation.value).to eq value
56
+
57
+ operation.save(group)
58
+ expect(group.name).to eq value
59
+ }
60
+ end
61
+
62
+ context 'remove displayName' do
63
+ let(:op) { 'remove' }
64
+ it {
65
+ allow(Scimaenaga.config).to(
66
+ receive(:mutable_group_attributes_schema).and_return(mutable_attributes_schema)
67
+ )
68
+ allow(Scimaenaga.config).to(
69
+ receive(:group_member_relation_attribute).and_return(group_member_relation_attribute)
70
+ )
71
+ expect(operation.op).to eq 'remove'
72
+ expect(operation.path_scim).to eq(attribute: path, rest_path: [])
73
+ expect(operation.path_sp).to eq :name
74
+ expect(operation.value).to eq value
75
+
76
+ operation.save(group)
77
+ expect(group.name).to eq nil
78
+ }
79
+ end
80
+
81
+ context 'add member' do
82
+ let(:op) { 'add' }
83
+ let(:path) { 'members' }
84
+ let(:value) { [{ 'value' => user3.id.to_s }, { 'value' => user4.id.to_s }] }
85
+ it {
86
+ allow(Scimaenaga.config).to(
87
+ receive(:mutable_group_attributes_schema).and_return(mutable_attributes_schema)
88
+ )
89
+ allow(Scimaenaga.config).to(
90
+ receive(:group_member_relation_attribute).and_return(group_member_relation_attribute)
91
+ )
92
+ expect(operation.op).to eq 'add'
93
+ expect(operation.path_scim).to eq(attribute: 'members', rest_path: [])
94
+ expect(operation.path_sp).to eq :user_ids
95
+ expect(operation.value).to eq value
96
+
97
+ operation.save(group)
98
+ expect(group.users).to eq [user1, user2, user3, user4]
99
+ }
100
+ end
101
+
102
+ context 'replace member' do
103
+ let(:op) { 'replace' }
104
+ let(:path) { 'members' }
105
+ let(:value) { [{ 'value' => user3.id.to_s }, { 'value' => user4.id.to_s }] }
106
+ it {
107
+ allow(Scimaenaga.config).to(
108
+ receive(:mutable_group_attributes_schema).and_return(mutable_attributes_schema)
109
+ )
110
+ allow(Scimaenaga.config).to(
111
+ receive(:group_member_relation_attribute).and_return(group_member_relation_attribute)
112
+ )
113
+ expect(operation.op).to eq 'replace'
114
+ expect(operation.path_scim).to eq(attribute: 'members', rest_path: [])
115
+ expect(operation.path_sp).to eq :user_ids
116
+ expect(operation.value).to eq value
117
+
118
+ operation.save(group)
119
+ expect(group.users).to eq [user3, user4]
120
+ }
121
+ end
122
+
123
+ context 'remove user ids' do
124
+ let(:op) { 'remove' }
125
+ let(:path) { 'members' }
126
+ let(:value) { [{ 'value' => user1.id.to_s }, { 'value' => user2.id.to_s }] }
127
+ it {
128
+ allow(Scimaenaga.config).to(
129
+ receive(:mutable_group_attributes_schema).and_return(mutable_attributes_schema)
130
+ )
131
+ allow(Scimaenaga.config).to(
132
+ receive(:group_member_relation_attribute).and_return(group_member_relation_attribute)
133
+ )
134
+ expect(operation.op).to eq 'remove'
135
+ expect(operation.path_scim).to eq(attribute: 'members', rest_path: [])
136
+ expect(operation.path_sp).to eq :user_ids
137
+ expect(operation.value).to eq value
138
+
139
+ operation.save(group)
140
+ expect(group.users).to eq []
141
+ }
142
+ end
143
+
144
+ context 'remove user id (with filter)' do
145
+ let(:op) { 'remove' }
146
+ let(:path) { "members[value eq \"#{user1.id}\"]" }
147
+ let(:value) { nil }
148
+ it {
149
+ allow(Scimaenaga.config).to(
150
+ receive(:mutable_group_attributes_schema).and_return(mutable_attributes_schema)
151
+ )
152
+ allow(Scimaenaga.config).to(
153
+ receive(:group_member_relation_attribute).and_return(group_member_relation_attribute)
154
+ )
155
+ expect(operation.op).to eq 'remove'
156
+ expect(operation.path_scim).to eq(attribute: 'members',
157
+ filter: { attribute: 'value', operator: 'eq', parameter: user1.id.to_s }, rest_path: [])
158
+ expect(operation.path_sp).to eq :user_ids
159
+ expect(operation.value).to eq nil
160
+
161
+ operation.save(group)
162
+ expect(group.users).to eq [user2]
163
+ }
164
+ end
165
+ end
@@ -0,0 +1,101 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe ScimPatchOperationUser do
6
+ let(:op) { 'replace' }
7
+ let(:path) { 'userName' }
8
+ let(:value) { 'taro.suzuki' }
9
+ let(:mutable_attributes_schema) do
10
+ {
11
+ userName: :name,
12
+ displayName: :display_name,
13
+ emails: [
14
+ {
15
+ value: :email,
16
+ }
17
+ ],
18
+ name: {
19
+ familyName: :family_name,
20
+ givenName: :given_name,
21
+ },
22
+ active: :active,
23
+ }
24
+ end
25
+
26
+ let(:operation) do
27
+ described_class.new(
28
+ op,
29
+ path,
30
+ value
31
+ )
32
+ end
33
+ describe '#initialize' do
34
+ context 'replace single attribute' do
35
+ it {
36
+ allow(Scimaenaga.config).to(
37
+ receive(:mutable_user_attributes_schema).and_return(mutable_attributes_schema)
38
+ )
39
+ expect(operation.op).to eq 'replace'
40
+ expect(operation.path_scim).to eq(attribute: path, rest_path: [])
41
+ expect(operation.path_sp).to eq :name
42
+ expect(operation.value).to eq value
43
+ }
44
+ end
45
+
46
+ context 'add single attribute' do
47
+ let(:op) { 'add' }
48
+ it {
49
+ allow(Scimaenaga.config).to(
50
+ receive(:mutable_user_attributes_schema).and_return(mutable_attributes_schema)
51
+ )
52
+ expect(operation.op).to eq 'add'
53
+ expect(operation.path_scim).to eq(attribute: path, rest_path: [])
54
+ expect(operation.path_sp).to eq :name
55
+ expect(operation.value).to eq value
56
+ }
57
+ end
58
+
59
+ context 'remove single attribute' do
60
+ let(:op) { 'remove' }
61
+ it {
62
+ allow(Scimaenaga.config).to(
63
+ receive(:mutable_user_attributes_schema).and_return(mutable_attributes_schema)
64
+ )
65
+ expect(operation.op).to eq 'remove'
66
+ expect(operation.path_scim).to eq(attribute: path, rest_path: [])
67
+ expect(operation.path_sp).to eq :name
68
+ expect(operation.value).to eq value
69
+ }
70
+ end
71
+
72
+ context 'replace email address' do
73
+ let(:path) { 'emails[type eq "work"].value' }
74
+ let(:value) { 'taro.suzuki@example.com' }
75
+ it {
76
+ allow(Scimaenaga.config).to(
77
+ receive(:mutable_user_attributes_schema).and_return(mutable_attributes_schema)
78
+ )
79
+ expect(operation.op).to eq 'replace'
80
+ expect(operation.path_scim).to eq(attribute: 'emails',
81
+ filter: { attribute: 'type', operator: 'eq', parameter: 'work' }, rest_path: ['value'])
82
+ expect(operation.path_sp).to eq :email
83
+ expect(operation.value).to eq value
84
+ }
85
+ end
86
+
87
+ context 'replace name.familyName' do
88
+ let(:path) { 'name.familyName' }
89
+ let(:value) { 'Suzuki' }
90
+ it {
91
+ allow(Scimaenaga.config).to(
92
+ receive(:mutable_user_attributes_schema).and_return(mutable_attributes_schema)
93
+ )
94
+ expect(operation.op).to eq 'replace'
95
+ expect(operation.path_scim).to eq(attribute: 'name', rest_path: ['familyName'])
96
+ expect(operation.path_sp).to eq :family_name
97
+ expect(operation.value).to eq value
98
+ }
99
+ end
100
+ end
101
+ end
@@ -3,35 +3,39 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe ScimPatch do
6
- let(:params) do
7
- {
8
- 'schemas' => ['urn:ietf:params:scim:api:messages:2.0:PatchOp'],
9
- 'Operations' => [
10
- {
11
- 'op' => 'Replace',
12
- 'path' => 'userName',
13
- 'value' => 'taro.suzuki',
14
- },
15
- {
16
- 'op' => 'Replace',
17
- 'path' => 'emails[type eq "work"].value',
18
- 'value' => 'taro.suzuki@example.com',
19
- },
20
- {
21
- 'op' => 'Replace',
22
- 'path' => 'name.familyName',
23
- 'value' => 'Suzuki',
24
- },
25
- {
26
- 'op' => 'Replace',
27
- 'path' => 'active',
28
- 'value' => 'False',
29
- }
30
- ],
6
+ shared_examples :user do
7
+ let(:patch) { ScimPatch.new(params, :user) }
8
+ it {
9
+ allow(Scimaenaga.config).to(
10
+ receive(:mutable_user_attributes_schema).and_return(mutable_user_attributes_schema)
11
+ )
12
+
13
+ expect(patch.operations[0].op).to eq 'replace'
14
+ expect(patch.operations[0].path_scim).to eq(attribute: 'emails',
15
+ filter: { attribute: 'type', operator: 'eq', parameter: 'work' }, rest_path: ['value'])
16
+ expect(patch.operations[0].path_sp).to eq :email
17
+ expect(patch.operations[0].value).to eq 'taro.suzuki@example.com'
18
+
19
+ expect(patch.operations[1].op).to eq 'replace'
20
+ expect(patch.operations[1].path_scim).to eq(attribute: 'userName', rest_path: [])
21
+ expect(patch.operations[1].path_sp).to eq :name
22
+ expect(patch.operations[1].value).to eq 'taro.suzuki'
23
+
24
+ expect(patch.operations[2].op).to eq 'replace'
25
+ expect(patch.operations[2].path_scim).to eq(attribute: 'name',
26
+ rest_path: ['familyName'])
27
+ expect(patch.operations[2].path_sp).to eq :family_name
28
+ expect(patch.operations[2].value).to eq 'Suzuki'
29
+
30
+ expect(patch.operations[3].op).to eq 'replace'
31
+ expect(patch.operations[3].path_scim).to eq(attribute: 'active',
32
+ rest_path: [])
33
+ expect(patch.operations[3].path_sp).to eq :active
34
+ expect(patch.operations[3].value).to eq false
31
35
  }
32
36
  end
33
37
 
34
- let(:mutable_attributes_schema) do
38
+ let(:mutable_user_attributes_schema) do
35
39
  {
36
40
  userName: :name,
37
41
  displayName: :display_name,
@@ -48,29 +52,109 @@ describe ScimPatch do
48
52
  }
49
53
  end
50
54
 
51
- let(:patch) { described_class.new(params, mutable_attributes_schema) }
55
+ let(:mutable_group_attributes_schema) do
56
+ {
57
+ displayName: :name,
58
+ }
59
+ end
52
60
 
53
- describe '#initialize' do
54
- it {
55
- expect(patch.operations[0].operations[0].op).to eq :replace
56
- expect(patch.operations[0].operations[0].path_scim).to eq 'userName'
57
- expect(patch.operations[0].operations[0].path_sp).to eq :name
58
- expect(patch.operations[0].operations[0].value).to eq 'taro.suzuki'
61
+ describe '#initialize :user' do
62
+ context :multiple_single_value_operations do
63
+ let(:params) do
64
+ {
65
+ 'schemas' => ['urn:ietf:params:scim:api:messages:2.0:PatchOp'],
66
+ 'Operations' => [
67
+ {
68
+ 'op' => 'Replace',
69
+ 'path' => 'emails[type eq "work"].value',
70
+ 'value' => 'taro.suzuki@example.com',
71
+ },
72
+ {
73
+ 'op' => 'Replace',
74
+ 'path' => 'userName',
75
+ 'value' => 'taro.suzuki',
76
+ },
77
+ {
78
+ 'op' => 'Replace',
79
+ 'path' => 'name.familyName',
80
+ 'value' => 'Suzuki',
81
+ },
82
+ {
83
+ 'op' => 'Replace',
84
+ 'path' => 'active',
85
+ 'value' => 'False',
86
+ }
87
+ ],
88
+ }
89
+ end
90
+ it_behaves_like :user
91
+ end
59
92
 
60
- expect(patch.operations[1].operations[0].op).to eq :replace
61
- expect(patch.operations[1].operations[0].path_scim).to eq 'emails[type eq "work"].value'
62
- expect(patch.operations[1].operations[0].path_sp).to eq :email
63
- expect(patch.operations[1].operations[0].value).to eq 'taro.suzuki@example.com'
93
+ context :multiple_value_operation do
94
+ let(:params) do
95
+ {
96
+ 'schemas' => ['urn:ietf:params:scim:api:messages:2.0:PatchOp'],
97
+ 'Operations' => [
98
+ {
99
+ 'op' => 'replace',
100
+ 'path' => 'emails[type eq "work"].value',
101
+ 'value' => 'taro.suzuki@example.com',
102
+ },
103
+ {
104
+ 'op' => 'replace',
105
+ 'value' => {
106
+ 'userName' => 'taro.suzuki',
107
+ 'name.familyName' => 'Suzuki',
108
+ 'active' => false,
109
+ },
110
+ }
111
+ ],
112
+ }
113
+ end
114
+ it_behaves_like :user
115
+ end
116
+ end
117
+
118
+ describe '#initialize :group' do
119
+ let(:params) do
120
+ {
121
+ 'schemas' => ['urn:ietf:params:scim:api:messages:2.0:PatchOp'],
122
+ 'Operations' => [
123
+ {
124
+ 'op' => 'Replace',
125
+ 'path' => 'displayName',
126
+ 'value' => 'groupA',
127
+ },
128
+ {
129
+ 'op' => 'Add',
130
+ 'path' => 'members',
131
+ 'value' => [
132
+ {
133
+ 'value' => '1',
134
+ },
135
+ {
136
+ 'value' => '2',
137
+ }
138
+ ],
139
+ }
140
+ ],
141
+ }
142
+ end
143
+ let(:patch) { described_class.new(params, :group) }
144
+ it {
145
+ allow(Scimaenaga.config).to(
146
+ receive(:mutable_group_attributes_schema).and_return(mutable_group_attributes_schema)
147
+ )
64
148
 
65
- expect(patch.operations[2].operations[0].op).to eq :replace
66
- expect(patch.operations[2].operations[0].path_scim).to eq 'name.familyName'
67
- expect(patch.operations[2].operations[0].path_sp).to eq :family_name
68
- expect(patch.operations[2].operations[0].value).to eq 'Suzuki'
149
+ expect(patch.operations[0].op).to eq 'replace'
150
+ expect(patch.operations[0].path_scim).to eq(attribute: 'displayName', rest_path: [])
151
+ expect(patch.operations[0].path_sp).to eq :name
152
+ expect(patch.operations[0].value).to eq 'groupA'
69
153
 
70
- expect(patch.operations[3].operations[0].op).to eq :replace
71
- expect(patch.operations[3].operations[0].path_scim).to eq 'active'
72
- expect(patch.operations[3].operations[0].path_sp).to eq :active
73
- expect(patch.operations[3].operations[0].value).to eq false
154
+ expect(patch.operations[1].op).to eq 'add'
155
+ expect(patch.operations[1].path_scim).to eq(attribute: 'members', rest_path: [])
156
+ expect(patch.operations[1].path_sp).to eq :user_ids
157
+ expect(patch.operations[1].value).to eq [{ 'value' => '1' }, { 'value' => '2' }]
74
158
  }
75
159
  end
76
160
 
@@ -2,19 +2,18 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe ScimRails::ScimQueryParser do
6
-
5
+ describe Scimaenaga::ScimQueryParser do
7
6
  let(:query_string) { 'userName eq "taro"' }
8
- let(:queryable_attributes) {
7
+ let(:queryable_attributes) do
9
8
  {
10
9
  userName: :name,
11
10
  emails: [
12
11
  {
13
- value: :email
12
+ value: :email,
14
13
  }
15
- ]
14
+ ],
16
15
  }
17
- }
16
+ end
18
17
  let(:parser) { described_class.new(query_string, queryable_attributes) }
19
18
 
20
19
  describe '#attribute' do