auth0 4.7.0 → 4.8.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 +50 -0
- data/.github/CODEOWNERS +1 -0
- data/.gitignore +0 -1
- data/CHANGELOG.md +27 -0
- data/DEPLOYMENT.md +11 -3
- data/Gemfile +2 -1
- data/Gemfile.lock +172 -0
- data/README.md +2 -2
- data/auth0.gemspec +1 -3
- data/codecov.yml +22 -0
- data/deploy_documentation.sh +1 -1
- data/lib/auth0/api/v2.rb +4 -0
- data/lib/auth0/api/v2/anomaly.rb +36 -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 +117 -4
- data/lib/auth0/exception.rb +33 -7
- data/lib/auth0/mixins/httpproxy.rb +10 -7
- data/lib/auth0/mixins/permission_struct.rb +3 -0
- data/lib/auth0/mixins/validation.rb +25 -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 +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_add_role_users/should_add_a_User_to_the_Role_successfully.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_delete_role/should_delete_the_Role_successfully.yml +60 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role/should_get_the_Role_successfully.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role_permissions/should_get_exactly_1_Permission.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role_permissions/should_get_the_added_Permission_from_the_Role_successfully.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role_users/should_get_exactly_1_User.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role_users/should_get_the_added_User_from_the_Role_successfully.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_roles/should_get_the_Role_successfully.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_remove_role_permissions/should_remove_a_Permission_from_the_Role_successfully.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_update_role/should_update_the_Role_successfully.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/create_test_api.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/create_test_role.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/create_test_user.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/delete_test_api.yml +60 -0
- data/spec/fixtures/vcr_cassettes/{Auth0_Api_V2_Users/_delete_user/should_delete_the_user_successfully.yml → Auth0_Api_V2_Roles/delete_test_user.yml} +14 -8
- 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 +60 -0
- 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/v2/anomaly_spec.rb +26 -0
- data/spec/lib/auth0/api/v2/jobs_spec.rb +33 -1
- data/spec/lib/auth0/api/v2/roles_spec.rb +360 -0
- data/spec/lib/auth0/api/v2/users_spec.rb +406 -66
- data/spec/lib/auth0/mixins/httpproxy_spec.rb +57 -0
- data/spec/spec_helper.rb +5 -6
- data/spec/support/credentials.rb +4 -13
- data/spec/support/dummy_class.rb +1 -1
- data/spec/support/stub_response.rb +1 -1
- metadata +96 -10
- 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
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
describe Auth0::Api::V2::Anomaly do
|
|
3
|
+
let(:client) { Auth0Client.new(v2_creds) }
|
|
4
|
+
let(:ip) { '192.0.2.0' }
|
|
5
|
+
|
|
6
|
+
describe '.check_if_ip_is_blocked', vcr: true do
|
|
7
|
+
it 'should return 200 response code' do
|
|
8
|
+
expect { client.check_if_ip_is_blocked(ip) }.to_not raise_error
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe '.remove_ip_block', vcr: true do
|
|
13
|
+
it 'should remove an IP successfully' do
|
|
14
|
+
expect { client.remove_ip_block(ip) }.to_not raise_error
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Auth0::Api::V2::Roles do
|
|
4
|
+
attr_reader :client, :test_user, :test_role_name, :test_permission, :test_api, :test_role
|
|
5
|
+
|
|
6
|
+
before(:all) do
|
|
7
|
+
@client ||= Auth0::Client.new(v2_creds)
|
|
8
|
+
|
|
9
|
+
@test_user_name = "#{entity_suffix}-username-for-roles"
|
|
10
|
+
@test_user_email = "#{entity_suffix}-#{@test_user_name}@auth0.com"
|
|
11
|
+
|
|
12
|
+
@test_api_name = "#{entity_suffix}-test-api-for-roles"
|
|
13
|
+
@test_api_scope = 'test:scope'
|
|
14
|
+
|
|
15
|
+
@test_role_name = "#{entity_suffix}-test-role"
|
|
16
|
+
|
|
17
|
+
@test_permission = Permission.new("#{entity_suffix}-test-permission", @test_api_name)
|
|
18
|
+
|
|
19
|
+
VCR.use_cassette('Auth0_Api_V2_Roles/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_Roles/create_test_api') do
|
|
29
|
+
@test_api ||= client.create_resource_server(
|
|
30
|
+
@test_api_name,
|
|
31
|
+
name: @test_api_name,
|
|
32
|
+
scopes: [{ value: @test_api_scope }]
|
|
33
|
+
)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
VCR.use_cassette('Auth0_Api_V2_Roles/create_test_role') do
|
|
37
|
+
@test_role ||= client.create_role(
|
|
38
|
+
@test_role_name,
|
|
39
|
+
description: 'Test role description'
|
|
40
|
+
)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
after(:all) do
|
|
45
|
+
VCR.use_cassette('Auth0_Api_V2_Roles/delete_test_user') do
|
|
46
|
+
client.delete_user test_user['user_id']
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
VCR.use_cassette('Auth0_Api_V2_Roles/delete_test_api') do
|
|
50
|
+
client.delete_resource_server test_api['id']
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe '.create_role' do
|
|
55
|
+
it 'should create the Role successfully' do
|
|
56
|
+
expect(test_role).to include('id', 'name', 'description')
|
|
57
|
+
expect(test_role).to include(
|
|
58
|
+
'name' => @test_role_name,
|
|
59
|
+
'description' => 'Test role description'
|
|
60
|
+
)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
describe '.get_role', vcr: true do
|
|
65
|
+
let(:test_get_role) { client.get_role test_role['id'] }
|
|
66
|
+
|
|
67
|
+
it 'should get the Role successfully' do
|
|
68
|
+
expect(test_get_role).to include('id', 'name', 'description')
|
|
69
|
+
expect(test_get_role).to include(
|
|
70
|
+
'id' => test_role['id'],
|
|
71
|
+
'name' => @test_role_name,
|
|
72
|
+
'description' => 'Test role description'
|
|
73
|
+
)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
describe '.get_roles', vcr: true do
|
|
78
|
+
it 'should get the Role successfully' do
|
|
79
|
+
expect(client.get_roles.count).to be >= 1
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
describe '.update_role', vcr: true do
|
|
84
|
+
it 'should update the Role successfully' do
|
|
85
|
+
expect(
|
|
86
|
+
client.update_role(
|
|
87
|
+
test_role['id'],
|
|
88
|
+
name: 'New name',
|
|
89
|
+
description: 'New description'
|
|
90
|
+
)
|
|
91
|
+
).to include(
|
|
92
|
+
'name' => 'New name',
|
|
93
|
+
'description' => 'New description'
|
|
94
|
+
)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
describe '.add_role_users', vcr: true do
|
|
99
|
+
it 'should add a User to the Role successfully' do
|
|
100
|
+
expect { client.add_role_users test_role['id'], [test_user['user_id']] }.to_not raise_error
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
describe '.get_role_users', vcr: true do
|
|
105
|
+
let(:test_get_role_users) { client.get_role_users test_role['id'] }
|
|
106
|
+
|
|
107
|
+
it 'should get exactly 1 User' do
|
|
108
|
+
expect(test_get_role_users.count).to equal 1
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
it 'should get the added User from the Role successfully' do
|
|
112
|
+
expect(test_get_role_users[0]['user_id']).to eq(test_user['user_id'])
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
describe '.add_role_permissions', vcr: true do
|
|
117
|
+
it 'should add a Permission to the Role successfully' do
|
|
118
|
+
expect { client.add_role_permissions test_role['id'], [test_permission] }.to_not raise_error
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
describe '.get_role_permissions', vcr: true do
|
|
123
|
+
let(:test_get_role_permissions) { client.get_role_permissions test_role['id'] }
|
|
124
|
+
|
|
125
|
+
it 'should get exactly 1 Permission' do
|
|
126
|
+
expect(test_get_role_permissions.count).to equal 1
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it 'should get the added Permission from the Role successfully' do
|
|
130
|
+
expect(test_get_role_permissions[0]['permission_name']).to eq("#{entity_suffix}-test-permission")
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
describe '.remove_role_permissions', vcr: true do
|
|
135
|
+
it 'should remove a Permission from the Role successfully' do
|
|
136
|
+
expect { client.remove_role_permissions test_role['id'], [test_permission] }.to_not raise_error
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
describe '.delete_role', vcr: true do
|
|
141
|
+
it 'should delete the Role successfully' do
|
|
142
|
+
expect { client.delete_role test_role['id'] }.to_not raise_error
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
@@ -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
|
|
@@ -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,14 +13,46 @@ describe Auth0::Api::V2::Jobs do
|
|
|
13
13
|
end
|
|
14
14
|
it { expect { @instance.get_job('') }.to raise_error('Must specify a job id') }
|
|
15
15
|
end
|
|
16
|
+
context '.get_job_errors' do
|
|
17
|
+
it { expect(@instance).to respond_to(:get_job_errors) }
|
|
18
|
+
it 'expect client to send get to /api/v2/jobs/3/errors' do
|
|
19
|
+
expect(@instance).to receive(:get).with('/api/v2/jobs/3/errors')
|
|
20
|
+
expect { @instance.get_job_errors(3) }.not_to raise_error
|
|
21
|
+
end
|
|
22
|
+
it { expect { @instance.get_job_errors('') }.to raise_error('Must specify a job id') }
|
|
23
|
+
end
|
|
16
24
|
context '.import_users' do
|
|
17
25
|
it { expect(@instance).to respond_to(:import_users) }
|
|
18
26
|
it 'expect client to send post to /api/v2/jobs/users-imports' do
|
|
19
27
|
expect(@instance).to receive(:post_file).with(
|
|
20
|
-
'/api/v2/jobs/users-imports',
|
|
28
|
+
'/api/v2/jobs/users-imports',
|
|
29
|
+
users: 'file',
|
|
30
|
+
connection_id: 'connnection_id',
|
|
31
|
+
upsert: false,
|
|
32
|
+
external_id: nil,
|
|
33
|
+
send_completion_email: true
|
|
21
34
|
)
|
|
22
35
|
expect { @instance.import_users('file', 'connnection_id') }.not_to raise_error
|
|
23
36
|
end
|
|
37
|
+
it 'expect client to send post to /api/v2/jobs/users-imports with options' do
|
|
38
|
+
expect(@instance).to receive(:post_file).with(
|
|
39
|
+
'/api/v2/jobs/users-imports',
|
|
40
|
+
users: 'file',
|
|
41
|
+
connection_id: 'connnection_id',
|
|
42
|
+
upsert: true,
|
|
43
|
+
external_id: 'external_1',
|
|
44
|
+
send_completion_email: false
|
|
45
|
+
)
|
|
46
|
+
expect do
|
|
47
|
+
@instance.import_users(
|
|
48
|
+
'file',
|
|
49
|
+
'connnection_id',
|
|
50
|
+
upsert: true,
|
|
51
|
+
external_id: 'external_1',
|
|
52
|
+
send_completion_email: false
|
|
53
|
+
)
|
|
54
|
+
end.not_to raise_error
|
|
55
|
+
end
|
|
24
56
|
it { expect { @instance.import_users('', 'connnection_id') }.to raise_error('Must specify a valid file') }
|
|
25
57
|
it { expect { @instance.import_users('users', '') }.to raise_error('Must specify a connection_id') }
|
|
26
58
|
end
|