descope 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/ci.yaml +54 -0
- data/.gitignore +59 -0
- data/.release-please-manifest.json +3 -0
- data/.rubocop.yml +10 -0
- data/.rubocop_todo.yml +10 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +90 -0
- data/Gemfile +22 -0
- data/Gemfile.lock +204 -0
- data/LICENSE +21 -0
- data/README.md +1171 -0
- data/Rakefile +31 -0
- data/descope.gemspec +34 -0
- data/examples/ruby/Gemfile +4 -0
- data/examples/ruby/Gemfile.lock +41 -0
- data/examples/ruby/access_key_app.rb +45 -0
- data/examples/ruby/enchantedlink_app.rb +65 -0
- data/examples/ruby/magiclink_app.rb +81 -0
- data/examples/ruby/management/Gemfile +5 -0
- data/examples/ruby/management/Gemfile.lock +38 -0
- data/examples/ruby/management/access_key_app.rb +71 -0
- data/examples/ruby/management/audit_app.rb +25 -0
- data/examples/ruby/management/authz_app.rb +135 -0
- data/examples/ruby/management/authz_files.json +229 -0
- data/examples/ruby/management/flow_app.rb +57 -0
- data/examples/ruby/management/permission_app.rb +56 -0
- data/examples/ruby/management/role_app.rb +58 -0
- data/examples/ruby/management/tenant_app.rb +60 -0
- data/examples/ruby/management/user_app.rb +60 -0
- data/examples/ruby/oauth_app.rb +39 -0
- data/examples/ruby/otp_app.rb +50 -0
- data/examples/ruby/password_app.rb +76 -0
- data/examples/ruby/saml_app.rb +38 -0
- data/examples/ruby-on-rails-api/descope/.dockerignore +37 -0
- data/examples/ruby-on-rails-api/descope/.gitattributes +9 -0
- data/examples/ruby-on-rails-api/descope/.gitignore +40 -0
- data/examples/ruby-on-rails-api/descope/.node-version +1 -0
- data/examples/ruby-on-rails-api/descope/.ruby-version +1 -0
- data/examples/ruby-on-rails-api/descope/Dockerfile +75 -0
- data/examples/ruby-on-rails-api/descope/Gemfile +67 -0
- data/examples/ruby-on-rails-api/descope/Gemfile.lock +284 -0
- data/examples/ruby-on-rails-api/descope/Procfile.dev +3 -0
- data/examples/ruby-on-rails-api/descope/README.md +54 -0
- data/examples/ruby-on-rails-api/descope/Rakefile +6 -0
- data/examples/ruby-on-rails-api/descope/app/assets/builds/.keep +0 -0
- data/examples/ruby-on-rails-api/descope/app/assets/config/manifest.js +3 -0
- data/examples/ruby-on-rails-api/descope/app/assets/images/.keep +0 -0
- data/examples/ruby-on-rails-api/descope/app/assets/images/descope.jpeg +0 -0
- data/examples/ruby-on-rails-api/descope/app/assets/images/favicon.ico +0 -0
- data/examples/ruby-on-rails-api/descope/app/assets/images/logo192.png +0 -0
- data/examples/ruby-on-rails-api/descope/app/assets/images/logo512.png +0 -0
- data/examples/ruby-on-rails-api/descope/app/assets/stylesheets/application.bootstrap.scss +67 -0
- data/examples/ruby-on-rails-api/descope/app/channels/application_cable/channel.rb +4 -0
- data/examples/ruby-on-rails-api/descope/app/channels/application_cable/connection.rb +4 -0
- data/examples/ruby-on-rails-api/descope/app/controllers/application_controller.rb +2 -0
- data/examples/ruby-on-rails-api/descope/app/controllers/concerns/.keep +0 -0
- data/examples/ruby-on-rails-api/descope/app/controllers/homepage_controller.rb +4 -0
- data/examples/ruby-on-rails-api/descope/app/controllers/session_controller.rb +66 -0
- data/examples/ruby-on-rails-api/descope/app/helpers/application_helper.rb +2 -0
- data/examples/ruby-on-rails-api/descope/app/helpers/homepage_helper.rb +2 -0
- data/examples/ruby-on-rails-api/descope/app/helpers/session_helper.rb +2 -0
- data/examples/ruby-on-rails-api/descope/app/javascript/App.css +53 -0
- data/examples/ruby-on-rails-api/descope/app/javascript/application.js +5 -0
- data/examples/ruby-on-rails-api/descope/app/javascript/components/App.jsx +4 -0
- data/examples/ruby-on-rails-api/descope/app/javascript/components/Dashboard.jsx +60 -0
- data/examples/ruby-on-rails-api/descope/app/javascript/components/Home.jsx +27 -0
- data/examples/ruby-on-rails-api/descope/app/javascript/components/Login.jsx +45 -0
- data/examples/ruby-on-rails-api/descope/app/javascript/components/Profile.jsx +81 -0
- data/examples/ruby-on-rails-api/descope/app/javascript/components/index.html +11 -0
- data/examples/ruby-on-rails-api/descope/app/javascript/components/index.jsx +24 -0
- data/examples/ruby-on-rails-api/descope/app/javascript/controllers/application.js +9 -0
- data/examples/ruby-on-rails-api/descope/app/javascript/controllers/index.js +5 -0
- data/examples/ruby-on-rails-api/descope/app/javascript/reportWebVitals.js +13 -0
- data/examples/ruby-on-rails-api/descope/app/javascript/routes/index.jsx +17 -0
- data/examples/ruby-on-rails-api/descope/app/jobs/application_job.rb +7 -0
- data/examples/ruby-on-rails-api/descope/app/mailers/application_mailer.rb +4 -0
- data/examples/ruby-on-rails-api/descope/app/models/application_record.rb +3 -0
- data/examples/ruby-on-rails-api/descope/app/models/concerns/.keep +0 -0
- data/examples/ruby-on-rails-api/descope/app/views/homepage/index.html.erb +2 -0
- data/examples/ruby-on-rails-api/descope/app/views/layouts/application.html.erb +16 -0
- data/examples/ruby-on-rails-api/descope/app/views/layouts/mailer.html.erb +13 -0
- data/examples/ruby-on-rails-api/descope/app/views/layouts/mailer.text.erb +1 -0
- data/examples/ruby-on-rails-api/descope/app/views/session/index.html.erb +2 -0
- data/examples/ruby-on-rails-api/descope/bin/bundle +109 -0
- data/examples/ruby-on-rails-api/descope/bin/dev +11 -0
- data/examples/ruby-on-rails-api/descope/bin/docker-entrypoint +8 -0
- data/examples/ruby-on-rails-api/descope/bin/rails +4 -0
- data/examples/ruby-on-rails-api/descope/bin/rake +4 -0
- data/examples/ruby-on-rails-api/descope/bin/setup +36 -0
- data/examples/ruby-on-rails-api/descope/build.js +30 -0
- data/examples/ruby-on-rails-api/descope/config/application.rb +42 -0
- data/examples/ruby-on-rails-api/descope/config/boot.rb +4 -0
- data/examples/ruby-on-rails-api/descope/config/cable.yml +10 -0
- data/examples/ruby-on-rails-api/descope/config/config.yml +9 -0
- data/examples/ruby-on-rails-api/descope/config/credentials.yml.enc +1 -0
- data/examples/ruby-on-rails-api/descope/config/database.yml +25 -0
- data/examples/ruby-on-rails-api/descope/config/environment.rb +5 -0
- data/examples/ruby-on-rails-api/descope/config/environments/development.rb +76 -0
- data/examples/ruby-on-rails-api/descope/config/environments/production.rb +97 -0
- data/examples/ruby-on-rails-api/descope/config/environments/test.rb +64 -0
- data/examples/ruby-on-rails-api/descope/config/initializers/assets.rb +13 -0
- data/examples/ruby-on-rails-api/descope/config/initializers/content_security_policy.rb +25 -0
- data/examples/ruby-on-rails-api/descope/config/initializers/filter_parameter_logging.rb +8 -0
- data/examples/ruby-on-rails-api/descope/config/initializers/inflections.rb +16 -0
- data/examples/ruby-on-rails-api/descope/config/initializers/load_config.rb +12 -0
- data/examples/ruby-on-rails-api/descope/config/initializers/permissions_policy.rb +13 -0
- data/examples/ruby-on-rails-api/descope/config/locales/en.yml +31 -0
- data/examples/ruby-on-rails-api/descope/config/puma.rb +35 -0
- data/examples/ruby-on-rails-api/descope/config/routes.rb +18 -0
- data/examples/ruby-on-rails-api/descope/config/storage.yml +34 -0
- data/examples/ruby-on-rails-api/descope/config.ru +6 -0
- data/examples/ruby-on-rails-api/descope/db/seeds.rb +9 -0
- data/examples/ruby-on-rails-api/descope/lib/assets/.keep +0 -0
- data/examples/ruby-on-rails-api/descope/lib/tasks/.keep +0 -0
- data/examples/ruby-on-rails-api/descope/log/.keep +0 -0
- data/examples/ruby-on-rails-api/descope/package-lock.json +19680 -0
- data/examples/ruby-on-rails-api/descope/package.json +51 -0
- data/examples/ruby-on-rails-api/descope/public/404.html +67 -0
- data/examples/ruby-on-rails-api/descope/public/422.html +67 -0
- data/examples/ruby-on-rails-api/descope/public/500.html +66 -0
- data/examples/ruby-on-rails-api/descope/public/apple-touch-icon-precomposed.png +0 -0
- data/examples/ruby-on-rails-api/descope/public/apple-touch-icon.png +0 -0
- data/examples/ruby-on-rails-api/descope/public/favicon.ico +0 -0
- data/examples/ruby-on-rails-api/descope/public/robots.txt +1 -0
- data/examples/ruby-on-rails-api/descope/storage/.keep +0 -0
- data/examples/ruby-on-rails-api/descope/tmp/.keep +0 -0
- data/examples/ruby-on-rails-api/descope/tmp/pids/.keep +0 -0
- data/examples/ruby-on-rails-api/descope/tmp/storage/.keep +0 -0
- data/examples/ruby-on-rails-api/descope/vendor/.keep +0 -0
- data/examples/ruby-on-rails-api/descope/yarn.lock +10780 -0
- data/lib/descope/api/v1/auth/enchantedlink.rb +156 -0
- data/lib/descope/api/v1/auth/magiclink.rb +170 -0
- data/lib/descope/api/v1/auth/oauth.rb +72 -0
- data/lib/descope/api/v1/auth/otp.rb +186 -0
- data/lib/descope/api/v1/auth/password.rb +100 -0
- data/lib/descope/api/v1/auth/saml.rb +48 -0
- data/lib/descope/api/v1/auth/totp.rb +72 -0
- data/lib/descope/api/v1/auth.rb +452 -0
- data/lib/descope/api/v1/management/access_key.rb +81 -0
- data/lib/descope/api/v1/management/audit.rb +82 -0
- data/lib/descope/api/v1/management/authz.rb +165 -0
- data/lib/descope/api/v1/management/common.rb +147 -0
- data/lib/descope/api/v1/management/flow.rb +55 -0
- data/lib/descope/api/v1/management/password.rb +58 -0
- data/lib/descope/api/v1/management/permission.rb +48 -0
- data/lib/descope/api/v1/management/project.rb +53 -0
- data/lib/descope/api/v1/management/role.rb +48 -0
- data/lib/descope/api/v1/management/scim.rb +206 -0
- data/lib/descope/api/v1/management/sso_settings.rb +153 -0
- data/lib/descope/api/v1/management/tenant.rb +71 -0
- data/lib/descope/api/v1/management/user.rb +619 -0
- data/lib/descope/api/v1/management.rb +38 -0
- data/lib/descope/api/v1/session.rb +84 -0
- data/lib/descope/api/v1.rb +13 -0
- data/lib/descope/client.rb +6 -0
- data/lib/descope/exception.rb +50 -0
- data/lib/descope/mixins/common.rb +129 -0
- data/lib/descope/mixins/headers.rb +15 -0
- data/lib/descope/mixins/http.rb +133 -0
- data/lib/descope/mixins/initializer.rb +80 -0
- data/lib/descope/mixins/logging.rb +30 -0
- data/lib/descope/mixins/validation.rb +79 -0
- data/lib/descope/mixins.rb +22 -0
- data/lib/descope/version.rb +7 -0
- data/lib/descope.rb +9 -0
- data/lib/descope_client.rb +5 -0
- data/release-please-config.json +18 -0
- data/renovate.json +6 -0
- data/spec/factories/user.rb +16 -0
- data/spec/lib.descope/api/v1/auth/enchantedlink_spec.rb +159 -0
- data/spec/lib.descope/api/v1/auth/magiclink_spec.rb +282 -0
- data/spec/lib.descope/api/v1/auth/oauth_spec.rb +117 -0
- data/spec/lib.descope/api/v1/auth/otp_spec.rb +285 -0
- data/spec/lib.descope/api/v1/auth/password_spec.rb +124 -0
- data/spec/lib.descope/api/v1/auth/saml_spec.rb +55 -0
- data/spec/lib.descope/api/v1/auth/totp_spec.rb +70 -0
- data/spec/lib.descope/api/v1/auth_spec.rb +372 -0
- data/spec/lib.descope/api/v1/management/access_key_spec.rb +118 -0
- data/spec/lib.descope/api/v1/management/audit_spec.rb +78 -0
- data/spec/lib.descope/api/v1/management/authz_spec.rb +336 -0
- data/spec/lib.descope/api/v1/management/flow_spec.rb +78 -0
- data/spec/lib.descope/api/v1/management/password_spec.rb +25 -0
- data/spec/lib.descope/api/v1/management/permission_spec.rb +81 -0
- data/spec/lib.descope/api/v1/management/project_spec.rb +63 -0
- data/spec/lib.descope/api/v1/management/role_spec.rb +85 -0
- data/spec/lib.descope/api/v1/management/scim_spec.rb +312 -0
- data/spec/lib.descope/api/v1/management/sso_settings_spec.rb +172 -0
- data/spec/lib.descope/api/v1/management/tenant_spec.rb +141 -0
- data/spec/lib.descope/api/v1/management/user_spec.rb +667 -0
- data/spec/lib.descope/api/v1/session_spec.rb +117 -0
- data/spec/lib.descope/client_spec.rb +40 -0
- data/spec/spec_helper.rb +72 -0
- data/spec/support/client_config.rb +14 -0
- data/spec/support/dummy_class.rb +36 -0
- data/spec/support/utils.rb +32 -0
- metadata +420 -0
@@ -0,0 +1,312 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Descope::Api::V1::Management::SCIM do
|
6
|
+
before(:all) do
|
7
|
+
dummy_instance = DummyClass.new
|
8
|
+
dummy_instance.extend(Descope::Api::V1::Management::SCIM)
|
9
|
+
@instance = dummy_instance
|
10
|
+
end
|
11
|
+
|
12
|
+
context '.scim_search_groups' do
|
13
|
+
it 'should respond to .scim_search_groups' do
|
14
|
+
expect(@instance).to respond_to :scim_search_groups
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'is expected to get scim groups' do
|
18
|
+
filter = 'filter'
|
19
|
+
start_index = 1
|
20
|
+
count = 10
|
21
|
+
excluded_attributes = { abc: '123' }
|
22
|
+
url = @instance.send(:compose_scim_search_groups_url,
|
23
|
+
filter,
|
24
|
+
start_index,
|
25
|
+
count,
|
26
|
+
excluded_attributes)
|
27
|
+
expect(@instance).to receive(:get).with(url)
|
28
|
+
expect do
|
29
|
+
@instance.scim_search_groups(filter:, start_index:, count:, excluded_attributes:)
|
30
|
+
end.not_to raise_error
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context '.scim_create_group' do
|
35
|
+
it 'should respond to .scim_create_group' do
|
36
|
+
expect(@instance).to respond_to :scim_create_group
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'is expected to create scim group' do
|
40
|
+
group_id = 'group_id'
|
41
|
+
display_name = 'display_name'
|
42
|
+
members = ['members']
|
43
|
+
external_id = 'external_id'
|
44
|
+
excluded_attributes = { abc: '123' }
|
45
|
+
body = @instance.send(:compose_scim_create_group_body,
|
46
|
+
group_id,
|
47
|
+
display_name,
|
48
|
+
members,
|
49
|
+
external_id,
|
50
|
+
excluded_attributes)
|
51
|
+
expect(@instance).to receive(:post).with(Descope::Api::V1::Management::Common::SCIM_GROUPS_PATH, body)
|
52
|
+
expect do
|
53
|
+
@instance.scim_create_group(group_id:,
|
54
|
+
display_name:,
|
55
|
+
members:,
|
56
|
+
external_id:,
|
57
|
+
excluded_attributes:)
|
58
|
+
end.not_to raise_error
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context '.scim_load_group' do
|
63
|
+
it 'should respond to .scim_load_group' do
|
64
|
+
expect(@instance).to respond_to :scim_load_group
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'is expected to load scim group' do
|
68
|
+
group_id = 'G123'
|
69
|
+
display_name = 'for display'
|
70
|
+
external_id = '1234'
|
71
|
+
excluded_attributes = { 'some': 'thing' }
|
72
|
+
url = @instance.send(
|
73
|
+
:compose_scim_create_group_url,
|
74
|
+
group_id, display_name, external_id, excluded_attributes
|
75
|
+
)
|
76
|
+
expect(@instance).to receive(:get).with(url)
|
77
|
+
expect do
|
78
|
+
@instance.scim_load_group(group_id:, display_name:, external_id:, excluded_attributes:)
|
79
|
+
end.not_to raise_error
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context '.scim_update_group' do
|
84
|
+
it 'should respond to .scim_update_group' do
|
85
|
+
expect(@instance).to respond_to :scim_update_group
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'is expected to update scim group' do
|
89
|
+
group_id = 'G123'
|
90
|
+
display_name = 'for display'
|
91
|
+
members = ['member1']
|
92
|
+
external_id = '1234'
|
93
|
+
excluded_attributes = { 'some': 'thing' }
|
94
|
+
body = @instance.send(
|
95
|
+
:compose_scim_update_group_body,
|
96
|
+
group_id, display_name, members, external_id, excluded_attributes
|
97
|
+
)
|
98
|
+
url = "#{SCIM_GROUPS_PATH}/#{group_id}"
|
99
|
+
expect(@instance).to receive(:patch).with(url, body)
|
100
|
+
expect do
|
101
|
+
@instance.scim_update_group(group_id:, display_name:, members:, external_id:, excluded_attributes:)
|
102
|
+
end.not_to raise_error
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context '.scim_delete_group' do
|
107
|
+
it 'should respond to .scim_delete_group' do
|
108
|
+
expect(@instance).to respond_to :scim_delete_group
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'is expected to delete scim group' do
|
112
|
+
group_id = 'G123'
|
113
|
+
url = "#{SCIM_GROUPS_PATH}/#{group_id}"
|
114
|
+
expect(@instance).to receive(:delete).with(url)
|
115
|
+
expect { @instance.scim_delete_group(group_id) }.not_to raise_error
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context '.scim_patch_group' do
|
120
|
+
it 'should respond to .scim_patch_group' do
|
121
|
+
expect(@instance).to respond_to :scim_patch_group
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'is expected to patch scim group' do
|
125
|
+
group_id = 'G123'
|
126
|
+
user_id = 'U123'
|
127
|
+
operations = [
|
128
|
+
{
|
129
|
+
op: 'add',
|
130
|
+
path: '/auth',
|
131
|
+
value_string: 'something',
|
132
|
+
value_boolean: 'true',
|
133
|
+
value_array: [1, 2, 3]
|
134
|
+
}, {
|
135
|
+
op: 'remove',
|
136
|
+
path: '/authOTP',
|
137
|
+
value_string: 'done',
|
138
|
+
value_boolean: 'false',
|
139
|
+
value_array: [4, 5, 6]
|
140
|
+
}
|
141
|
+
]
|
142
|
+
|
143
|
+
url = @instance.send(:compose_scim_patch_group_url, group_id, user_id, operations)
|
144
|
+
|
145
|
+
expect(@instance).to receive(:patch).with(url)
|
146
|
+
expect do
|
147
|
+
@instance.scim_patch_group(group_id:, user_id:, operations:)
|
148
|
+
end.not_to raise_error
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
context '.scim_load_resource_types' do
|
153
|
+
it 'should respond to .scim_load_resource_types' do
|
154
|
+
expect(@instance).to respond_to :scim_load_resource_types
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'is expected to load scim resource types' do
|
158
|
+
url = "#{SCIM_RESOURCE_TYPES_PATH}"
|
159
|
+
expect(@instance).to receive(:get).with(url)
|
160
|
+
expect { @instance.scim_load_resource_types }.not_to raise_error
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
context '.scim_load_service_provider_config' do
|
165
|
+
it 'should respond to .scim_load_service_provider_config' do
|
166
|
+
expect(@instance).to respond_to :scim_load_service_provider_config
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'is expected to load scim service provider config' do
|
170
|
+
url = "#{SCIM_SERVICE_PROVIDER_CONFIG_PATH}"
|
171
|
+
expect(@instance).to receive(:get).with(url)
|
172
|
+
expect { @instance.scim_load_service_provider_config }.not_to raise_error
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
context '.scim_search_users' do
|
177
|
+
it 'should respond to .scim_search_users' do
|
178
|
+
expect(@instance).to respond_to :scim_search_users
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'is expected to search scim users' do
|
182
|
+
filter = 'filter'
|
183
|
+
start_index = 1
|
184
|
+
count = 10
|
185
|
+
url = @instance.send(:compose_scim_search_users_url,
|
186
|
+
filter,
|
187
|
+
start_index,
|
188
|
+
count)
|
189
|
+
expect(@instance).to receive(:get).with(url)
|
190
|
+
expect do
|
191
|
+
@instance.scim_search_users(filter:, start_index:, count:)
|
192
|
+
end.not_to raise_error
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
context '.scim_create_user' do
|
197
|
+
it 'should respond to .scim_create_user' do
|
198
|
+
expect(@instance).to respond_to :scim_create_user
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'is expected to create scim user' do
|
202
|
+
user_id = 'user_id'
|
203
|
+
display_name = 'display_name'
|
204
|
+
emails = ['email']
|
205
|
+
phone_numbers = ['phone_number']
|
206
|
+
active = true
|
207
|
+
name = {
|
208
|
+
given_name: 'given_name',
|
209
|
+
family_name: 'family_name',
|
210
|
+
last_name: 'last_name'
|
211
|
+
}
|
212
|
+
user_name = 'user_name'
|
213
|
+
|
214
|
+
body = @instance.send(:compose_scim_create_user_body,
|
215
|
+
user_id,
|
216
|
+
display_name,
|
217
|
+
emails,
|
218
|
+
phone_numbers,
|
219
|
+
active,
|
220
|
+
name,
|
221
|
+
user_name)
|
222
|
+
expect(@instance).to receive(:post).with(SCIM_USERS_PATH, body)
|
223
|
+
expect do
|
224
|
+
@instance.scim_create_user(
|
225
|
+
user_id:,
|
226
|
+
display_name:,
|
227
|
+
emails:,
|
228
|
+
phone_numbers:,
|
229
|
+
active:,
|
230
|
+
name:,
|
231
|
+
user_name:
|
232
|
+
)
|
233
|
+
end.not_to raise_error
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
context '.scim_load_user' do
|
238
|
+
it 'should respond to .scim_load_user' do
|
239
|
+
expect(@instance).to respond_to :scim_load_user
|
240
|
+
end
|
241
|
+
|
242
|
+
it 'is expected to load scim user' do
|
243
|
+
user_id = 'U123'
|
244
|
+
url = "#{SCIM_USERS_PATH}/#{user_id}"
|
245
|
+
expect(@instance).to receive(:get).with(url)
|
246
|
+
expect do
|
247
|
+
@instance.scim_load_user(user_id)
|
248
|
+
end.not_to raise_error
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
context '.scim_update_user' do
|
253
|
+
it 'should respond to .scim_update_user' do
|
254
|
+
expect(@instance).to respond_to :scim_update_user
|
255
|
+
end
|
256
|
+
|
257
|
+
it 'is expected to load scim user' do
|
258
|
+
user_id = 'U123'
|
259
|
+
url = "#{SCIM_USERS_PATH}/#{user_id}"
|
260
|
+
expect(@instance).to receive(:patch).with(url)
|
261
|
+
expect do
|
262
|
+
@instance.scim_update_user(user_id)
|
263
|
+
end.not_to raise_error
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
context '.scim_delete_user' do
|
268
|
+
it 'should respond to .scim_delete_user' do
|
269
|
+
expect(@instance).to respond_to :scim_delete_user
|
270
|
+
end
|
271
|
+
|
272
|
+
it 'is expected to delete scim user' do
|
273
|
+
user_id = 'U123'
|
274
|
+
url = "#{SCIM_USERS_PATH}/#{user_id}"
|
275
|
+
expect(@instance).to receive(:delete).with(url)
|
276
|
+
expect { @instance.scim_delete_user(user_id) }.not_to raise_error
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
context '.scim_patch_user' do
|
281
|
+
it 'should respond to .scim_patch_user' do
|
282
|
+
expect(@instance).to respond_to :scim_patch_user
|
283
|
+
end
|
284
|
+
|
285
|
+
it 'is expected to patch scim user' do
|
286
|
+
user_id = 'U123'
|
287
|
+
group_id = 'G123'
|
288
|
+
operations = [
|
289
|
+
{
|
290
|
+
op: 'add',
|
291
|
+
path: '/auth',
|
292
|
+
value_string: 'something',
|
293
|
+
value_boolean: 'true',
|
294
|
+
value_array: [1, 2, 3]
|
295
|
+
}, {
|
296
|
+
op: 'remove',
|
297
|
+
path: '/authOTP',
|
298
|
+
value_string: 'done',
|
299
|
+
value_boolean: 'false',
|
300
|
+
value_array: [4, 5, 6]
|
301
|
+
}
|
302
|
+
]
|
303
|
+
|
304
|
+
body = @instance.send(:compose_scim_patch_user_body, user_id, group_id, operations)
|
305
|
+
|
306
|
+
expect(@instance).to receive(:patch).with(SCIM_USERS_PATH, body)
|
307
|
+
expect do
|
308
|
+
@instance.scim_patch_user(user_id:, group_id:, operations:)
|
309
|
+
end.not_to raise_error
|
310
|
+
end
|
311
|
+
end
|
312
|
+
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Descope::Api::V1::Management::SSOSettings do
|
6
|
+
before(:all) do
|
7
|
+
dummy_instance = DummyClass.new
|
8
|
+
dummy_instance.extend(Descope::Api::V1::Management::SSOSettings)
|
9
|
+
@instance = dummy_instance
|
10
|
+
end
|
11
|
+
|
12
|
+
context '.get_sso_settings' do
|
13
|
+
it 'should respond to .get_sso_settings' do
|
14
|
+
expect(@instance).to respond_to :get_sso_settings
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'is expected to get SSO settings' do
|
18
|
+
expect(@instance).to receive(:get).with(
|
19
|
+
SSO_SETTINGS_PATH, { tenantId: '123' }
|
20
|
+
)
|
21
|
+
expect { @instance.get_sso_settings('123') }.not_to raise_error
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context '.delete_sso_settings' do
|
26
|
+
it 'should respond to .delete_sso_settings' do
|
27
|
+
expect(@instance).to respond_to :delete_sso_settings
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'is expected to delete SSO settings' do
|
31
|
+
expect(@instance).to receive(:delete).with(
|
32
|
+
SSO_SETTINGS_PATH, { tenantId: '123' }
|
33
|
+
)
|
34
|
+
expect { @instance.delete_sso_settings('123') }.not_to raise_error
|
35
|
+
end
|
36
|
+
|
37
|
+
context '.configure_sso_oidc_settings' do
|
38
|
+
it 'should respond to .configure_sso_oidc' do
|
39
|
+
expect(@instance).to respond_to :configure_sso_oidc
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'is expected to configure SSO settings' do
|
43
|
+
expect(@instance).to receive(:post).with(
|
44
|
+
SSO_OIDC_PATH, {
|
45
|
+
tenantId: '123',
|
46
|
+
settings: {
|
47
|
+
name: 'test',
|
48
|
+
clientId: 'test',
|
49
|
+
scope: ['test'],
|
50
|
+
userAttrMapping: {
|
51
|
+
loginId: 'test',
|
52
|
+
username: 'test',
|
53
|
+
name: 'test'
|
54
|
+
},
|
55
|
+
callbackDomain: 'test'
|
56
|
+
},
|
57
|
+
redirectUrl: 'test',
|
58
|
+
domain: 'test'
|
59
|
+
}
|
60
|
+
)
|
61
|
+
expect do
|
62
|
+
@instance.configure_sso_oidc(
|
63
|
+
tenant_id: '123',
|
64
|
+
settings: {
|
65
|
+
name: 'test',
|
66
|
+
client_id: 'test',
|
67
|
+
scope: ['test'],
|
68
|
+
user_attr_mapping: {
|
69
|
+
login_id: 'test',
|
70
|
+
username: 'test',
|
71
|
+
name: 'test'
|
72
|
+
},
|
73
|
+
callback_domain: 'test'
|
74
|
+
},
|
75
|
+
redirect_url: 'test',
|
76
|
+
domain: 'test'
|
77
|
+
)
|
78
|
+
end.not_to raise_error
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context '.configure_sso_saml_settings' do
|
84
|
+
it 'should respond to .configure_sso_saml' do
|
85
|
+
expect(@instance).to respond_to :configure_sso_saml
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'is expected to configure SSO settings' do
|
89
|
+
expect(@instance).to receive(:post).with(
|
90
|
+
SSO_SAML_PATH, {
|
91
|
+
tenantId: '123',
|
92
|
+
settings: {
|
93
|
+
name: 'test',
|
94
|
+
clientId: 'test',
|
95
|
+
scope: ['test'],
|
96
|
+
userAttrMapping: {
|
97
|
+
loginId: 'test',
|
98
|
+
username: 'test',
|
99
|
+
name: 'test'
|
100
|
+
},
|
101
|
+
callbackDomain: 'test'
|
102
|
+
},
|
103
|
+
redirectUrl: 'test',
|
104
|
+
domain: 'test'
|
105
|
+
}
|
106
|
+
)
|
107
|
+
expect do
|
108
|
+
@instance.configure_sso_saml(
|
109
|
+
tenant_id: '123',
|
110
|
+
settings: {
|
111
|
+
name: 'test',
|
112
|
+
client_id: 'test',
|
113
|
+
scope: ['test'],
|
114
|
+
user_attr_mapping: {
|
115
|
+
login_id: 'test',
|
116
|
+
username: 'test',
|
117
|
+
name: 'test'
|
118
|
+
},
|
119
|
+
callback_domain: 'test'
|
120
|
+
},
|
121
|
+
redirect_url: 'test',
|
122
|
+
domain: 'test'
|
123
|
+
)
|
124
|
+
end.not_to raise_error
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
context '.configure_sso_saml_metadata' do
|
129
|
+
it 'should respond to .configure_sso_saml_metadata' do
|
130
|
+
expect(@instance).to respond_to :configure_sso_saml_metadata
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'is expected to configure SAML metadata' do
|
134
|
+
expect(@instance).to receive(:post).with(
|
135
|
+
SSO_SAML_METADATA_PATH, {
|
136
|
+
tenantId: '123',
|
137
|
+
settings: {
|
138
|
+
name: 'test',
|
139
|
+
clientId: 'test',
|
140
|
+
scope: ['test'],
|
141
|
+
userAttrMapping: {
|
142
|
+
loginId: 'test',
|
143
|
+
username: 'test',
|
144
|
+
name: 'test'
|
145
|
+
},
|
146
|
+
callbackDomain: 'test'
|
147
|
+
},
|
148
|
+
redirectUrl: 'test',
|
149
|
+
domain: 'test'
|
150
|
+
}
|
151
|
+
)
|
152
|
+
expect do
|
153
|
+
@instance.configure_sso_saml_metadata(
|
154
|
+
tenant_id: '123',
|
155
|
+
settings: {
|
156
|
+
name: 'test',
|
157
|
+
client_id: 'test',
|
158
|
+
scope: ['test'],
|
159
|
+
user_attr_mapping: {
|
160
|
+
login_id: 'test',
|
161
|
+
username: 'test',
|
162
|
+
name: 'test'
|
163
|
+
},
|
164
|
+
callback_domain: 'test'
|
165
|
+
},
|
166
|
+
redirect_url: 'test',
|
167
|
+
domain: 'test'
|
168
|
+
)
|
169
|
+
end.not_to raise_error
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Descope::Api::V1::Management::Tenant do
|
6
|
+
before(:all) do
|
7
|
+
dummy_instance = DummyClass.new
|
8
|
+
dummy_instance.extend(Descope::Api::V1::Management::Tenant)
|
9
|
+
@instance = dummy_instance
|
10
|
+
end
|
11
|
+
|
12
|
+
context '.create_tenant' do
|
13
|
+
it 'should respond to .create_tenant' do
|
14
|
+
expect(@instance).to respond_to :create_tenant
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'is expected to create a new tenant' do
|
18
|
+
expect(@instance).to receive(:post).with(
|
19
|
+
TENANT_CREATE_PATH, {
|
20
|
+
name: 'test',
|
21
|
+
id: 'test',
|
22
|
+
selfProvisioningDomains: %w[descope.com descope.io],
|
23
|
+
customAttributes: [
|
24
|
+
{ name: 'test', value: 'test' },
|
25
|
+
{ name: 'test2', value: 'test2' }
|
26
|
+
]
|
27
|
+
}
|
28
|
+
)
|
29
|
+
expect do
|
30
|
+
@instance.create_tenant(
|
31
|
+
name: 'test',
|
32
|
+
id: 'test',
|
33
|
+
self_provisioning_domains: %w[descope.com descope.io],
|
34
|
+
custom_attributes: [
|
35
|
+
{ name: 'test', value: 'test' },
|
36
|
+
{ name: 'test2', value: 'test2' }
|
37
|
+
]
|
38
|
+
)
|
39
|
+
end.not_to raise_error
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context '.update_tenant' do
|
44
|
+
it 'should respond to .update_tenant' do
|
45
|
+
expect(@instance).to respond_to :update_tenant
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'is expected to update a tenant' do
|
49
|
+
expect(@instance).to receive(:post).with(
|
50
|
+
TENANT_UPDATE_PATH, {
|
51
|
+
name: 'test',
|
52
|
+
id: 'test',
|
53
|
+
selfProvisioningDomains: %w[descope.com descope.io],
|
54
|
+
customAttributes: [
|
55
|
+
{ name: 'test', value: 'test' },
|
56
|
+
{ name: 'test2', value: 'test2' }
|
57
|
+
]
|
58
|
+
}
|
59
|
+
)
|
60
|
+
expect do
|
61
|
+
@instance.update_tenant(
|
62
|
+
name: 'test',
|
63
|
+
id: 'test',
|
64
|
+
self_provisioning_domains: %w[descope.com descope.io],
|
65
|
+
custom_attributes: [
|
66
|
+
{ name: 'test', value: 'test' },
|
67
|
+
{ name: 'test2', value: 'test2' }
|
68
|
+
]
|
69
|
+
)
|
70
|
+
end.not_to raise_error
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context '.delete_tenant' do
|
75
|
+
it 'should respond to .delete_tenant' do
|
76
|
+
expect(@instance).to respond_to :delete_tenant
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'is expected to delete a tenant' do
|
80
|
+
expect(@instance).to receive(:post).with(
|
81
|
+
TENANT_DELETE_PATH, { id: 'test' }
|
82
|
+
)
|
83
|
+
expect { @instance.delete_tenant('test') }.not_to raise_error
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context '.load_tenant' do
|
88
|
+
it 'should respond to .load_tenant' do
|
89
|
+
expect(@instance).to respond_to :load_tenant
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'is expected to load a tenant' do
|
93
|
+
expect(@instance).to receive(:get).with(
|
94
|
+
TENANT_LOAD_PATH, { id: 'test' }
|
95
|
+
)
|
96
|
+
expect { @instance.load_tenant('test') }.not_to raise_error
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context '.load_all_tenants' do
|
101
|
+
it 'should respond to .load_all_tenants' do
|
102
|
+
expect(@instance).to respond_to :load_all_tenants
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'is expected to load all tenants' do
|
106
|
+
expect(@instance).to receive(:get).with(TENANT_LOAD_ALL_PATH)
|
107
|
+
expect { @instance.load_all_tenants }.not_to raise_error
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
context '.search_all_tenants' do
|
112
|
+
it 'should respond to .search_all_tenants' do
|
113
|
+
expect(@instance).to respond_to :search_all_tenants
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'is expected to search all tenants' do
|
117
|
+
expect(@instance).to receive(:post).with(
|
118
|
+
TENANT_SEARCH_ALL_PATH, {
|
119
|
+
ids: %w[test1 test2],
|
120
|
+
names: %w[test1 test2],
|
121
|
+
selfProvisioningDomains: %w[descope.com descope.io],
|
122
|
+
customAttributes: [
|
123
|
+
{ name: 'test', value: 'test' },
|
124
|
+
{ name: 'test2', value: 'test2' }
|
125
|
+
]
|
126
|
+
}
|
127
|
+
)
|
128
|
+
expect do
|
129
|
+
@instance.search_all_tenants(
|
130
|
+
ids: %w[test1 test2],
|
131
|
+
names: %w[test1 test2],
|
132
|
+
self_provisioning_domains: %w[descope.com descope.io],
|
133
|
+
custom_attributes: [
|
134
|
+
{ name: 'test', value: 'test' },
|
135
|
+
{ name: 'test2', value: 'test2' }
|
136
|
+
]
|
137
|
+
)
|
138
|
+
end.not_to raise_error
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|