Skip to content

Commit 94c0780

Browse files
authored
Merge pull request #1 from Zensaburou/update_login
Update login
2 parents 0fd1783 + b579a7d commit 94c0780

8 files changed

+42
-40
lines changed

lib/auth0/api/authentication_endpoints.rb

+10-9
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,17 @@ def login(username, password, id_token = nil, connection_name = UP_AUTH, options
5757
raise Auth0::InvalidParameter, 'Must supply a valid username' if username.to_s.empty?
5858
raise Auth0::InvalidParameter, 'Must supply a valid password' if password.to_s.empty?
5959
request_params = {
60-
client_id: @client_id,
61-
username: username,
62-
password: password,
63-
scope: options.fetch(:scope, 'openid'),
64-
connection: connection_name,
65-
grant_type: options.fetch(:grant_type, password),
66-
id_token: id_token,
67-
device: options.fetch(:device, nil)
60+
client_id: @client_id,
61+
client_secret: @client_secret,
62+
username: username,
63+
password: password,
64+
scope: options.fetch(:scope, 'openid'),
65+
connection: connection_name,
66+
grant_type: options.fetch(:grant_type, password),
67+
id_token: id_token,
68+
device: options.fetch(:device, nil)
6869
}
69-
post('/oauth/ro', request_params)
70+
post('/oauth/token', request_params)
7071
end
7172

7273
# Signup using username/password

spec/integration/lib/auth0/api/api_authentication_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
attr_reader :client, :impersonate_user, :impersonator_user, :global_client, :password
44

55
before(:all) do
6-
@client = Auth0Client.new(v2_creds)
6+
@client = Auth0Client.new(Credentials.v2_creds)
77
impersonate_username = Faker::Internet.user_name
88
impersonate_email = "#{entity_suffix}#{Faker::Internet.safe_email(impersonate_username)}"
99
@password = Faker::Internet.password

spec/lib/auth0/api/authentication_endpoints_spec.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@
5757

5858
context '.login' do
5959
it { expect(@instance).to respond_to(:login) }
60-
it 'is expected to make post to /oauth/ro' do
60+
it 'is expected to make post to /oauth/token' do
6161
expect(@instance).to receive(:post).with(
62-
'/oauth/ro',
63-
client_id: @instance.client_id, username: '[email protected]',
62+
'/oauth/token',
63+
client_id: @instance.client_id,
64+
username: '[email protected]',
65+
client_secret: @instance.client_secret,
6466
password: 'password', scope: 'openid', connection: 'Username-Password-Authentication',
6567
grant_type: 'password', id_token: nil, device: nil
6668
)

spec/spec_helper.rb

+23
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,25 @@
1+
require 'dotenv'
2+
3+
Dotenv.load
4+
15
mode = ENV['MODE'] || 'unit'
6+
7+
$LOAD_PATH.unshift File.expand_path('..', __FILE__)
8+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
9+
10+
require 'rspec'
11+
require 'rack/test'
12+
require 'faker'
13+
require 'auth0'
14+
15+
Dir['./lib/**/*.rb'].each { |f| require f }
16+
Dir['./spec/support/**/*.rb'].each { |f| require f }
17+
Dir['./spec/support/*.rb'].each { |f| require f }
18+
19+
def entity_suffix
20+
(ENV['TRAVIS_JOB_ID'] || 'local').delete('_')
21+
end
22+
23+
puts "Entity suffix is #{entity_suffix}"
24+
225
require_relative "spec_helper_#{mode}"

spec/spec_helper_full.rb

-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
$LOAD_PATH.unshift File.expand_path('..', __FILE__)
2-
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3-
41
require 'coveralls'
52
Coveralls.wear!
63

@@ -10,25 +7,11 @@
107
add_filter '/spec/integration'
118
end
129

13-
require 'rspec'
14-
require 'rack/test'
15-
require 'faker'
16-
require 'auth0'
1710
require 'pry'
1811

19-
Dir['./lib/**/*.rb'].each { |f| require f }
20-
Dir['./spec/support/**/*.rb'].each { |f| require f }
21-
22-
def entity_suffix
23-
(ENV['TRAVIS_JOB_ID'] || 'local').delete('_')
24-
end
25-
26-
puts "Entity suffix is #{entity_suffix}"
27-
2812
RSpec.configure do |config|
2913
config.filter_run focus: true
3014
config.run_all_when_everything_filtered = true
31-
config.include Rack::Test::Methods
3215
config.include Credentials
3316
config.after(:suite) do
3417
puts "Cleaning up for #{entity_suffix}"

spec/spec_helper_unit.rb

-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
$LOAD_PATH.unshift File.expand_path('..', __FILE__)
2-
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3-
require 'rspec'
4-
require 'rack/test'
5-
require 'faker'
6-
require 'auth0'
7-
Dir['./lib/**/*.rb'].each { |f| require f }
8-
Dir['./spec/support/**/*.rb'].each { |f| require f }
91
RSpec.configure do |config|
10-
config.include Rack::Test::Methods
112
config.fail_fast = true
123
end

spec/support/credentials.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
module Credentials
2+
module_function
3+
24
def v1_creds
35
{ client_id: ENV['CLIENT_ID'],
46
client_secret: ENV['CLIENT_SECRET'],

spec/support/dummy_class.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class DummyClass
2-
attr_reader :domain, :client_id
2+
attr_reader :domain, :client_id, :client_secret
33

44
def initialize
55
@domain = 'test.auth0.com'

0 commit comments

Comments
 (0)