descope 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ci.yaml +54 -0
  3. data/.gitignore +59 -0
  4. data/.release-please-manifest.json +3 -0
  5. data/.rubocop.yml +10 -0
  6. data/.rubocop_todo.yml +10 -0
  7. data/.ruby-version +1 -0
  8. data/CHANGELOG.md +90 -0
  9. data/Gemfile +22 -0
  10. data/Gemfile.lock +204 -0
  11. data/LICENSE +21 -0
  12. data/README.md +1171 -0
  13. data/Rakefile +31 -0
  14. data/descope.gemspec +34 -0
  15. data/examples/ruby/Gemfile +4 -0
  16. data/examples/ruby/Gemfile.lock +41 -0
  17. data/examples/ruby/access_key_app.rb +45 -0
  18. data/examples/ruby/enchantedlink_app.rb +65 -0
  19. data/examples/ruby/magiclink_app.rb +81 -0
  20. data/examples/ruby/management/Gemfile +5 -0
  21. data/examples/ruby/management/Gemfile.lock +38 -0
  22. data/examples/ruby/management/access_key_app.rb +71 -0
  23. data/examples/ruby/management/audit_app.rb +25 -0
  24. data/examples/ruby/management/authz_app.rb +135 -0
  25. data/examples/ruby/management/authz_files.json +229 -0
  26. data/examples/ruby/management/flow_app.rb +57 -0
  27. data/examples/ruby/management/permission_app.rb +56 -0
  28. data/examples/ruby/management/role_app.rb +58 -0
  29. data/examples/ruby/management/tenant_app.rb +60 -0
  30. data/examples/ruby/management/user_app.rb +60 -0
  31. data/examples/ruby/oauth_app.rb +39 -0
  32. data/examples/ruby/otp_app.rb +50 -0
  33. data/examples/ruby/password_app.rb +76 -0
  34. data/examples/ruby/saml_app.rb +38 -0
  35. data/examples/ruby-on-rails-api/descope/.dockerignore +37 -0
  36. data/examples/ruby-on-rails-api/descope/.gitattributes +9 -0
  37. data/examples/ruby-on-rails-api/descope/.gitignore +40 -0
  38. data/examples/ruby-on-rails-api/descope/.node-version +1 -0
  39. data/examples/ruby-on-rails-api/descope/.ruby-version +1 -0
  40. data/examples/ruby-on-rails-api/descope/Dockerfile +75 -0
  41. data/examples/ruby-on-rails-api/descope/Gemfile +67 -0
  42. data/examples/ruby-on-rails-api/descope/Gemfile.lock +284 -0
  43. data/examples/ruby-on-rails-api/descope/Procfile.dev +3 -0
  44. data/examples/ruby-on-rails-api/descope/README.md +54 -0
  45. data/examples/ruby-on-rails-api/descope/Rakefile +6 -0
  46. data/examples/ruby-on-rails-api/descope/app/assets/builds/.keep +0 -0
  47. data/examples/ruby-on-rails-api/descope/app/assets/config/manifest.js +3 -0
  48. data/examples/ruby-on-rails-api/descope/app/assets/images/.keep +0 -0
  49. data/examples/ruby-on-rails-api/descope/app/assets/images/descope.jpeg +0 -0
  50. data/examples/ruby-on-rails-api/descope/app/assets/images/favicon.ico +0 -0
  51. data/examples/ruby-on-rails-api/descope/app/assets/images/logo192.png +0 -0
  52. data/examples/ruby-on-rails-api/descope/app/assets/images/logo512.png +0 -0
  53. data/examples/ruby-on-rails-api/descope/app/assets/stylesheets/application.bootstrap.scss +67 -0
  54. data/examples/ruby-on-rails-api/descope/app/channels/application_cable/channel.rb +4 -0
  55. data/examples/ruby-on-rails-api/descope/app/channels/application_cable/connection.rb +4 -0
  56. data/examples/ruby-on-rails-api/descope/app/controllers/application_controller.rb +2 -0
  57. data/examples/ruby-on-rails-api/descope/app/controllers/concerns/.keep +0 -0
  58. data/examples/ruby-on-rails-api/descope/app/controllers/homepage_controller.rb +4 -0
  59. data/examples/ruby-on-rails-api/descope/app/controllers/session_controller.rb +66 -0
  60. data/examples/ruby-on-rails-api/descope/app/helpers/application_helper.rb +2 -0
  61. data/examples/ruby-on-rails-api/descope/app/helpers/homepage_helper.rb +2 -0
  62. data/examples/ruby-on-rails-api/descope/app/helpers/session_helper.rb +2 -0
  63. data/examples/ruby-on-rails-api/descope/app/javascript/App.css +53 -0
  64. data/examples/ruby-on-rails-api/descope/app/javascript/application.js +5 -0
  65. data/examples/ruby-on-rails-api/descope/app/javascript/components/App.jsx +4 -0
  66. data/examples/ruby-on-rails-api/descope/app/javascript/components/Dashboard.jsx +60 -0
  67. data/examples/ruby-on-rails-api/descope/app/javascript/components/Home.jsx +27 -0
  68. data/examples/ruby-on-rails-api/descope/app/javascript/components/Login.jsx +45 -0
  69. data/examples/ruby-on-rails-api/descope/app/javascript/components/Profile.jsx +81 -0
  70. data/examples/ruby-on-rails-api/descope/app/javascript/components/index.html +11 -0
  71. data/examples/ruby-on-rails-api/descope/app/javascript/components/index.jsx +24 -0
  72. data/examples/ruby-on-rails-api/descope/app/javascript/controllers/application.js +9 -0
  73. data/examples/ruby-on-rails-api/descope/app/javascript/controllers/index.js +5 -0
  74. data/examples/ruby-on-rails-api/descope/app/javascript/reportWebVitals.js +13 -0
  75. data/examples/ruby-on-rails-api/descope/app/javascript/routes/index.jsx +17 -0
  76. data/examples/ruby-on-rails-api/descope/app/jobs/application_job.rb +7 -0
  77. data/examples/ruby-on-rails-api/descope/app/mailers/application_mailer.rb +4 -0
  78. data/examples/ruby-on-rails-api/descope/app/models/application_record.rb +3 -0
  79. data/examples/ruby-on-rails-api/descope/app/models/concerns/.keep +0 -0
  80. data/examples/ruby-on-rails-api/descope/app/views/homepage/index.html.erb +2 -0
  81. data/examples/ruby-on-rails-api/descope/app/views/layouts/application.html.erb +16 -0
  82. data/examples/ruby-on-rails-api/descope/app/views/layouts/mailer.html.erb +13 -0
  83. data/examples/ruby-on-rails-api/descope/app/views/layouts/mailer.text.erb +1 -0
  84. data/examples/ruby-on-rails-api/descope/app/views/session/index.html.erb +2 -0
  85. data/examples/ruby-on-rails-api/descope/bin/bundle +109 -0
  86. data/examples/ruby-on-rails-api/descope/bin/dev +11 -0
  87. data/examples/ruby-on-rails-api/descope/bin/docker-entrypoint +8 -0
  88. data/examples/ruby-on-rails-api/descope/bin/rails +4 -0
  89. data/examples/ruby-on-rails-api/descope/bin/rake +4 -0
  90. data/examples/ruby-on-rails-api/descope/bin/setup +36 -0
  91. data/examples/ruby-on-rails-api/descope/build.js +30 -0
  92. data/examples/ruby-on-rails-api/descope/config/application.rb +42 -0
  93. data/examples/ruby-on-rails-api/descope/config/boot.rb +4 -0
  94. data/examples/ruby-on-rails-api/descope/config/cable.yml +10 -0
  95. data/examples/ruby-on-rails-api/descope/config/config.yml +9 -0
  96. data/examples/ruby-on-rails-api/descope/config/credentials.yml.enc +1 -0
  97. data/examples/ruby-on-rails-api/descope/config/database.yml +25 -0
  98. data/examples/ruby-on-rails-api/descope/config/environment.rb +5 -0
  99. data/examples/ruby-on-rails-api/descope/config/environments/development.rb +76 -0
  100. data/examples/ruby-on-rails-api/descope/config/environments/production.rb +97 -0
  101. data/examples/ruby-on-rails-api/descope/config/environments/test.rb +64 -0
  102. data/examples/ruby-on-rails-api/descope/config/initializers/assets.rb +13 -0
  103. data/examples/ruby-on-rails-api/descope/config/initializers/content_security_policy.rb +25 -0
  104. data/examples/ruby-on-rails-api/descope/config/initializers/filter_parameter_logging.rb +8 -0
  105. data/examples/ruby-on-rails-api/descope/config/initializers/inflections.rb +16 -0
  106. data/examples/ruby-on-rails-api/descope/config/initializers/load_config.rb +12 -0
  107. data/examples/ruby-on-rails-api/descope/config/initializers/permissions_policy.rb +13 -0
  108. data/examples/ruby-on-rails-api/descope/config/locales/en.yml +31 -0
  109. data/examples/ruby-on-rails-api/descope/config/puma.rb +35 -0
  110. data/examples/ruby-on-rails-api/descope/config/routes.rb +18 -0
  111. data/examples/ruby-on-rails-api/descope/config/storage.yml +34 -0
  112. data/examples/ruby-on-rails-api/descope/config.ru +6 -0
  113. data/examples/ruby-on-rails-api/descope/db/seeds.rb +9 -0
  114. data/examples/ruby-on-rails-api/descope/lib/assets/.keep +0 -0
  115. data/examples/ruby-on-rails-api/descope/lib/tasks/.keep +0 -0
  116. data/examples/ruby-on-rails-api/descope/log/.keep +0 -0
  117. data/examples/ruby-on-rails-api/descope/package-lock.json +19680 -0
  118. data/examples/ruby-on-rails-api/descope/package.json +51 -0
  119. data/examples/ruby-on-rails-api/descope/public/404.html +67 -0
  120. data/examples/ruby-on-rails-api/descope/public/422.html +67 -0
  121. data/examples/ruby-on-rails-api/descope/public/500.html +66 -0
  122. data/examples/ruby-on-rails-api/descope/public/apple-touch-icon-precomposed.png +0 -0
  123. data/examples/ruby-on-rails-api/descope/public/apple-touch-icon.png +0 -0
  124. data/examples/ruby-on-rails-api/descope/public/favicon.ico +0 -0
  125. data/examples/ruby-on-rails-api/descope/public/robots.txt +1 -0
  126. data/examples/ruby-on-rails-api/descope/storage/.keep +0 -0
  127. data/examples/ruby-on-rails-api/descope/tmp/.keep +0 -0
  128. data/examples/ruby-on-rails-api/descope/tmp/pids/.keep +0 -0
  129. data/examples/ruby-on-rails-api/descope/tmp/storage/.keep +0 -0
  130. data/examples/ruby-on-rails-api/descope/vendor/.keep +0 -0
  131. data/examples/ruby-on-rails-api/descope/yarn.lock +10780 -0
  132. data/lib/descope/api/v1/auth/enchantedlink.rb +156 -0
  133. data/lib/descope/api/v1/auth/magiclink.rb +170 -0
  134. data/lib/descope/api/v1/auth/oauth.rb +72 -0
  135. data/lib/descope/api/v1/auth/otp.rb +186 -0
  136. data/lib/descope/api/v1/auth/password.rb +100 -0
  137. data/lib/descope/api/v1/auth/saml.rb +48 -0
  138. data/lib/descope/api/v1/auth/totp.rb +72 -0
  139. data/lib/descope/api/v1/auth.rb +452 -0
  140. data/lib/descope/api/v1/management/access_key.rb +81 -0
  141. data/lib/descope/api/v1/management/audit.rb +82 -0
  142. data/lib/descope/api/v1/management/authz.rb +165 -0
  143. data/lib/descope/api/v1/management/common.rb +147 -0
  144. data/lib/descope/api/v1/management/flow.rb +55 -0
  145. data/lib/descope/api/v1/management/password.rb +58 -0
  146. data/lib/descope/api/v1/management/permission.rb +48 -0
  147. data/lib/descope/api/v1/management/project.rb +53 -0
  148. data/lib/descope/api/v1/management/role.rb +48 -0
  149. data/lib/descope/api/v1/management/scim.rb +206 -0
  150. data/lib/descope/api/v1/management/sso_settings.rb +153 -0
  151. data/lib/descope/api/v1/management/tenant.rb +71 -0
  152. data/lib/descope/api/v1/management/user.rb +619 -0
  153. data/lib/descope/api/v1/management.rb +38 -0
  154. data/lib/descope/api/v1/session.rb +84 -0
  155. data/lib/descope/api/v1.rb +13 -0
  156. data/lib/descope/client.rb +6 -0
  157. data/lib/descope/exception.rb +50 -0
  158. data/lib/descope/mixins/common.rb +129 -0
  159. data/lib/descope/mixins/headers.rb +15 -0
  160. data/lib/descope/mixins/http.rb +133 -0
  161. data/lib/descope/mixins/initializer.rb +80 -0
  162. data/lib/descope/mixins/logging.rb +30 -0
  163. data/lib/descope/mixins/validation.rb +79 -0
  164. data/lib/descope/mixins.rb +22 -0
  165. data/lib/descope/version.rb +7 -0
  166. data/lib/descope.rb +9 -0
  167. data/lib/descope_client.rb +5 -0
  168. data/release-please-config.json +18 -0
  169. data/renovate.json +6 -0
  170. data/spec/factories/user.rb +16 -0
  171. data/spec/lib.descope/api/v1/auth/enchantedlink_spec.rb +159 -0
  172. data/spec/lib.descope/api/v1/auth/magiclink_spec.rb +282 -0
  173. data/spec/lib.descope/api/v1/auth/oauth_spec.rb +117 -0
  174. data/spec/lib.descope/api/v1/auth/otp_spec.rb +285 -0
  175. data/spec/lib.descope/api/v1/auth/password_spec.rb +124 -0
  176. data/spec/lib.descope/api/v1/auth/saml_spec.rb +55 -0
  177. data/spec/lib.descope/api/v1/auth/totp_spec.rb +70 -0
  178. data/spec/lib.descope/api/v1/auth_spec.rb +372 -0
  179. data/spec/lib.descope/api/v1/management/access_key_spec.rb +118 -0
  180. data/spec/lib.descope/api/v1/management/audit_spec.rb +78 -0
  181. data/spec/lib.descope/api/v1/management/authz_spec.rb +336 -0
  182. data/spec/lib.descope/api/v1/management/flow_spec.rb +78 -0
  183. data/spec/lib.descope/api/v1/management/password_spec.rb +25 -0
  184. data/spec/lib.descope/api/v1/management/permission_spec.rb +81 -0
  185. data/spec/lib.descope/api/v1/management/project_spec.rb +63 -0
  186. data/spec/lib.descope/api/v1/management/role_spec.rb +85 -0
  187. data/spec/lib.descope/api/v1/management/scim_spec.rb +312 -0
  188. data/spec/lib.descope/api/v1/management/sso_settings_spec.rb +172 -0
  189. data/spec/lib.descope/api/v1/management/tenant_spec.rb +141 -0
  190. data/spec/lib.descope/api/v1/management/user_spec.rb +667 -0
  191. data/spec/lib.descope/api/v1/session_spec.rb +117 -0
  192. data/spec/lib.descope/client_spec.rb +40 -0
  193. data/spec/spec_helper.rb +72 -0
  194. data/spec/support/client_config.rb +14 -0
  195. data/spec/support/dummy_class.rb +36 -0
  196. data/spec/support/utils.rb +32 -0
  197. metadata +420 -0
@@ -0,0 +1,117 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Descope::Api::V1::Session do
6
+ before(:all) do
7
+ dummy_instance = DummyClass.new
8
+ dummy_instance.extend(Descope::Api::V1::Session)
9
+ dummy_instance.extend(Descope::Mixins::Common::EndpointsV1)
10
+ @instance = dummy_instance
11
+ end
12
+
13
+ context '.token_validation_key' do
14
+ it 'is expected to respond to token validation key' do
15
+ expect(@instance).to respond_to(:token_validation_key)
16
+ end
17
+
18
+ it 'is expected to get v2 public key' do
19
+ project_id = 'project123'
20
+ expect(@instance).to receive(:get).with(
21
+ "#{Descope::Mixins::Common::EndpointsV2::PUBLIC_KEY_PATH}/#{project_id}"
22
+ )
23
+
24
+ expect { @instance.token_validation_key('project123') }.not_to raise_error
25
+ end
26
+ end
27
+
28
+ context '.refresh_session' do
29
+ it 'is expected to respond to refresh session' do
30
+ expect(@instance).to respond_to(:refresh_session)
31
+ end
32
+
33
+ it 'is expected to post refresh session' do
34
+ jwt_response = { 'fake': 'response' }
35
+ allow(@instance).to receive(:generate_jwt_response).and_return(jwt_response)
36
+
37
+ expect(@instance).to receive(:post).with(REFRESH_TOKEN_PATH, {}, {}, 'refresh_token')
38
+ allow(@instance).to receive(:validate_token).with('refresh_token', nil).and_return({})
39
+ expect { @instance.refresh_session(refresh_token: 'refresh_token') }.not_to raise_error
40
+ end
41
+ end
42
+
43
+ context '.me' do
44
+ it 'is expected to respond to /me' do
45
+ expect(@instance).to respond_to(:me)
46
+ end
47
+
48
+ it 'is expected to get /me' do
49
+ expect(@instance).to receive(:get).with(ME_PATH, {}, {}, nil)
50
+
51
+ expect { @instance.me }.not_to raise_error
52
+ end
53
+ end
54
+
55
+ context '.sign_out' do
56
+ it 'is expected to respond to sign out' do
57
+ expect(@instance).to respond_to(:sign_out)
58
+ end
59
+
60
+ it 'is expected to post sign out' do
61
+ expect(@instance).to receive(:post).with(LOGOUT_PATH, {}, {}, nil)
62
+
63
+ expect { @instance.sign_out }.not_to raise_error
64
+ end
65
+ end
66
+
67
+ context '.sign_out_all' do
68
+ it 'is expected to respond to sign out all' do
69
+ expect(@instance).to respond_to(:sign_out_all)
70
+ end
71
+
72
+ it 'is expected to post sign out all' do
73
+ expect(@instance).to receive(:post).with(LOGOUT_ALL_PATH, {}, {}, nil)
74
+
75
+ expect { @instance.sign_out_all }.not_to raise_error
76
+ end
77
+ end
78
+
79
+ context '.validate_session' do
80
+ it 'is expected to respond to validate session' do
81
+ expect(@instance).to respond_to(:validate_session)
82
+ end
83
+
84
+ it 'is expected to raise error if session token is nil' do
85
+ expect { @instance.validate_session }.to raise_error(
86
+ Descope::AuthException,
87
+ 'Session token is required for validation'
88
+ )
89
+ end
90
+
91
+ it 'is expected to raise error if session token is empty' do
92
+ expect { @instance.validate_session(session_token: '') }.to raise_error(
93
+ Descope::AuthException,
94
+ 'Session token is required for validation'
95
+ )
96
+ end
97
+
98
+ end
99
+
100
+ context '.validate_and_refresh_session' do
101
+ it 'is expected to respond to validate and refresh session' do
102
+ expect(@instance).to respond_to(:validate_and_refresh_session)
103
+ end
104
+
105
+ it 'is expected to try and validate session or refresh session' do
106
+ expect { @instance.validate_and_refresh_session(session_token: 'invalid_session_token') }.to raise_error(
107
+ Descope::AuthException,
108
+ 'Refresh token is required to refresh a session'
109
+ )
110
+ allow(@instance).to receive(:validate_session).with(session_token: 'session_token', audience: nil).and_raise(Descope::AuthException).and_return({})
111
+ jwt_response = { 'fake': 'response' }
112
+ allow(@instance).to receive(:generate_jwt_response).and_return(jwt_response)
113
+ allow(@instance).to receive(:refresh_session).and_return({})
114
+ expect { @instance.validate_and_refresh_session(session_token: 'session_token', refresh_token: 'refresh_token') }.to_not raise_error
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe Descope::Client do
4
+ shared_examples_for 'v1 API client' do
5
+ it { should be_a Descope::Api::V1 }
6
+ it { should be_a Descope::Api::V1::Management }
7
+ it { should be_a Descope::Api::V1::Management::User }
8
+ it { should be_a Descope::Api::V1::Management::Flow }
9
+ it { should be_a Descope::Api::V1::Management::AccessKey }
10
+ it { should be_a Descope::Api::V1::Management::Tenant }
11
+ it { should be_a Descope::Api::V1::Management::Permission }
12
+ it { should be_a Descope::Api::V1::Management::Role }
13
+ it { should be_a Descope::Api::V1::Management::Project }
14
+ it { should be_a Descope::Api::V1::Management::Authz }
15
+ it { should be_a Descope::Api::V1::Management::Audit }
16
+ it { should be_a Descope::Api::V1::Session }
17
+ it { should be_a Descope::Api::V1::Auth }
18
+ it { should be_a Descope::Api::V1::Auth::Password }
19
+ it { should be_a Descope::Api::V1::Auth::EnchantedLink }
20
+ it { should be_a Descope::Api::V1::Auth::MagicLink }
21
+ it { should be_a Descope::Api::V1::Auth::OAuth }
22
+ it { should be_a Descope::Api::V1::Auth::OTP }
23
+ it { should be_a Descope::Api::V1::Auth::SAML }
24
+ it { should be_a Descope::Api::V1::Auth::SAML }
25
+ it { should be_a Descope::Api::V1::Auth::TOTP }
26
+ end
27
+
28
+ let(:project_id) { 'P2AbcZVJYEUBGhX8LNjItawh5nAp' }
29
+ let(:management_key) { 'Abcdefg' }
30
+
31
+ describe 'V1 client with token' do
32
+ let(:subject) do
33
+ Descope::Client.new(
34
+ project_id:,
35
+ management_key:
36
+ )
37
+ end
38
+ it_should_behave_like 'v1 API client'
39
+ end
40
+ end
@@ -0,0 +1,72 @@
1
+ require 'rack/test'
2
+ require 'faker'
3
+ require 'json'
4
+ require 'concurrent'
5
+ require 'openssl'
6
+ require 'base64'
7
+ require 'descope'
8
+ require 'super_diff/rspec'
9
+ require 'factory_bot'
10
+
11
+ if RUBY_VERSION >= '2.7.2'
12
+ # NOTE: https://bugs.ruby-lang.org/issues/17000
13
+ Warning[:deprecated] = true
14
+ end
15
+
16
+ require 'simplecov'
17
+ require 'simplecov-html'
18
+
19
+ SimpleCov.start
20
+ SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
21
+
22
+ if ENV['CI'] == 'true'
23
+ require 'simplecov-cobertura'
24
+ SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
25
+ end
26
+
27
+ require 'webmock/rspec'
28
+ WebMock.allow_net_connect!
29
+
30
+ $LOAD_PATH.unshift File.expand_path('..', __FILE__)
31
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
32
+
33
+ Dir['./lib/*.rb'].each { |f| require f }
34
+ Dir['./lib/api/**/*.rb'].each { |f| require f }
35
+ Dir['./spec/support/**/*.rb'].each { |f| require f }
36
+ Dir['./spec/support/*.rb'].each { |f| require f }
37
+
38
+ include Descope::Api::V1::Management::Common
39
+ include Descope::Mixins::Common
40
+ include Descope::Mixins::Common::EndpointsV1
41
+ include Descope::Mixins::Common::EndpointsV2
42
+ include Descope::Api::V1::Auth
43
+
44
+ require 'rspec'
45
+ RSpec.configure do |config|
46
+ config.filter_run focus: true
47
+ config.run_all_when_everything_filtered = true
48
+
49
+ config.expect_with :rspec do |c|
50
+ c.max_formatted_output_length = 1000000
51
+ end
52
+
53
+ config.include FactoryBot::Syntax::Methods
54
+ config.before(:suite) do
55
+ FactoryBot.find_definitions
56
+ end
57
+ end
58
+
59
+
60
+ def wait(time, increment = 5, elapsed_time = 0, &block)
61
+ yield
62
+ rescue RSpec::Expectations::ExpectationNotMetError => e
63
+ raise e if elapsed_time >= time
64
+ sleep increment
65
+ wait(time, increment, elapsed_time + increment, &block)
66
+ end
67
+
68
+ def entity_suffix
69
+ 'rubytest-210908'
70
+ end
71
+
72
+ puts "Entity suffix is #{entity_suffix}"
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Configuration
4
+ module_function
5
+
6
+ def config
7
+ {
8
+ base_uri: ENV.fetch('DESCOPE_BASE_URI', nil),
9
+ project_id: ENV.fetch('DESCOPE_PROJECT_ID', nil),
10
+ management_key: ENV.fetch('DESCOPE_MANAGEMENT_KEY', nil),
11
+ log_level: ENV.fetch('DESCOPE_LOG_LEVEL', 'info')
12
+ }
13
+ end
14
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ class DummyClass
4
+ include Descope::Mixins::Logging
5
+ include Descope::Mixins::Headers
6
+ include Descope::Mixins::Common
7
+ include Descope::Mixins::Common::EndpointsV1
8
+ include Descope::Api::V1::Management::Common
9
+ include Descope::Api::V1::Auth
10
+
11
+ attr_reader :base_uri, :headers
12
+
13
+ def initialize
14
+ @base_uri = 'test.descope.com'
15
+ @headers = {
16
+ 'Content-Type' => 'application/json',
17
+ 'x-descope-sdk-name': 'ruby',
18
+ 'x-descope-sdk-ruby-version': RUBY_VERSION,
19
+ 'x-descope-sdk-version': Descope::SDK_VERSION
20
+ }
21
+ @project_id = 'P2abcde12345'
22
+ @management_key = 'management_key'
23
+ @public_keys = {}
24
+ @mlock = Mutex.new
25
+ @logger ||= Descope::Mixins::Logging.logger_for(self.class.name, 'info')
26
+ end
27
+
28
+ %i[get post post_file post_form put patch delete delete_with_body].each do |method|
29
+ define_method(method) do |uri, body = {}, extra_headers = {}, pswd = nil|
30
+ body = body.delete_if { |_, v| v.nil? }
31
+ authorization_header(pswd) unless pswd.nil? || pswd.empty?
32
+ {}
33
+ end
34
+ end
35
+
36
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SpecUtils
4
+ module_function
5
+
6
+ def generate_password
7
+ lowercase_characters = ('a'..'z').to_a
8
+ uppercase_characters = ('A'..'Z').to_a
9
+ digits = ('0'..'9').to_a
10
+ special_chars = %w[! @ # $ % ^ & *]
11
+
12
+ # Ensure one character from each category
13
+ password = lowercase_characters.sample +
14
+ uppercase_characters.sample +
15
+ digits.sample +
16
+ special_chars.sample
17
+
18
+ # Fill in remaining characters randomly
19
+ 4.times { password += [lowercase_characters, uppercase_characters, digits, special_chars].sample.sample }
20
+
21
+ # Randomize the order of characters to make the password less predictable
22
+ password.split('').shuffle.join
23
+ end
24
+
25
+ def deep_stringify_keys(hash)
26
+ hash.transform_keys!(&:to_s)
27
+ hash.each_value do |value|
28
+ deep_stringify_keys(value) if value.is_a? Hash
29
+ value.each { |v| deep_stringify_keys(v) if v.is_a? Hash } if value.is_a? Array
30
+ end
31
+ end
32
+ end