From f3b8db6fd849908f30fdf4fed411126643f223a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Mon, 7 May 2018 15:20:52 +0200 Subject: [PATCH] FactoryGirl => FactoryBot (opf/openproject#6304) --- .../authentication_controller_spec.rb | 12 ++++++------ .../two_factor_devices_controller_spec.rb | 8 ++++---- .../my/remember_cookie_controller.rb | 2 +- .../my/two_factor_devices_controller_spec.rb | 18 +++++++++--------- .../two_factor_devices_controller_spec.rb | 12 ++++++------ ...two_factor_authentication_device_factory.rb | 4 ++-- spec/features/account_activation_spec.rb | 4 ++-- .../admin_edit_two_factor_devices_spec.rb | 8 ++++---- .../backup_codes/generate_backup_codes.rb | 2 +- .../login_with_backup_code_spec.rb | 4 ++-- spec/features/login/login_enforced_2fa_spec.rb | 4 ++-- spec/features/login/login_with_2fa_spec.rb | 4 ++-- spec/features/login/login_without_2fa_spec.rb | 4 ++-- .../login/switch_available_devices_spec.rb | 6 +++--- spec/features/my_two_factor_devices_spec.rb | 2 +- spec/features/password_change_spec.rb | 8 ++++---- .../login_with_remember_cookie_spec.rb | 4 ++-- spec/lib/token_strategies/message_bird_spec.rb | 4 ++-- spec/models/devices/default_device_spec.rb | 12 ++++++------ spec/models/devices/totp_spec.rb | 2 +- spec/models/user_spec.rb | 2 +- .../token_delivery/message_bird_spec.rb | 4 ++-- spec/services/token_delivery/restdt_spec.rb | 6 +++--- spec/services/token_delivery/sns_spec.rb | 4 ++-- spec/services/token_delivery/totp_spec.rb | 4 ++-- spec/services/token_service_spec.rb | 10 +++++----- 26 files changed, 77 insertions(+), 77 deletions(-) diff --git a/spec/controllers/two_factor_authentication/authentication_controller_spec.rb b/spec/controllers/two_factor_authentication/authentication_controller_spec.rb index 2b57abc..406c39a 100644 --- a/spec/controllers/two_factor_authentication/authentication_controller_spec.rb +++ b/spec/controllers/two_factor_authentication/authentication_controller_spec.rb @@ -5,7 +5,7 @@ let(:valid_credentials) do { username: 'foobar', password: 'AAA1111!!!!' } end - let(:user) { FactoryGirl.create(:user, login: 'foobar', password: 'AAA1111!!!!', password_confirmation: 'AAA1111!!!!') } + let(:user) { FactoryBot.create(:user, login: 'foobar', password: 'AAA1111!!!!', password_confirmation: 'AAA1111!!!!') } before do # Assume the user has any memberships @@ -59,7 +59,7 @@ end context 'with a non-default device' do - let!(:device) { FactoryGirl.create :two_factor_authentication_device_sms, user: user, default: false, channel: :sms } + let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, default: false, channel: :sms } before do session[:authenticated_user_id] = user.id @@ -71,24 +71,24 @@ end context 'with an invalid device' do - let!(:device) { FactoryGirl.create :two_factor_authentication_device_totp, user: user, channel: :totp } + let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, channel: :totp } it_behaves_like '2FA login request failure', I18n.t('two_factor_authentication.error_no_matching_strategy') end context 'with an active device' do - let!(:device) { FactoryGirl.create :two_factor_authentication_device_sms, user: user, channel: :sms } + let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, channel: :sms } it_behaves_like '2FA SMS request success' end end describe 'with two active strategy', with_config: { '2fa' => { active_strategies: [:developer, :totp] } } do context 'with a totp device' do - let!(:device) { FactoryGirl.create :two_factor_authentication_device_totp, user: user, channel: :totp } + let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, channel: :totp } it_behaves_like '2FA TOTP request success' end context 'with an sms device' do - let!(:device) { FactoryGirl.create :two_factor_authentication_device_sms, user: user, channel: :sms } + let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, channel: :sms } it_behaves_like '2FA SMS request success' end end diff --git a/spec/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller_spec.rb b/spec/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller_spec.rb index 1c6a1d3..aac91b4 100644 --- a/spec/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller_spec.rb +++ b/spec/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller_spec.rb @@ -2,7 +2,7 @@ require_relative './../authentication_controller_shared_examples' describe ::TwoFactorAuthentication::ForcedRegistration::TwoFactorDevicesController, with_2fa_ee: true do - let(:user) { FactoryGirl.create(:user, login: 'foobar') } + let(:user) { FactoryBot.create(:user, login: 'foobar') } let(:logged_in_user) { User.anonymous } let(:active_strategies) { [] } let(:config) { {} } @@ -134,7 +134,7 @@ describe 'and registered totp device' do let(:active_strategies) { [:totp] } - let!(:device) { FactoryGirl.create :two_factor_authentication_device_totp, user: user, active: false, default: false} + let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, active: false, default: false} it 'renders the confirmation page' do get :confirm, params: { device_id: device.id } @@ -145,7 +145,7 @@ end describe 'with registered device' do - let!(:device) { FactoryGirl.create :two_factor_authentication_device_sms, user: user, active: false, default: false} + let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: false, default: false} it 'renders the confirmation page' do get :confirm, params: { device_id: device.id } @@ -173,7 +173,7 @@ describe 'and registered totp device' do let(:active_strategies) { [:totp] } - let!(:device) { FactoryGirl.create :two_factor_authentication_device_totp, user: user, active: false, default: false} + let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, active: false, default: false} it 'renders a 400 on missing token' do post :confirm, params: { device_id: device.id } diff --git a/spec/controllers/two_factor_authentication/my/remember_cookie_controller.rb b/spec/controllers/two_factor_authentication/my/remember_cookie_controller.rb index 4507fc0..86e455c 100644 --- a/spec/controllers/two_factor_authentication/my/remember_cookie_controller.rb +++ b/spec/controllers/two_factor_authentication/my/remember_cookie_controller.rb @@ -2,7 +2,7 @@ require_relative './../authentication_controller_shared_examples' describe ::TwoFactorAuthentication::My::RememberCookieController do - let(:user) { FactoryGirl.create(:user, login: 'foobar') } + let(:user) { FactoryBot.create(:user, login: 'foobar') } let(:logged_in_user) { user } before do diff --git a/spec/controllers/two_factor_authentication/my/two_factor_devices_controller_spec.rb b/spec/controllers/two_factor_authentication/my/two_factor_devices_controller_spec.rb index c706b8b..1b656e6 100644 --- a/spec/controllers/two_factor_authentication/my/two_factor_devices_controller_spec.rb +++ b/spec/controllers/two_factor_authentication/my/two_factor_devices_controller_spec.rb @@ -2,8 +2,8 @@ require_relative './../authentication_controller_shared_examples' describe ::TwoFactorAuthentication::My::TwoFactorDevicesController, with_2fa_ee: true do - let(:user) { FactoryGirl.create(:user, login: 'foobar') } - let(:other_user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user, login: 'foobar') } + let(:other_user) { FactoryBot.create(:user) } let(:logged_in_user) { user } let(:active_strategies) { [] } let(:config) { {} } @@ -115,7 +115,7 @@ describe 'and registered totp device' do let(:active_strategies) { [:totp] } - let!(:device) { FactoryGirl.create :two_factor_authentication_device_totp, user: user, active: false, default: false} + let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, active: false, default: false} it 'renders the confirmation page' do get :confirm, params: { device_id: device.id } @@ -126,7 +126,7 @@ end describe 'with registered device' do - let!(:device) { FactoryGirl.create :two_factor_authentication_device_sms, user: user, active: false, default: false} + let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: false, default: false} it 'renders the confirmation page' do get :confirm, params: { device_id: device.id } @@ -154,7 +154,7 @@ describe 'and registered totp device' do let(:active_strategies) { [:totp] } - let!(:device) { FactoryGirl.create :two_factor_authentication_device_totp, user: user, active: false, default: false} + let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, active: false, default: false} it 'renders a 400 on missing token' do post :confirm, params: { device_id: device.id } @@ -187,7 +187,7 @@ end context 'with another default device present' do - let!(:default_device) { FactoryGirl.create :two_factor_authentication_device_totp, user: user, default: true} + let!(:default_device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: true} it 'activates the device when entered correctly' do allow_any_instance_of(::TwoFactorAuthentication::TokenService) @@ -220,7 +220,7 @@ end context 'with existing non-default device' do - let!(:device) { FactoryGirl.create :two_factor_authentication_device_totp, user: user, default: false} + let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: false} it 'deletes it' do delete :destroy, params: { device_id: device.id } @@ -230,7 +230,7 @@ end context 'with existing default device' do - let!(:device) { FactoryGirl.create :two_factor_authentication_device_totp, user: user, default: true} + let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: true} it 'deletes it' do delete :destroy, params: { device_id: device.id } @@ -240,7 +240,7 @@ end context 'with existing default device AND enforced' do - let!(:device) { FactoryGirl.create :two_factor_authentication_device_totp, user: user, default: true} + let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: true} let(:config) { { enforced: true } } it 'cannot be deleted' do diff --git a/spec/controllers/two_factor_authentication/users/two_factor_devices_controller_spec.rb b/spec/controllers/two_factor_authentication/users/two_factor_devices_controller_spec.rb index 9e3c73d..4e56c5c 100644 --- a/spec/controllers/two_factor_authentication/users/two_factor_devices_controller_spec.rb +++ b/spec/controllers/two_factor_authentication/users/two_factor_devices_controller_spec.rb @@ -2,9 +2,9 @@ require_relative './../authentication_controller_shared_examples' describe ::TwoFactorAuthentication::Users::TwoFactorDevicesController, with_2fa_ee: true do - let(:admin) { FactoryGirl.create :admin } - let(:user) { FactoryGirl.create(:user, login: 'foobar') } - let(:other_user) { FactoryGirl.create(:user) } + let(:admin) { FactoryBot.create :admin } + let(:user) { FactoryBot.create(:user, login: 'foobar') } + let(:other_user) { FactoryBot.create(:user) } let(:logged_in_user) { admin } let(:active_strategies) { [:developer] } let(:config) { {} } @@ -123,7 +123,7 @@ end context 'with existing non-default device' do - let!(:device) { FactoryGirl.create :two_factor_authentication_device_totp, user: user, default: false} + let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: false} it 'deletes it' do delete :destroy, params: { id: user.id, device_id: device.id } @@ -133,7 +133,7 @@ end context 'with existing default device' do - let!(:device) { FactoryGirl.create :two_factor_authentication_device_totp, user: user, default: true} + let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: true} it 'deletes it' do delete :destroy, params: { id: user.id, device_id: device.id } @@ -143,7 +143,7 @@ end context 'with existing default device AND enforced' do - let!(:device) { FactoryGirl.create :two_factor_authentication_device_totp, user: user, default: true} + let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: true} let(:config) { { enforced: true } } it 'cannot be deleted' do diff --git a/spec/factories/two_factor_authentication_device_factory.rb b/spec/factories/two_factor_authentication_device_factory.rb index 682e690..efce362 100644 --- a/spec/factories/two_factor_authentication_device_factory.rb +++ b/spec/factories/two_factor_authentication_device_factory.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :two_factor_authentication_device_sms, class: ::TwoFactorAuthentication::Device::Sms do user channel :sms @@ -17,7 +17,7 @@ end end -FactoryGirl.define do +FactoryBot.define do factory :two_factor_authentication_device_totp, class: ::TwoFactorAuthentication::Device::Totp do user channel :totp diff --git a/spec/features/account_activation_spec.rb b/spec/features/account_activation_spec.rb index cc170cd..e0592a1 100644 --- a/spec/features/account_activation_spec.rb +++ b/spec/features/account_activation_spec.rb @@ -7,7 +7,7 @@ js: true, with_config: {:'2fa' => {active_strategies: [:developer]}} do let(:user) { - user = FactoryGirl.build :user, first_login: true + user = FactoryBot.build :user, first_login: true UserInvitation.invite_user! user user @@ -38,7 +38,7 @@ def activate! end context 'when not enforced, but device present' do - let!(:device) { FactoryGirl.create :two_factor_authentication_device_sms, user: user, default: true} + let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, default: true} it 'requests a OTP' do sms_token = nil diff --git a/spec/features/admin_edit_two_factor_devices_spec.rb b/spec/features/admin_edit_two_factor_devices_spec.rb index 14197d9..6bb04ec 100644 --- a/spec/features/admin_edit_two_factor_devices_spec.rb +++ b/spec/features/admin_edit_two_factor_devices_spec.rb @@ -5,9 +5,9 @@ js: true do let(:dialog) { ::Components::PasswordConfirmationDialog.new } let(:user_password) {'admin!' * 4} - let(:other_user) { FactoryGirl.create :user, login: 'bob' } + let(:other_user) { FactoryBot.create :user, login: 'bob' } let(:admin) do - FactoryGirl.create(:admin, + FactoryBot.create(:admin, password: user_password, password_confirmation: user_password, ) @@ -62,8 +62,8 @@ end context 'with multiple devices registered' do - let!(:device1) { FactoryGirl.create :two_factor_authentication_device_sms, user: other_user } - let!(:device2) { FactoryGirl.create :two_factor_authentication_device_totp, user: other_user, default: false } + let!(:device1) { FactoryBot.create :two_factor_authentication_device_sms, user: other_user } + let!(:device2) { FactoryBot.create :two_factor_authentication_device_totp, user: other_user, default: false } it 'allows to delete all' do visit edit_user_path(other_user, tab: :two_factor_authentication) diff --git a/spec/features/backup_codes/generate_backup_codes.rb b/spec/features/backup_codes/generate_backup_codes.rb index 5d90b6d..9b7f7b9 100644 --- a/spec/features/backup_codes/generate_backup_codes.rb +++ b/spec/features/backup_codes/generate_backup_codes.rb @@ -6,7 +6,7 @@ js: true do let(:user_password) {'bob!' * 4} let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, login: 'bob', password: user_password, password_confirmation: user_password, diff --git a/spec/features/backup_codes/login_with_backup_code_spec.rb b/spec/features/backup_codes/login_with_backup_code_spec.rb index 3c29a94..793d09f 100644 --- a/spec/features/backup_codes/login_with_backup_code_spec.rb +++ b/spec/features/backup_codes/login_with_backup_code_spec.rb @@ -6,13 +6,13 @@ js: true do let(:user_password) {'bob!' * 4} let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, login: 'bob', password: user_password, password_confirmation: user_password, ) end - let!(:device) { FactoryGirl.create :two_factor_authentication_device_sms, user: user, active: true, default: true} + let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: true, default: true} context 'user has no backup code' do it 'does not show the backup code link' do diff --git a/spec/features/login/login_enforced_2fa_spec.rb b/spec/features/login/login_enforced_2fa_spec.rb index dbc3aec..1b5c1d0 100644 --- a/spec/features/login/login_enforced_2fa_spec.rb +++ b/spec/features/login/login_enforced_2fa_spec.rb @@ -6,7 +6,7 @@ js: true do let(:user_password) {'bob!' * 4} let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, login: 'bob', password: user_password, password_confirmation: user_password, @@ -14,7 +14,7 @@ end context 'with a default device' do - let!(:device) { FactoryGirl.create :two_factor_authentication_device_sms, user: user, active: true, default: true} + let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: true, default: true} it 'requests a 2FA' do sms_token = nil diff --git a/spec/features/login/login_with_2fa_spec.rb b/spec/features/login/login_with_2fa_spec.rb index 04b9f29..12cd20d 100644 --- a/spec/features/login/login_with_2fa_spec.rb +++ b/spec/features/login/login_with_2fa_spec.rb @@ -6,7 +6,7 @@ js: true do let(:user_password) {'bob!' * 4} let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, login: 'bob', password: user_password, password_confirmation: user_password, @@ -14,7 +14,7 @@ end context 'with a default device' do - let!(:device) { FactoryGirl.create :two_factor_authentication_device_sms, user: user, active: true, default: true} + let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: true, default: true} it 'requests a 2FA' do sms_token = nil diff --git a/spec/features/login/login_without_2fa_spec.rb b/spec/features/login/login_without_2fa_spec.rb index 1caf2c9..56d8ea1 100644 --- a/spec/features/login/login_without_2fa_spec.rb +++ b/spec/features/login/login_without_2fa_spec.rb @@ -6,7 +6,7 @@ js: true do let(:user_password) {'bob!' * 4} let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, login: 'bob', password: user_password, password_confirmation: user_password, @@ -14,7 +14,7 @@ end context 'non-default device' do - let!(:device) { FactoryGirl.create :two_factor_authentication_device_sms, user: user, active: true, default: false} + let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: true, default: false} it_behaves_like 'login without 2FA' end diff --git a/spec/features/login/switch_available_devices_spec.rb b/spec/features/login/switch_available_devices_spec.rb index de3de60..713e1a8 100644 --- a/spec/features/login/switch_available_devices_spec.rb +++ b/spec/features/login/switch_available_devices_spec.rb @@ -6,7 +6,7 @@ js: true do let(:user_password) {'bob!' * 4} let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, login: 'bob', password: user_password, password_confirmation: user_password, @@ -14,8 +14,8 @@ end context 'with two default device' do - let!(:device) { FactoryGirl.create :two_factor_authentication_device_sms, user: user, active: true, default: true} - let!(:device2) { FactoryGirl.create :two_factor_authentication_device_totp, user: user, active: true, default: false} + let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: true, default: true} + let!(:device2) { FactoryBot.create :two_factor_authentication_device_totp, user: user, active: true, default: false} it 'requests a 2FA and allows switching' do first_login_step diff --git a/spec/features/my_two_factor_devices_spec.rb b/spec/features/my_two_factor_devices_spec.rb index 4116ae5..7b6d7d9 100644 --- a/spec/features/my_two_factor_devices_spec.rb +++ b/spec/features/my_two_factor_devices_spec.rb @@ -6,7 +6,7 @@ let(:dialog) { ::Components::PasswordConfirmationDialog.new } let(:user_password) {'bob!' * 4} let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, login: 'bob', password: user_password, password_confirmation: user_password, diff --git a/spec/features/password_change_spec.rb b/spec/features/password_change_spec.rb index a4e3ba5..e2f93c8 100644 --- a/spec/features/password_change_spec.rb +++ b/spec/features/password_change_spec.rb @@ -6,7 +6,7 @@ let(:user_password) {'bob' * 4} let(:new_user_password) {'obb' * 4} let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, login: 'bob', password: user_password, password_confirmation: user_password, @@ -54,7 +54,7 @@ def handle_password_change(requires_otp: true) end context 'when device present' do - let!(:device) { FactoryGirl.create :two_factor_authentication_device_sms, user: user, default: true } + let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, default: true } it 'requires the password change after expired' do expect(user.current_password).not_to be_expired @@ -90,7 +90,7 @@ def handle_password_change(requires_otp: true) let(:user_password) {'bob' * 4} let(:new_user_password) {'obb' * 4} let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, force_password_change: true, first_login: true, login: 'bob', @@ -105,7 +105,7 @@ def handle_password_change(requires_otp: true) end context 'when device present' do - let!(:device) { FactoryGirl.create :two_factor_authentication_device_sms, user: user, default: true } + let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, default: true } it 'requires the password change' do handle_password_change diff --git a/spec/features/remember_cookie/login_with_remember_cookie_spec.rb b/spec/features/remember_cookie/login_with_remember_cookie_spec.rb index 43bf167..15e6085 100644 --- a/spec/features/remember_cookie/login_with_remember_cookie_spec.rb +++ b/spec/features/remember_cookie/login_with_remember_cookie_spec.rb @@ -7,13 +7,13 @@ js: true do let(:user_password) {'bob!' * 4} let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, login: 'bob', password: user_password, password_confirmation: user_password, ) end - let!(:device) { FactoryGirl.create :two_factor_authentication_device_sms, user: user, active: true, default: true} + let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: true, default: true} def login_with_cookie page.driver.browser.manage.delete_all_cookies diff --git a/spec/lib/token_strategies/message_bird_spec.rb b/spec/lib/token_strategies/message_bird_spec.rb index 05e16dc..696d320 100644 --- a/spec/lib/token_strategies/message_bird_spec.rb +++ b/spec/lib/token_strategies/message_bird_spec.rb @@ -4,8 +4,8 @@ describe ::OpenProject::TwoFactorAuthentication::TokenStrategy::MessageBird, with_2fa_ee: true do let(:channel) { :sms } let(:locale) { 'en' } - let(:user) { FactoryGirl.create :user, language: locale } - let(:device) { FactoryGirl.create :two_factor_authentication_device_sms, user: user, channel: channel } + let(:user) { FactoryBot.create :user, language: locale } + let(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, channel: channel } let(:strategy) { described_class.new user: user, device: device, channel: channel } before do diff --git a/spec/models/devices/default_device_spec.rb b/spec/models/devices/default_device_spec.rb index 65948e6..85159fd 100644 --- a/spec/models/devices/default_device_spec.rb +++ b/spec/models/devices/default_device_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' describe 'Default device', with_2fa_ee: true, type: :model do - let(:user) { FactoryGirl.create :user } - let(:subject) { FactoryGirl.build :two_factor_authentication_device_totp, user: user, default: true } - let(:other_otp) { FactoryGirl.build :two_factor_authentication_device_totp, user: user, default: true } + let(:user) { FactoryBot.create :user } + let(:subject) { FactoryBot.build :two_factor_authentication_device_totp, user: user, default: true } + let(:other_otp) { FactoryBot.build :two_factor_authentication_device_totp, user: user, default: true } it 'can be set if nothing else exists' do expect(subject.save).to eq true @@ -13,9 +13,9 @@ end context 'assuming another default exists' do - let(:other_otp) { FactoryGirl.create :two_factor_authentication_device_totp, user: user, default: true } - let(:other_sms) { FactoryGirl.create :two_factor_authentication_device_sms, user: user, default: false } - let(:subject) { FactoryGirl.create :two_factor_authentication_device_totp, user: user, default: false } + let(:other_otp) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: true } + let(:other_sms) { FactoryBot.create :two_factor_authentication_device_sms, user: user, default: false } + let(:subject) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: false } before do other_otp diff --git a/spec/models/devices/totp_spec.rb b/spec/models/devices/totp_spec.rb index 85152c1..6262926 100644 --- a/spec/models/devices/totp_spec.rb +++ b/spec/models/devices/totp_spec.rb @@ -2,7 +2,7 @@ require 'timecop' describe ::TwoFactorAuthentication::Device::Totp, with_2fa_ee: true, type: :model do - let(:user) { FactoryGirl.create :user } + let(:user) { FactoryBot.create :user } let(:channel) { :totp } subject { described_class.new identifier: 'foo', channel: channel, user: user, active: true } diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 32e31e7..368d1b8 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -4,7 +4,7 @@ module OpenProject::TwoFactorAuthentication::Patches module UserSpec describe User, with_2fa_ee: true do def create_user(auth_source_id = nil) - @user = FactoryGirl.build(:user) + @user = FactoryBot.build(:user) @username = @user.login @password = @user.password @user.auth_source_id = auth_source_id diff --git a/spec/services/token_delivery/message_bird_spec.rb b/spec/services/token_delivery/message_bird_spec.rb index 27d959a..9785c8f 100644 --- a/spec/services/token_delivery/message_bird_spec.rb +++ b/spec/services/token_delivery/message_bird_spec.rb @@ -3,9 +3,9 @@ describe ::OpenProject::TwoFactorAuthentication::TokenStrategy::MessageBird, with_2fa_ee: true do describe 'sending messages' do - let!(:user) { FactoryGirl.create :user, language: locale } + let!(:user) { FactoryBot.create :user, language: locale } let!(:locale) { 'en' } - let!(:device) { FactoryGirl.create :two_factor_authentication_device_sms, user: user, channel: channel } + let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, channel: channel } let(:service_url) { 'https://example.org/foobar' } let(:params) { diff --git a/spec/services/token_delivery/restdt_spec.rb b/spec/services/token_delivery/restdt_spec.rb index 0e8ea19..1b1c1bc 100644 --- a/spec/services/token_delivery/restdt_spec.rb +++ b/spec/services/token_delivery/restdt_spec.rb @@ -2,8 +2,8 @@ describe ::OpenProject::TwoFactorAuthentication::TokenStrategy::Restdt, with_2fa_ee: true do describe 'sending messages' do - let!(:user) { FactoryGirl.create :user } - let!(:device) { FactoryGirl.create :two_factor_authentication_device_sms, user: user, channel: channel } + let!(:user) { FactoryBot.create :user } + let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, channel: channel } let(:service_url) { 'https://example.org/foobar' } let(:params) { @@ -85,7 +85,7 @@ end context 'with german locale' do - let(:user) { FactoryGirl.create(:user, language: 'de') } + let(:user) { FactoryBot.create(:user, language: 'de') } let(:expected_params) { { lang: 'de' } } it_behaves_like 'API response', true diff --git a/spec/services/token_delivery/sns_spec.rb b/spec/services/token_delivery/sns_spec.rb index aab11ec..0c4619d 100644 --- a/spec/services/token_delivery/sns_spec.rb +++ b/spec/services/token_delivery/sns_spec.rb @@ -3,8 +3,8 @@ describe ::OpenProject::TwoFactorAuthentication::TokenStrategy::Sns, with_2fa_ee: true do describe 'sending messages' do let(:phone) { '+49 123456789' } - let!(:user) { FactoryGirl.create :user } - let!(:device) { FactoryGirl.create :two_factor_authentication_device_sms, user: user, channel: channel } + let!(:user) { FactoryBot.create :user } + let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, channel: channel } let(:channel) { :sms } let(:params) { diff --git a/spec/services/token_delivery/totp_spec.rb b/spec/services/token_delivery/totp_spec.rb index deef496..5ac4e7c 100644 --- a/spec/services/token_delivery/totp_spec.rb +++ b/spec/services/token_delivery/totp_spec.rb @@ -2,8 +2,8 @@ describe ::OpenProject::TwoFactorAuthentication::TokenStrategy::Totp, with_2fa_ee: true do describe 'sending messages' do - let!(:user) { FactoryGirl.create :user } - let!(:device) { FactoryGirl.create :two_factor_authentication_device_totp, user: user, default: true} + let!(:user) { FactoryBot.create :user } + let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: true} before do allow(OpenProject::Configuration) diff --git a/spec/services/token_service_spec.rb b/spec/services/token_service_spec.rb index 8b6afa8..a4af599 100644 --- a/spec/services/token_service_spec.rb +++ b/spec/services/token_service_spec.rb @@ -2,7 +2,7 @@ describe ::TwoFactorAuthentication::TokenService, with_2fa_ee: true do describe 'sending messages' do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } let(:dev_strategy) { ::OpenProject::TwoFactorAuthentication::TokenStrategy::Developer } let(:configuration) do { @@ -72,7 +72,7 @@ end context 'and matching device exists' do - let!(:device) { FactoryGirl.create :two_factor_authentication_device_sms, user: user, default: true } + let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, default: true } it 'submits the request' do expect(subject.requires_token?).to be_truthy @@ -82,7 +82,7 @@ end context 'and non-matching device exists' do - let!(:device) { FactoryGirl.create :two_factor_authentication_device_totp, user: user, default: true } + let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: true } it 'submits the request' do expect(subject.requires_token?).to be_truthy @@ -94,8 +94,8 @@ context 'when developer and totp strategies are set' do let(:active_strategies) { [:developer, :totp] } - let!(:totp_device) { FactoryGirl.create :two_factor_authentication_device_totp, user: user, default: true } - let!(:sms_device) { FactoryGirl.create :two_factor_authentication_device_sms, user: user, default: false } + let!(:totp_device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: true } + let!(:sms_device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, default: false } subject { described_class.new user: user, use_device: use_device }