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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yaml +4 -4
- data/.github/workflows/publish-gem.yaml +2 -2
- data/.github/workflows/release-please.yaml +1 -1
- data/.release-please-manifest.json +1 -1
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +1 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +10 -0
- data/Gemfile +5 -5
- data/Gemfile.lock +32 -32
- data/README.md +233 -1
- data/lib/descope/api/v1/auth/enchantedlink.rb +76 -9
- data/lib/descope/api/v1/management/access_key.rb +8 -7
- data/lib/descope/api/v1/management/analytics.rb +62 -0
- data/lib/descope/api/v1/management/audit.rb +2 -2
- data/lib/descope/api/v1/management/authz.rb +15 -15
- data/lib/descope/api/v1/management/common.rb +76 -0
- data/lib/descope/api/v1/management/descoper.rb +45 -0
- data/lib/descope/api/v1/management/engine.rb +44 -0
- data/lib/descope/api/v1/management/fga.rb +64 -0
- data/lib/descope/api/v1/management/flow.rb +5 -5
- data/lib/descope/api/v1/management/group.rb +42 -0
- data/lib/descope/api/v1/management/jwt_template.rb +49 -0
- data/lib/descope/api/v1/management/lists.rb +96 -0
- data/lib/descope/api/v1/management/management_key.rb +54 -0
- data/lib/descope/api/v1/management/outbound_app.rb +112 -0
- data/lib/descope/api/v1/management/password.rb +2 -2
- data/lib/descope/api/v1/management/permission.rb +4 -4
- data/lib/descope/api/v1/management/project.rb +5 -5
- data/lib/descope/api/v1/management/role.rb +5 -5
- data/lib/descope/api/v1/management/scim.rb +14 -14
- data/lib/descope/api/v1/management/scope_claim_mapping.rb +34 -0
- data/lib/descope/api/v1/management/sso_application.rb +7 -7
- data/lib/descope/api/v1/management/sso_settings.rb +5 -5
- data/lib/descope/api/v1/management/tenant.rb +8 -6
- data/lib/descope/api/v1/management/third_party_application.rb +190 -0
- data/lib/descope/api/v1/management/user.rb +36 -36
- data/lib/descope/api/v1/management.rb +22 -0
- data/lib/descope/http_client.rb +30 -0
- data/lib/descope/mixins/common.rb +1 -0
- data/lib/descope/mixins/http.rb +23 -16
- data/lib/descope/mixins/initializer.rb +19 -9
- data/lib/descope/mixins/requests.rb +24 -0
- data/lib/descope/mixins.rb +2 -1
- data/lib/descope/version.rb +1 -1
- data/spec/integration/lib.descope/api/v1/management/user_spec.rb +1 -1
- data/spec/lib.descope/api/v1/auth/enchantedlink_spec.rb +163 -1
- data/spec/lib.descope/api/v1/management/access_key_spec.rb +7 -7
- data/spec/lib.descope/api/v1/management/analytics_spec.rb +82 -0
- data/spec/lib.descope/api/v1/management/audit_spec.rb +2 -2
- data/spec/lib.descope/api/v1/management/authz_spec.rb +16 -16
- data/spec/lib.descope/api/v1/management/descoper_spec.rb +101 -0
- data/spec/lib.descope/api/v1/management/engine_spec.rb +115 -0
- data/spec/lib.descope/api/v1/management/fga_spec.rb +169 -0
- data/spec/lib.descope/api/v1/management/flow_spec.rb +5 -5
- data/spec/lib.descope/api/v1/management/group_spec.rb +72 -0
- data/spec/lib.descope/api/v1/management/jwt_template_spec.rb +103 -0
- data/spec/lib.descope/api/v1/management/lists_spec.rb +285 -0
- data/spec/lib.descope/api/v1/management/management_key_spec.rb +109 -0
- data/spec/lib.descope/api/v1/management/outbound_app_spec.rb +236 -0
- data/spec/lib.descope/api/v1/management/password_spec.rb +2 -2
- data/spec/lib.descope/api/v1/management/permission_spec.rb +4 -4
- data/spec/lib.descope/api/v1/management/project_spec.rb +4 -4
- data/spec/lib.descope/api/v1/management/role_spec.rb +5 -5
- data/spec/lib.descope/api/v1/management/scim_spec.rb +14 -14
- data/spec/lib.descope/api/v1/management/scope_claim_mapping_spec.rb +59 -0
- data/spec/lib.descope/api/v1/management/sso_application_spec.rb +6 -6
- data/spec/lib.descope/api/v1/management/sso_settings_spec.rb +5 -5
- data/spec/lib.descope/api/v1/management/tenant_spec.rb +6 -6
- data/spec/lib.descope/api/v1/management/third_party_application_spec.rb +171 -0
- data/spec/lib.descope/api/v1/management/user_spec.rb +36 -36
- data/spec/lib.descope/auth_management_key_spec.rb +151 -0
- data/spec/support/client_config.rb +1 -0
- data/spec/support/dummy_class.rb +12 -9
- metadata +28 -3
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Descope::Api::V1::Management::OutboundApp do
|
|
6
|
+
before(:all) do
|
|
7
|
+
dummy_instance = DummyClass.new
|
|
8
|
+
dummy_instance.extend(Descope::Api::V1::Management::OutboundApp)
|
|
9
|
+
@instance = dummy_instance
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe '.fetch_outbound_app_user_token' do
|
|
13
|
+
let(:mock_response) do
|
|
14
|
+
{
|
|
15
|
+
'token' => {
|
|
16
|
+
'id' => 'token-123',
|
|
17
|
+
'appId' => 'app-123',
|
|
18
|
+
'userId' => 'user-123',
|
|
19
|
+
'tokenSub' => 'sub-123',
|
|
20
|
+
'accessToken' => 'access-token-value',
|
|
21
|
+
'accessTokenType' => 'Bearer',
|
|
22
|
+
'accessTokenExpiry' => '2025-12-31T23:59:59Z',
|
|
23
|
+
'hasRefreshToken' => true,
|
|
24
|
+
'refreshToken' => 'refresh-token-value',
|
|
25
|
+
'scopes' => %w[read write],
|
|
26
|
+
'tenantId' => 'tenant-123'
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'responds to fetch_outbound_app_user_token' do
|
|
32
|
+
expect(@instance).to respond_to :fetch_outbound_app_user_token
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'raises an error when app_id is empty' do
|
|
36
|
+
expect do
|
|
37
|
+
@instance.fetch_outbound_app_user_token(app_id: '', user_id: 'user-123')
|
|
38
|
+
end.to raise_error(Descope::ArgumentException, 'app_id cannot be empty')
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'raises an error when app_id is nil' do
|
|
42
|
+
expect do
|
|
43
|
+
@instance.fetch_outbound_app_user_token(app_id: nil, user_id: 'user-123')
|
|
44
|
+
end.to raise_error(Descope::ArgumentException, 'app_id cannot be empty')
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'raises an error when user_id is empty' do
|
|
48
|
+
expect do
|
|
49
|
+
@instance.fetch_outbound_app_user_token(app_id: 'app-123', user_id: '')
|
|
50
|
+
end.to raise_error(Descope::ArgumentException, 'Missing user id')
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'raises an error when user_id is nil' do
|
|
54
|
+
expect do
|
|
55
|
+
@instance.fetch_outbound_app_user_token(app_id: 'app-123', user_id: nil)
|
|
56
|
+
end.to raise_error(Descope::ArgumentException, 'Missing user id')
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it 'fetches token with required parameters only' do
|
|
60
|
+
expect(@instance).to receive(:mgmt_post).with(
|
|
61
|
+
'/v1/mgmt/outbound/app/user/token',
|
|
62
|
+
{
|
|
63
|
+
appId: 'app-123',
|
|
64
|
+
userId: 'user-123'
|
|
65
|
+
}
|
|
66
|
+
).and_return(mock_response)
|
|
67
|
+
|
|
68
|
+
result = @instance.fetch_outbound_app_user_token(app_id: 'app-123', user_id: 'user-123')
|
|
69
|
+
expect(result['token']['accessToken']).to eq('access-token-value')
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it 'fetches token with scopes' do
|
|
73
|
+
expect(@instance).to receive(:mgmt_post).with(
|
|
74
|
+
'/v1/mgmt/outbound/app/user/token',
|
|
75
|
+
{
|
|
76
|
+
appId: 'app-123',
|
|
77
|
+
userId: 'user-123',
|
|
78
|
+
scopes: %w[read write]
|
|
79
|
+
}
|
|
80
|
+
).and_return(mock_response)
|
|
81
|
+
|
|
82
|
+
result = @instance.fetch_outbound_app_user_token(
|
|
83
|
+
app_id: 'app-123',
|
|
84
|
+
user_id: 'user-123',
|
|
85
|
+
scopes: %w[read write]
|
|
86
|
+
)
|
|
87
|
+
expect(result['token']['scopes']).to eq(%w[read write])
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'fetches token with options' do
|
|
91
|
+
expect(@instance).to receive(:mgmt_post).with(
|
|
92
|
+
'/v1/mgmt/outbound/app/user/token',
|
|
93
|
+
{
|
|
94
|
+
appId: 'app-123',
|
|
95
|
+
userId: 'user-123',
|
|
96
|
+
options: {
|
|
97
|
+
withRefreshToken: true,
|
|
98
|
+
forceRefresh: true
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
).and_return(mock_response)
|
|
102
|
+
|
|
103
|
+
result = @instance.fetch_outbound_app_user_token(
|
|
104
|
+
app_id: 'app-123',
|
|
105
|
+
user_id: 'user-123',
|
|
106
|
+
with_refresh_token: true,
|
|
107
|
+
force_refresh: true
|
|
108
|
+
)
|
|
109
|
+
expect(result['token']['hasRefreshToken']).to be(true)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it 'fetches token with tenant_id' do
|
|
113
|
+
expect(@instance).to receive(:mgmt_post).with(
|
|
114
|
+
'/v1/mgmt/outbound/app/user/token',
|
|
115
|
+
{
|
|
116
|
+
appId: 'app-123',
|
|
117
|
+
userId: 'user-123',
|
|
118
|
+
tenantId: 'tenant-123'
|
|
119
|
+
}
|
|
120
|
+
).and_return(mock_response)
|
|
121
|
+
|
|
122
|
+
result = @instance.fetch_outbound_app_user_token(
|
|
123
|
+
app_id: 'app-123',
|
|
124
|
+
user_id: 'user-123',
|
|
125
|
+
tenant_id: 'tenant-123'
|
|
126
|
+
)
|
|
127
|
+
expect(result['token']['tenantId']).to eq('tenant-123')
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
it 'fetches token with all parameters' do
|
|
131
|
+
expect(@instance).to receive(:mgmt_post).with(
|
|
132
|
+
'/v1/mgmt/outbound/app/user/token',
|
|
133
|
+
{
|
|
134
|
+
appId: 'app-123',
|
|
135
|
+
userId: 'user-123',
|
|
136
|
+
scopes: %w[read write],
|
|
137
|
+
tenantId: 'tenant-123',
|
|
138
|
+
options: {
|
|
139
|
+
withRefreshToken: true,
|
|
140
|
+
forceRefresh: false
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
).and_return(mock_response)
|
|
144
|
+
|
|
145
|
+
result = @instance.fetch_outbound_app_user_token(
|
|
146
|
+
app_id: 'app-123',
|
|
147
|
+
user_id: 'user-123',
|
|
148
|
+
scopes: %w[read write],
|
|
149
|
+
tenant_id: 'tenant-123',
|
|
150
|
+
with_refresh_token: true,
|
|
151
|
+
force_refresh: false
|
|
152
|
+
)
|
|
153
|
+
expect(result['token']['id']).to eq('token-123')
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
describe '.delete_outbound_app_user_tokens' do
|
|
158
|
+
it 'responds to delete_outbound_app_user_tokens' do
|
|
159
|
+
expect(@instance).to respond_to :delete_outbound_app_user_tokens
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
it 'raises an error when both app_id and user_id are empty' do
|
|
163
|
+
expect do
|
|
164
|
+
@instance.delete_outbound_app_user_tokens(app_id: '', user_id: '')
|
|
165
|
+
end.to raise_error(Descope::ArgumentException, 'At least one of app_id or user_id must be provided')
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
it 'raises an error when both app_id and user_id are nil' do
|
|
169
|
+
expect do
|
|
170
|
+
@instance.delete_outbound_app_user_tokens
|
|
171
|
+
end.to raise_error(Descope::ArgumentException, 'At least one of app_id or user_id must be provided')
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
it 'deletes tokens by app_id only' do
|
|
175
|
+
expect(@instance).to receive(:mgmt_delete).with(
|
|
176
|
+
'/v1/mgmt/outbound/user/tokens',
|
|
177
|
+
{ appId: 'app-123' }
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
expect do
|
|
181
|
+
@instance.delete_outbound_app_user_tokens(app_id: 'app-123')
|
|
182
|
+
end.not_to raise_error
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
it 'deletes tokens by user_id only' do
|
|
186
|
+
expect(@instance).to receive(:mgmt_delete).with(
|
|
187
|
+
'/v1/mgmt/outbound/user/tokens',
|
|
188
|
+
{ userId: 'user-123' }
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
expect do
|
|
192
|
+
@instance.delete_outbound_app_user_tokens(user_id: 'user-123')
|
|
193
|
+
end.not_to raise_error
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
it 'deletes tokens by both app_id and user_id' do
|
|
197
|
+
expect(@instance).to receive(:mgmt_delete).with(
|
|
198
|
+
'/v1/mgmt/outbound/user/tokens',
|
|
199
|
+
{ appId: 'app-123', userId: 'user-123' }
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
expect do
|
|
203
|
+
@instance.delete_outbound_app_user_tokens(app_id: 'app-123', user_id: 'user-123')
|
|
204
|
+
end.not_to raise_error
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
describe '.delete_outbound_app_token_by_id' do
|
|
209
|
+
it 'responds to delete_outbound_app_token_by_id' do
|
|
210
|
+
expect(@instance).to respond_to :delete_outbound_app_token_by_id
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
it 'raises an error when token_id is empty' do
|
|
214
|
+
expect do
|
|
215
|
+
@instance.delete_outbound_app_token_by_id(token_id: '')
|
|
216
|
+
end.to raise_error(Descope::ArgumentException, 'token_id cannot be empty')
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
it 'raises an error when token_id is nil' do
|
|
220
|
+
expect do
|
|
221
|
+
@instance.delete_outbound_app_token_by_id(token_id: nil)
|
|
222
|
+
end.to raise_error(Descope::ArgumentException, 'token_id cannot be empty')
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
it 'deletes token by id' do
|
|
226
|
+
expect(@instance).to receive(:mgmt_delete).with(
|
|
227
|
+
'/v1/mgmt/outbound/token',
|
|
228
|
+
{ id: 'token-123' }
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
expect do
|
|
232
|
+
@instance.delete_outbound_app_token_by_id(token_id: 'token-123')
|
|
233
|
+
end.not_to raise_error
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
end
|
|
@@ -11,14 +11,14 @@ describe Descope::Api::V1::Management::Password do
|
|
|
11
11
|
|
|
12
12
|
context '.get_password_settings' do
|
|
13
13
|
it 'should get password settings' do
|
|
14
|
-
expect(@instance).to receive(:
|
|
14
|
+
expect(@instance).to receive(:mgmt_get).with('/v1/mgmt/password/settings', { tenantId: 'tenant_id' })
|
|
15
15
|
@instance.get_password_settings('tenant_id')
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
context '.update_password_settings' do
|
|
20
20
|
it 'should update password settings' do
|
|
21
|
-
expect(@instance).to receive(:
|
|
21
|
+
expect(@instance).to receive(:mgmt_post).with('/v1/mgmt/password/settings', { 'minLength' => 10 })
|
|
22
22
|
@instance.update_password_settings({ min_length: 10 })
|
|
23
23
|
end
|
|
24
24
|
end
|
|
@@ -15,7 +15,7 @@ describe Descope::Api::V1::Management::Permission do
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it 'is expected to create a new permission' do
|
|
18
|
-
expect(@instance).to receive(:
|
|
18
|
+
expect(@instance).to receive(:mgmt_post).with(
|
|
19
19
|
PERMISSION_CREATE_PATH, {
|
|
20
20
|
name: 'test',
|
|
21
21
|
description: 'test'
|
|
@@ -36,7 +36,7 @@ describe Descope::Api::V1::Management::Permission do
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
it 'is expected to update a permission' do
|
|
39
|
-
expect(@instance).to receive(:
|
|
39
|
+
expect(@instance).to receive(:mgmt_post).with(
|
|
40
40
|
PERMISSION_UPDATE_PATH, {
|
|
41
41
|
name: 'test',
|
|
42
42
|
newName: 'production',
|
|
@@ -59,7 +59,7 @@ describe Descope::Api::V1::Management::Permission do
|
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
it 'is expected to delete a permission' do
|
|
62
|
-
expect(@instance).to receive(:
|
|
62
|
+
expect(@instance).to receive(:mgmt_post).with(
|
|
63
63
|
PERMISSION_DELETE_PATH, { name: 'test' }
|
|
64
64
|
)
|
|
65
65
|
expect do
|
|
@@ -74,7 +74,7 @@ describe Descope::Api::V1::Management::Permission do
|
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
it 'is expected to delete a permission' do
|
|
77
|
-
expect(@instance).to receive(:
|
|
77
|
+
expect(@instance).to receive(:mgmt_get).with(PERMISSION_LOAD_ALL_PATH)
|
|
78
78
|
expect { @instance.load_all_permissions }.not_to raise_error
|
|
79
79
|
end
|
|
80
80
|
end
|
|
@@ -15,7 +15,7 @@ describe Descope::Api::V1::Management::Project do
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it 'is expected to rename the current project' do
|
|
18
|
-
expect(@instance).to receive(:
|
|
18
|
+
expect(@instance).to receive(:mgmt_post).with(
|
|
19
19
|
PROJECT_UPDATE_NAME, { name: 'test' }
|
|
20
20
|
)
|
|
21
21
|
expect { @instance.rename_project('test') }.not_to raise_error
|
|
@@ -28,7 +28,7 @@ describe Descope::Api::V1::Management::Project do
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it 'is expected to export the current project' do
|
|
31
|
-
expect(@instance).to receive(:
|
|
31
|
+
expect(@instance).to receive(:mgmt_post).with(PROJECT_EXPORT_PATH)
|
|
32
32
|
expect do
|
|
33
33
|
@instance.export_project
|
|
34
34
|
end.not_to raise_error
|
|
@@ -41,7 +41,7 @@ describe Descope::Api::V1::Management::Project do
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
it 'is expected to import a project' do
|
|
44
|
-
expect(@instance).to receive(:
|
|
44
|
+
expect(@instance).to receive(:mgmt_post).with(
|
|
45
45
|
PROJECT_IMPORT_PATH, { files: 'files' }
|
|
46
46
|
)
|
|
47
47
|
expect do
|
|
@@ -56,7 +56,7 @@ describe Descope::Api::V1::Management::Project do
|
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
it 'is expected to clone the current project' do
|
|
59
|
-
expect(@instance).to receive(:
|
|
59
|
+
expect(@instance).to receive(:mgmt_post).with(PROJECT_CLONE, { name: 'test', tag: 'test' })
|
|
60
60
|
expect { @instance.clone_project(name: 'test', tag: 'test') }.not_to raise_error
|
|
61
61
|
end
|
|
62
62
|
end
|
|
@@ -15,7 +15,7 @@ describe Descope::Api::V1::Management::Role do
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it 'is expected to create a new role' do
|
|
18
|
-
expect(@instance).to receive(:
|
|
18
|
+
expect(@instance).to receive(:mgmt_post).with(
|
|
19
19
|
ROLE_CREATE_PATH, {
|
|
20
20
|
name: 'test',
|
|
21
21
|
description: 'test',
|
|
@@ -40,7 +40,7 @@ describe Descope::Api::V1::Management::Role do
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
it 'is expected to update a role' do
|
|
43
|
-
expect(@instance).to receive(:
|
|
43
|
+
expect(@instance).to receive(:mgmt_post).with(
|
|
44
44
|
ROLE_UPDATE_PATH, {
|
|
45
45
|
name: 'test',
|
|
46
46
|
newName: 'production',
|
|
@@ -67,7 +67,7 @@ describe Descope::Api::V1::Management::Role do
|
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
it 'is expected to delete a role' do
|
|
70
|
-
expect(@instance).to receive(:
|
|
70
|
+
expect(@instance).to receive(:mgmt_post).with(
|
|
71
71
|
ROLE_DELETE_PATH, { name: 'test', tenantId: 'test' }
|
|
72
72
|
)
|
|
73
73
|
expect do
|
|
@@ -82,7 +82,7 @@ describe Descope::Api::V1::Management::Role do
|
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
it 'is expected to delete a role' do
|
|
85
|
-
expect(@instance).to receive(:
|
|
85
|
+
expect(@instance).to receive(:mgmt_get).with(ROLE_LOAD_ALL_PATH)
|
|
86
86
|
expect { @instance.load_all_roles }.not_to raise_error
|
|
87
87
|
end
|
|
88
88
|
end
|
|
@@ -93,7 +93,7 @@ describe Descope::Api::V1::Management::Role do
|
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
it 'is expected to search roles' do
|
|
96
|
-
expect(@instance).to receive(:
|
|
96
|
+
expect(@instance).to receive(:mgmt_post).with(
|
|
97
97
|
ROLE_SEARCH_PATH, {
|
|
98
98
|
roleNames: %w[tester test2],
|
|
99
99
|
tenantIds: %w[t1 t2],
|
|
@@ -24,7 +24,7 @@ describe Descope::Api::V1::Management::SCIM do
|
|
|
24
24
|
start_index,
|
|
25
25
|
count,
|
|
26
26
|
excluded_attributes)
|
|
27
|
-
expect(@instance).to receive(:
|
|
27
|
+
expect(@instance).to receive(:mgmt_get).with(url)
|
|
28
28
|
expect do
|
|
29
29
|
@instance.scim_search_groups(filter:, start_index:, count:, excluded_attributes:)
|
|
30
30
|
end.not_to raise_error
|
|
@@ -48,7 +48,7 @@ describe Descope::Api::V1::Management::SCIM do
|
|
|
48
48
|
members,
|
|
49
49
|
external_id,
|
|
50
50
|
excluded_attributes)
|
|
51
|
-
expect(@instance).to receive(:
|
|
51
|
+
expect(@instance).to receive(:mgmt_post).with(Descope::Api::V1::Management::Common::SCIM_GROUPS_PATH, body)
|
|
52
52
|
expect do
|
|
53
53
|
@instance.scim_create_group(group_id:,
|
|
54
54
|
display_name:,
|
|
@@ -73,7 +73,7 @@ describe Descope::Api::V1::Management::SCIM do
|
|
|
73
73
|
:compose_scim_create_group_url,
|
|
74
74
|
group_id, display_name, external_id, excluded_attributes
|
|
75
75
|
)
|
|
76
|
-
expect(@instance).to receive(:
|
|
76
|
+
expect(@instance).to receive(:mgmt_get).with(url)
|
|
77
77
|
expect do
|
|
78
78
|
@instance.scim_load_group(group_id:, display_name:, external_id:, excluded_attributes:)
|
|
79
79
|
end.not_to raise_error
|
|
@@ -96,7 +96,7 @@ describe Descope::Api::V1::Management::SCIM do
|
|
|
96
96
|
group_id, display_name, members, external_id, excluded_attributes
|
|
97
97
|
)
|
|
98
98
|
url = "#{SCIM_GROUPS_PATH}/#{group_id}"
|
|
99
|
-
expect(@instance).to receive(:
|
|
99
|
+
expect(@instance).to receive(:mgmt_patch).with(url, body)
|
|
100
100
|
expect do
|
|
101
101
|
@instance.scim_update_group(group_id:, display_name:, members:, external_id:, excluded_attributes:)
|
|
102
102
|
end.not_to raise_error
|
|
@@ -111,7 +111,7 @@ describe Descope::Api::V1::Management::SCIM do
|
|
|
111
111
|
it 'is expected to delete scim group' do
|
|
112
112
|
group_id = 'G123'
|
|
113
113
|
url = "#{SCIM_GROUPS_PATH}/#{group_id}"
|
|
114
|
-
expect(@instance).to receive(:
|
|
114
|
+
expect(@instance).to receive(:mgmt_delete).with(url)
|
|
115
115
|
expect { @instance.scim_delete_group(group_id) }.not_to raise_error
|
|
116
116
|
end
|
|
117
117
|
end
|
|
@@ -142,7 +142,7 @@ describe Descope::Api::V1::Management::SCIM do
|
|
|
142
142
|
|
|
143
143
|
url = @instance.send(:compose_scim_patch_group_url, group_id, user_id, operations)
|
|
144
144
|
|
|
145
|
-
expect(@instance).to receive(:
|
|
145
|
+
expect(@instance).to receive(:mgmt_patch).with(url)
|
|
146
146
|
expect do
|
|
147
147
|
@instance.scim_patch_group(group_id:, user_id:, operations:)
|
|
148
148
|
end.not_to raise_error
|
|
@@ -156,7 +156,7 @@ describe Descope::Api::V1::Management::SCIM do
|
|
|
156
156
|
|
|
157
157
|
it 'is expected to load scim resource types' do
|
|
158
158
|
url = "#{SCIM_RESOURCE_TYPES_PATH}"
|
|
159
|
-
expect(@instance).to receive(:
|
|
159
|
+
expect(@instance).to receive(:mgmt_get).with(url)
|
|
160
160
|
expect { @instance.scim_load_resource_types }.not_to raise_error
|
|
161
161
|
end
|
|
162
162
|
end
|
|
@@ -168,7 +168,7 @@ describe Descope::Api::V1::Management::SCIM do
|
|
|
168
168
|
|
|
169
169
|
it 'is expected to load scim service provider config' do
|
|
170
170
|
url = "#{SCIM_SERVICE_PROVIDER_CONFIG_PATH}"
|
|
171
|
-
expect(@instance).to receive(:
|
|
171
|
+
expect(@instance).to receive(:mgmt_get).with(url)
|
|
172
172
|
expect { @instance.scim_load_service_provider_config }.not_to raise_error
|
|
173
173
|
end
|
|
174
174
|
end
|
|
@@ -186,7 +186,7 @@ describe Descope::Api::V1::Management::SCIM do
|
|
|
186
186
|
filter,
|
|
187
187
|
start_index,
|
|
188
188
|
count)
|
|
189
|
-
expect(@instance).to receive(:
|
|
189
|
+
expect(@instance).to receive(:mgmt_get).with(url)
|
|
190
190
|
expect do
|
|
191
191
|
@instance.scim_search_users(filter:, start_index:, count:)
|
|
192
192
|
end.not_to raise_error
|
|
@@ -219,7 +219,7 @@ describe Descope::Api::V1::Management::SCIM do
|
|
|
219
219
|
active,
|
|
220
220
|
name,
|
|
221
221
|
user_name)
|
|
222
|
-
expect(@instance).to receive(:
|
|
222
|
+
expect(@instance).to receive(:mgmt_post).with(SCIM_USERS_PATH, body)
|
|
223
223
|
expect do
|
|
224
224
|
@instance.scim_create_user(
|
|
225
225
|
user_id:,
|
|
@@ -242,7 +242,7 @@ describe Descope::Api::V1::Management::SCIM do
|
|
|
242
242
|
it 'is expected to load scim user' do
|
|
243
243
|
user_id = 'U123'
|
|
244
244
|
url = "#{SCIM_USERS_PATH}/#{user_id}"
|
|
245
|
-
expect(@instance).to receive(:
|
|
245
|
+
expect(@instance).to receive(:mgmt_get).with(url)
|
|
246
246
|
expect do
|
|
247
247
|
@instance.scim_load_user(user_id)
|
|
248
248
|
end.not_to raise_error
|
|
@@ -257,7 +257,7 @@ describe Descope::Api::V1::Management::SCIM do
|
|
|
257
257
|
it 'is expected to load scim user' do
|
|
258
258
|
user_id = 'U123'
|
|
259
259
|
url = "#{SCIM_USERS_PATH}/#{user_id}"
|
|
260
|
-
expect(@instance).to receive(:
|
|
260
|
+
expect(@instance).to receive(:mgmt_patch).with(url)
|
|
261
261
|
expect do
|
|
262
262
|
@instance.scim_update_user(user_id)
|
|
263
263
|
end.not_to raise_error
|
|
@@ -272,7 +272,7 @@ describe Descope::Api::V1::Management::SCIM do
|
|
|
272
272
|
it 'is expected to delete scim user' do
|
|
273
273
|
user_id = 'U123'
|
|
274
274
|
url = "#{SCIM_USERS_PATH}/#{user_id}"
|
|
275
|
-
expect(@instance).to receive(:
|
|
275
|
+
expect(@instance).to receive(:mgmt_delete).with(url)
|
|
276
276
|
expect { @instance.scim_delete_user(user_id) }.not_to raise_error
|
|
277
277
|
end
|
|
278
278
|
end
|
|
@@ -303,7 +303,7 @@ describe Descope::Api::V1::Management::SCIM do
|
|
|
303
303
|
|
|
304
304
|
body = @instance.send(:compose_scim_patch_user_body, user_id, group_id, operations)
|
|
305
305
|
|
|
306
|
-
expect(@instance).to receive(:
|
|
306
|
+
expect(@instance).to receive(:mgmt_patch).with(SCIM_USERS_PATH, body)
|
|
307
307
|
expect do
|
|
308
308
|
@instance.scim_patch_user(user_id:, group_id:, operations:)
|
|
309
309
|
end.not_to raise_error
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Descope::Api::V1::Management::ScopeClaimMapping do
|
|
6
|
+
before(:all) do
|
|
7
|
+
dummy_instance = DummyClass.new
|
|
8
|
+
dummy_instance.extend(Descope::Api::V1::Management::ScopeClaimMapping)
|
|
9
|
+
@instance = dummy_instance
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context '.get_scope_claim_mapping' do
|
|
13
|
+
it 'should respond to .get_scope_claim_mapping' do
|
|
14
|
+
expect(@instance).to respond_to :get_scope_claim_mapping
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'is expected to get the project-wide OIDC scope-to-claim mappings' do
|
|
18
|
+
expect(@instance).to receive(:mgmt_post).with(SCOPE_CLAIM_MAPPING_GET_PATH)
|
|
19
|
+
expect do
|
|
20
|
+
@instance.get_scope_claim_mapping
|
|
21
|
+
end.not_to raise_error
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
context '.set_scope_claim_mapping' do
|
|
26
|
+
it 'should respond to .set_scope_claim_mapping' do
|
|
27
|
+
expect(@instance).to respond_to :set_scope_claim_mapping
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'is expected to set the project-wide OIDC scope-to-claim mappings' do
|
|
31
|
+
mappings = [
|
|
32
|
+
{
|
|
33
|
+
scope: 'name-of-scope',
|
|
34
|
+
claims: %w[claim1 claim2]
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
expect(@instance).to receive(:mgmt_post).with(
|
|
38
|
+
SCOPE_CLAIM_MAPPING_SET_PATH,
|
|
39
|
+
{ mappings: mappings }
|
|
40
|
+
)
|
|
41
|
+
expect do
|
|
42
|
+
@instance.set_scope_claim_mapping(mappings: mappings)
|
|
43
|
+
end.not_to raise_error
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context '.delete_scope_claim_mapping' do
|
|
48
|
+
it 'should respond to .delete_scope_claim_mapping' do
|
|
49
|
+
expect(@instance).to respond_to :delete_scope_claim_mapping
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'is expected to delete the project-wide OIDC scope-to-claim mappings' do
|
|
53
|
+
expect(@instance).to receive(:mgmt_post).with(SCOPE_CLAIM_MAPPING_DELETE_PATH)
|
|
54
|
+
expect do
|
|
55
|
+
@instance.delete_scope_claim_mapping
|
|
56
|
+
end.not_to raise_error
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -15,7 +15,7 @@ describe Descope::Api::V1::Management::SSOApplication do
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it 'is expected to create SAML application' do
|
|
18
|
-
expect(@instance).to receive(:
|
|
18
|
+
expect(@instance).to receive(:mgmt_post).with(
|
|
19
19
|
SSO_APPLICATION_OIDC_CREATE_PATH, {
|
|
20
20
|
id: 'tenant1',
|
|
21
21
|
name: 'test',
|
|
@@ -44,7 +44,7 @@ describe Descope::Api::V1::Management::SSOApplication do
|
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
it 'is expected to create SAML application' do
|
|
47
|
-
expect(@instance).to receive(:
|
|
47
|
+
expect(@instance).to receive(:mgmt_post).with(
|
|
48
48
|
SSO_APPLICATION_SAML_CREATE_PATH, {
|
|
49
49
|
name: 'test',
|
|
50
50
|
description: 'awesome tenant',
|
|
@@ -172,7 +172,7 @@ describe Descope::Api::V1::Management::SSOApplication do
|
|
|
172
172
|
end
|
|
173
173
|
|
|
174
174
|
it 'is expected to update sso oidc application' do
|
|
175
|
-
expect(@instance).to receive(:
|
|
175
|
+
expect(@instance).to receive(:mgmt_post).with(
|
|
176
176
|
SSO_APPLICATION_OIDC_UPDATE_PATH, {
|
|
177
177
|
id: 'tenant1',
|
|
178
178
|
name: 'test',
|
|
@@ -195,21 +195,21 @@ describe Descope::Api::V1::Management::SSOApplication do
|
|
|
195
195
|
end
|
|
196
196
|
|
|
197
197
|
it 'is expected to delete sso app' do
|
|
198
|
-
expect(@instance).to receive(:
|
|
198
|
+
expect(@instance).to receive(:mgmt_delete).with(
|
|
199
199
|
SSO_APPLICATION_DELETE_PATH, { id: 'tenant1' }
|
|
200
200
|
)
|
|
201
201
|
expect { @instance.delete_sso_app('tenant1') }.not_to raise_error
|
|
202
202
|
end
|
|
203
203
|
|
|
204
204
|
it 'is expected to load sso app' do
|
|
205
|
-
expect(@instance).to receive(:
|
|
205
|
+
expect(@instance).to receive(:mgmt_get).with(
|
|
206
206
|
SSO_APPLICATION_LOAD_PATH, { id: 'tenant1' }
|
|
207
207
|
)
|
|
208
208
|
expect { @instance.load_sso_app('tenant1') }.not_to raise_error
|
|
209
209
|
end
|
|
210
210
|
|
|
211
211
|
it 'is expected to load all sso apps' do
|
|
212
|
-
expect(@instance).to receive(:
|
|
212
|
+
expect(@instance).to receive(:mgmt_get).with(
|
|
213
213
|
SSO_APPLICATION_LOAD_ALL_PATH, {}
|
|
214
214
|
)
|
|
215
215
|
expect { @instance.load_all_sso_apps }.not_to raise_error
|
|
@@ -15,7 +15,7 @@ describe Descope::Api::V1::Management::SSOSettings do
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it 'is expected to get SSO settings' do
|
|
18
|
-
expect(@instance).to receive(:
|
|
18
|
+
expect(@instance).to receive(:mgmt_get).with(
|
|
19
19
|
SSO_SETTINGS_PATH, { tenantId: '123' }
|
|
20
20
|
)
|
|
21
21
|
expect { @instance.get_sso_settings('123') }.not_to raise_error
|
|
@@ -28,7 +28,7 @@ describe Descope::Api::V1::Management::SSOSettings do
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it 'is expected to delete SSO settings' do
|
|
31
|
-
expect(@instance).to receive(:
|
|
31
|
+
expect(@instance).to receive(:mgmt_delete).with(
|
|
32
32
|
SSO_SETTINGS_PATH, { tenantId: '123' }
|
|
33
33
|
)
|
|
34
34
|
expect { @instance.delete_sso_settings('123') }.not_to raise_error
|
|
@@ -40,7 +40,7 @@ describe Descope::Api::V1::Management::SSOSettings do
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
it 'is expected to configure SSO settings' do
|
|
43
|
-
expect(@instance).to receive(:
|
|
43
|
+
expect(@instance).to receive(:mgmt_post).with(
|
|
44
44
|
SSO_OIDC_PATH, {
|
|
45
45
|
tenantId: '123',
|
|
46
46
|
settings: {
|
|
@@ -86,7 +86,7 @@ describe Descope::Api::V1::Management::SSOSettings do
|
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
it 'is expected to configure SSO settings' do
|
|
89
|
-
expect(@instance).to receive(:
|
|
89
|
+
expect(@instance).to receive(:mgmt_post).with(
|
|
90
90
|
SSO_SETTINGS_PATH, {
|
|
91
91
|
tenantId: '123',
|
|
92
92
|
settings: {
|
|
@@ -131,7 +131,7 @@ describe Descope::Api::V1::Management::SSOSettings do
|
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
it 'is expected to configure SAML metadata' do
|
|
134
|
-
expect(@instance).to receive(:
|
|
134
|
+
expect(@instance).to receive(:mgmt_post).with(
|
|
135
135
|
SSO_METADATA_PATH, {
|
|
136
136
|
tenantId: '123',
|
|
137
137
|
settings: {
|