descope 1.1.0 → 1.2.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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yaml +4 -4
  3. data/.github/workflows/publish-gem.yaml +2 -2
  4. data/.github/workflows/release-please.yaml +1 -1
  5. data/.release-please-manifest.json +1 -1
  6. data/.rubocop.yml +1 -1
  7. data/.rubocop_todo.yml +1 -1
  8. data/.ruby-version +1 -1
  9. data/CHANGELOG.md +10 -0
  10. data/Gemfile +5 -5
  11. data/Gemfile.lock +32 -32
  12. data/README.md +233 -1
  13. data/lib/descope/api/v1/auth/enchantedlink.rb +76 -9
  14. data/lib/descope/api/v1/management/access_key.rb +8 -7
  15. data/lib/descope/api/v1/management/analytics.rb +62 -0
  16. data/lib/descope/api/v1/management/audit.rb +2 -2
  17. data/lib/descope/api/v1/management/authz.rb +15 -15
  18. data/lib/descope/api/v1/management/common.rb +76 -0
  19. data/lib/descope/api/v1/management/descoper.rb +45 -0
  20. data/lib/descope/api/v1/management/engine.rb +44 -0
  21. data/lib/descope/api/v1/management/fga.rb +64 -0
  22. data/lib/descope/api/v1/management/flow.rb +5 -5
  23. data/lib/descope/api/v1/management/group.rb +42 -0
  24. data/lib/descope/api/v1/management/jwt_template.rb +49 -0
  25. data/lib/descope/api/v1/management/lists.rb +96 -0
  26. data/lib/descope/api/v1/management/management_key.rb +54 -0
  27. data/lib/descope/api/v1/management/outbound_app.rb +112 -0
  28. data/lib/descope/api/v1/management/password.rb +2 -2
  29. data/lib/descope/api/v1/management/permission.rb +4 -4
  30. data/lib/descope/api/v1/management/project.rb +5 -5
  31. data/lib/descope/api/v1/management/role.rb +5 -5
  32. data/lib/descope/api/v1/management/scim.rb +14 -14
  33. data/lib/descope/api/v1/management/scope_claim_mapping.rb +34 -0
  34. data/lib/descope/api/v1/management/sso_application.rb +7 -7
  35. data/lib/descope/api/v1/management/sso_settings.rb +5 -5
  36. data/lib/descope/api/v1/management/tenant.rb +8 -6
  37. data/lib/descope/api/v1/management/third_party_application.rb +190 -0
  38. data/lib/descope/api/v1/management/user.rb +36 -36
  39. data/lib/descope/api/v1/management.rb +22 -0
  40. data/lib/descope/http_client.rb +30 -0
  41. data/lib/descope/mixins/common.rb +1 -0
  42. data/lib/descope/mixins/http.rb +23 -16
  43. data/lib/descope/mixins/initializer.rb +19 -9
  44. data/lib/descope/mixins/requests.rb +24 -0
  45. data/lib/descope/mixins.rb +2 -1
  46. data/lib/descope/version.rb +1 -1
  47. data/spec/integration/lib.descope/api/v1/management/user_spec.rb +1 -1
  48. data/spec/lib.descope/api/v1/auth/enchantedlink_spec.rb +163 -1
  49. data/spec/lib.descope/api/v1/management/access_key_spec.rb +7 -7
  50. data/spec/lib.descope/api/v1/management/analytics_spec.rb +82 -0
  51. data/spec/lib.descope/api/v1/management/audit_spec.rb +2 -2
  52. data/spec/lib.descope/api/v1/management/authz_spec.rb +16 -16
  53. data/spec/lib.descope/api/v1/management/descoper_spec.rb +101 -0
  54. data/spec/lib.descope/api/v1/management/engine_spec.rb +115 -0
  55. data/spec/lib.descope/api/v1/management/fga_spec.rb +169 -0
  56. data/spec/lib.descope/api/v1/management/flow_spec.rb +5 -5
  57. data/spec/lib.descope/api/v1/management/group_spec.rb +72 -0
  58. data/spec/lib.descope/api/v1/management/jwt_template_spec.rb +103 -0
  59. data/spec/lib.descope/api/v1/management/lists_spec.rb +285 -0
  60. data/spec/lib.descope/api/v1/management/management_key_spec.rb +109 -0
  61. data/spec/lib.descope/api/v1/management/outbound_app_spec.rb +236 -0
  62. data/spec/lib.descope/api/v1/management/password_spec.rb +2 -2
  63. data/spec/lib.descope/api/v1/management/permission_spec.rb +4 -4
  64. data/spec/lib.descope/api/v1/management/project_spec.rb +4 -4
  65. data/spec/lib.descope/api/v1/management/role_spec.rb +5 -5
  66. data/spec/lib.descope/api/v1/management/scim_spec.rb +14 -14
  67. data/spec/lib.descope/api/v1/management/scope_claim_mapping_spec.rb +59 -0
  68. data/spec/lib.descope/api/v1/management/sso_application_spec.rb +6 -6
  69. data/spec/lib.descope/api/v1/management/sso_settings_spec.rb +5 -5
  70. data/spec/lib.descope/api/v1/management/tenant_spec.rb +6 -6
  71. data/spec/lib.descope/api/v1/management/third_party_application_spec.rb +171 -0
  72. data/spec/lib.descope/api/v1/management/user_spec.rb +36 -36
  73. data/spec/lib.descope/auth_management_key_spec.rb +151 -0
  74. data/spec/support/client_config.rb +1 -0
  75. data/spec/support/dummy_class.rb +12 -9
  76. metadata +28 -3
@@ -34,7 +34,7 @@ describe Descope::Api::V1::Management::Authz do
34
34
  }
35
35
  ]
36
36
  }
37
- expect(@instance).to receive(:post).with(
37
+ expect(@instance).to receive(:mgmt_post).with(
38
38
  AUTHZ_SCHEMA_SAVE,
39
39
  {
40
40
  schema: schema,
@@ -53,7 +53,7 @@ describe Descope::Api::V1::Management::Authz do
53
53
  end
54
54
 
55
55
  it 'is expected to delete the schema for the project which will also delete all relations' do
56
- expect(@instance).to receive(:post).with(AUTHZ_SCHEMA_DELETE)
56
+ expect(@instance).to receive(:mgmt_post).with(AUTHZ_SCHEMA_DELETE)
57
57
  expect do
58
58
  @instance.authz_delete_schema
59
59
  end.not_to raise_error
@@ -66,7 +66,7 @@ describe Descope::Api::V1::Management::Authz do
66
66
  end
67
67
 
68
68
  it 'is expected to load the schema for the project' do
69
- expect(@instance).to receive(:post).with(AUTHZ_SCHEMA_LOAD)
69
+ expect(@instance).to receive(:mgmt_post).with(AUTHZ_SCHEMA_LOAD)
70
70
  expect do
71
71
  @instance.authz_load_schema
72
72
  end.not_to raise_error
@@ -79,7 +79,7 @@ describe Descope::Api::V1::Management::Authz do
79
79
  end
80
80
 
81
81
  it 'is expected to create or update the given namespace' do
82
- expect(@instance).to receive(:post).with(
82
+ expect(@instance).to receive(:mgmt_post).with(
83
83
  AUTHZ_NS_SAVE,
84
84
  {
85
85
  namespace: 'test-namespace',
@@ -99,7 +99,7 @@ describe Descope::Api::V1::Management::Authz do
99
99
  end
100
100
 
101
101
  it 'is expected to delete the given namespace' do
102
- expect(@instance).to receive(:post).with(
102
+ expect(@instance).to receive(:mgmt_post).with(
103
103
  AUTHZ_NS_DELETE,
104
104
  {
105
105
  name: 'test-namespace',
@@ -118,7 +118,7 @@ describe Descope::Api::V1::Management::Authz do
118
118
  end
119
119
 
120
120
  it 'is expected to create or update the given relation definition' do
121
- expect(@instance).to receive(:post).with(
121
+ expect(@instance).to receive(:mgmt_post).with(
122
122
  AUTHZ_RD_SAVE,
123
123
  {
124
124
  relationDefinition: 'test-relation-definition',
@@ -144,7 +144,7 @@ describe Descope::Api::V1::Management::Authz do
144
144
  end
145
145
 
146
146
  it 'is expected to delete the given relation definition' do
147
- expect(@instance).to receive(:post).with(
147
+ expect(@instance).to receive(:mgmt_post).with(
148
148
  AUTHZ_RD_DELETE,
149
149
  {
150
150
  name: 'test-relation-definition',
@@ -168,7 +168,7 @@ describe Descope::Api::V1::Management::Authz do
168
168
  end
169
169
 
170
170
  it 'is expected to create the given relation' do
171
- expect(@instance).to receive(:post).with(
171
+ expect(@instance).to receive(:mgmt_post).with(
172
172
  AUTHZ_RE_CREATE,
173
173
  {
174
174
  relations: 'test-relations'
@@ -186,7 +186,7 @@ describe Descope::Api::V1::Management::Authz do
186
186
  end
187
187
 
188
188
  it 'is expected to delete the given relation' do
189
- expect(@instance).to receive(:post).with(
189
+ expect(@instance).to receive(:mgmt_post).with(
190
190
  AUTHZ_RE_DELETE,
191
191
  { relations: [{ resource: 'some-note', relationDefinition: 'owner', namespace: 'note', target: 'some-user' }] }
192
192
  )
@@ -204,7 +204,7 @@ describe Descope::Api::V1::Management::Authz do
204
204
  end
205
205
 
206
206
  it 'is expected to delete the given relations for resources' do
207
- expect(@instance).to receive(:post).with(
207
+ expect(@instance).to receive(:mgmt_post).with(
208
208
  AUTHZ_RE_DELETE_RESOURCES,
209
209
  {
210
210
  resources: 'test-resources'
@@ -222,7 +222,7 @@ describe Descope::Api::V1::Management::Authz do
222
222
  end
223
223
 
224
224
  it 'is expected to return true if the given resource has relations' do
225
- expect(@instance).to receive(:post).with(
225
+ expect(@instance).to receive(:mgmt_post).with(
226
226
  AUTHZ_RE_HAS_RELATIONS,
227
227
  {
228
228
  relationQueries: ['some-query']
@@ -240,7 +240,7 @@ describe Descope::Api::V1::Management::Authz do
240
240
  end
241
241
 
242
242
  it 'is expected to return the list of targets who can access the given resource with the given RD' do
243
- expect(@instance).to receive(:post).with(
243
+ expect(@instance).to receive(:mgmt_post).with(
244
244
  AUTHZ_RE_WHO,
245
245
  {
246
246
  resource: 'test-resource',
@@ -261,7 +261,7 @@ describe Descope::Api::V1::Management::Authz do
261
261
  end
262
262
 
263
263
  it 'is expected to return the list of relations for the given resources' do
264
- expect(@instance).to receive(:post).with(
264
+ expect(@instance).to receive(:mgmt_post).with(
265
265
  AUTHZ_RE_RESOURCE,
266
266
  {
267
267
  resources: ['test-resources']
@@ -279,7 +279,7 @@ describe Descope::Api::V1::Management::Authz do
279
279
  end
280
280
 
281
281
  it 'is expected to return the list of relations for the given targets' do
282
- expect(@instance).to receive(:post).with(
282
+ expect(@instance).to receive(:mgmt_post).with(
283
283
  AUTHZ_RE_TARGETS,
284
284
  {
285
285
  targets: ['test-targets']
@@ -306,7 +306,7 @@ describe Descope::Api::V1::Management::Authz do
306
306
  end
307
307
 
308
308
  before do
309
- allow(@instance).to receive(:post).with(
309
+ allow(@instance).to receive(:mgmt_post).with(
310
310
  AUTHZ_RE_TARGET_ALL,
311
311
  {
312
312
  target: 'test-target'
@@ -319,7 +319,7 @@ describe Descope::Api::V1::Management::Authz do
319
319
  end
320
320
 
321
321
  it 'is expected to return the list of relations for the given target' do
322
- expect(@instance).to receive(:post).with(
322
+ expect(@instance).to receive(:mgmt_post).with(
323
323
  AUTHZ_RE_TARGET_ALL,
324
324
  {
325
325
  target: 'test-target'
@@ -0,0 +1,101 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Descope::Api::V1::Management::Descoper do
6
+ before(:all) do
7
+ dummy_instance = DummyClass.new
8
+ dummy_instance.extend(Descope::Api::V1::Management::Descoper)
9
+ @instance = dummy_instance
10
+ end
11
+
12
+ context '.create_descoper' do
13
+ it 'should respond to .create_descoper' do
14
+ expect(@instance).to respond_to :create_descoper
15
+ end
16
+
17
+ it 'is expected to create the given descopers' do
18
+ expect(@instance).to receive(:mgmt_put).with(
19
+ DESCOPER_CREATE_PATH,
20
+ {
21
+ descopers: [{ name: 'test-descoper' }]
22
+ }
23
+ )
24
+ expect do
25
+ @instance.create_descoper([{ name: 'test-descoper' }])
26
+ end.not_to raise_error
27
+ end
28
+ end
29
+
30
+ context '.update_descoper' do
31
+ it 'should respond to .update_descoper' do
32
+ expect(@instance).to respond_to :update_descoper
33
+ end
34
+
35
+ it 'is expected to update the given descoper' do
36
+ expect(@instance).to receive(:mgmt_patch).with(
37
+ DESCOPER_UPDATE_PATH,
38
+ {
39
+ id: 'test-id',
40
+ attributes: { key: 'value' },
41
+ rbac: { roles: ['admin'] }
42
+ }
43
+ )
44
+ expect do
45
+ @instance.update_descoper(id: 'test-id', attributes: { key: 'value' }, rbac: { roles: ['admin'] })
46
+ end.not_to raise_error
47
+ end
48
+ end
49
+
50
+ context '.get_descoper' do
51
+ it 'should respond to .get_descoper' do
52
+ expect(@instance).to respond_to :get_descoper
53
+ end
54
+
55
+ it 'is expected to get the given descoper by id' do
56
+ expect(@instance).to receive(:mgmt_get).with(
57
+ DESCOPER_GET_PATH,
58
+ {
59
+ id: 'test-id'
60
+ }
61
+ )
62
+ expect do
63
+ @instance.get_descoper(id: 'test-id')
64
+ end.not_to raise_error
65
+ end
66
+ end
67
+
68
+ context '.delete_descoper' do
69
+ it 'should respond to .delete_descoper' do
70
+ expect(@instance).to respond_to :delete_descoper
71
+ end
72
+
73
+ it 'is expected to delete the given descoper by id' do
74
+ expect(@instance).to receive(:mgmt_delete).with(
75
+ DESCOPER_DELETE_PATH,
76
+ {
77
+ id: 'test-id'
78
+ }
79
+ )
80
+ expect do
81
+ @instance.delete_descoper(id: 'test-id')
82
+ end.not_to raise_error
83
+ end
84
+ end
85
+
86
+ context '.search_descopers' do
87
+ it 'should respond to .search_descopers' do
88
+ expect(@instance).to respond_to :search_descopers
89
+ end
90
+
91
+ it 'is expected to search (list) all descopers' do
92
+ expect(@instance).to receive(:mgmt_post).with(
93
+ DESCOPER_SEARCH_PATH,
94
+ {}
95
+ )
96
+ expect do
97
+ @instance.search_descopers
98
+ end.not_to raise_error
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,115 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Descope::Api::V1::Management::Engine do
6
+ before(:all) do
7
+ dummy_instance = DummyClass.new
8
+ dummy_instance.extend(Descope::Api::V1::Management::Engine)
9
+ @instance = dummy_instance
10
+ end
11
+
12
+ context '.create_engine' do
13
+ it 'should respond to .create_engine' do
14
+ expect(@instance).to respond_to :create_engine
15
+ end
16
+
17
+ it 'is expected to create a new engine' do
18
+ expect(@instance).to receive(:mgmt_post).with(
19
+ ENGINE_CREATE_PATH,
20
+ {
21
+ name: 'test-engine'
22
+ }
23
+ )
24
+ expect do
25
+ @instance.create_engine(name: 'test-engine')
26
+ end.not_to raise_error
27
+ end
28
+ end
29
+
30
+ context '.update_engine' do
31
+ it 'should respond to .update_engine' do
32
+ expect(@instance).to respond_to :update_engine
33
+ end
34
+
35
+ it 'is expected to update an existing engine' do
36
+ expect(@instance).to receive(:mgmt_post).with(
37
+ ENGINE_UPDATE_PATH,
38
+ {
39
+ id: 'test-id',
40
+ name: 'test-engine'
41
+ }
42
+ )
43
+ expect do
44
+ @instance.update_engine(id: 'test-id', name: 'test-engine')
45
+ end.not_to raise_error
46
+ end
47
+ end
48
+
49
+ context '.delete_engine' do
50
+ it 'should respond to .delete_engine' do
51
+ expect(@instance).to respond_to :delete_engine
52
+ end
53
+
54
+ it 'is expected to delete an existing engine' do
55
+ expect(@instance).to receive(:mgmt_post).with(
56
+ ENGINE_DELETE_PATH,
57
+ {
58
+ id: 'test-id'
59
+ }
60
+ )
61
+ expect do
62
+ @instance.delete_engine(id: 'test-id')
63
+ end.not_to raise_error
64
+ end
65
+ end
66
+
67
+ context '.load_engine' do
68
+ it 'should respond to .load_engine' do
69
+ expect(@instance).to respond_to :load_engine
70
+ end
71
+
72
+ it 'is expected to load an engine by id' do
73
+ expect(@instance).to receive(:mgmt_get).with(
74
+ ENGINE_LOAD_PATH,
75
+ {
76
+ id: 'test-id'
77
+ }
78
+ )
79
+ expect do
80
+ @instance.load_engine(id: 'test-id')
81
+ end.not_to raise_error
82
+ end
83
+ end
84
+
85
+ context '.load_all_engines' do
86
+ it 'should respond to .load_all_engines' do
87
+ expect(@instance).to respond_to :load_all_engines
88
+ end
89
+
90
+ it 'is expected to load all engines' do
91
+ expect(@instance).to receive(:mgmt_get).with(ENGINE_LOAD_ALL_PATH)
92
+ expect do
93
+ @instance.load_all_engines
94
+ end.not_to raise_error
95
+ end
96
+ end
97
+
98
+ context '.rotate_engine_secret' do
99
+ it 'should respond to .rotate_engine_secret' do
100
+ expect(@instance).to respond_to :rotate_engine_secret
101
+ end
102
+
103
+ it 'is expected to rotate the secret for an engine' do
104
+ expect(@instance).to receive(:mgmt_post).with(
105
+ ENGINE_ROTATE_SECRET_PATH,
106
+ {
107
+ id: 'test-id'
108
+ }
109
+ )
110
+ expect do
111
+ @instance.rotate_engine_secret(id: 'test-id')
112
+ end.not_to raise_error
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,169 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Descope::Api::V1::Management::FGA do
6
+ before(:all) do
7
+ dummy_instance = DummyClass.new
8
+ dummy_instance.extend(Descope::Api::V1::Management::FGA)
9
+ @instance = dummy_instance
10
+ end
11
+
12
+ context '.fga_save_schema' do
13
+ it 'should respond to .fga_save_schema' do
14
+ expect(@instance).to respond_to :fga_save_schema
15
+ end
16
+
17
+ it 'is expected to save the FGA schema' do
18
+ schema = 'model AuthZ 1.0\ntype user\ntype doc\n relation owner: user'
19
+ expect(@instance).to receive(:mgmt_post).with(
20
+ FGA_SAVE_SCHEMA_PATH,
21
+ { dsl: schema }
22
+ )
23
+ expect do
24
+ @instance.fga_save_schema(schema: schema)
25
+ end.not_to raise_error
26
+ end
27
+ end
28
+
29
+ context '.fga_load_schema' do
30
+ it 'should respond to .fga_load_schema' do
31
+ expect(@instance).to respond_to :fga_load_schema
32
+ end
33
+
34
+ it 'is expected to load the FGA schema' do
35
+ expect(@instance).to receive(:mgmt_get).with(FGA_LOAD_SCHEMA_PATH)
36
+ expect do
37
+ @instance.fga_load_schema
38
+ end.not_to raise_error
39
+ end
40
+ end
41
+
42
+ context '.fga_create_relations' do
43
+ it 'should respond to .fga_create_relations' do
44
+ expect(@instance).to respond_to :fga_create_relations
45
+ end
46
+
47
+ it 'is expected to create the given relations' do
48
+ tuples = [{ resource: 'doc1', relation: 'owner', target: 'user1' }]
49
+ expect(@instance).to receive(:mgmt_post).with(
50
+ FGA_CREATE_RELATIONS_PATH,
51
+ { tuples: tuples }
52
+ )
53
+ expect do
54
+ @instance.fga_create_relations(tuples: tuples)
55
+ end.not_to raise_error
56
+ end
57
+ end
58
+
59
+ context '.fga_delete_relations' do
60
+ it 'should respond to .fga_delete_relations' do
61
+ expect(@instance).to respond_to :fga_delete_relations
62
+ end
63
+
64
+ it 'is expected to delete the given relations' do
65
+ tuples = [{ resource: 'doc1', relation: 'owner', target: 'user1' }]
66
+ expect(@instance).to receive(:mgmt_post).with(
67
+ FGA_DELETE_RELATIONS_PATH,
68
+ { tuples: tuples }
69
+ )
70
+ expect do
71
+ @instance.fga_delete_relations(tuples: tuples)
72
+ end.not_to raise_error
73
+ end
74
+ end
75
+
76
+ context '.fga_check' do
77
+ it 'should respond to .fga_check' do
78
+ expect(@instance).to respond_to :fga_check
79
+ end
80
+
81
+ it 'is expected to check the given relations' do
82
+ tuples = [{ resource: 'doc1', relation: 'owner', target: 'user1' }]
83
+ expect(@instance).to receive(:mgmt_post).with(
84
+ FGA_CHECK_PATH,
85
+ { tuples: tuples }
86
+ )
87
+ expect do
88
+ @instance.fga_check(tuples: tuples)
89
+ end.not_to raise_error
90
+ end
91
+ end
92
+
93
+ context '.fga_load_mappable_schema' do
94
+ it 'should respond to .fga_load_mappable_schema' do
95
+ expect(@instance).to respond_to :fga_load_mappable_schema
96
+ end
97
+
98
+ it 'is expected to load the mappable schema for the given tenant' do
99
+ expect(@instance).to receive(:mgmt_get).with(
100
+ FGA_LOAD_MAPPABLE_SCHEMA_PATH,
101
+ { tenantId: 'tenant-1' }
102
+ )
103
+ expect do
104
+ @instance.fga_load_mappable_schema(tenant_id: 'tenant-1')
105
+ end.not_to raise_error
106
+ end
107
+
108
+ it 'is expected to include resourcesLimit when options are given' do
109
+ expect(@instance).to receive(:mgmt_get).with(
110
+ FGA_LOAD_MAPPABLE_SCHEMA_PATH,
111
+ { tenantId: 'tenant-1', resourcesLimit: 10 }
112
+ )
113
+ expect do
114
+ @instance.fga_load_mappable_schema(tenant_id: 'tenant-1', options: { resourcesLimit: 10 })
115
+ end.not_to raise_error
116
+ end
117
+ end
118
+
119
+ context '.fga_search_mappable_resources' do
120
+ it 'should respond to .fga_search_mappable_resources' do
121
+ expect(@instance).to respond_to :fga_search_mappable_resources
122
+ end
123
+
124
+ it 'is expected to search for mappable resources for the given tenant' do
125
+ resources_queries = [{ resourceType: 'doc' }]
126
+ expect(@instance).to receive(:mgmt_post).with(
127
+ FGA_SEARCH_MAPPABLE_RESOURCES_PATH,
128
+ { tenantId: 'tenant-1', resourcesQueries: resources_queries }
129
+ )
130
+ expect do
131
+ @instance.fga_search_mappable_resources(tenant_id: 'tenant-1', resources_queries: resources_queries)
132
+ end.not_to raise_error
133
+ end
134
+ end
135
+
136
+ context '.fga_load_resources_details' do
137
+ it 'should respond to .fga_load_resources_details' do
138
+ expect(@instance).to respond_to :fga_load_resources_details
139
+ end
140
+
141
+ it 'is expected to load the details of the given resource identifiers' do
142
+ resource_identifiers = [{ resourceId: 'doc1', resourceType: 'doc' }]
143
+ expect(@instance).to receive(:mgmt_post).with(
144
+ FGA_RESOURCES_LOAD_PATH,
145
+ { resourceIdentifiers: resource_identifiers }
146
+ )
147
+ expect do
148
+ @instance.fga_load_resources_details(resource_identifiers: resource_identifiers)
149
+ end.not_to raise_error
150
+ end
151
+ end
152
+
153
+ context '.fga_save_resources_details' do
154
+ it 'should respond to .fga_save_resources_details' do
155
+ expect(@instance).to respond_to :fga_save_resources_details
156
+ end
157
+
158
+ it 'is expected to save the details of the given resources' do
159
+ resources_details = [{ resourceId: 'doc1', resourceType: 'doc', displayName: 'Document 1' }]
160
+ expect(@instance).to receive(:mgmt_post).with(
161
+ FGA_RESOURCES_SAVE_PATH,
162
+ { resourcesDetails: resources_details }
163
+ )
164
+ expect do
165
+ @instance.fga_save_resources_details(resources_details: resources_details)
166
+ end.not_to raise_error
167
+ end
168
+ end
169
+ end
@@ -15,7 +15,7 @@ describe Descope::Api::V1::Management::Flow do
15
15
  end
16
16
 
17
17
  it 'is expected to get flows' do
18
- expect(@instance).to receive(:post).with(FLOW_LIST_PATH, { ids: %w[123 456] })
18
+ expect(@instance).to receive(:mgmt_post).with(FLOW_LIST_PATH, { ids: %w[123 456] })
19
19
  expect { @instance.list_or_search_flows(%w[123 456]) }.not_to raise_error
20
20
  end
21
21
  end
@@ -26,7 +26,7 @@ describe Descope::Api::V1::Management::Flow do
26
26
  end
27
27
 
28
28
  it 'is expected to export flow' do
29
- expect(@instance).to receive(:post).with(FLOW_EXPORT_PATH, { flowId: '123' })
29
+ expect(@instance).to receive(:mgmt_post).with(FLOW_EXPORT_PATH, { flowId: '123' })
30
30
  expect { @instance.export_flow('123') }.not_to raise_error
31
31
  end
32
32
  end
@@ -37,7 +37,7 @@ describe Descope::Api::V1::Management::Flow do
37
37
  end
38
38
 
39
39
  it 'is expected to import flow' do
40
- expect(@instance).to receive(:post).with(
40
+ expect(@instance).to receive(:mgmt_post).with(
41
41
  FLOW_IMPORT_PATH, {
42
42
  flowId: '123',
43
43
  flow: 'flow',
@@ -60,7 +60,7 @@ describe Descope::Api::V1::Management::Flow do
60
60
  end
61
61
 
62
62
  it 'is expected to export theme' do
63
- expect(@instance).to receive(:post).with(THEME_EXPORT_PATH)
63
+ expect(@instance).to receive(:mgmt_post).with(THEME_EXPORT_PATH)
64
64
  expect { @instance.export_theme }.not_to raise_error
65
65
  end
66
66
  end
@@ -71,7 +71,7 @@ describe Descope::Api::V1::Management::Flow do
71
71
  end
72
72
 
73
73
  it 'is expected to import theme' do
74
- expect(@instance).to receive(:post).with(THEME_IMPORT_PATH, { theme: 'theme123' })
74
+ expect(@instance).to receive(:mgmt_post).with(THEME_IMPORT_PATH, { theme: 'theme123' })
75
75
  expect { @instance.import_theme('theme123') }.not_to raise_error
76
76
  end
77
77
  end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Descope::Api::V1::Management::Group do
6
+ before(:all) do
7
+ dummy_instance = DummyClass.new
8
+ dummy_instance.extend(Descope::Api::V1::Management::Group)
9
+ @instance = dummy_instance
10
+ end
11
+
12
+ context '.load_all_groups' do
13
+ it 'should respond to .load_all_groups' do
14
+ expect(@instance).to respond_to :load_all_groups
15
+ end
16
+
17
+ it 'is expected to load all groups for a given tenant id' do
18
+ expect(@instance).to receive(:mgmt_post).with(
19
+ GROUP_LOAD_ALL_PATH,
20
+ {
21
+ tenantId: 'tenant-id'
22
+ }
23
+ )
24
+ expect do
25
+ @instance.load_all_groups(tenant_id: 'tenant-id')
26
+ end.not_to raise_error
27
+ end
28
+ end
29
+
30
+ context '.load_all_groups_for_members' do
31
+ it 'should respond to .load_all_groups_for_members' do
32
+ expect(@instance).to respond_to :load_all_groups_for_members
33
+ end
34
+
35
+ it 'is expected to load all groups for the given user and login ids' do
36
+ expect(@instance).to receive(:mgmt_post).with(
37
+ GROUP_LOAD_ALL_FOR_MEMBER_PATH,
38
+ {
39
+ tenantId: 'tenant-id',
40
+ loginIds: ['login-id'],
41
+ userIds: ['user-id']
42
+ }
43
+ )
44
+ expect do
45
+ @instance.load_all_groups_for_members(
46
+ tenant_id: 'tenant-id',
47
+ user_ids: ['user-id'],
48
+ login_ids: ['login-id']
49
+ )
50
+ end.not_to raise_error
51
+ end
52
+ end
53
+
54
+ context '.load_all_group_members' do
55
+ it 'should respond to .load_all_group_members' do
56
+ expect(@instance).to respond_to :load_all_group_members
57
+ end
58
+
59
+ it 'is expected to load all members of the given group id' do
60
+ expect(@instance).to receive(:mgmt_post).with(
61
+ GROUP_LOAD_ALL_GROUP_MEMBERS_PATH,
62
+ {
63
+ tenantId: 'tenant-id',
64
+ groupId: 'group-id'
65
+ }
66
+ )
67
+ expect do
68
+ @instance.load_all_group_members(tenant_id: 'tenant-id', group_id: 'group-id')
69
+ end.not_to raise_error
70
+ end
71
+ end
72
+ end