2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-29 07:56:52 +00:00
|
|
|
require 'spec_helper'
|
2015-07-10 21:11:39 +00:00
|
|
|
|
2020-06-03 18:08:28 +00:00
|
|
|
RSpec.describe 'Admin disables 2FA for a user' do
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'successfully', :js do
|
2020-11-23 15:09:37 +00:00
|
|
|
admin = create(:admin)
|
|
|
|
sign_in(admin)
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
2015-07-10 21:11:39 +00:00
|
|
|
user = create(:user, :two_factor)
|
|
|
|
|
|
|
|
edit_user(user)
|
|
|
|
page.within('.two-factor-status') do
|
2017-10-26 16:57:57 +00:00
|
|
|
accept_confirm { click_link 'Disable' }
|
2015-07-10 21:11:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
page.within('.two-factor-status') do
|
|
|
|
expect(page).to have_content 'Disabled'
|
|
|
|
expect(page).not_to have_button 'Disable'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
it 'for a user without 2FA enabled' do
|
2020-11-23 15:09:37 +00:00
|
|
|
admin = create(:admin)
|
|
|
|
sign_in(admin)
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
2015-07-10 21:11:39 +00:00
|
|
|
user = create(:user)
|
|
|
|
|
|
|
|
edit_user(user)
|
|
|
|
|
|
|
|
page.within('.two-factor-status') do
|
|
|
|
expect(page).not_to have_button 'Disable'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit_user(user)
|
|
|
|
visit admin_user_path(user)
|
|
|
|
end
|
|
|
|
end
|