2016-02-16 22:55:24 -05:00
|
|
|
FactoryGirl.define do
|
|
|
|
sequence(:name) { FFaker::Name.name }
|
|
|
|
|
2016-04-13 01:39:18 -04:00
|
|
|
factory :user, aliases: [:author, :assignee, :recipient, :owner, :creator, :resource_owner] do
|
2016-02-16 22:55:24 -05:00
|
|
|
email { FFaker::Internet.email }
|
|
|
|
name
|
|
|
|
sequence(:username) { |n| "#{FFaker::Internet.user_name}#{n}" }
|
|
|
|
password "12345678"
|
|
|
|
confirmed_at { Time.now }
|
|
|
|
confirmation_token { nil }
|
|
|
|
can_create_group true
|
|
|
|
|
|
|
|
trait :admin do
|
|
|
|
admin true
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :two_factor do
|
2016-06-06 00:38:42 -04:00
|
|
|
two_factor_via_otp
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :two_factor_via_otp do
|
2016-02-16 22:55:24 -05:00
|
|
|
before(:create) do |user|
|
2016-06-06 00:38:42 -04:00
|
|
|
user.otp_required_for_login = true
|
2016-02-16 22:55:24 -05:00
|
|
|
user.otp_secret = User.generate_otp_secret(32)
|
|
|
|
user.otp_grace_period_started_at = Time.now
|
|
|
|
user.generate_otp_backup_codes!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-06 00:38:42 -04:00
|
|
|
trait :two_factor_via_u2f do
|
|
|
|
transient { registrations_count 5 }
|
|
|
|
|
|
|
|
after(:create) do |user, evaluator|
|
|
|
|
create_list(:u2f_registration, evaluator.registrations_count, user: user)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-02-16 22:55:24 -05:00
|
|
|
factory :omniauth_user do
|
|
|
|
transient do
|
|
|
|
extern_uid '123456'
|
|
|
|
provider 'ldapmain'
|
|
|
|
end
|
|
|
|
|
|
|
|
after(:create) do |user, evaluator|
|
|
|
|
user.identities << create(
|
|
|
|
:identity,
|
|
|
|
provider: evaluator.provider,
|
|
|
|
extern_uid: evaluator.extern_uid
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :admin, traits: [:admin]
|
|
|
|
end
|
|
|
|
end
|