descope 1.0.7 → 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 +51 -12
- data/.github/workflows/publish-gem.yaml +6 -33
- data/.github/workflows/release-please.yaml +36 -0
- data/.gitignore +3 -2
- 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 +31 -0
- data/Gemfile +7 -6
- data/Gemfile.lock +46 -45
- data/README.md +244 -1
- data/examples/ruby-on-rails-api/descope/package-lock.json +16 -10
- data/examples/ruby-on-rails-api/descope/yarn.lock +3 -3
- 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 +25 -18
- data/lib/descope/mixins/initializer.rb +23 -11
- 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/auth/enchantedlink_spec.rb +19 -21
- data/spec/integration/lib.descope/api/v1/auth/magiclink_spec.rb +5 -1
- data/spec/integration/lib.descope/api/v1/auth/otp_spec.rb +5 -1
- data/spec/integration/lib.descope/api/v1/auth/session_spec.rb +24 -5
- data/spec/integration/lib.descope/api/v1/auth/totp_spec.rb +5 -1
- data/spec/integration/lib.descope/api/v1/management/access_key_spec.rb +10 -2
- data/spec/integration/lib.descope/api/v1/management/authz_spec.rb +26 -5
- data/spec/integration/lib.descope/api/v1/management/permissions_spec.rb +20 -2
- data/spec/integration/lib.descope/api/v1/management/project_spec.rb +16 -2
- data/spec/integration/lib.descope/api/v1/management/roles_spec.rb +114 -36
- data/spec/integration/lib.descope/api/v1/management/user_spec.rb +21 -4
- 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/lib.descope/mixins/http_spec.rb +17 -6
- data/spec/support/client_config.rb +1 -0
- data/spec/support/dummy_class.rb +12 -9
- data/spec/support/utils.rb +15 -0
- metadata +29 -3
|
@@ -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(:
|
|
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(:
|
|
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(:
|
|
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(:
|
|
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(:
|
|
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
|
|
@@ -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
|