Commit 5f43cae6 authored by Robert Speicher's avatar Robert Speicher

Add :two_factor trait to User factory

parent b050bb5b
......@@ -28,6 +28,13 @@ FactoryGirl.define do
admin true
end
trait :two_factor do
before(:create) do |user|
user.otp_required_for_login = true
user.otp_secret = User.generate_otp_secret
end
end
factory :omniauth_user do
ignore do
extern_uid '123456'
......
require 'spec_helper'
feature 'Login' do
let(:user) { create(:user) }
context 'with two-factor authentication' do
before do
user.otp_required_for_login = true
user.otp_secret = User.generate_otp_secret
user.save!
end
context 'with valid username/password' do
let(:user) { create(:user, :two_factor) }
before do
login_with(user)
expect(page).to have_content('Two-factor Authentication')
......@@ -80,6 +74,8 @@ feature 'Login' do
end
context 'without two-factor authentication' do
let(:user) { create(:user) }
it 'allows basic login' do
login_with(user)
expect(current_path).to eq root_path
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment