auth0 4.0.0 → 4.1.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/.gitignore +1 -0
- data/.rubocop.yml +2 -1
- data/.rubocop_todo.yml +0 -2
- data/.travis.yml +4 -2
- data/CHANGELOG.md +40 -38
- data/DEPLOYMENT.md +5 -0
- data/Gemfile +1 -1
- data/README.md +20 -2
- data/Rakefile +1 -1
- data/auth0.gemspec +4 -3
- data/doc_config/templates/default/layout/html/footer.erb +1 -1
- data/examples/ruby-api/.gitignore +86 -0
- data/examples/ruby-api/Gemfile +8 -0
- data/examples/ruby-api/README.md +24 -0
- data/examples/ruby-api/config.ru +2 -0
- data/examples/ruby-api/main.rb +33 -0
- data/examples/ruby-on-rails-api/.gitignore +18 -0
- data/examples/ruby-on-rails-api/Gemfile +48 -0
- data/examples/ruby-on-rails-api/README.md +27 -0
- data/examples/ruby-on-rails-api/Rakefile +6 -0
- data/examples/ruby-on-rails-api/app/assets/images/.keep +0 -0
- data/examples/ruby-on-rails-api/app/assets/javascripts/application.js +16 -0
- data/examples/ruby-on-rails-api/app/assets/stylesheets/application.css +15 -0
- data/examples/ruby-on-rails-api/app/controllers/application_controller.rb +8 -0
- data/examples/ruby-on-rails-api/app/controllers/concerns/.keep +0 -0
- data/examples/ruby-on-rails-api/app/controllers/ping_controller.rb +6 -0
- data/examples/ruby-on-rails-api/app/controllers/secured_ping_controller.rb +11 -0
- data/examples/ruby-on-rails-api/app/helpers/application_helper.rb +3 -0
- data/examples/ruby-on-rails-api/app/mailers/.keep +0 -0
- data/examples/ruby-on-rails-api/app/models/.keep +0 -0
- data/examples/ruby-on-rails-api/app/models/concerns/.keep +0 -0
- data/examples/ruby-on-rails-api/app/views/layouts/application.html.erb +14 -0
- data/examples/ruby-on-rails-api/bin/bundle +3 -0
- data/examples/ruby-on-rails-api/bin/rails +4 -0
- data/examples/ruby-on-rails-api/bin/rake +4 -0
- data/examples/ruby-on-rails-api/bin/setup +29 -0
- data/examples/ruby-on-rails-api/config.ru +4 -0
- data/examples/ruby-on-rails-api/config/application.rb +23 -0
- data/examples/ruby-on-rails-api/config/boot.rb +4 -0
- data/examples/ruby-on-rails-api/config/database.yml +27 -0
- data/examples/ruby-on-rails-api/config/environment.rb +5 -0
- data/examples/ruby-on-rails-api/config/environments/development.rb +37 -0
- data/examples/ruby-on-rails-api/config/environments/production.rb +83 -0
- data/examples/ruby-on-rails-api/config/environments/test.rb +41 -0
- data/examples/ruby-on-rails-api/config/initializers/backtrace_silencers.rb +7 -0
- data/examples/ruby-on-rails-api/config/initializers/cookies_serializer.rb +3 -0
- data/examples/ruby-on-rails-api/config/initializers/dotenv.rb +4 -0
- data/examples/ruby-on-rails-api/config/initializers/filter_parameter_logging.rb +4 -0
- data/examples/ruby-on-rails-api/config/initializers/inflections.rb +16 -0
- data/examples/ruby-on-rails-api/config/initializers/knock.rb +53 -0
- data/examples/ruby-on-rails-api/config/initializers/mime_types.rb +4 -0
- data/examples/ruby-on-rails-api/config/initializers/session_store.rb +3 -0
- data/examples/ruby-on-rails-api/config/initializers/wrap_parameters.rb +14 -0
- data/examples/ruby-on-rails-api/config/locales/en.yml +23 -0
- data/examples/ruby-on-rails-api/config/routes.rb +58 -0
- data/examples/ruby-on-rails-api/config/secrets.yml +28 -0
- data/examples/ruby-on-rails-api/db/schema.rb +15 -0
- data/examples/ruby-on-rails-api/db/seeds.rb +7 -0
- data/examples/ruby-on-rails-api/lib/assets/.keep +0 -0
- data/examples/ruby-on-rails-api/lib/tasks/.keep +0 -0
- data/examples/ruby-on-rails-api/log/.keep +0 -0
- data/examples/ruby-on-rails-api/public/404.html +67 -0
- data/examples/ruby-on-rails-api/public/422.html +67 -0
- data/examples/ruby-on-rails-api/public/500.html +66 -0
- data/examples/ruby-on-rails-api/public/favicon.ico +0 -0
- data/examples/ruby-on-rails-api/public/robots.txt +5 -0
- data/examples/ruby-on-rails-api/test/controllers/.keep +0 -0
- data/examples/ruby-on-rails-api/test/fixtures/.keep +0 -0
- data/examples/ruby-on-rails-api/test/helpers/.keep +0 -0
- data/examples/ruby-on-rails-api/test/integration/.keep +0 -0
- data/examples/ruby-on-rails-api/test/mailers/.keep +0 -0
- data/examples/ruby-on-rails-api/test/models/.keep +0 -0
- data/examples/ruby-on-rails-api/test/ping_controller_test.rb +8 -0
- data/examples/ruby-on-rails-api/test/secured_ping_controller_test.rb +26 -0
- data/examples/ruby-on-rails-api/test/test_helper.rb +16 -0
- data/lib/auth0/api/authentication_endpoints.rb +59 -30
- data/lib/auth0/api/v1/clients.rb +1 -1
- data/lib/auth0/api/v1/connections.rb +4 -3
- data/lib/auth0/api/v1/logs.rb +1 -1
- data/lib/auth0/api/v1/rules.rb +1 -1
- data/lib/auth0/api/v1/users.rb +5 -5
- data/lib/auth0/api/v2.rb +10 -0
- data/lib/auth0/api/v2/blacklists.rb +1 -1
- data/lib/auth0/api/v2/client_grants.rb +57 -0
- data/lib/auth0/api/v2/clients.rb +14 -14
- data/lib/auth0/api/v2/connections.rb +19 -20
- data/lib/auth0/api/v2/device_credentials.rb +76 -0
- data/lib/auth0/api/v2/emails.rb +5 -7
- data/lib/auth0/api/v2/jobs.rb +15 -12
- data/lib/auth0/api/v2/logs.rb +65 -0
- data/lib/auth0/api/v2/resource_servers.rb +61 -0
- data/lib/auth0/api/v2/rules.rb +21 -20
- data/lib/auth0/api/v2/stats.rb +2 -2
- data/lib/auth0/api/v2/tenants.rb +6 -4
- data/lib/auth0/api/v2/tickets.rb +13 -14
- data/lib/auth0/api/v2/user_blocks.rb +62 -0
- data/lib/auth0/api/v2/users.rb +63 -32
- data/lib/auth0/client.rb +0 -2
- data/lib/auth0/mixins.rb +4 -3
- data/lib/auth0/mixins/httpproxy.rb +55 -0
- data/lib/auth0/mixins/initializer.rb +27 -10
- data/lib/auth0/version.rb +1 -1
- data/spec/integration/lib/auth0/api/api_authentication_spec.rb +118 -0
- data/spec/integration/lib/auth0/api/v2/api_blacklist_spec.rb +1 -1
- data/spec/integration/lib/auth0/api/v2/api_client_grants_spec.rb +53 -0
- data/spec/integration/lib/auth0/api/v2/api_clients_spec.rb +5 -2
- data/spec/integration/lib/auth0/api/v2/api_connections_spec.rb +8 -5
- data/spec/integration/lib/auth0/api/v2/api_device_credentials_spec.rb +67 -0
- data/spec/integration/lib/auth0/api/v2/api_email_spec.rb +15 -8
- data/spec/integration/lib/auth0/api/v2/api_jobs_spec.rb +11 -9
- data/spec/integration/lib/auth0/api/v2/api_logs_spec.rb +69 -0
- data/spec/integration/lib/auth0/api/v2/api_resource_servers_spec.rb +47 -0
- data/spec/integration/lib/auth0/api/v2/api_rules_spec.rb +2 -1
- data/spec/integration/lib/auth0/api/v2/api_tickets_spec.rb +2 -2
- data/spec/integration/lib/auth0/api/v2/api_user_blocks_spec.rb +73 -0
- data/spec/integration/lib/auth0/api/v2/api_users_spec.rb +32 -5
- data/spec/integration/lib/auth0/auth0_client_spec.rb +14 -11
- data/spec/lib/auth0/api/authentication_endpoints_spec.rb +116 -56
- data/spec/lib/auth0/api/v1/connections_spec.rb +2 -4
- data/spec/lib/auth0/api/v1/rules_spec.rb +2 -1
- data/spec/lib/auth0/api/v1/users_spec.rb +17 -9
- data/spec/lib/auth0/api/v2/client_grants_spec.rb +44 -0
- data/spec/lib/auth0/api/v2/connections_spec.rb +2 -1
- data/spec/lib/auth0/api/v2/device_credentials_spec.rb +73 -0
- data/spec/lib/auth0/api/v2/jobs_spec.rb +3 -2
- data/spec/lib/auth0/api/v2/logs_spec.rb +48 -0
- data/spec/lib/auth0/api/v2/resource_servers_spec.rb +63 -0
- data/spec/lib/auth0/api/v2/rules_spec.rb +8 -4
- data/spec/lib/auth0/api/v2/tenants_spec.rb +2 -1
- data/spec/lib/auth0/api/v2/tickets_spec.rb +4 -7
- data/spec/lib/auth0/api/v2/user_blocks_spec.rb +52 -0
- data/spec/lib/auth0/api/v2/users_spec.rb +39 -6
- data/spec/lib/auth0/client_spec.rb +8 -5
- data/spec/lib/auth0/mixins/httpproxy_spec.rb +225 -0
- data/spec/lib/auth0/mixins/initializer_spec.rb +1 -1
- data/spec/spec_helper_full.rb +12 -3
- data/spec/spec_helper_unit.rb +2 -2
- data/spec/support/credentials.rb +6 -4
- data/spec/support/dummy_class.rb +2 -1
- data/spec/support/dummy_class_for_proxy.rb +2 -2
- data/spec/support/dummy_class_for_restclient.rb +2 -0
- metadata +117 -9
- data/lib/auth0/mixins/httparty_proxy.rb +0 -38
- data/spec/lib/auth0/mixins/httparty_proxy_spec.rb +0 -148
|
@@ -9,8 +9,9 @@ module Auth0
|
|
|
9
9
|
# By Default API v2
|
|
10
10
|
def initialize(config)
|
|
11
11
|
options = Hash[config.map { |(k, v)| [k.to_sym, v] }]
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
@base_uri = base_url(options)
|
|
13
|
+
@headers = client_headers(config)
|
|
14
|
+
@timeout = options[:timeout] || 10
|
|
14
15
|
extend Auth0::Api::AuthenticationEndpoints
|
|
15
16
|
@client_id = options[:client_id]
|
|
16
17
|
initialize_api(options)
|
|
@@ -21,17 +22,32 @@ module Auth0
|
|
|
21
22
|
klass.send :prepend, Initializer
|
|
22
23
|
end
|
|
23
24
|
|
|
25
|
+
def authorization_header(token)
|
|
26
|
+
add_headers('Authorization' => "Bearer #{token}")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def authorization_header_basic(options)
|
|
30
|
+
connection_id = options.fetch(:connection_id, Auth0::Api::AuthenticationEndpoints::UP_AUTH)
|
|
31
|
+
user = options.fetch(:user, nil)
|
|
32
|
+
password = options.fetch(:password, nil)
|
|
33
|
+
add_headers('Authorization' => "Basic #{Base64.strict_encode64("#{connection_id}\\#{user}:#{password}")}")
|
|
34
|
+
end
|
|
35
|
+
|
|
24
36
|
private
|
|
25
37
|
|
|
26
38
|
def initialize_api(options)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
api_v2?(options) ? initialize_v2(options) : initialize_v1(options)
|
|
40
|
+
raise InvalidCredentials, 'Must supply a valid API token' if @token.nil?
|
|
41
|
+
if options.fetch(:authorization, nil) == 'Basic'
|
|
42
|
+
authorization_header_basic(options)
|
|
43
|
+
else
|
|
44
|
+
authorization_header(@token)
|
|
45
|
+
end
|
|
30
46
|
end
|
|
31
47
|
|
|
32
48
|
def base_url(options)
|
|
33
49
|
@domain = options[:domain] || options[:namespace]
|
|
34
|
-
|
|
50
|
+
raise InvalidApiNamespace, 'Api namespace must supply an API domain' if @domain.to_s.empty?
|
|
35
51
|
"https://#{@domain}"
|
|
36
52
|
end
|
|
37
53
|
|
|
@@ -52,20 +68,21 @@ module Auth0
|
|
|
52
68
|
|
|
53
69
|
def initialize_v2(options)
|
|
54
70
|
extend Auth0::Api::V2
|
|
71
|
+
@client_secret = options[:client_secret]
|
|
55
72
|
@token = options[:access_token] || options[:token]
|
|
56
73
|
end
|
|
57
74
|
|
|
58
75
|
def initialize_v1(options)
|
|
59
76
|
extend Auth0::Api::V1
|
|
60
77
|
@client_secret = options[:client_secret]
|
|
61
|
-
|
|
78
|
+
raise InvalidCredentials, 'Invalid API v1 client_id and client_secret' if @client_id.nil? || @client_secret.nil?
|
|
62
79
|
@token = obtain_access_token
|
|
63
80
|
end
|
|
64
81
|
|
|
65
|
-
def
|
|
66
|
-
version = options[:api_version] ||
|
|
82
|
+
def api_v2?(options)
|
|
83
|
+
version = options[:api_version] || 2
|
|
67
84
|
protocol = options[:protocols].to_s
|
|
68
|
-
!protocol.include?('
|
|
85
|
+
!protocol.include?('v1') && (protocol.include?('v2') || version == 2)
|
|
69
86
|
end
|
|
70
87
|
end
|
|
71
88
|
end
|
data/lib/auth0/version.rb
CHANGED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
describe Auth0::Api::AuthenticationEndpoints do
|
|
3
|
+
attr_reader :client, :impersonate_user, :impersonator_user, :global_client, :password
|
|
4
|
+
|
|
5
|
+
before(:all) do
|
|
6
|
+
@client = Auth0Client.new(v2_creds)
|
|
7
|
+
impersonate_username = Faker::Internet.user_name
|
|
8
|
+
impersonate_email = "#{entity_suffix}#{Faker::Internet.safe_email(impersonate_username)}"
|
|
9
|
+
@password = Faker::Internet.password
|
|
10
|
+
@impersonate_user = client.create_user(impersonate_username, 'email' => impersonate_email,
|
|
11
|
+
'password' => password,
|
|
12
|
+
'email_verified' => true,
|
|
13
|
+
'connection' =>
|
|
14
|
+
Auth0::Api::AuthenticationEndpoints::UP_AUTH,
|
|
15
|
+
'app_metadata' => {})
|
|
16
|
+
|
|
17
|
+
impersonator_username = Faker::Internet.user_name
|
|
18
|
+
impersonator_email = "#{entity_suffix}#{Faker::Internet.safe_email(impersonator_username)}"
|
|
19
|
+
@impersonator_user = client.create_user(impersonator_username, 'email' => impersonator_email,
|
|
20
|
+
'password' => password,
|
|
21
|
+
'email_verified' => true,
|
|
22
|
+
'connection' =>
|
|
23
|
+
Auth0::Api::AuthenticationEndpoints::UP_AUTH,
|
|
24
|
+
'app_metadata' => {})
|
|
25
|
+
|
|
26
|
+
@global_client = Auth0Client.new(v1_global_creds)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
after(:all) do
|
|
30
|
+
client.delete_user(impersonate_user['user_id'])
|
|
31
|
+
client.delete_user(impersonator_user['user_id'])
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe '.obtain_access_token' do
|
|
35
|
+
let(:acces_token) { global_client.obtain_access_token }
|
|
36
|
+
it { expect(acces_token).to_not be_nil }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe '.login' do
|
|
40
|
+
let(:login) { global_client.login(impersonate_user['email'], password) }
|
|
41
|
+
it { expect(login).to(include('id_token', 'access_token', 'token_type')) }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe '.signup' do
|
|
45
|
+
let(:signup_username) { Faker::Internet.user_name }
|
|
46
|
+
let(:signup_email) { "#{entity_suffix}#{Faker::Internet.safe_email(signup_username)}" }
|
|
47
|
+
let(:signup) { global_client.signup(signup_email, password) }
|
|
48
|
+
it { expect(signup).to(include('_id', 'email')) }
|
|
49
|
+
it { expect(signup['email']).to eq signup_email }
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe '.change_password' do
|
|
53
|
+
let(:change_password) do
|
|
54
|
+
global_client.change_password(impersonate_user['user_id'], password)
|
|
55
|
+
end
|
|
56
|
+
it { expect(change_password).to eq '"We\'ve just sent you an email to reset your password."' }
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
skip '.start_passwordless_email_flow' do
|
|
60
|
+
let(:start_passwordless_email_flow) do
|
|
61
|
+
global_client.start_passwordless_email_flow(impersonate_user['email'])
|
|
62
|
+
end
|
|
63
|
+
it { expect(start_passwordless_email_flow['email']).to eq impersonate_user['email'] }
|
|
64
|
+
it { expect(start_passwordless_email_flow).to(include('_id', 'email')) }
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
skip '.start_passwordless_sms_flow' do
|
|
68
|
+
let(:phone_number) { '+19143686854' }
|
|
69
|
+
let(:start_passwordless_sms_flow) { global_client.start_passwordless_sms_flow(phone_number) }
|
|
70
|
+
it { expect(start_passwordless_sms_flow['phone_number']).to eq phone_number }
|
|
71
|
+
it { expect(start_passwordless_sms_flow).to(include('_id', 'phone_number', 'request_language')) }
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
describe '.saml_metadata' do
|
|
75
|
+
let(:saml_metadata) { global_client.saml_metadata }
|
|
76
|
+
it { expect(saml_metadata).to(include('<EntityDescriptor')) }
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
describe '.wsfed_metadata' do
|
|
80
|
+
let(:wsfed_metadata) { global_client.wsfed_metadata }
|
|
81
|
+
it { expect(wsfed_metadata).to(include('<EntityDescriptor')) }
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
describe '.token_info' do
|
|
85
|
+
let(:id_token) { global_client.login(impersonate_user['email'], password)['id_token'] }
|
|
86
|
+
let(:token_info) { global_client.token_info(id_token) }
|
|
87
|
+
it { expect(token_info).to(include('email', 'clientID', 'global_client_id')) }
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
describe '.delegation' do
|
|
91
|
+
let(:id_token) { global_client.login(impersonate_user['email'], password)['id_token'] }
|
|
92
|
+
let(:target) { global_client.clients[0]['clientID'] }
|
|
93
|
+
let(:delegation) { global_client.delegation(id_token, target) }
|
|
94
|
+
it { expect(delegation).to(include('token_type', 'expires_in', 'id_token')) }
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
describe '.impersonation' do
|
|
98
|
+
let(:impersonate_url) do
|
|
99
|
+
global_client.impersonate(impersonate_user['user_id'], ENV['CLIENT_ID'], impersonator_user['user_id'], {})
|
|
100
|
+
end
|
|
101
|
+
it { expect(impersonate_url).to_not be_nil }
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
describe '.unlink_user' do
|
|
105
|
+
let(:access_token) { global_client.login(impersonate_user['email'], password)['access_token'] }
|
|
106
|
+
let(:unlink_user) { global_client.unlink_user(access_token, impersonator_user['user_id']) }
|
|
107
|
+
it { expect(unlink_user).to eq 'OK' }
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
describe '.user_info' do
|
|
111
|
+
let(:access_token) { global_client.login(impersonate_user['email'], password)['access_token'] }
|
|
112
|
+
let(:credentials) { { client_id: ENV['CLIENT_ID'], token: access_token, domain: ENV['DOMAIN'] } }
|
|
113
|
+
let(:client) { Auth0Client.new(credentials) }
|
|
114
|
+
let(:user_info) { client.user_info }
|
|
115
|
+
it { expect(user_info['email']).to eq impersonate_user['email'] }
|
|
116
|
+
it { expect(user_info).to(include('clientID', 'identities', 'nickname', 'picture')) }
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -4,7 +4,7 @@ describe Auth0::Api::V2::Blacklists do
|
|
|
4
4
|
let(:token) { 'faketoken' }
|
|
5
5
|
|
|
6
6
|
describe '.add_token_to_blacklist' do
|
|
7
|
-
it { expect(client.add_token_to_blacklist(token)).to
|
|
7
|
+
it { expect(client.add_token_to_blacklist(token)).to be_empty }
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
describe '.blacklisted_tokens' do
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
describe Auth0::Api::V2::ClientGrants do
|
|
3
|
+
attr_reader :client, :client_id, :audience, :existing_grant, :scope
|
|
4
|
+
|
|
5
|
+
before(:all) do
|
|
6
|
+
@client = Auth0Client.new(v2_creds)
|
|
7
|
+
@client_id = Faker::Lorem.word
|
|
8
|
+
@audience = Faker::Internet.url
|
|
9
|
+
@scope = [Faker::Lorem.word]
|
|
10
|
+
@existing_grant = client.create_client_grant('client_id' => client_id, 'audience' => audience, 'scope' => scope)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
after(:all) do
|
|
14
|
+
grants = client.client_grants
|
|
15
|
+
grants.each do |grant|
|
|
16
|
+
client.delete_client_grant(grant['id'])
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe '.client_grants' do
|
|
21
|
+
let(:client_grants) { client.client_grants }
|
|
22
|
+
|
|
23
|
+
it { expect(client_grants.size).to be > 0 }
|
|
24
|
+
it { expect(client_grants).to include(existing_grant) }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe '.create_client_grant' do
|
|
28
|
+
let(:new_client) { Faker::Lorem.word }
|
|
29
|
+
|
|
30
|
+
it do
|
|
31
|
+
expect(
|
|
32
|
+
client.create_client_grant('client_id' => new_client, 'audience' => audience,
|
|
33
|
+
'scope' => scope)
|
|
34
|
+
).to(include('client_id' => new_client, 'audience' => audience, 'scope' => scope))
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe '.patch_client_grant' do
|
|
39
|
+
let(:new_scope) { [Faker::Lorem.word] }
|
|
40
|
+
it do
|
|
41
|
+
expect(
|
|
42
|
+
client.patch_client_grant(
|
|
43
|
+
existing_grant['id'],
|
|
44
|
+
'scope' => new_scope
|
|
45
|
+
)
|
|
46
|
+
).to(include('scope' => new_scope))
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe '.delete_client_grant' do
|
|
51
|
+
it { expect { client.delete_client_grant(existing_grant['id']) }.to_not raise_error }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -50,7 +50,8 @@ describe Auth0::Api::V2::Clients do
|
|
|
50
50
|
describe '.create_client' do
|
|
51
51
|
it do
|
|
52
52
|
expect(client.create_client(client_name, custom_login_page_on: false)).to(
|
|
53
|
-
include('name' => client_name, 'custom_login_page_on' => false)
|
|
53
|
+
include('name' => client_name, 'custom_login_page_on' => false)
|
|
54
|
+
)
|
|
54
55
|
end
|
|
55
56
|
it { expect { client.create_client('', custom_login_page_on: false) }.to raise_error(Auth0::MissingParameter) }
|
|
56
57
|
end
|
|
@@ -61,7 +62,9 @@ describe Auth0::Api::V2::Clients do
|
|
|
61
62
|
client.patch_client(
|
|
62
63
|
existing_client['client_id'],
|
|
63
64
|
custom_login_page_on: false,
|
|
64
|
-
sso: true
|
|
65
|
+
sso: true
|
|
66
|
+
)
|
|
67
|
+
).to(include('custom_login_page_on' => false, 'sso' => true))
|
|
65
68
|
end
|
|
66
69
|
it { expect { client.patch_client('', custom_login_page_on: false) }.to raise_error(Auth0::MissingClientId) }
|
|
67
70
|
end
|
|
@@ -18,14 +18,15 @@ describe Auth0::Api::V2::Connections do
|
|
|
18
18
|
let(:connections) { client.connections }
|
|
19
19
|
|
|
20
20
|
it { expect(connections.size).to be > 0 }
|
|
21
|
-
it { expect(connections.find { |con| con['name'] == name }).to_not
|
|
21
|
+
it { expect(connections.find { |con| con['name'] == name }).to_not be_empty }
|
|
22
22
|
|
|
23
23
|
context '#filters' do
|
|
24
24
|
it { expect(client.connections(strategy: strategy).size).to be > 0 }
|
|
25
25
|
it { expect(client.connections(strategy: strategy, fields: [:name].join(',')).first).to include('name') }
|
|
26
26
|
it do
|
|
27
27
|
expect(client.connections(strategy: strategy, fields: [:name].join(','), include_fields: false).first).to_not(
|
|
28
|
-
include('name')
|
|
28
|
+
include('name')
|
|
29
|
+
)
|
|
29
30
|
end
|
|
30
31
|
end
|
|
31
32
|
end
|
|
@@ -39,7 +40,8 @@ describe Auth0::Api::V2::Connections do
|
|
|
39
40
|
it { expect(client.connection(connection['id'], fields: [:name, :id].join(','))).to include('id', 'name') }
|
|
40
41
|
it do
|
|
41
42
|
expect(client.connection(connection['id'], fields: [:name, :id].join(','), include_fields: false)).to_not(
|
|
42
|
-
include('id', 'name')
|
|
43
|
+
include('id', 'name')
|
|
44
|
+
)
|
|
43
45
|
end
|
|
44
46
|
end
|
|
45
47
|
end
|
|
@@ -66,7 +68,8 @@ describe Auth0::Api::V2::Connections do
|
|
|
66
68
|
let(:options) { { username: new_name } }
|
|
67
69
|
it do
|
|
68
70
|
expect(client.update_connection(connection_to_update['id'], 'options' => options)['options']).to include(
|
|
69
|
-
'username' => new_name
|
|
71
|
+
'username' => new_name
|
|
72
|
+
)
|
|
70
73
|
end
|
|
71
74
|
end
|
|
72
75
|
|
|
@@ -85,7 +88,7 @@ describe Auth0::Api::V2::Connections do
|
|
|
85
88
|
client.connections.find { |connection| connection['name'] == Auth0::Api::AuthenticationEndpoints::UP_AUTH }
|
|
86
89
|
end
|
|
87
90
|
|
|
88
|
-
it { expect(client.delete_connection_user(connection['id'], email)).to
|
|
91
|
+
it { expect(client.delete_connection_user(connection['id'], email)).to be_empty }
|
|
89
92
|
end
|
|
90
93
|
|
|
91
94
|
after(:all) do
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'base64'
|
|
3
|
+
describe Auth0::Api::V2::DeviceCredentials do
|
|
4
|
+
attr_reader :user, :client, :basic_client, :existing_device_credentials
|
|
5
|
+
|
|
6
|
+
before(:all) do
|
|
7
|
+
@client = Auth0Client.new(v2_creds)
|
|
8
|
+
username = Faker::Internet.user_name
|
|
9
|
+
email = "#{entity_suffix}#{Faker::Internet.safe_email(username)}"
|
|
10
|
+
password = Faker::Internet.password
|
|
11
|
+
@user = client.create_user(username, 'email' => email,
|
|
12
|
+
'password' => password,
|
|
13
|
+
'email_verified' => true,
|
|
14
|
+
'connection' => Auth0::Api::AuthenticationEndpoints::UP_AUTH,
|
|
15
|
+
'app_metadata' => {})
|
|
16
|
+
|
|
17
|
+
basic_creds = { connection_id: Auth0::Api::AuthenticationEndpoints::UP_AUTH,
|
|
18
|
+
user: email,
|
|
19
|
+
password: password,
|
|
20
|
+
authorization: 'Basic' }
|
|
21
|
+
|
|
22
|
+
@basic_client = Auth0Client.new(v2_creds.merge(basic_creds))
|
|
23
|
+
@existing_device_credentials = basic_client.create_device_credential(
|
|
24
|
+
"#{user['name']}_phone_1",
|
|
25
|
+
'dmFsdWU=',
|
|
26
|
+
'68753A44-4D6F-1226-9C60-0050E4C00067',
|
|
27
|
+
ENV['CLIENT_ID']
|
|
28
|
+
)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
after(:all) do
|
|
32
|
+
client.delete_user(user['user_id'])
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe '.device_credentials' do
|
|
36
|
+
let(:device_credentials) { basic_client.device_credentials(ENV['CLIENT_ID']) }
|
|
37
|
+
it { expect(device_credentials.size).to be > 0 }
|
|
38
|
+
it { expect(device_credentials.find { |cred| cred['id'] == existing_device_credentials['id'] }).to_not be_empty }
|
|
39
|
+
context '#filter_by_type' do
|
|
40
|
+
let(:filtered_device_credentials) { basic_client.device_credentials(ENV['CLIENT_ID'], type: 'refresh_token') }
|
|
41
|
+
it do
|
|
42
|
+
expect(filtered_device_credentials.find do |cred|
|
|
43
|
+
cred['id'] == existing_device_credentials['id']
|
|
44
|
+
end).to eq nil
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe '.create_device_credential' do
|
|
50
|
+
let!(:new_credentials) do
|
|
51
|
+
basic_client.create_device_credential(
|
|
52
|
+
"#{user['name']}_phone_2",
|
|
53
|
+
'dmFsdWU=',
|
|
54
|
+
'68753A44-4D6F-1226-9C60-0050E4C00067',
|
|
55
|
+
ENV['CLIENT_ID']
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
it do
|
|
59
|
+
expect(basic_client.device_credentials(ENV['CLIENT_ID'])
|
|
60
|
+
.find { |cred| cred['id'] == new_credentials['id'] }).to_not be_empty
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
describe '.delete_device_credential' do
|
|
65
|
+
it { expect { basic_client.delete_device_credential(existing_device_credentials['id']) }.to_not raise_error }
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -13,7 +13,7 @@ describe Auth0::Api::V2::Emails do
|
|
|
13
13
|
let(:name) { 'mandrill' }
|
|
14
14
|
let(:enabled) { true }
|
|
15
15
|
let(:credentials) { { 'api_key' => 'api_key' } }
|
|
16
|
-
let(:settings) { { 'first_setting' =>
|
|
16
|
+
let(:settings) { { 'first_setting' => 'first_setting_set', 'second_setting' => 'second_setting_set' } }
|
|
17
17
|
let(:body) do
|
|
18
18
|
{ 'name' => name,
|
|
19
19
|
'enabled' => enabled,
|
|
@@ -25,7 +25,8 @@ describe Auth0::Api::V2::Emails do
|
|
|
25
25
|
let!(:email_provider) { client.configure_provider(body) }
|
|
26
26
|
it do
|
|
27
27
|
expect(email_provider).to include(
|
|
28
|
-
'name' => name, 'enabled' => enabled, 'credentials' => credentials, 'settings' => settings
|
|
28
|
+
'name' => name, 'enabled' => enabled, 'credentials' => credentials, 'settings' => settings
|
|
29
|
+
)
|
|
29
30
|
end
|
|
30
31
|
end
|
|
31
32
|
|
|
@@ -37,12 +38,15 @@ describe Auth0::Api::V2::Emails do
|
|
|
37
38
|
context '#filters' do
|
|
38
39
|
it do
|
|
39
40
|
expect(
|
|
40
|
-
client.get_provider(fields: [:name, :enabled, :credentials].join(','), include_fields: true)
|
|
41
|
-
|
|
41
|
+
client.get_provider(fields: [:name, :enabled, :credentials].join(','), include_fields: true)
|
|
42
|
+
).to(
|
|
43
|
+
include('name', 'enabled', 'credentials')
|
|
44
|
+
)
|
|
42
45
|
end
|
|
43
46
|
it do
|
|
44
47
|
expect(
|
|
45
|
-
client.get_provider(fields: [:enabled].join(','), include_fields: false).first
|
|
48
|
+
client.get_provider(fields: [:enabled].join(','), include_fields: false).first
|
|
49
|
+
).to_not(include('enabled'))
|
|
46
50
|
end
|
|
47
51
|
end
|
|
48
52
|
end
|
|
@@ -58,9 +62,12 @@ describe Auth0::Api::V2::Emails do
|
|
|
58
62
|
end
|
|
59
63
|
it do
|
|
60
64
|
expect(
|
|
61
|
-
client.update_provider(update_body)
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
client.update_provider(update_body)
|
|
66
|
+
).to(
|
|
67
|
+
include(
|
|
68
|
+
'name' => update_name, 'enabled' => enabled, 'credentials' => credentials, 'settings' => update_settings
|
|
69
|
+
)
|
|
70
|
+
)
|
|
64
71
|
end
|
|
65
72
|
end
|
|
66
73
|
|