auth0 4.7.0 → 4.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +23 -0
- data/.env.example +2 -0
- data/.github/CODEOWNERS +1 -0
- data/.github/stale.yml +20 -0
- data/.gitignore +0 -1
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +83 -0
- data/DEPLOYMENT.md +25 -3
- data/Gemfile +3 -1
- data/Gemfile.lock +231 -0
- data/README.md +114 -25
- data/auth0.gemspec +6 -6
- data/codecov.yml +22 -0
- data/deploy_documentation.sh +1 -1
- data/lib/auth0.rb +1 -0
- data/lib/auth0/algorithm.rb +5 -0
- data/lib/auth0/api/authentication_endpoints.rb +38 -2
- data/lib/auth0/api/v2.rb +6 -0
- data/lib/auth0/api/v2/anomaly.rb +36 -0
- data/lib/auth0/api/v2/client_grants.rb +5 -1
- data/lib/auth0/api/v2/guardian.rb +142 -0
- data/lib/auth0/api/v2/jobs.rb +22 -3
- data/lib/auth0/api/v2/roles.rb +172 -0
- data/lib/auth0/api/v2/users.rb +115 -4
- data/lib/auth0/exception.rb +35 -7
- data/lib/auth0/mixins.rb +8 -3
- data/lib/auth0/mixins/httpproxy.rb +11 -8
- data/lib/auth0/mixins/permission_struct.rb +3 -0
- data/lib/auth0/mixins/validation.rb +340 -0
- data/lib/auth0/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Anomaly/_check_if_ip_is_blocked/should_return_200_response_code.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Anomaly/_remove_ip_block/should_remove_an_IP_successfully.yml +60 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_client_grants/should_return_at_least_1_result.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_client_grants/should_return_the_first_page_of_one_result.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_client_grants/should_return_the_test_client_grant.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_delete_client_grant/should_delete_the_test_client_grant.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_patch_client_grant/should_update_the_test_client_grant.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/create_test_client.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/create_test_client_grant.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/delete_test_client.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/delete_test_client_grant.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_client/_filters/should_exclude_and_include_fields_properly.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_client/_filters/should_include_the_specified_fields.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_client/should_get_the_test_client.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/_filters/should_exclude_fields_not_specified.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/_filters/should_exclude_the_specified_fields.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/_filters/should_include_the_specified_fields.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/_filters/should_paginate_results.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/should_get_at_least_one_client.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_delete_client/should_delete_the_test_client_without_an_error.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_patch_client/should_update_the_client_with_the_correct_attributes.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/create_test_client.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connection/_filters/should_exclude_the_fields_indicated.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connection/_filters/should_include_the_fields_indicated.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connection/should_find_the_correct_connection.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/_filters/should_include_previously-created_connection_when_filtered.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/_filters/should_should_exclude_the_fields_indicated_from_filtered_results.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/_filters/should_should_include_the_fields_indicated_from_filtered_results.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/should_include_the_previously_created_connection.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/should_not_be_empty.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_delete_connection/should_delete_the_connection.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_delete_connection_user/should_delete_the_user_created.yml +2 -2
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_update_connection/should_update_the_connection.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/create_test_connection.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/create_test_user.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/create_test_user.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/delete_test_credential.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/delete_test_user.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_configure_provider/should_configure_a_new_email_provider.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_delete_provider/should_delete_the_existing_email_provider_without_an_error.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_delete_provider/should_throw_an_error_trying_to_get_the_email_provider.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_get_provider/_filters/should_get_the_existing_email_provider_with_specific_fields.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_get_provider/_filters/should_get_the_existing_email_provider_without_specific_fields.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_get_provider/should_get_the_existing_email_provider.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_update_provider/should_update_the_existing_email_provider.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/delete_existing_provider.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_log/should_match_the_created_log_entry.yml +2 -2
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_log/should_not_be_empty.yml +2 -2
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_filters/should_exclude_fields_not_specified.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_filters/should_exclude_the_specified_fields.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_filters/should_have_one_log_entry.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_filters/should_include_the_specified_fields.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_from/should_take_one_log_entry.yml +2 -2
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/create_test_user.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/delete_test_disabled_rule.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/delete_test_enabled_rule.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/delete_test_user.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_add_role_permissions/should_add_a_Permission_to_the_Role_successfully.yml +69 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_add_role_users/should_add_a_User_to_the_Role_successfully.yml +69 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_delete_role/should_delete_the_Role_successfully.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role/should_get_the_Role_successfully.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role_permissions/should_get_exactly_1_Permission.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role_permissions/should_get_the_added_Permission_from_the_Role_successfully.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role_users/should_get_exactly_1_User.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role_users/should_get_the_added_User_from_the_Role_successfully.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_roles/should_get_the_Role_successfully.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_remove_role_permissions/should_remove_a_Permission_from_the_Role_successfully.yml +64 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_update_role/should_update_the_Role_successfully.yml +69 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/create_test_api.yml +69 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/create_test_role.yml +69 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/create_test_user.yml +69 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/delete_test_api.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/delete_test_user.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_delete_rule/should_delete_the_test_disabled_rule_without_an_error.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_delete_rule/should_delete_the_test_enabled_rule_without_an_error.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rule/_filters/should_exclude_the_fields_not_specified.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rule/_filters/should_exclude_the_specified_fields.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rule/_filters/should_include_the_specified_fields.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rule/should_get_a_specific_rule.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_exclude_fields_not_specified.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_include_the_specified_fields.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_return_at_least_1_disabled_rule.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_return_at_least_1_enabled_rule.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_return_paginated_results.yml +2 -2
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/should_return_at_least_1_rule.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_update_rule/should_update_the_disabled_rule_to_be_enabled.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/create_test_disabled_rule.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/create_test_enabled_rule.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Stats/_active_users/should_have_at_least_one_active_user.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Stats/_daily_stats/should_have_at_least_one_stats_entry_for_the_timeframe.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_get_tenant_settings/should_get_the_tenant_settings.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_get_tenant_settings_with_specific_fields/should_exclude_a_field_not_requested.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_get_tenant_settings_with_specific_fields/should_include_the_field_requested.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_update_tenant_settings/should_revert_the_tenant_name.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_update_tenant_settings/should_update_the_tenant_settings_with_a_new_tenant_name.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tickets/_post_email_verification/should_create_an_email_verification_ticket.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tickets/_post_password_change/should_create_a_password_change_ticket.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tickets/create_test_user.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tickets/delete_test_user.yml +1 -1
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_add_user_permissions/should_add_a_Permissions_for_a_User_successfully.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_add_user_roles/should_add_a_Role_to_a_User_successfully.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_delete_user/{should_delete_the_user_successfully.yml → should_delete_the_User_successfully.yml} +14 -8
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_delete_user/should_delete_the_secondary_User_successfully.yml +60 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_delete_user_provider/should_attempt_to_delete_the_MFA_provider_for_the_User.yml +60 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_get_enrollments/should_get_Enrollments_for_a_User_successfully.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_get_user_permissions/should_get_exactly_1_Permission_for_a_User_successfully.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_get_user_permissions/should_get_the_correct_Permission_for_a_User_successfully.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_get_user_roles/should_get_Roles_for_a_User_successfully.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_invalidate_browsers/should_invalidate_MFA_browsers_for_the_User_successfully.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_link_user_account/should_link_two_Users_successfully.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_patch_user/should_patch_the_User_successfully.yml +68 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_remove_user_permissions/should_remove_a_Permission_from_a_User_successfully.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_remove_user_roles/should_remove_a_Role_from_a_User_successfully.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_unlink_user_account/should_unlink_two_Users_successfully.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user/_filters/should_exclude_fields_not_indicated.yml +15 -10
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user/_filters/should_exclude_the_fields_indicated.yml +15 -13
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user/_filters/should_include_the_fields_indicated.yml +15 -13
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user/should_retrieve_the_created_user.yml +15 -16
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user_logs/should_get_Logs_for_a_User_successfully.yml +69 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/is_expected_to_find_a_user_with_a_v2_search_engine_query.yml +14 -8
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/is_expected_to_find_a_user_with_a_v3_search_engine_query.yml +14 -8
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/should_exclude_the_indicated_fields_when_paginated.yml +13 -7
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/should_include_the_indicated_fields_when_paginated.yml +13 -7
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/should_not_include_other_fields_when_paginated.yml +13 -7
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/should_return_the_correct_number_of_results_when_paginated.yml +13 -7
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/should_have_at_least_one_user.yml +13 -7
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/create_secondary_test_user.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/create_test_api.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/create_test_role.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/create_test_user.yml +15 -16
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/delete_test_api.yml +60 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/delete_test_role.yml +60 -0
- data/spec/integration/lib/auth0/api/v2/api_anomaly_spec.rb +17 -0
- data/spec/integration/lib/auth0/api/v2/api_roles_spec.rb +145 -0
- data/spec/integration/lib/auth0/api/v2/api_users_spec.rb +150 -32
- data/spec/integration/lib/auth0/auth0_client_spec.rb +3 -4
- data/spec/lib/auth0/api/authentication_endpoints_spec.rb +37 -10
- data/spec/lib/auth0/api/v2/anomaly_spec.rb +26 -0
- data/spec/lib/auth0/api/v2/client_grants_spec.rb +17 -0
- data/spec/lib/auth0/api/v2/guardian_spec.rb +154 -0
- data/spec/lib/auth0/api/v2/jobs_spec.rb +33 -1
- data/spec/lib/auth0/api/v2/roles_spec.rb +362 -0
- data/spec/lib/auth0/api/v2/users_spec.rb +406 -66
- data/spec/lib/auth0/mixins/httpproxy_spec.rb +81 -2
- data/spec/lib/auth0/mixins/validation_spec.rb +474 -0
- data/spec/spec_helper.rb +11 -7
- data/spec/support/credentials.rb +4 -13
- data/spec/support/dummy_class.rb +1 -1
- data/spec/support/stub_response.rb +1 -1
- metadata +145 -23
- data/.travis.yml +0 -18
- data/build_travis.sh +0 -7
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_patch_user/should_patch_email_verified_and_return_the_updated_data.yml +0 -68
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_patch_user/should_patch_user_metadata_and_return_the_updated_user.yml +0 -69
@@ -1,21 +1,65 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
describe Auth0::Api::V2::Users do
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
3
|
+
|
4
|
+
attr_reader :client, :test_user_name, :test_user_email, :test_user, :test_user_secondary,
|
5
|
+
:test_role, :test_api_name, :test_permission_name, :test_permission
|
6
|
+
|
7
|
+
before(:all) do
|
8
|
+
@client ||= Auth0::Client.new(v2_creds)
|
9
|
+
|
10
|
+
@test_user_name = "#{entity_suffix}-username"
|
11
|
+
@test_user_email = "#{entity_suffix}-#{@test_user_name}@auth0.com"
|
12
|
+
|
13
|
+
@test_api_name = "#{entity_suffix}-test-api-for-users"
|
14
|
+
@test_api_scope = 'test:scope'
|
15
|
+
|
16
|
+
@test_permission_name = "#{entity_suffix}-test-permission-for-users"
|
17
|
+
@test_permission = Permission.new("#{entity_suffix}-test-permission-for-users", @test_api_name)
|
18
|
+
|
19
|
+
VCR.use_cassette('Auth0_Api_V2_Users/create_test_user') do
|
20
|
+
@test_user ||= client.create_user(
|
21
|
+
@test_user_name,
|
22
|
+
email: @test_user_email,
|
23
|
+
password: Faker::Internet.password,
|
24
|
+
connection: Auth0::Api::AuthenticationEndpoints::UP_AUTH
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
VCR.use_cassette('Auth0_Api_V2_Users/create_secondary_test_user') do
|
29
|
+
@test_user_secondary ||= client.create_user(
|
30
|
+
"#{test_user_name}-secondary",
|
31
|
+
email: "#{entity_suffix}-#{@test_user_name}-secondary@auth0.com",
|
32
|
+
password: Faker::Internet.password,
|
33
|
+
connection: Auth0::Api::AuthenticationEndpoints::UP_AUTH
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
VCR.use_cassette('Auth0_Api_V2_Users/create_test_api') do
|
38
|
+
@test_api ||= client.create_resource_server(
|
39
|
+
@test_api_name,
|
40
|
+
name: @test_api_name,
|
41
|
+
scopes: [{ value: @test_api_scope }]
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
VCR.use_cassette('Auth0_Api_V2_Users/create_test_role') do
|
46
|
+
@test_role ||= client.create_role(
|
47
|
+
"#{entity_suffix}-test-role-for-users",
|
48
|
+
description: 'Test role description'
|
15
49
|
)
|
16
50
|
end
|
17
51
|
end
|
18
52
|
|
53
|
+
after(:all) do
|
54
|
+
VCR.use_cassette('Auth0_Api_V2_Users/delete_test_api') do
|
55
|
+
client.delete_resource_server @test_api['id']
|
56
|
+
end
|
57
|
+
|
58
|
+
VCR.use_cassette('Auth0_Api_V2_Users/delete_test_role') do
|
59
|
+
client.delete_role @test_role['id']
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
19
63
|
describe '.create_user', vcr: true do
|
20
64
|
it 'should return the created user' do
|
21
65
|
expect(test_user).to include('user_id', 'email', 'email_verified', 'name')
|
@@ -138,45 +182,119 @@ describe Auth0::Api::V2::Users do
|
|
138
182
|
describe '.patch_user', vcr: true do
|
139
183
|
let(:patch_user_body) do
|
140
184
|
{
|
185
|
+
'email_verified' => true,
|
141
186
|
'user_metadata' => {
|
142
187
|
'addresses' => { 'home_address' => '742 Evergreen Terrace' }
|
143
188
|
}
|
144
189
|
}
|
145
190
|
end
|
146
191
|
|
147
|
-
it 'should
|
148
|
-
expect
|
192
|
+
it 'should patch the User successfully' do
|
193
|
+
expect(
|
194
|
+
client.patch_user(test_user['user_id'], patch_user_body)
|
195
|
+
).to include(patch_user_body)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
describe '.delete_user_provider', vcr: true do
|
200
|
+
it 'should attempt to delete the MFA provider for the User' do
|
201
|
+
expect { client.delete_user_provider test_user['user_id'], 'google-authenticator' }.to_not raise_error
|
149
202
|
end
|
203
|
+
end
|
204
|
+
|
205
|
+
describe '.link_user_account', vcr: true do
|
206
|
+
let(:secondary_account_body) do
|
207
|
+
{
|
208
|
+
provider: 'auth0',
|
209
|
+
user_id: test_user_secondary['user_id']
|
210
|
+
}
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'should link two Users successfully' do
|
214
|
+
expect { client.link_user_account test_user['user_id'], secondary_account_body }.to_not raise_error
|
215
|
+
end
|
216
|
+
end
|
150
217
|
|
151
|
-
|
218
|
+
describe '.unlink_user_account', vcr: true do
|
219
|
+
it 'should unlink two Users successfully' do
|
152
220
|
expect do
|
153
|
-
client.
|
154
|
-
end.
|
221
|
+
client.unlink_user_account test_user['user_id'], 'auth0', test_user_secondary['user_id']
|
222
|
+
end.to_not raise_error
|
155
223
|
end
|
224
|
+
end
|
156
225
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
test_user['user_id'],
|
161
|
-
'email_verified' => true
|
162
|
-
)
|
163
|
-
).to include('email_verified' => true)
|
226
|
+
describe '.user_logs', vcr: true do
|
227
|
+
it 'should get Logs for a User successfully' do
|
228
|
+
expect { client.user_logs( test_user['user_id'], per_page: 2 ) }.to_not raise_error
|
164
229
|
end
|
230
|
+
end
|
165
231
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
).to include(patch_user_body)
|
232
|
+
describe '.add_user_roles', vcr: true do
|
233
|
+
it 'should add a Role to a User successfully' do
|
234
|
+
expect { client.add_user_roles test_user['user_id'], [ test_role['id'] ] }.to_not raise_error
|
170
235
|
end
|
171
236
|
end
|
172
237
|
|
173
|
-
describe '.
|
174
|
-
it 'should
|
175
|
-
expect
|
238
|
+
describe '.get_user_roles', vcr: true do
|
239
|
+
it 'should get Roles for a User successfully' do
|
240
|
+
expect( client.get_user_roles(test_user['user_id']).first ).to include(
|
241
|
+
'id' => test_role['id']
|
242
|
+
)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
describe '.remove_user_roles', vcr: true do
|
247
|
+
it 'should remove a Role from a User successfully' do
|
248
|
+
expect { client.remove_user_roles test_user['user_id'], [ test_role['id'] ] }.to_not raise_error
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
describe '.get_enrollments', vcr: true do
|
253
|
+
it 'should get Enrollments for a User successfully' do
|
254
|
+
expect { client.get_enrollments test_user['user_id'] }.to_not raise_error
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
describe '.add_user_permissions', vcr: true do
|
259
|
+
it 'should add a Permissions for a User successfully' do
|
260
|
+
expect { client.add_user_permissions test_user['user_id'], [ test_permission ] }.to_not raise_error
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
describe '.get_user_permissions', vcr: true do
|
265
|
+
let(:test_get_user_permissions) do
|
266
|
+
client.get_user_permissions test_user['user_id']
|
267
|
+
end
|
268
|
+
|
269
|
+
it 'should get exactly 1 Permission for a User successfully' do
|
270
|
+
expect( test_get_user_permissions.count ).to eq 1
|
176
271
|
end
|
177
272
|
|
178
|
-
it 'should
|
273
|
+
it 'should get the correct Permission for a User successfully' do
|
274
|
+
expect( test_get_user_permissions.first['permission_name'] ).to eq test_permission_name
|
275
|
+
expect( test_get_user_permissions.first['resource_server_name'] ).to eq test_api_name
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
describe '.remove_user_permissions', vcr: true do
|
280
|
+
it 'should remove a Permission from a User successfully' do
|
281
|
+
expect { client.remove_user_permissions test_user['user_id'], [ test_permission ] }.to_not raise_error
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
describe '.invalidate_browsers', vcr: true do
|
286
|
+
it 'should invalidate MFA browsers for the User successfully' do
|
287
|
+
expect { client.invalidate_browsers test_user['user_id'] }.to_not raise_error
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
describe '.delete_user', vcr: true do
|
292
|
+
it 'should delete the User successfully' do
|
179
293
|
expect { client.delete_user test_user['user_id'] }.to_not raise_error
|
180
294
|
end
|
295
|
+
|
296
|
+
it 'should delete the secondary User successfully' do
|
297
|
+
expect { client.delete_user test_user_secondary['user_id'] }.to_not raise_error
|
298
|
+
end
|
181
299
|
end
|
182
300
|
end
|
@@ -44,19 +44,18 @@ describe Auth0::Client do
|
|
44
44
|
api_version: 2, token: 'token'
|
45
45
|
}, Auth0::InvalidApiNamespace
|
46
46
|
|
47
|
-
let(:
|
48
|
-
let(:v2_credentials) { { domain: ENV['DOMAIN'] } }
|
47
|
+
let(:v2_credentials) { { domain: 'test.auth0.com' } }
|
49
48
|
|
50
49
|
shared_examples 'valid credentials' do
|
51
50
|
it { expect { Auth0Client.new(credentials) }.to_not raise_error }
|
52
51
|
end
|
53
52
|
|
54
53
|
it_should_behave_like 'valid credentials' do
|
55
|
-
let(:credentials) { v2_credentials.merge(token:
|
54
|
+
let(:credentials) { v2_credentials.merge(token: 'TEST_API_TOKEN') }
|
56
55
|
end
|
57
56
|
|
58
57
|
it_should_behave_like 'valid credentials' do
|
59
|
-
let(:credentials) { v2_credentials.merge(access_token:
|
58
|
+
let(:credentials) { v2_credentials.merge(access_token: 'TEST_API_TOKEN') }
|
60
59
|
end
|
61
60
|
|
62
61
|
context 'client headers' do
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# rubocop:disable Metrics/BlockLength
|
2
4
|
require 'spec_helper'
|
3
5
|
describe Auth0::Api::AuthenticationEndpoints do
|
@@ -20,7 +22,7 @@ describe Auth0::Api::AuthenticationEndpoints do
|
|
20
22
|
grant_type: 'client_credentials',
|
21
23
|
client_id: @instance.client_id,
|
22
24
|
client_secret: @instance.client_secret,
|
23
|
-
audience: @instance.audience
|
25
|
+
audience: @instance.audience
|
24
26
|
).and_return('access_token' => 'AccessToken')
|
25
27
|
|
26
28
|
expect(@instance.api_token.token).to eql 'AccessToken'
|
@@ -32,7 +34,7 @@ describe Auth0::Api::AuthenticationEndpoints do
|
|
32
34
|
grant_type: 'client_credentials',
|
33
35
|
client_id: @instance.client_id,
|
34
36
|
client_secret: @instance.client_secret,
|
35
|
-
audience: '__test_audience__'
|
37
|
+
audience: '__test_audience__'
|
36
38
|
).and_return('access_token' => 'AccessToken')
|
37
39
|
|
38
40
|
expect(
|
@@ -47,7 +49,7 @@ describe Auth0::Api::AuthenticationEndpoints do
|
|
47
49
|
allow(@instance).to receive(:post).with(
|
48
50
|
'/oauth/token', client_id: @instance.client_id, client_secret: @instance.client_secret, grant_type: 'client_credentials'
|
49
51
|
)
|
50
|
-
|
52
|
+
.and_return('access_token' => 'AccessToken')
|
51
53
|
|
52
54
|
expect(@instance).to receive(:post).with(
|
53
55
|
'/oauth/token', client_id: @instance.client_id, client_secret: @instance.client_secret, grant_type: 'client_credentials'
|
@@ -90,7 +92,6 @@ describe Auth0::Api::AuthenticationEndpoints do
|
|
90
92
|
it { expect { @instance.obtain_user_tokens('code', '') }.to raise_error 'Must supply a valid redirect_uri' }
|
91
93
|
end
|
92
94
|
|
93
|
-
|
94
95
|
context '.exchange_auth_code_for_tokens' do
|
95
96
|
it { is_expected.to respond_to(:exchange_auth_code_for_tokens) }
|
96
97
|
|
@@ -183,7 +184,6 @@ describe Auth0::Api::AuthenticationEndpoints do
|
|
183
184
|
).to eq 'AccessToken'
|
184
185
|
end
|
185
186
|
|
186
|
-
|
187
187
|
it 'is expected to make post request to /oauth/token with custom params' do
|
188
188
|
allow(@instance).to receive(:post).with(
|
189
189
|
'/oauth/token',
|
@@ -241,7 +241,6 @@ describe Auth0::Api::AuthenticationEndpoints do
|
|
241
241
|
end
|
242
242
|
|
243
243
|
it 'should make post to /oauth/token with custom params' do
|
244
|
-
|
245
244
|
allow(@instance).to receive(:post).with(
|
246
245
|
'/oauth/token',
|
247
246
|
username: 'test@test.com',
|
@@ -355,7 +354,8 @@ describe Auth0::Api::AuthenticationEndpoints do
|
|
355
354
|
expect(@instance).to receive(:post).with(
|
356
355
|
'/passwordless/start',
|
357
356
|
client_id: @instance.client_id,
|
358
|
-
|
357
|
+
client_secret: @instance.client_secret,
|
358
|
+
connection: 'email',
|
359
359
|
email: 'test@test.com',
|
360
360
|
send: 'code',
|
361
361
|
authParams: {
|
@@ -388,6 +388,7 @@ describe Auth0::Api::AuthenticationEndpoints do
|
|
388
388
|
expect(@instance).to receive(:post).with(
|
389
389
|
'/passwordless/start',
|
390
390
|
client_id: @instance.client_id,
|
391
|
+
client_secret: @instance.client_secret,
|
391
392
|
connection: 'sms',
|
392
393
|
phone_number: phone_number
|
393
394
|
)
|
@@ -550,7 +551,7 @@ describe Auth0::Api::AuthenticationEndpoints do
|
|
550
551
|
context '.userinfo' do
|
551
552
|
it { is_expected.to respond_to(:user_info) }
|
552
553
|
it 'is expected to make a GET request to /userinfo' do
|
553
|
-
is_expected.to receive(:get).with('/userinfo', {}, {'Authorization' => 'Bearer access-token'})
|
554
|
+
is_expected.to receive(:get).with('/userinfo', {}, { 'Authorization' => 'Bearer access-token' })
|
554
555
|
subject.userinfo 'access-token'
|
555
556
|
end
|
556
557
|
end
|
@@ -603,7 +604,7 @@ describe Auth0::Api::AuthenticationEndpoints do
|
|
603
604
|
|
604
605
|
it 'is expected to return a logout url with a client ID' do
|
605
606
|
expect(@instance.logout_url(return_to, include_client: true).to_s).to eq(
|
606
|
-
"https://#{@instance.domain}/v2/logout"
|
607
|
+
"https://#{@instance.domain}/v2/logout" \
|
607
608
|
"?returnTo=http%3A%2F%2Freturnto.com&client_id=#{@instance.client_id}"
|
608
609
|
)
|
609
610
|
end
|
@@ -653,7 +654,7 @@ describe Auth0::Api::AuthenticationEndpoints do
|
|
653
654
|
end
|
654
655
|
|
655
656
|
it 'is expected to get the wsfed url with wctx' do
|
656
|
-
expect(@instance.wsfed_url(UP_AUTH, {wctx: 'wctx_test'}).to_s).to eq(
|
657
|
+
expect(@instance.wsfed_url(UP_AUTH, { wctx: 'wctx_test' }).to_s).to eq(
|
657
658
|
"https://#{@instance.domain}/wsfed/#{@instance.client_id}" \
|
658
659
|
"?whr=#{UP_AUTH}&wctx=wctx_test"
|
659
660
|
)
|
@@ -672,5 +673,31 @@ describe Auth0::Api::AuthenticationEndpoints do
|
|
672
673
|
)
|
673
674
|
end
|
674
675
|
end
|
676
|
+
|
677
|
+
# Auth0::API::AuthenticationEndpoints.validate_id_token
|
678
|
+
context '.validate_id_token' do
|
679
|
+
it { expect(@instance).to respond_to(:validate_id_token) }
|
680
|
+
|
681
|
+
it 'is expected not to raise an error with default values' do
|
682
|
+
stub_request(:get, 'https://test.auth0.com/.well-known/jwks.json').to_return(body: JWKS_RESPONSE_1.to_json)
|
683
|
+
token = 'eyJhbGciOiJSUzI1NiIsImtpZCI6InRlc3Qta2V5LTEifQ.eyJpc3MiOiJodHRwczovL3Rlc3QuYXV0aDAuY29tLyIsInN1YiI6ImF1dGgwfDEyMzQ1Njc4OSIsImF1ZCI6WyJfX3Rlc3RfYXVkaWVuY2VfXyIsIl9fdGVzdF9jbGllbnRfaWRfXyJdLCJleHAiOjI1MzgzMDExNDYsImlhdCI6MTU4NzU5MjU2MSwiYXpwIjoiX190ZXN0X2NsaWVudF9pZF9fIn0.X35Hfa1C9RtuJIj7Eky2iO4elY9XqCDRy8ieFAft63vGds9vhP38x8QHbJifmLs6vDEOySKfJMWhklp3oaXm6Tk6gyUQEaliW_pXUgZt8C3Xo125R8BMCDQeVJg8Abevbg6FpHpYztWpQuI609tmpoTczx7pXMmAneg6e4LNYvvtzaFD_0M0cxtjkm4OcevCJszNBru3tdXwRynkGbMYeXgoa_FumAshRvIvh-4dtkyNWsepo5IVTvixxF3FVoFaXOOycmFXh9gxOppG4lvE78AFB9AQ9LNS-DNhcXszbPs9KHMrg2bqhSL8Razqd3m2a1MXkdLMBD5DY499MVnb5w'
|
684
|
+
|
685
|
+
expect { @instance.validate_id_token(token) }.to_not raise_exception
|
686
|
+
end
|
687
|
+
|
688
|
+
it 'is expected not to raise an error with custom values' do
|
689
|
+
token = 'eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJpc3N1ZXIiLCJzdWIiOiJhdXRoMHwxMjM0NTY3ODkiLCJhdWQiOlsiYXVkaWVuY2UiLCJhbm90aGVyX2F1ZGllbmNlIl0sImV4cCI6MjUzODMwMTE0NiwiaWF0IjoxNTg3NTkyNTYxLCJub25jZSI6Im5vbmNlIiwiYXpwIjoiYXVkaWVuY2UiLCJhdXRoX3RpbWUiOjE1ODc2Nzg5NjF9.u39qTvuUmbzj5jsXjATXxjxJt0u064G1IAumoi18gm0'
|
690
|
+
|
691
|
+
expect do
|
692
|
+
@instance.validate_id_token(token,
|
693
|
+
algorithm: Auth0::Algorithm::HS256.secret('secret'),
|
694
|
+
leeway: 100,
|
695
|
+
nonce: 'nonce',
|
696
|
+
max_age: 2538301146,
|
697
|
+
issuer: 'issuer',
|
698
|
+
audience: 'audience')
|
699
|
+
end.to_not raise_exception
|
700
|
+
end
|
701
|
+
end
|
675
702
|
end
|
676
703
|
# rubocop:enable Metrics/BlockLength
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Auth0::Api::V2::Anomaly do
|
3
|
+
before :all do
|
4
|
+
dummy_instance = DummyClass.new
|
5
|
+
dummy_instance.extend(Auth0::Api::V2::Anomaly)
|
6
|
+
@instance = dummy_instance
|
7
|
+
end
|
8
|
+
|
9
|
+
context '.check_if_ip_is_blocked' do
|
10
|
+
it { expect(@instance).to respond_to(:check_if_ip_is_blocked) }
|
11
|
+
it 'expect client to send get to /api/v2/anomaly/blocks/ips/192.0.2.0' do
|
12
|
+
expect(@instance).to receive(:get).with('/api/v2/anomaly/blocks/ips/192.0.2.0')
|
13
|
+
expect { @instance.check_if_ip_is_blocked('192.0.2.0') }.not_to raise_error
|
14
|
+
end
|
15
|
+
it { expect { @instance.check_if_ip_is_blocked('') }.to raise_error('Must specify an IP') }
|
16
|
+
end
|
17
|
+
|
18
|
+
context '.remove_ip_block' do
|
19
|
+
it { expect(@instance).to respond_to(:remove_ip_block) }
|
20
|
+
it 'expect client to send delete to /api/v2/anomaly/blocks/ips/192.0.2.0' do
|
21
|
+
expect(@instance).to receive(:delete).with('/api/v2/anomaly/blocks/ips/192.0.2.0')
|
22
|
+
expect { @instance.remove_ip_block('192.0.2.0') }.not_to raise_error
|
23
|
+
end
|
24
|
+
it { expect { @instance.remove_ip_block('') }.to raise_error('Must specify an IP') }
|
25
|
+
end
|
26
|
+
end
|
@@ -13,15 +13,32 @@ describe Auth0::Api::V2::ClientGrants do
|
|
13
13
|
it 'is expected to get /api/v2/client-grants/' do
|
14
14
|
expect(@instance).to receive(:get).with(
|
15
15
|
'/api/v2/client-grants',
|
16
|
+
client_id: nil,
|
17
|
+
audience: nil,
|
16
18
|
page: nil,
|
17
19
|
per_page: nil
|
18
20
|
)
|
19
21
|
expect { @instance.client_grants }.not_to raise_error
|
20
22
|
end
|
21
23
|
|
24
|
+
it 'is expected to send get /api/v2/client-grants/ with client_id and audience' do
|
25
|
+
audience = "https://samples.auth0.com/api/v2/"
|
26
|
+
|
27
|
+
expect(@instance).to receive(:get).with(
|
28
|
+
'/api/v2/client-grants',
|
29
|
+
client_id: '1',
|
30
|
+
audience: audience,
|
31
|
+
page: nil,
|
32
|
+
per_page: nil
|
33
|
+
)
|
34
|
+
expect { @instance.client_grants(client_id: '1', audience: audience) }.not_to raise_error
|
35
|
+
end
|
36
|
+
|
22
37
|
it 'is expected to send get /api/v2/client-grants/ with pagination' do
|
23
38
|
expect(@instance).to receive(:get).with(
|
24
39
|
'/api/v2/client-grants',
|
40
|
+
client_id: nil,
|
41
|
+
audience: nil,
|
25
42
|
page: 1,
|
26
43
|
per_page: 2
|
27
44
|
)
|
@@ -0,0 +1,154 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Auth0::Api::V2::Guardian do
|
3
|
+
before :all do
|
4
|
+
dummy_instance = DummyClass.new
|
5
|
+
dummy_instance.extend(Auth0::Api::V2::Guardian)
|
6
|
+
@instance = dummy_instance
|
7
|
+
end
|
8
|
+
|
9
|
+
context '.guardian_factors' do
|
10
|
+
it 'is expected to respond to a guardian_factors method' do
|
11
|
+
expect(@instance).to respond_to(:guardian_factors)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'is expected to respond to a get_guardian_factors method' do
|
15
|
+
expect(@instance).to respond_to(:get_guardian_factors)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'is expected to get /api/v2/guardian/factors' do
|
19
|
+
expect(@instance).to receive(:get).with(
|
20
|
+
'/api/v2/guardian/factors'
|
21
|
+
)
|
22
|
+
expect { @instance.guardian_factors }.not_to raise_error
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context '.guardian_enrollment' do
|
27
|
+
it 'is expected to respond to a guardian_enrollment method' do
|
28
|
+
expect(@instance).to respond_to(:guardian_enrollment)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'is expected to call get request to /api/v2/guardian/enrollments/ENROLLMENT_ID' do
|
32
|
+
expect(@instance).to receive(:get).with(
|
33
|
+
'/api/v2/guardian/enrollments/ENROLLMENT_ID'
|
34
|
+
)
|
35
|
+
expect { @instance.guardian_enrollment('ENROLLMENT_ID') }.not_to raise_error
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'is expected to raise an exception when the enrollment ID is empty' do
|
39
|
+
expect { @instance.guardian_enrollment(nil) }.to raise_exception(Auth0::MissingParameter)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context '.delete_guardian_enrollment' do
|
44
|
+
it 'is expected to respond to a delete_guardian_enrollment method' do
|
45
|
+
expect(@instance).to respond_to(:delete_guardian_enrollment)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'is expected to delete /api/v2/guardian/enrollments/ENROLLMENT_ID' do
|
49
|
+
expect(@instance).to receive(:delete).with('/api/v2/guardian/enrollments/ENROLLMENT_ID')
|
50
|
+
@instance.delete_guardian_enrollment('ENROLLMENT_ID')
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'is expected not to delete /api/v2/guardian/enrollments/ENROLLMENT_ID if enrollment_id is blank' do
|
54
|
+
expect(@instance).not_to receive(:delete)
|
55
|
+
expect { @instance.delete_guardian_enrollment(nil) }.to raise_exception(
|
56
|
+
Auth0::MissingParameter
|
57
|
+
)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context '.guardian_sms_templates' do
|
62
|
+
it 'is expected to respond to a guardian_sms_templates method' do
|
63
|
+
expect(@instance).to respond_to(:guardian_sms_templates)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'is expected to call get request to /api/v2/guardian/factors/sms/templates' do
|
67
|
+
expect(@instance).to receive(:get).with(
|
68
|
+
'/api/v2/guardian/factors/sms/templates'
|
69
|
+
)
|
70
|
+
expect { @instance.guardian_sms_templates }.not_to raise_error
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context '.guardian_update_enrollment_verification_templates' do
|
75
|
+
it 'is expected to respond to a guardian_update_enrollment_verification_templates method' do
|
76
|
+
expect(@instance).to respond_to(:guardian_update_enrollment_verification_templates)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'is expected to patch /api/v2/guardian/factors/sms/templates' do
|
80
|
+
expect(@instance).to receive(:put).with('/api/v2/guardian/factors/sms/templates', 'BODY')
|
81
|
+
@instance.guardian_update_enrollment_verification_templates('BODY')
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context '.guardian_sns_provider_config' do
|
86
|
+
it 'is expected to respond to a guardian_sns_provider_config method' do
|
87
|
+
expect(@instance).to respond_to(:guardian_sns_provider_config)
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'is expected to call get request to /api/v2/guardian/factors/push-notification/providers/sns' do
|
91
|
+
expect(@instance).to receive(:get).with(
|
92
|
+
'/api/v2/guardian/factors/push-notification/providers/sns'
|
93
|
+
)
|
94
|
+
expect { @instance.guardian_sns_provider_config }.not_to raise_error
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context '.guardian_update_sns_provider_config' do
|
99
|
+
it 'is expected to respond to a guardian_update_sns_provider_config method' do
|
100
|
+
expect(@instance).to respond_to(:guardian_update_sns_provider_config)
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'is expected to patch /api/v2/guardian/factors/push-notification/providers/sns' do
|
104
|
+
expect(@instance).to receive(:put).with('/api/v2/guardian/factors/push-notification/providers/sns', 'BODY')
|
105
|
+
@instance.guardian_update_sns_provider_config('BODY')
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context '.guardian_twillo_provider_config' do
|
110
|
+
it 'is expected to respond to a guardian_twillo_provider_config method' do
|
111
|
+
expect(@instance).to respond_to(:guardian_twillo_provider_config)
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'is expected to call get request to /api/v2/guardian/factors/sms/providers/twilio' do
|
115
|
+
expect(@instance).to receive(:get).with(
|
116
|
+
'/api/v2/guardian/factors/sms/providers/twilio'
|
117
|
+
)
|
118
|
+
expect { @instance.guardian_twillo_provider_config }.not_to raise_error
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
context '.guardian_update_twillo_provider_config' do
|
123
|
+
it 'is expected to respond to a guardian_update_twillo_provider_config method' do
|
124
|
+
expect(@instance).to respond_to(:guardian_update_twillo_provider_config)
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'is expected to patch /api/v2/guardian/factors/sms/providers/twilio' do
|
128
|
+
expect(@instance).to receive(:put).with('/api/v2/guardian/factors/sms/providers/twilio', 'BODY')
|
129
|
+
@instance.guardian_update_twillo_provider_config('BODY')
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context '.guardian_create_enrollment_ticket' do
|
134
|
+
it 'is expected to respond to a guardian_create_enrollment_ticket method' do
|
135
|
+
expect(@instance).to respond_to(:guardian_create_enrollment_ticket)
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'is expected to post /api/v2/guardian/enrollments/ticket' do
|
139
|
+
expect(@instance).to receive(:post).with('/api/v2/guardian/enrollments/ticket', 'BODY')
|
140
|
+
@instance.guardian_create_enrollment_ticket('BODY')
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
context '.guardian_update_factor' do
|
145
|
+
it 'is expected to respond to a guardian_update_factor method' do
|
146
|
+
expect(@instance).to respond_to(:guardian_update_factor)
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'is expected to patch /api/v2/guardian/factors/NAME' do
|
150
|
+
expect(@instance).to receive(:put).with('/api/v2/guardian/factors/NAME', 'BODY')
|
151
|
+
@instance.guardian_update_factor('NAME', 'BODY')
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|