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
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Descope::Api::V1::Management::JWTTemplate do
6
+ before(:all) do
7
+ dummy_instance = DummyClass.new
8
+ dummy_instance.extend(Descope::Api::V1::Management::JWTTemplate)
9
+ @instance = dummy_instance
10
+ end
11
+
12
+ context '.create_jwt_template' do
13
+ it 'should respond to .create_jwt_template' do
14
+ expect(@instance).to respond_to :create_jwt_template
15
+ end
16
+
17
+ it 'is expected to create a new JWT template' do
18
+ template = {
19
+ name: 'name-of-template',
20
+ description: 'description of the template',
21
+ template: 'the template body',
22
+ conformanceIssuer: true,
23
+ authSchema: 'default'
24
+ }
25
+ expect(@instance).to receive(:mgmt_post).with(
26
+ JWT_TEMPLATE_CREATE_PATH,
27
+ { template: template }
28
+ )
29
+ expect do
30
+ @instance.create_jwt_template(template: template)
31
+ end.not_to raise_error
32
+ end
33
+ end
34
+
35
+ context '.update_jwt_template' do
36
+ it 'should respond to .update_jwt_template' do
37
+ expect(@instance).to respond_to :update_jwt_template
38
+ end
39
+
40
+ it 'is expected to update an existing JWT template' do
41
+ template = {
42
+ id: 'template-id',
43
+ name: 'name-of-template',
44
+ template: 'the template body'
45
+ }
46
+ expect(@instance).to receive(:mgmt_post).with(
47
+ JWT_TEMPLATE_UPDATE_PATH,
48
+ { template: template }
49
+ )
50
+ expect do
51
+ @instance.update_jwt_template(template: template)
52
+ end.not_to raise_error
53
+ end
54
+ end
55
+
56
+ context '.delete_jwt_template' do
57
+ it 'should respond to .delete_jwt_template' do
58
+ expect(@instance).to respond_to :delete_jwt_template
59
+ end
60
+
61
+ it 'is expected to delete the given JWT template' do
62
+ expect(@instance).to receive(:mgmt_post).with(
63
+ JWT_TEMPLATE_DELETE_PATH,
64
+ { id: 'template-id' }
65
+ )
66
+ expect do
67
+ @instance.delete_jwt_template(id: 'template-id')
68
+ end.not_to raise_error
69
+ end
70
+ end
71
+
72
+ context '.list_jwt_templates' do
73
+ it 'should respond to .list_jwt_templates' do
74
+ expect(@instance).to respond_to :list_jwt_templates
75
+ end
76
+
77
+ it 'is expected to list all JWT templates' do
78
+ expect(@instance).to receive(:mgmt_post).with(
79
+ JWT_TEMPLATE_LIST_PATH,
80
+ {}
81
+ )
82
+ expect do
83
+ @instance.list_jwt_templates
84
+ end.not_to raise_error
85
+ end
86
+ end
87
+
88
+ context '.load_jwt_template' do
89
+ it 'should respond to .load_jwt_template' do
90
+ expect(@instance).to respond_to :load_jwt_template
91
+ end
92
+
93
+ it 'is expected to load the given JWT template' do
94
+ expect(@instance).to receive(:mgmt_post).with(
95
+ JWT_TEMPLATE_LOAD_PATH,
96
+ { id: 'template-id' }
97
+ )
98
+ expect do
99
+ @instance.load_jwt_template(id: 'template-id')
100
+ end.not_to raise_error
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,285 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Descope::Api::V1::Management::Lists do
6
+ before(:all) do
7
+ dummy_instance = DummyClass.new
8
+ dummy_instance.extend(Descope::Api::V1::Management::Lists)
9
+ @instance = dummy_instance
10
+ end
11
+
12
+ context '.create_list' do
13
+ it 'should respond to .create_list' do
14
+ expect(@instance).to respond_to :create_list
15
+ end
16
+
17
+ it 'is expected to create a new list' do
18
+ expect(@instance).to receive(:mgmt_post).with(
19
+ LIST_CREATE_PATH,
20
+ {
21
+ name: 'test-list',
22
+ type: 'ip',
23
+ description: 'test description',
24
+ data: { 'foo' => 'bar' }
25
+ }
26
+ )
27
+ expect do
28
+ @instance.create_list(
29
+ name: 'test-list',
30
+ type: 'ip',
31
+ description: 'test description',
32
+ data: { 'foo' => 'bar' }
33
+ )
34
+ end.not_to raise_error
35
+ end
36
+
37
+ it 'is expected to create a new list without optional fields' do
38
+ expect(@instance).to receive(:mgmt_post).with(
39
+ LIST_CREATE_PATH,
40
+ { name: 'test-list', type: 'ip' }
41
+ )
42
+ expect do
43
+ @instance.create_list(name: 'test-list', type: 'ip')
44
+ end.not_to raise_error
45
+ end
46
+ end
47
+
48
+ context '.update_list' do
49
+ it 'should respond to .update_list' do
50
+ expect(@instance).to respond_to :update_list
51
+ end
52
+
53
+ it 'is expected to update an existing list' do
54
+ expect(@instance).to receive(:mgmt_post).with(
55
+ LIST_UPDATE_PATH,
56
+ {
57
+ id: 'test-id',
58
+ name: 'test-list',
59
+ type: 'ip',
60
+ description: 'test description',
61
+ data: { 'foo' => 'bar' }
62
+ }
63
+ )
64
+ expect do
65
+ @instance.update_list(
66
+ id: 'test-id',
67
+ name: 'test-list',
68
+ type: 'ip',
69
+ description: 'test description',
70
+ data: { 'foo' => 'bar' }
71
+ )
72
+ end.not_to raise_error
73
+ end
74
+ end
75
+
76
+ context '.delete_list' do
77
+ it 'should respond to .delete_list' do
78
+ expect(@instance).to respond_to :delete_list
79
+ end
80
+
81
+ it 'is expected to delete an existing list' do
82
+ expect(@instance).to receive(:mgmt_post).with(
83
+ LIST_DELETE_PATH,
84
+ { id: 'test-id' }
85
+ )
86
+ expect do
87
+ @instance.delete_list(id: 'test-id')
88
+ end.not_to raise_error
89
+ end
90
+ end
91
+
92
+ context '.load_list' do
93
+ it 'should respond to .load_list' do
94
+ expect(@instance).to respond_to :load_list
95
+ end
96
+
97
+ it 'is expected to load a list by id' do
98
+ expect(@instance).to receive(:mgmt_get).with("#{LIST_LOAD_PATH}/test-id")
99
+ expect do
100
+ @instance.load_list(id: 'test-id')
101
+ end.not_to raise_error
102
+ end
103
+ end
104
+
105
+ context '.load_list_by_name' do
106
+ it 'should respond to .load_list_by_name' do
107
+ expect(@instance).to respond_to :load_list_by_name
108
+ end
109
+
110
+ it 'is expected to load a list by name' do
111
+ expect(@instance).to receive(:mgmt_get).with("#{LIST_LOAD_BY_NAME_PATH}/test-list")
112
+ expect do
113
+ @instance.load_list_by_name(name: 'test-list')
114
+ end.not_to raise_error
115
+ end
116
+ end
117
+
118
+ context '.load_all_lists' do
119
+ it 'should respond to .load_all_lists' do
120
+ expect(@instance).to respond_to :load_all_lists
121
+ end
122
+
123
+ it 'is expected to load all lists' do
124
+ expect(@instance).to receive(:mgmt_get).with(LIST_LOAD_ALL_PATH)
125
+ expect do
126
+ @instance.load_all_lists
127
+ end.not_to raise_error
128
+ end
129
+ end
130
+
131
+ context '.import_lists' do
132
+ it 'should respond to .import_lists' do
133
+ expect(@instance).to respond_to :import_lists
134
+ end
135
+
136
+ it 'is expected to import the given lists' do
137
+ lists = [{ name: 'test-list', type: 'ip' }]
138
+ expect(@instance).to receive(:mgmt_post).with(
139
+ LIST_IMPORT_PATH,
140
+ { lists: }
141
+ )
142
+ expect do
143
+ @instance.import_lists(lists:)
144
+ end.not_to raise_error
145
+ end
146
+ end
147
+
148
+ context '.list_add_ips' do
149
+ it 'should respond to .list_add_ips' do
150
+ expect(@instance).to respond_to :list_add_ips
151
+ end
152
+
153
+ it 'is expected to add the given IPs to the list' do
154
+ expect(@instance).to receive(:mgmt_post).with(
155
+ LIST_ADD_IPS_PATH,
156
+ { id: 'test-id', ips: ['1.2.3.4'] }
157
+ )
158
+ expect do
159
+ @instance.list_add_ips(id: 'test-id', ips: ['1.2.3.4'])
160
+ end.not_to raise_error
161
+ end
162
+ end
163
+
164
+ context '.list_remove_ips' do
165
+ it 'should respond to .list_remove_ips' do
166
+ expect(@instance).to respond_to :list_remove_ips
167
+ end
168
+
169
+ it 'is expected to remove the given IPs from the list' do
170
+ expect(@instance).to receive(:mgmt_post).with(
171
+ LIST_REMOVE_IPS_PATH,
172
+ { id: 'test-id', ips: ['1.2.3.4'] }
173
+ )
174
+ expect do
175
+ @instance.list_remove_ips(id: 'test-id', ips: ['1.2.3.4'])
176
+ end.not_to raise_error
177
+ end
178
+ end
179
+
180
+ context '.list_check_ip' do
181
+ it 'should respond to .list_check_ip' do
182
+ expect(@instance).to respond_to :list_check_ip
183
+ end
184
+
185
+ it 'is expected to check whether the given IP exists in the list' do
186
+ expect(@instance).to receive(:mgmt_post).with(
187
+ LIST_CHECK_IP_PATH,
188
+ { id: 'test-id', ip: '1.2.3.4' }
189
+ )
190
+ expect do
191
+ @instance.list_check_ip(id: 'test-id', ip: '1.2.3.4')
192
+ end.not_to raise_error
193
+ end
194
+ end
195
+
196
+ context '.list_add_texts' do
197
+ it 'should respond to .list_add_texts' do
198
+ expect(@instance).to respond_to :list_add_texts
199
+ end
200
+
201
+ it 'is expected to add the given texts to the list' do
202
+ expect(@instance).to receive(:mgmt_post).with(
203
+ LIST_ADD_TEXTS_PATH,
204
+ { id: 'test-id', texts: ['some-text'] }
205
+ )
206
+ expect do
207
+ @instance.list_add_texts(id: 'test-id', texts: ['some-text'])
208
+ end.not_to raise_error
209
+ end
210
+ end
211
+
212
+ context '.list_remove_texts' do
213
+ it 'should respond to .list_remove_texts' do
214
+ expect(@instance).to respond_to :list_remove_texts
215
+ end
216
+
217
+ it 'is expected to remove the given texts from the list' do
218
+ expect(@instance).to receive(:mgmt_post).with(
219
+ LIST_REMOVE_TEXTS_PATH,
220
+ { id: 'test-id', texts: ['some-text'] }
221
+ )
222
+ expect do
223
+ @instance.list_remove_texts(id: 'test-id', texts: ['some-text'])
224
+ end.not_to raise_error
225
+ end
226
+ end
227
+
228
+ context '.list_check_text' do
229
+ it 'should respond to .list_check_text' do
230
+ expect(@instance).to respond_to :list_check_text
231
+ end
232
+
233
+ it 'is expected to check whether the given text exists in the list' do
234
+ expect(@instance).to receive(:mgmt_post).with(
235
+ LIST_CHECK_TEXT_PATH,
236
+ { id: 'test-id', text: 'some-text' }
237
+ )
238
+ expect do
239
+ @instance.list_check_text(id: 'test-id', text: 'some-text')
240
+ end.not_to raise_error
241
+ end
242
+ end
243
+
244
+ context '.list_check_texts' do
245
+ it 'should respond to .list_check_texts' do
246
+ expect(@instance).to respond_to :list_check_texts
247
+ end
248
+
249
+ it 'is expected to check whether any of the given texts exist in the list by default' do
250
+ expect(@instance).to receive(:mgmt_post).with(
251
+ LIST_CHECK_TEXT_PATH,
252
+ { id: 'test-id', texts: %w[text-1 text-2], matchAll: false }
253
+ )
254
+ expect do
255
+ @instance.list_check_texts(id: 'test-id', texts: %w[text-1 text-2])
256
+ end.not_to raise_error
257
+ end
258
+
259
+ it 'is expected to check whether all of the given texts exist in the list when match_all is set' do
260
+ expect(@instance).to receive(:mgmt_post).with(
261
+ LIST_CHECK_TEXT_PATH,
262
+ { id: 'test-id', texts: %w[text-1 text-2], matchAll: true }
263
+ )
264
+ expect do
265
+ @instance.list_check_texts(id: 'test-id', texts: %w[text-1 text-2], match_all: true)
266
+ end.not_to raise_error
267
+ end
268
+ end
269
+
270
+ context '.clear_list' do
271
+ it 'should respond to .clear_list' do
272
+ expect(@instance).to respond_to :clear_list
273
+ end
274
+
275
+ it 'is expected to clear all entries from the list' do
276
+ expect(@instance).to receive(:mgmt_post).with(
277
+ LIST_CLEAR_PATH,
278
+ { id: 'test-id' }
279
+ )
280
+ expect do
281
+ @instance.clear_list(id: 'test-id')
282
+ end.not_to raise_error
283
+ end
284
+ end
285
+ end
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Descope::Api::V1::Management::ManagementKey do
6
+ before(:all) do
7
+ dummy_instance = DummyClass.new
8
+ dummy_instance.extend(Descope::Api::V1::Management::ManagementKey)
9
+ @instance = dummy_instance
10
+ end
11
+
12
+ context '.create_management_key' do
13
+ it 'should respond to .create_management_key' do
14
+ expect(@instance).to respond_to :create_management_key
15
+ end
16
+
17
+ it 'is expected to create a management key' do
18
+ expect(@instance).to receive(:mgmt_put).with(
19
+ MGMT_KEY_CREATE_PATH, {
20
+ name: 'test',
21
+ description: 'test key',
22
+ expiresIn: 0,
23
+ permittedIps: ['1.2.3.4'],
24
+ reBac: { 'k1': 'v1' }
25
+ }
26
+ )
27
+ expect do
28
+ @instance.create_management_key(
29
+ name: 'test',
30
+ description: 'test key',
31
+ expires_in: 0,
32
+ permitted_ips: ['1.2.3.4'],
33
+ re_bac: { 'k1': 'v1' }
34
+ )
35
+ end.not_to raise_error
36
+ end
37
+ end
38
+
39
+ context '.update_management_key' do
40
+ it 'should respond to .update_management_key' do
41
+ expect(@instance).to respond_to :update_management_key
42
+ end
43
+
44
+ it 'is expected to update a management key' do
45
+ expect(@instance).to receive(:mgmt_patch).with(
46
+ MGMT_KEY_UPDATE_PATH, {
47
+ id: '123',
48
+ name: 'test1',
49
+ description: 'updated',
50
+ permittedIps: ['1.2.3.4'],
51
+ status: 'active'
52
+ }
53
+ )
54
+ expect do
55
+ @instance.update_management_key(
56
+ id: '123',
57
+ name: 'test1',
58
+ description: 'updated',
59
+ permitted_ips: ['1.2.3.4'],
60
+ status: 'active'
61
+ )
62
+ end.not_to raise_error
63
+ end
64
+ end
65
+
66
+ context '.get_management_key' do
67
+ it 'should respond to .get_management_key' do
68
+ expect(@instance).to respond_to :get_management_key
69
+ end
70
+
71
+ it 'is expected to get a management key' do
72
+ expect(@instance).to receive(:mgmt_get).with(
73
+ MGMT_KEY_GET_PATH, { id: '123' }
74
+ )
75
+ expect { @instance.get_management_key(id: '123') }.not_to raise_error
76
+ end
77
+ end
78
+
79
+ context '.delete_management_key' do
80
+ it 'should respond to .delete_management_key' do
81
+ expect(@instance).to respond_to :delete_management_key
82
+ end
83
+
84
+ it 'is expected to delete a management key' do
85
+ expect(@instance).to receive(:mgmt_post).with(
86
+ MGMT_KEY_DELETE_PATH, { ids: ['123'] }
87
+ )
88
+ expect { @instance.delete_management_key(id: '123') }.not_to raise_error
89
+ end
90
+ end
91
+
92
+ context '.search_management_keys' do
93
+ it 'should respond to .search_management_keys' do
94
+ expect(@instance).to respond_to :search_management_keys
95
+ end
96
+
97
+ it 'is expected to search management keys' do
98
+ expect(@instance).to receive(:mgmt_get).with(
99
+ MGMT_KEY_SEARCH_PATH, {
100
+ tenantIds: %w[123 456],
101
+ status: 'active'
102
+ }
103
+ )
104
+ expect do
105
+ @instance.search_management_keys(tenant_ids: %w[123 456], status: 'active')
106
+ end.not_to raise_error
107
+ end
108
+ end
109
+ end