Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up auth endpoint tests #120

Merged
merged 1 commit into from
Jul 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/auth0/api/authentication_endpoints.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def wsfed_url(connection = UP_AUTH)

# Build a URL query string from a hash.
def to_query(hash)
hash.map { |k, v| "#{k}=#{URI.escape(v)}" unless v.nil? }.reject(&:nil?).join('&')
hash.map { |k, v| "#{k}=#{CGI.escape(v)}" unless v.nil? }.reject(&:nil?).join('&')
end
end
end
Expand Down
73 changes: 28 additions & 45 deletions spec/integration/lib/auth0/api/api_authentication_spec.rb
Original file line number Diff line number Diff line change
@@ -1,78 +1,61 @@
require 'spec_helper'
describe Auth0::Api::AuthenticationEndpoints do
attr_reader :client, :impersonate_user, :impersonator_user, :global_client, :password
attr_reader :client,
:impersonate_user,
:global_client,
:password

before(:all) do
@client = Auth0Client.new(Credentials.v2_creds)
impersonate_username = Faker::Internet.user_name
impersonate_email = "#{entity_suffix}#{Faker::Internet.safe_email(impersonate_username)}"
@password = Faker::Internet.password
@impersonate_user = client.create_user(impersonate_username, 'email' => impersonate_email,
'password' => password,
'email_verified' => true,
'connection' =>
Auth0::Api::AuthenticationEndpoints::UP_AUTH,
'app_metadata' => {})

impersonator_username = Faker::Internet.user_name
impersonator_email = "#{entity_suffix}#{Faker::Internet.safe_email(impersonator_username)}"
@impersonator_user = client.create_user(impersonator_username, 'email' => impersonator_email,
'password' => password,
'email_verified' => true,
'connection' =>
Auth0::Api::AuthenticationEndpoints::UP_AUTH,
'app_metadata' => {})

@global_client = Auth0Client.new(v1_global_creds)
end

after(:all) do
client.delete_user(impersonate_user['user_id'])
client.delete_user(impersonator_user['user_id'])
impersonate_username = Faker::Internet.user_name
impersonate_email = "#{entity_suffix}" \
"#{Faker::Internet.safe_email(impersonate_username)}"
@password = Faker::Internet.password
@impersonate_user = client.create_user(
impersonate_username,
'email' => impersonate_email,
'password' => password,
'email_verified' => true,
'connection' =>
Auth0::Api::AuthenticationEndpoints::UP_AUTH,
'app_metadata' => {}
)
end

describe '.obtain_access_token' do
let(:acces_token) { global_client.obtain_access_token }
let(:acces_token) { @global_client.obtain_access_token }
it { expect(acces_token).to_not be_nil }
end

describe '.signup' do
let(:signup_username) { Faker::Internet.user_name }
let(:signup_email) { "#{entity_suffix}#{Faker::Internet.safe_email(signup_username)}" }
let(:signup) { global_client.signup(signup_email, password) }
let(:signup_email) {
"#{entity_suffix}#{Faker::Internet.safe_email(signup_username)}"
}
let(:signup) { @global_client.signup(signup_email, @password) }
it { expect(signup).to(include('_id', 'email')) }
it { expect(signup['email']).to eq signup_email }
end

describe '.change_password' do
let(:change_password) do
global_client.change_password(impersonate_user['user_id'], '')
@global_client.change_password(@impersonate_user['user_id'], '')
end
it { expect(change_password).to(include('We\'ve just sent you an email to reset your password.')) }
end

skip '.start_passwordless_email_flow' do
let(:start_passwordless_email_flow) do
global_client.start_passwordless_email_flow(impersonate_user['email'])
it do
expect(@global_client.change_password(@impersonate_user['user_id'], ''))
.to(include('We\'ve just sent you an email to reset your password.'))
end
it { expect(start_passwordless_email_flow['email']).to eq impersonate_user['email'] }
it { expect(start_passwordless_email_flow).to(include('_id', 'email')) }
end

skip '.start_passwordless_sms_flow' do
let(:phone_number) { '+19143686854' }
let(:start_passwordless_sms_flow) { global_client.start_passwordless_sms_flow(phone_number) }
it { expect(start_passwordless_sms_flow['phone_number']).to eq phone_number }
it { expect(start_passwordless_sms_flow).to(include('_id', 'phone_number', 'request_language')) }
end

describe '.saml_metadata' do
let(:saml_metadata) { global_client.saml_metadata }
let(:saml_metadata) { @global_client.saml_metadata }
it { expect(saml_metadata).to(include('<EntityDescriptor')) }
end

describe '.wsfed_metadata' do
let(:wsfed_metadata) { global_client.wsfed_metadata }
let(:wsfed_metadata) { @global_client.wsfed_metadata }
it { expect(wsfed_metadata).to(include('<EntityDescriptor')) }
end
end
Loading