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