auth0 5.18.1 → 5.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (342) hide show
  1. checksums.yaml +4 -4
  2. data/.version +1 -1
  3. data/CHANGELOG.md +9 -0
  4. data/README.md +11 -0
  5. data/auth0.gemspec +1 -3
  6. data/lib/auth0/mixins/token_management.rb +17 -14
  7. data/lib/auth0/version.rb +1 -1
  8. metadata +2 -336
  9. data/.bundle/config +0 -4
  10. data/.devcontainer/Dockerfile +0 -19
  11. data/.devcontainer/devcontainer.json +0 -37
  12. data/.env.example +0 -2
  13. data/.github/CODEOWNERS +0 -1
  14. data/.github/ISSUE_TEMPLATE/Bug Report.yml +0 -67
  15. data/.github/ISSUE_TEMPLATE/Feature Request.yml +0 -53
  16. data/.github/ISSUE_TEMPLATE/config.yml +0 -8
  17. data/.github/PULL_REQUEST_TEMPLATE.md +0 -35
  18. data/.github/actions/get-prerelease/action.yml +0 -30
  19. data/.github/actions/get-release-notes/action.yml +0 -42
  20. data/.github/actions/get-version/action.yml +0 -21
  21. data/.github/actions/release-create/action.yml +0 -47
  22. data/.github/actions/rl-scanner/action.yml +0 -71
  23. data/.github/actions/rubygems-publish/action.yml +0 -30
  24. data/.github/actions/setup/action.yml +0 -32
  25. data/.github/actions/tag-exists/action.yml +0 -36
  26. data/.github/dependabot.yml +0 -13
  27. data/.github/stale.yml +0 -20
  28. data/.github/workflows/codeql.yml +0 -53
  29. data/.github/workflows/matrix.json +0 -3
  30. data/.github/workflows/release.yml +0 -36
  31. data/.github/workflows/rl-scanner.yml +0 -65
  32. data/.github/workflows/ruby-release.yml +0 -72
  33. data/.github/workflows/semgrep.yml +0 -40
  34. data/.github/workflows/snyk.yml +0 -40
  35. data/.github/workflows/test.yml +0 -69
  36. data/.gitignore +0 -18
  37. data/.rspec +0 -3
  38. data/.rubocop.yml +0 -10
  39. data/.rubocop_todo.yml +0 -5
  40. data/.semgrepignore +0 -6
  41. data/.shiprc +0 -8
  42. data/.snyk +0 -17
  43. data/CODE_OF_CONDUCT.md +0 -3
  44. data/DEPLOYMENT.md +0 -61
  45. data/DEVELOPMENT.md +0 -35
  46. data/Dockerfile +0 -5
  47. data/EXAMPLES.md +0 -222
  48. data/Gemfile +0 -18
  49. data/Gemfile.lock +0 -239
  50. data/Guardfile +0 -37
  51. data/RUBYGEM.md +0 -9
  52. data/Rakefile +0 -31
  53. data/codecov.yml +0 -22
  54. data/examples/ruby-api/.env.example +0 -2
  55. data/examples/ruby-api/.gitignore +0 -80
  56. data/examples/ruby-api/Gemfile +0 -9
  57. data/examples/ruby-api/Gemfile.lock +0 -42
  58. data/examples/ruby-api/README.md +0 -24
  59. data/examples/ruby-api/config.ru +0 -2
  60. data/examples/ruby-api/main.rb +0 -33
  61. data/examples/ruby-on-rails-api/.env.example +0 -2
  62. data/examples/ruby-on-rails-api/.gitignore +0 -18
  63. data/examples/ruby-on-rails-api/Gemfile +0 -48
  64. data/examples/ruby-on-rails-api/README.md +0 -25
  65. data/examples/ruby-on-rails-api/Rakefile +0 -6
  66. data/examples/ruby-on-rails-api/app/assets/images/.keep +0 -0
  67. data/examples/ruby-on-rails-api/app/assets/javascripts/application.js +0 -16
  68. data/examples/ruby-on-rails-api/app/assets/stylesheets/application.css +0 -15
  69. data/examples/ruby-on-rails-api/app/controllers/application_controller.rb +0 -8
  70. data/examples/ruby-on-rails-api/app/controllers/concerns/.keep +0 -0
  71. data/examples/ruby-on-rails-api/app/controllers/ping_controller.rb +0 -6
  72. data/examples/ruby-on-rails-api/app/controllers/secured_ping_controller.rb +0 -11
  73. data/examples/ruby-on-rails-api/app/helpers/application_helper.rb +0 -3
  74. data/examples/ruby-on-rails-api/app/mailers/.keep +0 -0
  75. data/examples/ruby-on-rails-api/app/models/.keep +0 -0
  76. data/examples/ruby-on-rails-api/app/models/User.rb +0 -5
  77. data/examples/ruby-on-rails-api/app/models/concerns/.keep +0 -0
  78. data/examples/ruby-on-rails-api/app/views/layouts/application.html.erb +0 -14
  79. data/examples/ruby-on-rails-api/bin/bundle +0 -3
  80. data/examples/ruby-on-rails-api/bin/rails +0 -4
  81. data/examples/ruby-on-rails-api/bin/rake +0 -4
  82. data/examples/ruby-on-rails-api/bin/setup +0 -29
  83. data/examples/ruby-on-rails-api/config/application.rb +0 -23
  84. data/examples/ruby-on-rails-api/config/boot.rb +0 -4
  85. data/examples/ruby-on-rails-api/config/database.yml +0 -27
  86. data/examples/ruby-on-rails-api/config/environment.rb +0 -5
  87. data/examples/ruby-on-rails-api/config/environments/development.rb +0 -37
  88. data/examples/ruby-on-rails-api/config/environments/production.rb +0 -83
  89. data/examples/ruby-on-rails-api/config/environments/test.rb +0 -41
  90. data/examples/ruby-on-rails-api/config/initializers/backtrace_silencers.rb +0 -7
  91. data/examples/ruby-on-rails-api/config/initializers/cookies_serializer.rb +0 -3
  92. data/examples/ruby-on-rails-api/config/initializers/dotenv.rb +0 -4
  93. data/examples/ruby-on-rails-api/config/initializers/filter_parameter_logging.rb +0 -4
  94. data/examples/ruby-on-rails-api/config/initializers/inflections.rb +0 -16
  95. data/examples/ruby-on-rails-api/config/initializers/knock.rb +0 -35
  96. data/examples/ruby-on-rails-api/config/initializers/mime_types.rb +0 -4
  97. data/examples/ruby-on-rails-api/config/initializers/session_store.rb +0 -3
  98. data/examples/ruby-on-rails-api/config/initializers/wrap_parameters.rb +0 -14
  99. data/examples/ruby-on-rails-api/config/locales/en.yml +0 -23
  100. data/examples/ruby-on-rails-api/config/routes.rb +0 -58
  101. data/examples/ruby-on-rails-api/config/secrets.yml +0 -28
  102. data/examples/ruby-on-rails-api/config.ru +0 -4
  103. data/examples/ruby-on-rails-api/db/schema.rb +0 -15
  104. data/examples/ruby-on-rails-api/db/seeds.rb +0 -7
  105. data/examples/ruby-on-rails-api/lib/assets/.keep +0 -0
  106. data/examples/ruby-on-rails-api/lib/tasks/.keep +0 -0
  107. data/examples/ruby-on-rails-api/log/.keep +0 -0
  108. data/examples/ruby-on-rails-api/public/404.html +0 -67
  109. data/examples/ruby-on-rails-api/public/422.html +0 -67
  110. data/examples/ruby-on-rails-api/public/500.html +0 -66
  111. data/examples/ruby-on-rails-api/public/favicon.ico +0 -0
  112. data/examples/ruby-on-rails-api/public/robots.txt +0 -5
  113. data/examples/ruby-on-rails-api/test/controllers/.keep +0 -0
  114. data/examples/ruby-on-rails-api/test/fixtures/.keep +0 -0
  115. data/examples/ruby-on-rails-api/test/helpers/.keep +0 -0
  116. data/examples/ruby-on-rails-api/test/integration/.keep +0 -0
  117. data/examples/ruby-on-rails-api/test/mailers/.keep +0 -0
  118. data/examples/ruby-on-rails-api/test/models/.keep +0 -0
  119. data/examples/ruby-on-rails-api/test/ping_controller_test.rb +0 -8
  120. data/examples/ruby-on-rails-api/test/secured_ping_controller_test.rb +0 -26
  121. data/examples/ruby-on-rails-api/test/test_helper.rb +0 -16
  122. data/opslevel.yml +0 -5
  123. data/publish_rubygem.sh +0 -10
  124. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_change_password/should_trigger_a_password_reset.yml +0 -93
  125. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_login_with_resource_owner/should_fail_with_an_incorrect_email.yml +0 -85
  126. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_login_with_resource_owner/should_fail_with_an_incorrect_password.yml +0 -85
  127. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_login_with_resource_owner/should_fail_with_an_invalid_audience.yml +0 -86
  128. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_login_with_resource_owner/should_login_successfully_with_a_custom_audience.yml +0 -87
  129. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_login_with_resource_owner/should_login_successfully_with_a_default_scope.yml +0 -88
  130. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_saml_metadata/should_retrieve_SAML_metadata.yml +0 -110
  131. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_userinfo/should_fail_as_not_authorized.yml +0 -94
  132. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_userinfo/should_return_the_userinfo.yml +0 -176
  133. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_wsfed_metadata/should_retrieve_WSFED_metadata.yml +0 -98
  134. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/create_test_user.yml +0 -93
  135. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/delete_test_user.yml +0 -72
  136. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Blacklists/_add_token_to_blacklist/should_add_a_token_to_the_blacklist.yml +0 -74
  137. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Blacklists/_blacklisted_tokens/should_get_the_added_token_from_the_blacklist.yml +0 -74
  138. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_client_grants/should_return_at_least_1_result.yml +0 -78
  139. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_client_grants/should_return_the_test_client_grant.yml +0 -78
  140. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_delete_client_grant/should_delete_the_test_client_grant.yml +0 -72
  141. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_patch_client_grant/should_update_the_test_client_grant.yml +0 -76
  142. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/create_test_client.yml +0 -80
  143. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/create_test_client_grant.yml +0 -76
  144. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/delete_test_client.yml +0 -72
  145. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/delete_test_client_grant.yml +0 -72
  146. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_client/_filters/should_exclude_and_include_fields_properly.yml +0 -78
  147. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_client/_filters/should_include_the_specified_fields.yml +0 -74
  148. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_client/should_get_the_test_client.yml +0 -78
  149. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/_filters/should_exclude_fields_not_specified.yml +0 -79
  150. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/_filters/should_exclude_the_specified_fields.yml +0 -272
  151. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/_filters/should_include_the_specified_fields.yml +0 -88
  152. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/_filters/should_paginate_results.yml +0 -79
  153. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/should_get_at_least_one_client.yml +0 -271
  154. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_delete_client/should_delete_the_test_client_without_an_error.yml +0 -72
  155. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_patch_client/should_update_the_client_with_the_correct_attributes.yml +0 -81
  156. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/create_test_client.yml +0 -81
  157. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connection/_filters/should_exclude_the_fields_indicated.yml +0 -74
  158. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connection/_filters/should_include_the_fields_indicated.yml +0 -74
  159. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connection/should_find_the_correct_connection.yml +0 -74
  160. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/_filters/should_include_previously-created_connection_when_filtered.yml +0 -78
  161. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/_filters/should_should_exclude_the_fields_indicated_from_filtered_results.yml +0 -78
  162. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/_filters/should_should_include_the_fields_indicated_from_filtered_results.yml +0 -78
  163. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/should_include_the_previously_created_connection.yml +0 -79
  164. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/should_not_be_empty.yml +0 -79
  165. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_delete_connection/should_delete_the_connection.yml +0 -74
  166. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_delete_connection_user/should_delete_the_user_created.yml +0 -148
  167. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_update_connection/should_update_the_connection.yml +0 -76
  168. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/create_test_connection.yml +0 -76
  169. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/create_test_user.yml +0 -76
  170. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/create_test_credential.yml +0 -72
  171. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/create_test_user.yml +0 -76
  172. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/delete_test_user.yml +0 -72
  173. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_configure_provider/should_configure_a_new_email_provider.yml +0 -72
  174. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_delete_provider/should_delete_the_existing_email_provider_without_an_error.yml +0 -72
  175. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_delete_provider/should_throw_an_error_trying_to_get_the_email_provider.yml +0 -69
  176. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_get_provider/_filters/should_get_the_existing_email_provider_with_specific_fields.yml +0 -69
  177. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_get_provider/_filters/should_get_the_existing_email_provider_without_specific_fields.yml +0 -69
  178. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_get_provider/should_get_the_existing_email_provider.yml +0 -69
  179. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_update_provider/should_update_the_existing_email_provider.yml +0 -71
  180. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/delete_existing_provider.yml +0 -72
  181. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_export_users_and_get_job/should_create_an_export_users_job_successfully.yml +0 -76
  182. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_export_users_and_get_job/should_get_the_export_users_job.yml +0 -147
  183. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_import_users_and_get_job/should_create_an_import_users_job_successfully.yml +0 -81
  184. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_import_users_and_get_job/should_get_the_import_users_job.yml +0 -152
  185. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_send_verification_email_and_get_job/should_create_a_new_verification_email_job.yml +0 -149
  186. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_send_verification_email_and_get_job/should_get_the_completed_verification_email.yml +0 -220
  187. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_send_verification_email_and_get_job/should_reject_an_invalid_client_id.yml +0 -146
  188. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/delete_imported_user.yml +0 -143
  189. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/search_for_connection_id.yml +0 -79
  190. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_log/should_match_the_created_log_entry.yml +0 -293
  191. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_log/should_not_be_empty.yml +0 -293
  192. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_filters/should_exclude_fields_not_specified.yml +0 -74
  193. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_filters/should_exclude_the_specified_fields.yml +0 -75
  194. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_filters/should_have_one_log_entry.yml +0 -77
  195. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_filters/should_include_the_specified_fields.yml +0 -74
  196. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_from/should_take_one_log_entry.yml +0 -298
  197. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/create_test_user.yml +0 -76
  198. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/delete_test_disabled_rule.yml +0 -72
  199. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/delete_test_enabled_rule.yml +0 -72
  200. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/delete_test_user.yml +0 -72
  201. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_delete_resource_server/should_delete_the_test_server_without_an_error.yml +0 -72
  202. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_patch_resource_server/should_update_the_resource_server_with_the_correct_attributes.yml +0 -76
  203. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_resource_server/should_get_the_test_server.yml +0 -74
  204. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_resource_servers/should_get_the_test_server.yml +0 -182
  205. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_resource_servers/should_return_at_least_1_result.yml +0 -182
  206. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_resource_servers/should_return_the_first_page_of_one_result.yml +0 -171
  207. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/create_test_server.yml +0 -76
  208. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/delete_test_server.yml +0 -72
  209. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_add_role_permissions/should_add_a_Permission_to_the_Role_successfully.yml +0 -76
  210. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_add_role_users/should_add_a_User_to_the_Role_successfully.yml +0 -76
  211. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_delete_role/should_delete_the_Role_successfully.yml +0 -74
  212. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role/should_get_the_Role_successfully.yml +0 -75
  213. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role_permissions/should_get_exactly_1_Permission.yml +0 -74
  214. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role_permissions/should_get_the_added_Permission_from_the_Role_successfully.yml +0 -74
  215. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role_users/should_get_exactly_1_User.yml +0 -74
  216. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role_users/should_get_the_added_User_from_the_Role_successfully.yml +0 -74
  217. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_roles/should_get_the_Role_successfully.yml +0 -75
  218. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_remove_role_permissions/should_remove_a_Permission_from_the_Role_successfully.yml +0 -74
  219. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_update_role/should_update_the_Role_successfully.yml +0 -76
  220. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/create_test_api.yml +0 -76
  221. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/create_test_role.yml +0 -77
  222. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/create_test_user.yml +0 -76
  223. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/delete_test_api.yml +0 -72
  224. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/delete_test_user.yml +0 -72
  225. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_delete_rule/should_delete_the_test_disabled_rule_without_an_error.yml +0 -72
  226. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_delete_rule/should_delete_the_test_enabled_rule_without_an_error.yml +0 -72
  227. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rule/_filters/should_exclude_the_fields_not_specified.yml +0 -75
  228. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rule/_filters/should_exclude_the_specified_fields.yml +0 -75
  229. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rule/_filters/should_include_the_specified_fields.yml +0 -74
  230. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rule/should_get_a_specific_rule.yml +0 -75
  231. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_exclude_fields_not_specified.yml +0 -116
  232. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_include_the_specified_fields.yml +0 -118
  233. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_return_at_least_1_disabled_rule.yml +0 -95
  234. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_return_at_least_1_enabled_rule.yml +0 -104
  235. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_return_paginated_results.yml +0 -157
  236. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/should_return_at_least_1_rule.yml +0 -120
  237. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_update_rule/should_update_the_disabled_rule_to_be_enabled.yml +0 -77
  238. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/create_test_disabled_rule.yml +0 -78
  239. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/create_test_enabled_rule.yml +0 -78
  240. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Stats/_active_users/should_have_at_least_one_active_user.yml +0 -74
  241. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Stats/_daily_stats/should_have_at_least_one_stats_entry_for_the_timeframe.yml +0 -74
  242. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_get_tenant_settings/should_get_the_tenant_settings.yml +0 -108
  243. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_get_tenant_settings_with_specific_fields/should_exclude_a_field_not_requested.yml +0 -74
  244. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_get_tenant_settings_with_specific_fields/should_include_the_field_requested.yml +0 -74
  245. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_update_tenant_settings/should_revert_the_tenant_name.yml +0 -110
  246. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_update_tenant_settings/should_update_the_tenant_settings_with_a_new_tenant_name.yml +0 -110
  247. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tickets/_post_email_verification/should_create_an_email_verification_ticket.yml +0 -76
  248. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tickets/_post_password_change/should_create_a_password_change_ticket.yml +0 -76
  249. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tickets/create_test_user.yml +0 -76
  250. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tickets/delete_test_user.yml +0 -72
  251. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_add_user_permissions/should_add_a_Permissions_for_a_User_successfully.yml +0 -71
  252. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_add_user_roles/should_add_a_Role_to_a_User_successfully.yml +0 -74
  253. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_delete_user/should_delete_the_User_successfully.yml +0 -72
  254. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_delete_user/should_delete_the_secondary_User_successfully.yml +0 -72
  255. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_delete_user_provider/should_attempt_to_delete_the_MFA_provider_for_the_User.yml +0 -72
  256. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_get_enrollments/should_get_Enrollments_for_a_User_successfully.yml +0 -74
  257. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_get_user_permissions/should_get_exactly_1_Permission_for_a_User_successfully.yml +0 -74
  258. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_get_user_permissions/should_get_the_correct_Permission_for_a_User_successfully.yml +0 -74
  259. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_get_user_roles/should_get_Roles_for_a_User_successfully.yml +0 -75
  260. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_invalidate_browsers/should_invalidate_MFA_browsers_for_the_User_successfully.yml +0 -74
  261. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_link_user_account/should_link_two_Users_successfully.yml +0 -76
  262. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_patch_user/should_patch_the_User_successfully.yml +0 -78
  263. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_remove_user_permissions/should_remove_a_Permission_from_a_User_successfully.yml +0 -74
  264. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_remove_user_roles/should_remove_a_Role_from_a_User_successfully.yml +0 -74
  265. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_unlink_user_account/should_unlink_two_Users_successfully.yml +0 -74
  266. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user/_filters/should_exclude_fields_not_indicated.yml +0 -74
  267. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user/_filters/should_exclude_the_fields_indicated.yml +0 -74
  268. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user/_filters/should_include_the_fields_indicated.yml +0 -74
  269. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user/should_retrieve_the_created_user.yml +0 -74
  270. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user_logs/should_get_Logs_for_a_User_successfully.yml +0 -81
  271. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/is_expected_to_find_a_user_with_a_v2_search_engine_query.yml +0 -74
  272. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/is_expected_to_find_a_user_with_a_v3_search_engine_query.yml +0 -74
  273. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/should_exclude_the_indicated_fields_when_paginated.yml +0 -74
  274. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/should_include_the_indicated_fields_when_paginated.yml +0 -74
  275. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/should_not_include_other_fields_when_paginated.yml +0 -74
  276. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/should_return_the_correct_number_of_results_when_paginated.yml +0 -74
  277. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/should_have_at_least_one_user.yml +0 -75
  278. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/create_secondary_test_user.yml +0 -76
  279. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/create_test_api.yml +0 -76
  280. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/create_test_role.yml +0 -77
  281. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/create_test_user.yml +0 -76
  282. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/delete_test_api.yml +0 -72
  283. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/delete_test_role.yml +0 -74
  284. data/spec/integration/lib/auth0/api/api_authentication_spec.rb +0 -120
  285. data/spec/integration/lib/auth0/api/v2/api_blacklist_spec.rb +0 -27
  286. data/spec/integration/lib/auth0/api/v2/api_client_grants_spec.rb +0 -66
  287. data/spec/integration/lib/auth0/api/v2/api_clients_spec.rb +0 -166
  288. data/spec/integration/lib/auth0/api/v2/api_connections_spec.rb +0 -159
  289. data/spec/integration/lib/auth0/api/v2/api_email_spec.rb +0 -86
  290. data/spec/integration/lib/auth0/api/v2/api_jobs_spec.rb +0 -124
  291. data/spec/integration/lib/auth0/api/v2/api_logs_spec.rb +0 -91
  292. data/spec/integration/lib/auth0/api/v2/api_resource_servers_spec.rb +0 -130
  293. data/spec/integration/lib/auth0/api/v2/api_roles_spec.rb +0 -145
  294. data/spec/integration/lib/auth0/api/v2/api_rules_spec.rb +0 -177
  295. data/spec/integration/lib/auth0/api/v2/api_stats_spec.rb +0 -22
  296. data/spec/integration/lib/auth0/api/v2/api_tenants_spec.rb +0 -59
  297. data/spec/integration/lib/auth0/api/v2/api_tickets_spec.rb +0 -59
  298. data/spec/integration/lib/auth0/api/v2/api_user_blocks_spec.rb +0 -76
  299. data/spec/integration/lib/auth0/api/v2/api_users_spec.rb +0 -273
  300. data/spec/integration/lib/auth0/auth0_client_spec.rb +0 -90
  301. data/spec/lib/auth0/api/authentication_endpoints_spec.rb +0 -750
  302. data/spec/lib/auth0/api/v2/actions_spec.rb +0 -322
  303. data/spec/lib/auth0/api/v2/anomaly_spec.rb +0 -26
  304. data/spec/lib/auth0/api/v2/attack_protection_spec.rb +0 -132
  305. data/spec/lib/auth0/api/v2/blacklists_spec.rb +0 -25
  306. data/spec/lib/auth0/api/v2/branding_spec.rb +0 -71
  307. data/spec/lib/auth0/api/v2/client_grants_spec.rb +0 -106
  308. data/spec/lib/auth0/api/v2/clients_spec.rb +0 -155
  309. data/spec/lib/auth0/api/v2/connections_spec.rb +0 -164
  310. data/spec/lib/auth0/api/v2/device_credentials_spec.rb +0 -102
  311. data/spec/lib/auth0/api/v2/emails_spec.rb +0 -47
  312. data/spec/lib/auth0/api/v2/grants_spec.rb +0 -91
  313. data/spec/lib/auth0/api/v2/guardian_spec.rb +0 -154
  314. data/spec/lib/auth0/api/v2/jobs_spec.rb +0 -158
  315. data/spec/lib/auth0/api/v2/log_streams_spec.rb +0 -84
  316. data/spec/lib/auth0/api/v2/logs_spec.rb +0 -48
  317. data/spec/lib/auth0/api/v2/organizations_spec.rb +0 -708
  318. data/spec/lib/auth0/api/v2/prompts_spec.rb +0 -88
  319. data/spec/lib/auth0/api/v2/refresh_tokens_spec.rb +0 -51
  320. data/spec/lib/auth0/api/v2/resource_servers_spec.rb +0 -86
  321. data/spec/lib/auth0/api/v2/roles_spec.rb +0 -366
  322. data/spec/lib/auth0/api/v2/rules_spec.rb +0 -95
  323. data/spec/lib/auth0/api/v2/sessions_spec.rb +0 -71
  324. data/spec/lib/auth0/api/v2/stats_spec.rb +0 -22
  325. data/spec/lib/auth0/api/v2/tenants_spec.rb +0 -26
  326. data/spec/lib/auth0/api/v2/tickets_spec.rb +0 -118
  327. data/spec/lib/auth0/api/v2/user_blocks_spec.rb +0 -52
  328. data/spec/lib/auth0/api/v2/users_by_email_spec.rb +0 -21
  329. data/spec/lib/auth0/api/v2/users_spec.rb +0 -904
  330. data/spec/lib/auth0/client_spec.rb +0 -223
  331. data/spec/lib/auth0/mixins/httpproxy_spec.rb +0 -659
  332. data/spec/lib/auth0/mixins/initializer_spec.rb +0 -172
  333. data/spec/lib/auth0/mixins/token_management_spec.rb +0 -136
  334. data/spec/lib/auth0/mixins/validation_spec.rb +0 -562
  335. data/spec/spec_helper.rb +0 -70
  336. data/spec/support/credentials.rb +0 -11
  337. data/spec/support/dummy_class.rb +0 -18
  338. data/spec/support/dummy_class_for_proxy.rb +0 -5
  339. data/spec/support/dummy_class_for_restclient.rb +0 -2
  340. data/spec/support/dummy_class_for_tokens.rb +0 -20
  341. data/spec/support/import_users.json +0 -13
  342. data/spec/support/stub_response.rb +0 -1
@@ -1,659 +0,0 @@
1
- require 'json'
2
- require 'spec_helper'
3
-
4
- describe Auth0::Mixins::HTTPProxy do
5
- before :each do
6
- dummy_instance = DummyClassForProxy.new
7
- dummy_instance.extend(Auth0::Mixins::HTTPProxy)
8
- dummy_instance.base_uri = "https://auth0.com"
9
- dummy_instance.retry_count = 0
10
-
11
- @instance = dummy_instance
12
- @exception = DummyClassForRestClient.new
13
- end
14
-
15
- %i(get delete).each do |http_method|
16
- context ".#{http_method}" do
17
- it { expect(@instance).to respond_to(http_method.to_sym) }
18
- it "should call send http #{http_method} method to path defined through HTTP" do
19
- expect(RestClient::Request).to receive(:execute).with(method: http_method,
20
- url: 'https://auth0.com/test',
21
- timeout: nil,
22
- headers: { params: {} },
23
- payload: nil)
24
- .and_return(StubResponse.new({}, true, 200))
25
- expect { @instance.send(http_method, '/test') }.not_to raise_error
26
- end
27
-
28
- it 'should not raise exception if data returned not in json format (should be fixed in v2)' do
29
- allow(RestClient::Request).to receive(:execute).with(method: http_method,
30
- url: 'https://auth0.com/test',
31
- timeout: nil,
32
- headers: { params: {} },
33
- payload: nil)
34
- .and_return(StubResponse.new('Some random text here', true, 200))
35
- expect { @instance.send(http_method, '/test') }.not_to raise_error
36
- expect(@instance.send(http_method, '/test')).to eql('Some random text here')
37
- end
38
-
39
- it "should raise Auth0::Unauthorized on send http #{http_method}
40
- method to path defined through HTTP when 401 status received" do
41
- expect(RestClient::Request).to receive(:execute).with(method: http_method,
42
- url: 'https://auth0.com/test',
43
- timeout: nil,
44
- headers: { params: {} },
45
- payload: nil)
46
- .and_return(StubResponse.new({}, false, 401))
47
- expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::Unauthorized)
48
- end
49
-
50
- it "should raise Auth0::NotFound on send http #{http_method} method
51
- to path defined through HTTP when 404 status received" do
52
- expect(RestClient::Request).to receive(:execute).with(method: http_method,
53
- url: 'https://auth0.com/test',
54
- timeout: nil,
55
- headers: { params: {} },
56
- payload: nil)
57
- .and_return(StubResponse.new({}, false, 404))
58
- expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::NotFound)
59
- end
60
-
61
- it "should raise Auth0::Unsupported on send http #{http_method} method
62
- to path defined through HTTP when 418 or other unknown status received" do
63
- expect(RestClient::Request).to receive(:execute).with(method: http_method,
64
- url: 'https://auth0.com/test',
65
- timeout: nil,
66
- headers: { params: {} },
67
- payload: nil)
68
- .and_return(StubResponse.new({}, false, 418))
69
- expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::Unsupported)
70
- end
71
-
72
- it "should raise Auth0::RequestTimeout on send http #{http_method} method
73
- to path defined through HTTP when RestClient::RequestTimeout received" do
74
- allow(RestClient::Request).to receive(:execute).with(method: http_method,
75
- url: 'https://auth0.com/test',
76
- timeout: nil,
77
- headers: { params: {} },
78
- payload: nil)
79
- .and_raise(RestClient::Exceptions::OpenTimeout.new)
80
- expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::RequestTimeout)
81
- end
82
-
83
- it "should raise Auth0::BadRequest on send http #{http_method} method
84
- to path defined through HTTP when 400 status received" do
85
- @exception.response = StubResponse.new({}, false, 400)
86
- allow(RestClient::Request).to receive(:execute).with(method: http_method,
87
- url: 'https://auth0.com/test',
88
- timeout: nil,
89
- headers: { params: {} },
90
- payload: nil)
91
- .and_raise(@exception)
92
- expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::BadRequest)
93
- end
94
-
95
- it "should raise Auth0::AccessDenied on send http #{http_method} method
96
- to path defined through HTTP when 403" do
97
- @exception.response = StubResponse.new({}, false, 403)
98
- allow(RestClient::Request).to receive(:execute).with(method: http_method,
99
- url: 'https://auth0.com/test',
100
- timeout: nil,
101
- headers: { params: {} },
102
- payload: nil)
103
- .and_raise(@exception)
104
- expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::AccessDenied)
105
- end
106
-
107
- it "should raise Auth0::RateLimitEncountered on send http #{http_method} method
108
- to path defined through HTTP when 429 recieved" do
109
- headers = {
110
- :x_ratelimit_limit => 10,
111
- :x_ratelimit_remaining => 0,
112
- :x_ratelimit_reset => 1560564149
113
- }
114
- @exception.response = StubResponse.new({}, false, 429, headers)
115
- allow(RestClient::Request).to receive(:execute).with(method: http_method,
116
- url: 'https://auth0.com/test',
117
- timeout: nil,
118
- headers: { params: {} },
119
- payload: nil)
120
- .and_raise(@exception)
121
- expect { @instance.send(http_method, '/test') }.to raise_error { |error|
122
- expect(error).to be_a(Auth0::RateLimitEncountered)
123
- expect(error).to have_attributes(
124
- error_data: {
125
- headers: headers,
126
- code: 429
127
- },
128
- headers: headers,
129
- http_code: 429,
130
- reset: Time.at(1560564149)
131
- )
132
- }
133
- end
134
-
135
- it "should raise Auth0::ServerError on send http #{http_method} method
136
- to path defined through HTTP when 500 received" do
137
- @exception.response = StubResponse.new({}, false, 500)
138
- allow(RestClient::Request).to receive(:execute).with(method: http_method,
139
- url: 'https://auth0.com/test',
140
- timeout: nil,
141
- headers: { params: {} },
142
- payload: nil)
143
- .and_raise(@exception)
144
- expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::ServerError)
145
- end
146
-
147
- it 'should normalize path with Addressable::URI' do
148
- expect(RestClient::Request).to receive(:execute).with(method: http_method,
149
- url: 'https://auth0.com/te%20st%23test',
150
- timeout: nil,
151
- headers: { params: {} },
152
- payload: nil)
153
- .and_return(StubResponse.new({}, true, 200))
154
- expect { @instance.send(http_method, '/te st#test') }.not_to raise_error
155
- end
156
-
157
- context "when status 429 is recieved on send http #{http_method} method" do
158
- it "should retry 3 times when retry_count is not set" do
159
- retry_instance = DummyClassForProxy.new
160
- retry_instance.extend(Auth0::Mixins::HTTPProxy)
161
- retry_instance.base_uri = "https://auth0.com"
162
-
163
- @exception.response = StubResponse.new({}, false, 429)
164
- allow(RestClient::Request).to receive(:execute).with(method: http_method,
165
- url: 'https://auth0.com/test',
166
- timeout: nil,
167
- headers: { params: {} },
168
- payload: nil)
169
- .and_raise(@exception)
170
- expect(RestClient::Request).to receive(:execute).exactly(4).times
171
-
172
- expect { retry_instance.send(http_method, '/test') }.to raise_error { |error|
173
- expect(error).to be_a(Auth0::RateLimitEncountered)
174
- }
175
- end
176
-
177
- it "should retry 2 times when retry_count is set to 2" do
178
- retry_instance = DummyClassForProxy.new
179
- retry_instance.extend(Auth0::Mixins::HTTPProxy)
180
- retry_instance.base_uri = "https://auth0.com"
181
- retry_instance.retry_count = 2
182
-
183
- @exception.response = StubResponse.new({}, false, 429)
184
- allow(RestClient::Request).to receive(:execute).with(method: http_method,
185
- url: 'https://auth0.com/test',
186
- timeout: nil,
187
- headers: { params: {} },
188
- payload: nil)
189
- .and_raise(@exception)
190
- expect(RestClient::Request).to receive(:execute).exactly(3).times
191
-
192
- expect { retry_instance.send(http_method, '/test') }.to raise_error { |error|
193
- expect(error).to be_a(Auth0::RateLimitEncountered)
194
- }
195
- end
196
-
197
- it "should not retry when retry_count is set to 0" do
198
- retry_instance = DummyClassForProxy.new
199
- retry_instance.extend(Auth0::Mixins::HTTPProxy)
200
- retry_instance.base_uri = "https://auth0.com"
201
- retry_instance.retry_count = 0
202
-
203
- @exception.response = StubResponse.new({}, false, 429)
204
-
205
- allow(RestClient::Request).to receive(:execute).with(method: http_method,
206
- url: 'https://auth0.com/test',
207
- timeout: nil,
208
- headers: { params: {} },
209
- payload: nil)
210
- .and_raise(@exception)
211
-
212
- expect(RestClient::Request).to receive(:execute).exactly(1).times
213
- expect { retry_instance.send(http_method, '/test') }.to raise_error { |error|
214
- expect(error).to be_a(Auth0::RateLimitEncountered)
215
- }
216
- end
217
-
218
- it "should have have random retry times grow with jitter backoff" do
219
- retry_instance = DummyClassForProxy.new
220
- retry_instance.extend(Auth0::Mixins::HTTPProxy)
221
- retry_instance.base_uri = "https://auth0.com"
222
- retry_instance.retry_count = 2
223
- time_entries = []
224
- @time_start
225
-
226
- @exception.response = StubResponse.new({}, false, 429)
227
- allow(RestClient::Request).to receive(:execute).with(method: http_method,
228
- url: 'https://auth0.com/test',
229
- timeout: nil,
230
- headers: { params: {} },
231
- payload: nil) do
232
-
233
- time_entries.push(Time.now.to_f - @time_start.to_f)
234
- @time_start = Time.now.to_f # restart the clock
235
- raise @exception
236
- end
237
-
238
- @time_start = Time.now.to_f #start the clock
239
- retry_instance.send(http_method, '/test') rescue nil
240
- time_entries_first_set = time_entries.shift(time_entries.length)
241
-
242
- retry_instance.send(http_method, '/test') rescue nil
243
- time_entries.each_with_index do |entry, index|
244
- if index > 0 #skip the first request
245
- expect(entry != time_entries_first_set[index])
246
- end
247
- end
248
- end
249
- end
250
- end
251
- end
252
-
253
- def expected_payload(method, overrides = {})
254
- if method == :post_form
255
- {
256
- method: :post,
257
- url: 'https://auth0.com/test',
258
- timeout: nil,
259
- headers: nil,
260
- payload: {}
261
- }.merge(overrides)
262
- else
263
- {
264
- method: method,
265
- url: 'https://auth0.com/test',
266
- timeout: nil,
267
- headers: nil,
268
- payload: '{}'
269
- }.merge(overrides)
270
- end
271
- end
272
-
273
- %i(post post_form put patch).each do |http_method|
274
- context ".#{http_method}" do
275
- context 'when body is an Array' do
276
- let(:payload) { [{ permission_name: 'read:data', resource_server_identifier: 'https://api.example.com' }] }
277
-
278
- if http_method == :post_form
279
- it 'sends the array as-is without wrapping in a Hash' do
280
- expect(RestClient::Request).to receive(:execute) do |args|
281
- expect(args[:payload]).to be_an(Array)
282
- expect(args[:payload]).to eq(payload)
283
- end.and_return(StubResponse.new('[]', true, 200))
284
-
285
- @instance.send(http_method, '/test', payload)
286
- end
287
- else
288
- it 'sends the array as-is without wrapping in a Hash' do
289
- expect(RestClient::Request).to receive(:execute) do |args|
290
- parsed = JSON.parse(args[:payload], symbolize_names: true)
291
- expect(parsed).to be_an(Array)
292
- expect(parsed).to eq(payload)
293
- end.and_return(StubResponse.new('[]', true, 200))
294
-
295
- @instance.send(http_method, '/test', payload)
296
- end
297
- end
298
- end
299
-
300
- context 'when body is a Hash' do
301
- let(:payload) { { permission_name: 'read:data', resource_server_identifier: 'https://api.example.com' } }
302
-
303
- if http_method == :post_form
304
- it 'sends the Hash without modification' do
305
- expect(RestClient::Request).to receive(:execute) do |args|
306
- expect(args[:payload]).to be_a(Hash)
307
- expect(args[:payload]).to include(payload)
308
- end.and_return(StubResponse.new('{}', true, 200))
309
-
310
- @instance.send(http_method, '/test', payload)
311
- end
312
- else
313
- it 'sends the Hash as JSON without modification' do
314
- expect(RestClient::Request).to receive(:execute) do |args|
315
- parsed = JSON.parse(args[:payload], symbolize_names: true)
316
- expect(parsed).to be_a(Hash)
317
- expect(parsed).to eq(payload)
318
- end.and_return(StubResponse.new('{}', true, 200))
319
-
320
- @instance.send(http_method, '/test', payload)
321
- end
322
- end
323
- end
324
- it { expect(@instance).to respond_to(http_method.to_sym) }
325
- it "should call send http #{http_method} method to path defined through HTTP"do
326
- expect(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
327
- .and_return(StubResponse.new({}, true, 200))
328
- expect { @instance.send(http_method, '/test') }.not_to raise_error
329
- end
330
-
331
- it "should handle array parameters for #{http_method} method" do
332
- array_data = ['param1', 'param2']
333
- if http_method == :post_form
334
- expected_params = expected_payload(http_method, { payload: array_data })
335
- else
336
- expected_params = expected_payload(http_method, { payload: array_data.to_json })
337
- end
338
-
339
- expect(RestClient::Request).to receive(:execute).with(expected_params)
340
- .and_return(StubResponse.new({}, true, 200))
341
- expect { @instance.send(http_method, '/test', array_data) }.not_to raise_error
342
- end
343
-
344
- it 'should not raise exception if data returned not in json format (should be fixed in v2)' do
345
- allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
346
- .and_return(StubResponse.new('Some random text here', true, 200))
347
- expect { @instance.send(http_method, '/test') }.not_to raise_error
348
- expect(@instance.send(http_method, '/test')).to eql('Some random text here')
349
- end
350
-
351
- it "should raise Auth0::Unauthorized on send http #{http_method} method
352
- to path defined through HTTP when 401 status received" do
353
- @exception.response = StubResponse.new({}, false, 401)
354
- allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
355
- .and_raise(@exception)
356
- expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::Unauthorized)
357
- end
358
-
359
- it "should raise Auth0::RateLimitEncountered on send http #{http_method} method
360
- to path defined through HTTP when 429 status received" do
361
- headers = {
362
- :x_ratelimit_limit => 10,
363
- :x_ratelimit_remaining => 0,
364
- :x_ratelimit_reset => 1560564149
365
- }
366
- @exception.response = StubResponse.new({}, false, 429,headers)
367
- allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
368
- .and_raise(@exception)
369
- expect { @instance.send(http_method, '/test') }.to raise_error { |error|
370
- expect(error).to be_a(Auth0::RateLimitEncountered)
371
- expect(error).to have_attributes(
372
- error_data: {
373
- headers: headers,
374
- code: 429
375
- },
376
- headers: headers,
377
- http_code: 429,
378
- reset: Time.at(1560564149)
379
- )
380
- }
381
- end
382
-
383
- it "should raise Auth0::NotFound on send http #{http_method} method
384
- to path defined through HTTP when 404 status received" do
385
- @exception.response = StubResponse.new({}, false, 404)
386
- allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
387
- .and_raise(@exception)
388
- expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::NotFound)
389
- end
390
-
391
- it "should raise Auth0::Unsupported on send http #{http_method} method
392
- to path defined through HTTP when 418 or other unknown status received" do
393
- @exception.response = StubResponse.new({}, false, 418)
394
- allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
395
- .and_raise(@exception)
396
- expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::Unsupported)
397
- end
398
-
399
- it "should raise Auth0::RequestTimeout on send http #{http_method} method
400
- to path defined through HTTP when RestClient::RequestTimeout received" do
401
- allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
402
- .and_raise(RestClient::Exceptions::OpenTimeout.new)
403
- expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::RequestTimeout)
404
- end
405
-
406
- it "should raise Auth0::BadRequest on send http #{http_method} method
407
- to path defined through HTTP when 400 status received" do
408
- @exception.response = StubResponse.new({}, false, 400)
409
- allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
410
- .and_raise(@exception)
411
- expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::BadRequest)
412
- end
413
-
414
- it "should raise Auth0::ServerError on send http #{http_method} method
415
- to path defined through HTTP when 500 received" do
416
- @exception.response = StubResponse.new({}, false, 500)
417
- allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
418
- .and_raise(@exception)
419
- expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::ServerError)
420
- end
421
-
422
- it 'should normalize path with Addressable::URI' do
423
- expect(RestClient::Request).to receive(:execute).with(expected_payload(http_method, url: 'https://auth0.com/te%20st'))
424
- .and_return(StubResponse.new({}, true, 200))
425
- expect { @instance.send(http_method, '/te st') }.not_to raise_error
426
- end
427
-
428
- it 'should give the JSON representation of the error as the error message' do
429
- res = JSON.generate('statusCode' => 404,
430
- 'error' => 'Bad Request',
431
- 'message' => "Path validation error: 'String does not match pattern ^.+\\|.+$:
432
- 3241312' on property id (The user_id of the user to retrieve).",
433
- 'errorCode' => 'invalid_uri')
434
- expect(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
435
- .and_return(StubResponse.new(res, true, 404))
436
- expect { @instance.send(http_method, '/test') }.to raise_error(Auth0::NotFound, res)
437
- end
438
-
439
- context "when status 429 is recieved on send http #{http_method} method" do
440
- it "should retry 3 times when retry_count is not set" do
441
- retry_instance = DummyClassForProxy.new
442
- retry_instance.extend(Auth0::Mixins::HTTPProxy)
443
- retry_instance.base_uri = "https://auth0.com"
444
-
445
- @exception.response = StubResponse.new({}, false, 429)
446
- allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
447
- .and_raise(@exception)
448
- expect(RestClient::Request).to receive(:execute).exactly(4).times
449
-
450
- expect { retry_instance.send(http_method, '/test') }.to raise_error { |error|
451
- expect(error).to be_a(Auth0::RateLimitEncountered)
452
- }
453
- end
454
-
455
- it "should retry 2 times when retry_count is set to 2" do
456
- retry_instance = DummyClassForProxy.new
457
- retry_instance.extend(Auth0::Mixins::HTTPProxy)
458
- retry_instance.base_uri = "https://auth0.com"
459
- retry_instance.retry_count = 2
460
-
461
- @exception.response = StubResponse.new({}, false, 429)
462
- allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
463
- .and_raise(@exception)
464
- expect(RestClient::Request).to receive(:execute).exactly(3).times
465
-
466
- expect { retry_instance.send(http_method, '/test') }.to raise_error { |error|
467
- expect(error).to be_a(Auth0::RateLimitEncountered)
468
- }
469
- end
470
-
471
- it "should not retry when retry_count is set to 0" do
472
- retry_instance = DummyClassForProxy.new
473
- retry_instance.extend(Auth0::Mixins::HTTPProxy)
474
- retry_instance.base_uri = "https://auth0.com"
475
- retry_instance.retry_count = 0
476
-
477
- @exception.response = StubResponse.new({}, false, 429)
478
-
479
- allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method))
480
- .and_raise(@exception)
481
-
482
- expect(RestClient::Request).to receive(:execute).exactly(1).times
483
- expect { retry_instance.send(http_method, '/test') }.to raise_error { |error|
484
- expect(error).to be_a(Auth0::RateLimitEncountered)
485
- }
486
- end
487
-
488
- it "should have have random retry times grow with jitter backoff" do
489
- retry_instance = DummyClassForProxy.new
490
- retry_instance.extend(Auth0::Mixins::HTTPProxy)
491
- retry_instance.base_uri = "https://auth0.com"
492
- retry_instance.retry_count = 2
493
- time_entries = []
494
- @time_start
495
-
496
- @exception.response = StubResponse.new({}, false, 429)
497
- allow(RestClient::Request).to receive(:execute).with(expected_payload(http_method)) do
498
-
499
- time_entries.push(Time.now.to_f - @time_start.to_f)
500
- @time_start = Time.now.to_f # restart the clock
501
- raise @exception
502
- end
503
-
504
- @time_start = Time.now.to_f #start the clock
505
- retry_instance.send(http_method, '/test') rescue nil
506
- time_entries_first_set = time_entries.shift(time_entries.length)
507
-
508
- retry_instance.send(http_method, '/test') rescue nil
509
- time_entries.each_with_index do |entry, index|
510
- if index > 0 #skip the first request
511
- expect(entry != time_entries_first_set[index])
512
- end
513
- end
514
- end
515
- end
516
- end
517
-
518
- end
519
- end
520
-
521
- context "Renewing tokens" do
522
- let(:httpproxy_instance) {
523
- DummyClassForTokens.new(
524
- client_id: 'test-client-id',
525
- client_secret: 'test-client-secret',
526
- domain: 'auth0.com',
527
- )
528
- }
529
-
530
- %i(get delete).each do |http_method|
531
- context "for #{http_method}" do
532
- it 'should renew the token' do
533
- expect(RestClient::Request).to receive(:execute).with(hash_including(
534
- method: :post,
535
- url: 'https://auth0.com/oauth/token',
536
- )).and_return(StubResponse.new({
537
- "access_token" => "access_token",
538
- "expires_in" => 86400},
539
- true,
540
- 200))
541
-
542
- expect(RestClient::Request).to receive(:execute).with(hash_including(
543
- method: http_method,
544
- url: 'https://auth0.com/test'
545
- )).and_return(StubResponse.new('Some random text here', true, 200))
546
-
547
- expect { httpproxy_instance.send(http_method, '/test') }.not_to raise_error
548
- end
549
- end
550
- end
551
-
552
- %i(post put patch).each do |http_method|
553
- context "for #{http_method}" do
554
- it 'should renew the token' do
555
- expect(RestClient::Request).to receive(:execute).with(hash_including(
556
- method: :post,
557
- url: 'https://auth0.com/oauth/token',
558
- ) ).and_return(StubResponse.new({
559
- "access_token" => "access_token",
560
- "expires_in" => 86400},
561
- true,
562
- 200))
563
-
564
- expect(RestClient::Request).to receive(:execute).with(hash_including(
565
- method: http_method,
566
- url: 'https://auth0.com/test',
567
- headers: hash_including( "Authorization" => "Bearer access_token")
568
- )).and_return(StubResponse.new('Some random text here', true, 200))
569
-
570
- expect { httpproxy_instance.send(http_method, '/test') }.not_to raise_error
571
- end
572
- end
573
- end
574
-
575
- context "Using cached tokens" do
576
- let(:httpproxy_instance) {
577
- DummyClassForTokens.new(
578
- client_id: 'test-client-id',
579
- client_secret: 'test-client-secret',
580
- domain: 'auth0.com',
581
- token: 'access_token',
582
- token_expires_at: Time.now.to_i + 86400)
583
- }
584
-
585
- %i(get delete).each do |http_method|
586
- context "for #{http_method}" do
587
- it 'should use the cached token' do
588
- expect(RestClient::Request).not_to receive(:execute).with(hash_including(
589
- method: :post,
590
- url: 'https://auth0.com/oauth/token',
591
- ))
592
-
593
- expect(RestClient::Request).to receive(:execute).with(hash_including(
594
- method: http_method,
595
- url: 'https://auth0.com/test',
596
- headers: hash_including(params: {}, "Authorization" => "Bearer access_token")
597
- )).and_return(StubResponse.new('Some random text here', true, 200))
598
-
599
- expect { httpproxy_instance.send(http_method, '/test') }.not_to raise_error
600
- end
601
- end
602
- end
603
-
604
- %i(post put patch).each do |http_method|
605
- context "for #{http_method}" do
606
- it 'should use the cached token' do
607
- expect(RestClient::Request).not_to receive(:execute).with(hash_including(
608
- method: :post,
609
- url: 'https://auth0.com/oauth/token',
610
- ))
611
-
612
- expect(RestClient::Request).to receive(:execute).with(hash_including(
613
- method: http_method,
614
- url: 'https://auth0.com/test',
615
- headers: hash_including("Authorization" => "Bearer access_token")
616
- )).and_return(StubResponse.new('Some random text here', true, 200))
617
-
618
- expect { httpproxy_instance.send(http_method, '/test') }.not_to raise_error
619
- end
620
- end
621
- end
622
- end
623
-
624
- context 'Normal operation' do
625
- let(:httpproxy_instance) {
626
- DummyClassForTokens.new(
627
- client_id: 'test-client-id',
628
- client_secret: 'test-client-secret',
629
- domain: 'auth0.com',
630
- token: 'access_token',
631
- token_expires_at: Time.now.to_i + 86400)
632
- }
633
-
634
- # This sets up a test matrix to verify that both :get and :delete calls (the only two HTTP methods in the proxy that mutated headers)
635
- # don't bleed query params into subsequent calls to :post :patch and :put.
636
- %i(get delete).each do |http_get_delete|
637
- %i(post patch put).each do |http_ppp|
638
- it "should not bleed :#{http_get_delete} headers/parameters to the subsequent :#{http_ppp} request" do
639
- expect(RestClient::Request).to receive(:execute).with(hash_including(
640
- method: http_get_delete,
641
- url: "https://auth0.com/test-#{http_get_delete}",
642
- headers: hash_including(params: { email: 'test@test.com' })
643
- )).and_return(StubResponse.new('OK', true, 200))
644
-
645
- # email: parameter that is sent in the GET request should not appear
646
- # as a parameter in the `headers` hash for the subsequent PATCH request.
647
- expect(RestClient::Request).to receive(:execute).with(hash_including(
648
- method: http_ppp,
649
- url: "https://auth0.com/test-#{http_ppp}",
650
- headers: hash_not_including(:params)
651
- )).and_return(StubResponse.new('OK', true, 200))
652
-
653
- expect { httpproxy_instance.send(http_get_delete, "/test-#{http_get_delete}", { email: 'test@test.com' }) }.not_to raise_error
654
- expect { httpproxy_instance.send(http_ppp, "/test-#{http_ppp}") }.not_to raise_error
655
- end
656
- end
657
- end
658
- end
659
- end