2011-10-08 17:36:38 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-06-29 00:13:10 -04:00
|
|
|
describe "Admin::Users" do
|
2019-01-07 06:54:41 -05:00
|
|
|
include Spec::Support::Helpers::Features::ResponsiveTableHelpers
|
2018-11-29 07:00:20 -05:00
|
|
|
|
2017-01-02 06:07:11 -05:00
|
|
|
let!(:user) do
|
|
|
|
create(:omniauth_user, provider: 'twitter', extern_uid: '123456')
|
|
|
|
end
|
|
|
|
|
2019-01-07 06:54:41 -05:00
|
|
|
let!(:current_user) { create(:admin, last_activity_on: 5.days.ago) }
|
2017-06-21 19:44:10 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(current_user)
|
|
|
|
end
|
2011-10-08 17:36:38 -04:00
|
|
|
|
|
|
|
describe "GET /admin/users" do
|
2011-10-26 09:46:25 -04:00
|
|
|
before do
|
2011-10-08 17:36:38 -04:00
|
|
|
visit admin_users_path
|
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it "is ok" do
|
2015-02-12 13:17:35 -05:00
|
|
|
expect(current_path).to eq(admin_users_path)
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it "has users list" do
|
2017-01-02 06:07:11 -05:00
|
|
|
expect(page).to have_content(current_user.email)
|
|
|
|
expect(page).to have_content(current_user.name)
|
2019-01-07 06:54:41 -05:00
|
|
|
expect(page).to have_content(current_user.created_at.strftime("%e %b, %Y"))
|
|
|
|
expect(page).to have_content(current_user.last_activity_on.strftime("%e %b, %Y"))
|
2017-01-02 06:07:11 -05:00
|
|
|
expect(page).to have_content(user.email)
|
|
|
|
expect(page).to have_content(user.name)
|
2017-06-01 11:18:21 -04:00
|
|
|
expect(page).to have_link('Block', href: block_admin_user_path(user))
|
2018-02-08 00:17:12 -05:00
|
|
|
expect(page).to have_button('Delete user')
|
|
|
|
expect(page).to have_button('Delete user and contributions')
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
2015-06-19 16:31:36 -04:00
|
|
|
|
2019-01-07 06:54:41 -05:00
|
|
|
describe "view extra user information", :js do
|
|
|
|
it 'does not have the user popover open' do
|
|
|
|
expect(page).not_to have_selector('#__BV_popover_1__')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the user popover on hover' do
|
|
|
|
first_user_link = page.first('.js-user-link')
|
|
|
|
|
|
|
|
first_user_link.hover
|
|
|
|
|
|
|
|
expect(page).to have_selector('#__BV_popover_1__')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-29 07:00:20 -05:00
|
|
|
describe 'search and sort' do
|
|
|
|
before do
|
2019-01-07 06:54:41 -05:00
|
|
|
create(:user, name: 'Foo Bar', last_activity_on: 3.days.ago)
|
|
|
|
create(:user, name: 'Foo Baz', last_activity_on: 2.days.ago)
|
2018-11-29 07:00:20 -05:00
|
|
|
create(:user, name: 'Dmitriy')
|
|
|
|
end
|
|
|
|
|
2018-12-04 06:52:54 -05:00
|
|
|
it 'searches users by name' do
|
2018-11-29 07:00:20 -05:00
|
|
|
visit admin_users_path(search_query: 'Foo')
|
|
|
|
|
|
|
|
expect(page).to have_content('Foo Bar')
|
|
|
|
expect(page).to have_content('Foo Baz')
|
|
|
|
expect(page).not_to have_content('Dmitriy')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'sorts users by name' do
|
|
|
|
visit admin_users_path
|
|
|
|
|
|
|
|
sort_by('Name')
|
|
|
|
|
|
|
|
expect(first_row.text).to include('Dmitriy')
|
|
|
|
expect(second_row.text).to include('Foo Bar')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'sorts search results only' do
|
|
|
|
visit admin_users_path(search_query: 'Foo')
|
|
|
|
|
|
|
|
sort_by('Name')
|
|
|
|
|
|
|
|
expect(page).not_to have_content('Dmitriy')
|
|
|
|
expect(first_row.text).to include('Foo Bar')
|
|
|
|
expect(second_row.text).to include('Foo Baz')
|
|
|
|
end
|
2018-12-04 06:52:54 -05:00
|
|
|
|
|
|
|
it 'searches with respect of sorting' do
|
|
|
|
visit admin_users_path(sort: 'Name')
|
|
|
|
|
|
|
|
fill_in :search_query, with: 'Foo'
|
|
|
|
click_button('Search users')
|
|
|
|
|
|
|
|
expect(first_row.text).to include('Foo Bar')
|
|
|
|
expect(second_row.text).to include('Foo Baz')
|
|
|
|
end
|
2019-01-07 06:54:41 -05:00
|
|
|
|
|
|
|
it 'sorts users by recent last activity' do
|
|
|
|
visit admin_users_path(search_query: 'Foo')
|
|
|
|
|
|
|
|
sort_by('Recent last activity')
|
|
|
|
|
|
|
|
expect(first_row.text).to include('Foo Baz')
|
|
|
|
expect(second_row.text).to include('Foo Bar')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'sorts users by oldest last activity' do
|
|
|
|
visit admin_users_path(search_query: 'Foo')
|
|
|
|
|
|
|
|
sort_by('Oldest last activity')
|
|
|
|
|
|
|
|
expect(first_row.text).to include('Foo Bar')
|
|
|
|
expect(second_row.text).to include('Foo Baz')
|
|
|
|
end
|
2018-11-29 07:00:20 -05:00
|
|
|
end
|
|
|
|
|
2015-06-19 16:31:36 -04:00
|
|
|
describe 'Two-factor Authentication filters' do
|
|
|
|
it 'counts users who have enabled 2FA' do
|
2016-06-06 00:38:42 -04:00
|
|
|
create(:user, :two_factor)
|
2015-06-19 16:31:36 -04:00
|
|
|
|
|
|
|
visit admin_users_path
|
|
|
|
|
|
|
|
page.within('.filter-two-factor-enabled small') do
|
|
|
|
expect(page).to have_content('1')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'filters by users who have enabled 2FA' do
|
2016-06-06 00:38:42 -04:00
|
|
|
user = create(:user, :two_factor)
|
2015-06-19 16:31:36 -04:00
|
|
|
|
|
|
|
visit admin_users_path
|
|
|
|
click_link '2FA Enabled'
|
|
|
|
|
|
|
|
expect(page).to have_content(user.email)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'counts users who have not enabled 2FA' do
|
|
|
|
visit admin_users_path
|
|
|
|
|
|
|
|
page.within('.filter-two-factor-disabled small') do
|
|
|
|
expect(page).to have_content('2') # Including admin
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'filters by users who have not enabled 2FA' do
|
|
|
|
visit admin_users_path
|
|
|
|
click_link '2FA Disabled'
|
|
|
|
|
|
|
|
expect(page).to have_content(user.email)
|
|
|
|
end
|
|
|
|
end
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
2011-10-26 09:46:25 -04:00
|
|
|
describe "GET /admin/users/new" do
|
2018-08-07 11:53:33 -04:00
|
|
|
let(:user_username) { 'bang' }
|
|
|
|
|
2011-10-26 09:46:25 -04:00
|
|
|
before do
|
2011-10-08 17:36:38 -04:00
|
|
|
visit new_admin_user_path
|
2012-08-10 18:07:50 -04:00
|
|
|
fill_in "user_name", with: "Big Bang"
|
2018-08-07 11:53:33 -04:00
|
|
|
fill_in "user_username", with: user_username
|
2012-08-10 18:07:50 -04:00
|
|
|
fill_in "user_email", with: "bigbang@mail.com"
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it "creates new user" do
|
2013-04-18 10:28:09 -04:00
|
|
|
expect { click_button "Create user" }.to change {User.count}.by(1)
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it "applies defaults to user" do
|
2013-03-11 02:44:45 -04:00
|
|
|
click_button "Create user"
|
2015-02-06 01:40:35 -05:00
|
|
|
user = User.find_by(username: 'bang')
|
2017-06-21 09:48:12 -04:00
|
|
|
expect(user.projects_limit)
|
|
|
|
.to eq(Gitlab.config.gitlab.default_projects_limit)
|
|
|
|
expect(user.can_create_group)
|
|
|
|
.to eq(Gitlab.config.gitlab.default_can_create_group)
|
2013-03-11 02:44:45 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it "creates user with valid data" do
|
2013-04-18 10:28:09 -04:00
|
|
|
click_button "Create user"
|
2015-02-06 01:40:35 -05:00
|
|
|
user = User.find_by(username: 'bang')
|
2015-02-12 13:53:23 -05:00
|
|
|
expect(user.name).to eq('Big Bang')
|
|
|
|
expect(user.email).to eq('bigbang@mail.com')
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it "calls send mail" do
|
2015-11-30 09:12:31 -05:00
|
|
|
expect_any_instance_of(NotificationService).to receive(:new_user)
|
2012-06-20 12:29:10 -04:00
|
|
|
|
2014-06-17 15:51:43 -04:00
|
|
|
click_button "Create user"
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it "sends valid email to user with email & password" do
|
2015-11-30 11:03:07 -05:00
|
|
|
perform_enqueued_jobs do
|
|
|
|
click_button "Create user"
|
|
|
|
end
|
|
|
|
|
2015-02-06 01:40:35 -05:00
|
|
|
user = User.find_by(username: 'bang')
|
2014-06-17 15:51:43 -04:00
|
|
|
email = ActionMailer::Base.deliveries.last
|
2015-02-12 13:53:23 -05:00
|
|
|
expect(email.subject).to have_content('Account was created')
|
2015-02-12 13:17:35 -05:00
|
|
|
expect(email.text_part.body).to have_content(user.email)
|
|
|
|
expect(email.text_part.body).to have_content('password')
|
2012-11-06 08:30:48 -05:00
|
|
|
end
|
2018-08-07 11:53:33 -04:00
|
|
|
|
|
|
|
context 'username contains spaces' do
|
|
|
|
let(:user_username) { 'Bing bang' }
|
|
|
|
|
|
|
|
it "doesn't create the user and shows an error message" do
|
|
|
|
expect { click_button "Create user" }.to change {User.count}.by(0)
|
|
|
|
|
|
|
|
expect(page).to have_content('The form contains the following error')
|
|
|
|
expect(page).to have_content('Username can contain only letters, digits')
|
|
|
|
end
|
|
|
|
end
|
2018-08-30 08:53:06 -04:00
|
|
|
|
|
|
|
context 'with new users set to external enabled' do
|
|
|
|
context 'with regex to match internal user email address set', :js do
|
|
|
|
before do
|
|
|
|
stub_application_setting(user_default_external: true)
|
2018-11-15 04:56:21 -05:00
|
|
|
stub_application_setting(user_default_internal_regex: '\.internal@')
|
2018-08-30 08:53:06 -04:00
|
|
|
|
|
|
|
visit new_admin_user_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def expects_external_to_be_checked
|
|
|
|
expect(find('#user_external')).to be_checked
|
|
|
|
end
|
|
|
|
|
|
|
|
def expects_external_to_be_unchecked
|
|
|
|
expect(find('#user_external')).not_to be_checked
|
|
|
|
end
|
|
|
|
|
|
|
|
def expects_warning_to_be_hidden
|
|
|
|
expect(find('#warning_external_automatically_set', visible: :all)[:class]).to include 'hidden'
|
|
|
|
end
|
|
|
|
|
|
|
|
def expects_warning_to_be_shown
|
|
|
|
expect(find('#warning_external_automatically_set')[:class]).not_to include 'hidden'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'automatically unchecks external for matching email' do
|
|
|
|
expects_external_to_be_checked
|
|
|
|
expects_warning_to_be_hidden
|
|
|
|
|
|
|
|
fill_in 'user_email', with: 'test.internal@domain.ch'
|
|
|
|
|
|
|
|
expects_external_to_be_unchecked
|
|
|
|
expects_warning_to_be_shown
|
|
|
|
|
|
|
|
fill_in 'user_email', with: 'test@domain.ch'
|
|
|
|
|
|
|
|
expects_external_to_be_checked
|
|
|
|
expects_warning_to_be_hidden
|
|
|
|
|
|
|
|
uncheck 'user_external'
|
|
|
|
|
|
|
|
expects_warning_to_be_hidden
|
|
|
|
end
|
2018-11-15 04:56:21 -05:00
|
|
|
|
|
|
|
it 'creates an internal user' do
|
|
|
|
user_name = 'tester1'
|
|
|
|
fill_in 'user_email', with: 'test.internal@domain.ch'
|
|
|
|
fill_in 'user_name', with: 'tester1 name'
|
|
|
|
fill_in 'user_username', with: user_name
|
|
|
|
|
|
|
|
expects_external_to_be_unchecked
|
|
|
|
expects_warning_to_be_shown
|
|
|
|
|
|
|
|
click_button 'Create user'
|
|
|
|
|
|
|
|
new_user = User.find_by(username: user_name)
|
|
|
|
|
|
|
|
expect(new_user.external).to be_falsy
|
|
|
|
end
|
2018-08-30 08:53:06 -04:00
|
|
|
end
|
|
|
|
end
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
2011-10-26 09:46:25 -04:00
|
|
|
describe "GET /admin/users/:id" do
|
2016-07-25 14:16:19 -04:00
|
|
|
it "has user info" do
|
2011-10-08 17:36:38 -04:00
|
|
|
visit admin_users_path
|
2017-01-02 06:07:11 -05:00
|
|
|
click_link user.name
|
2011-10-08 17:36:38 -04:00
|
|
|
|
2017-01-02 06:07:11 -05:00
|
|
|
expect(page).to have_content(user.email)
|
|
|
|
expect(page).to have_content(user.name)
|
2018-08-19 15:13:48 -04:00
|
|
|
expect(page).to have_content(user.id)
|
2017-06-02 09:42:06 -04:00
|
|
|
expect(page).to have_link('Block user', href: block_admin_user_path(user))
|
2018-02-08 00:17:12 -05:00
|
|
|
expect(page).to have_button('Delete user')
|
|
|
|
expect(page).to have_button('Delete user and contributions')
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
2015-06-19 15:04:47 -04:00
|
|
|
|
2015-10-28 11:39:23 -04:00
|
|
|
describe 'Impersonation' do
|
|
|
|
let(:another_user) { create(:user) }
|
2017-06-14 14:18:56 -04:00
|
|
|
|
2015-10-28 11:39:23 -04:00
|
|
|
context 'before impersonating' do
|
2018-11-24 07:39:16 -05:00
|
|
|
subject { visit admin_user_path(user_to_visit) }
|
|
|
|
|
|
|
|
let(:user_to_visit) { another_user }
|
|
|
|
|
|
|
|
context 'for other users' do
|
|
|
|
it 'shows impersonate button for other users' do
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(page).to have_content('Impersonate')
|
|
|
|
end
|
2015-10-28 11:39:23 -04:00
|
|
|
end
|
2015-09-24 09:34:04 -04:00
|
|
|
|
2018-11-24 07:39:16 -05:00
|
|
|
context 'for admin itself' do
|
|
|
|
let(:user_to_visit) { current_user }
|
2015-09-24 09:34:04 -04:00
|
|
|
|
2018-11-24 07:39:16 -05:00
|
|
|
it 'does not show impersonate button for admin itself' do
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(page).not_to have_content('Impersonate')
|
|
|
|
end
|
2015-09-24 09:34:04 -04:00
|
|
|
end
|
2015-12-01 23:40:24 -05:00
|
|
|
|
2018-11-24 07:39:16 -05:00
|
|
|
context 'for blocked user' do
|
|
|
|
before do
|
|
|
|
another_user.block
|
|
|
|
end
|
2015-12-01 23:40:24 -05:00
|
|
|
|
2018-11-24 07:39:16 -05:00
|
|
|
it 'does not show impersonate button for blocked user' do
|
|
|
|
subject
|
2015-12-01 23:40:24 -05:00
|
|
|
|
2018-11-24 07:39:16 -05:00
|
|
|
expect(page).not_to have_content('Impersonate')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when impersonation is disabled' do
|
|
|
|
before do
|
|
|
|
stub_config_setting(impersonation_enabled: false)
|
|
|
|
end
|
2015-12-01 23:40:24 -05:00
|
|
|
|
2018-11-24 07:39:16 -05:00
|
|
|
it 'does not show impersonate button' do
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(page).not_to have_content('Impersonate')
|
|
|
|
end
|
2015-12-01 23:40:24 -05:00
|
|
|
end
|
2015-09-24 09:34:04 -04:00
|
|
|
end
|
|
|
|
|
2015-10-28 11:39:23 -04:00
|
|
|
context 'when impersonating' do
|
2018-11-24 07:39:16 -05:00
|
|
|
subject { click_link 'Impersonate' }
|
|
|
|
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
2018-11-24 07:39:16 -05:00
|
|
|
visit admin_user_path(another_user)
|
2017-06-14 14:18:56 -04:00
|
|
|
end
|
2015-10-28 11:39:23 -04:00
|
|
|
|
|
|
|
it 'logs in as the user when impersonate is clicked' do
|
2018-11-24 07:39:16 -05:00
|
|
|
subject
|
|
|
|
|
2016-07-05 08:10:46 -04:00
|
|
|
expect(page.find(:css, '.header-user .profile-link')['data-user']).to eql(another_user.username)
|
2015-10-28 11:39:23 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'sees impersonation log out icon' do
|
2018-11-24 07:39:16 -05:00
|
|
|
subject
|
2015-10-28 11:39:23 -04:00
|
|
|
|
2018-11-24 07:39:16 -05:00
|
|
|
icon = first('.fa.fa-user-secret')
|
2017-09-13 07:18:15 -04:00
|
|
|
expect(icon).not_to be nil
|
2015-10-28 11:39:23 -04:00
|
|
|
end
|
|
|
|
|
2018-11-24 07:39:16 -05:00
|
|
|
context 'a user with an expired password' do
|
|
|
|
before do
|
|
|
|
another_user.update(password_expires_at: Time.now - 5.minutes)
|
|
|
|
end
|
2015-10-28 11:39:23 -04:00
|
|
|
|
2018-11-24 07:39:16 -05:00
|
|
|
it 'does not redirect to password change page' do
|
|
|
|
subject
|
2015-10-28 11:39:23 -04:00
|
|
|
|
2018-11-24 07:39:16 -05:00
|
|
|
expect(current_path).to eq('/')
|
|
|
|
end
|
2017-09-13 07:18:15 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-24 07:39:16 -05:00
|
|
|
context 'ending impersonation' do
|
|
|
|
subject { find(:css, 'li.impersonation a').click }
|
|
|
|
|
2017-09-13 07:18:15 -04:00
|
|
|
before do
|
2018-11-24 07:39:16 -05:00
|
|
|
visit admin_user_path(another_user)
|
2017-09-13 07:18:15 -04:00
|
|
|
click_link 'Impersonate'
|
|
|
|
end
|
|
|
|
|
2018-11-24 07:39:16 -05:00
|
|
|
it 'logs out of impersonated user back to original user' do
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(page.find(:css, '.header-user .profile-link')['data-user']).to eq(current_user.username)
|
2017-09-13 07:18:15 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'is redirected back to the impersonated users page in the admin after stopping' do
|
2018-11-24 07:39:16 -05:00
|
|
|
subject
|
2017-09-13 07:18:15 -04:00
|
|
|
|
|
|
|
expect(current_path).to eq("/admin/users/#{another_user.username}")
|
2015-10-28 11:39:23 -04:00
|
|
|
end
|
2018-11-24 07:39:16 -05:00
|
|
|
|
|
|
|
context 'a user with an expired password' do
|
|
|
|
before do
|
|
|
|
another_user.update(password_expires_at: Time.now - 5.minutes)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is redirected back to the impersonated users page in the admin after stopping' do
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(current_path).to eq("/admin/users/#{another_user.username}")
|
|
|
|
end
|
|
|
|
end
|
2015-09-24 09:34:04 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-06-19 15:04:47 -04:00
|
|
|
describe 'Two-factor Authentication status' do
|
|
|
|
it 'shows when enabled' do
|
2017-01-02 06:07:11 -05:00
|
|
|
user.update_attribute(:otp_required_for_login, true)
|
2015-06-19 15:04:47 -04:00
|
|
|
|
2017-01-02 06:07:11 -05:00
|
|
|
visit admin_user_path(user)
|
2015-06-19 15:04:47 -04:00
|
|
|
|
|
|
|
expect_two_factor_status('Enabled')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows when disabled' do
|
2017-01-02 06:07:11 -05:00
|
|
|
visit admin_user_path(user)
|
2015-06-19 15:04:47 -04:00
|
|
|
|
|
|
|
expect_two_factor_status('Disabled')
|
|
|
|
end
|
|
|
|
|
|
|
|
def expect_two_factor_status(status)
|
|
|
|
page.within('.two-factor-status') do
|
|
|
|
expect(page).to have_content(status)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
2011-10-26 09:46:25 -04:00
|
|
|
describe "GET /admin/users/:id/edit" do
|
|
|
|
before do
|
2011-10-08 17:36:38 -04:00
|
|
|
visit admin_users_path
|
2017-01-02 06:07:11 -05:00
|
|
|
click_link "edit_user_#{user.id}"
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it "has user edit page" do
|
2015-02-12 13:53:23 -05:00
|
|
|
expect(page).to have_content('Name')
|
|
|
|
expect(page).to have_content('Password')
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "Update user" do
|
2011-10-26 09:46:25 -04:00
|
|
|
before do
|
2012-08-10 18:07:50 -04:00
|
|
|
fill_in "user_name", with: "Big Bang"
|
|
|
|
fill_in "user_email", with: "bigbang@mail.com"
|
2016-05-03 07:42:55 -04:00
|
|
|
fill_in "user_password", with: "AValidPassword1"
|
|
|
|
fill_in "user_password_confirmation", with: "AValidPassword1"
|
2017-02-06 16:38:08 -05:00
|
|
|
choose "user_access_level_admin"
|
2013-04-18 10:28:09 -04:00
|
|
|
click_button "Save changes"
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
2017-01-02 06:07:11 -05:00
|
|
|
it "shows page with new data" do
|
2015-02-12 13:53:23 -05:00
|
|
|
expect(page).to have_content('bigbang@mail.com')
|
|
|
|
expect(page).to have_content('Big Bang')
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it "changes user entry" do
|
2017-01-02 06:07:11 -05:00
|
|
|
user.reload
|
|
|
|
expect(user.name).to eq('Big Bang')
|
2017-04-08 22:20:57 -04:00
|
|
|
expect(user.admin?).to be_truthy
|
2017-01-02 06:07:11 -05:00
|
|
|
expect(user.password_expires_at).to be <= Time.now
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'update username to non ascii char' do
|
|
|
|
it do
|
|
|
|
fill_in 'user_username', with: '\u3042\u3044'
|
|
|
|
click_button('Save')
|
|
|
|
|
|
|
|
page.within '#error_explanation' do
|
|
|
|
expect(page).to have_content('Username')
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_selector(%(form[action="/admin/users/#{user.username}"]))
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-11-28 12:14:05 -05:00
|
|
|
|
|
|
|
describe "GET /admin/users/:id/projects" do
|
2017-01-02 06:20:22 -05:00
|
|
|
let(:group) { create(:group) }
|
2017-08-02 15:55:11 -04:00
|
|
|
let!(:project) { create(:project, group: group) }
|
2017-01-02 06:20:22 -05:00
|
|
|
|
2016-11-28 12:14:05 -05:00
|
|
|
before do
|
2017-01-02 06:20:22 -05:00
|
|
|
group.add_developer(user)
|
2016-11-28 12:14:05 -05:00
|
|
|
|
2017-01-02 06:20:22 -05:00
|
|
|
visit projects_admin_user_path(user)
|
2016-11-28 12:14:05 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it "lists group projects" do
|
2018-04-10 13:11:34 -04:00
|
|
|
within(:css, '.append-bottom-default + .card') do
|
2016-11-28 12:14:05 -05:00
|
|
|
expect(page).to have_content 'Group projects'
|
2018-05-03 11:45:13 -04:00
|
|
|
expect(page).to have_link group.name, href: admin_group_path(group)
|
2016-11-28 12:14:05 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'allows navigation to the group details' do
|
2018-04-10 13:11:34 -04:00
|
|
|
within(:css, '.append-bottom-default + .card') do
|
2017-01-02 06:20:22 -05:00
|
|
|
click_link group.name
|
2016-11-28 12:14:05 -05:00
|
|
|
end
|
|
|
|
within(:css, 'h3.page-title') do
|
2017-01-02 06:20:22 -05:00
|
|
|
expect(page).to have_content "Group: #{group.name}"
|
2016-11-28 12:14:05 -05:00
|
|
|
end
|
2017-01-02 06:20:22 -05:00
|
|
|
expect(page).to have_content project.name
|
2016-11-28 12:14:05 -05:00
|
|
|
end
|
2016-12-28 17:22:57 -05:00
|
|
|
|
|
|
|
it 'shows the group access level' do
|
2018-04-10 13:11:34 -04:00
|
|
|
within(:css, '.append-bottom-default + .card') do
|
2016-12-28 17:22:57 -05:00
|
|
|
expect(page).to have_content 'Developer'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
it 'allows group membership to be revoked', :js do
|
2016-12-28 17:22:57 -05:00
|
|
|
page.within(first('.group_member')) do
|
2017-09-27 07:34:41 -04:00
|
|
|
accept_confirm { find('.btn-remove').click }
|
2016-12-28 17:22:57 -05:00
|
|
|
end
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-12-28 17:22:57 -05:00
|
|
|
|
|
|
|
expect(page).not_to have_selector('.group_member')
|
|
|
|
end
|
2016-11-28 12:14:05 -05:00
|
|
|
end
|
2017-01-02 06:07:11 -05:00
|
|
|
|
2018-06-09 02:45:05 -04:00
|
|
|
describe 'show breadcrumbs' do
|
|
|
|
it do
|
|
|
|
visit admin_user_path(user)
|
|
|
|
|
|
|
|
check_breadcrumb(user.name)
|
|
|
|
|
|
|
|
visit projects_admin_user_path(user)
|
|
|
|
|
|
|
|
check_breadcrumb(user.name)
|
|
|
|
|
|
|
|
visit keys_admin_user_path(user)
|
|
|
|
|
|
|
|
check_breadcrumb(user.name)
|
|
|
|
|
|
|
|
visit admin_user_impersonation_tokens_path(user)
|
|
|
|
|
|
|
|
check_breadcrumb(user.name)
|
|
|
|
|
|
|
|
visit admin_user_identities_path(user)
|
|
|
|
|
|
|
|
check_breadcrumb(user.name)
|
|
|
|
|
|
|
|
visit new_admin_user_identity_path(user)
|
|
|
|
|
|
|
|
check_breadcrumb("New Identity")
|
|
|
|
|
|
|
|
visit admin_user_identities_path(user)
|
|
|
|
|
|
|
|
find('.table').find(:link, 'Edit').click
|
|
|
|
|
|
|
|
check_breadcrumb("Edit Identity")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-01-02 06:07:11 -05:00
|
|
|
describe 'show user attributes' do
|
|
|
|
it do
|
|
|
|
visit admin_users_path
|
|
|
|
|
|
|
|
click_link user.name
|
|
|
|
|
|
|
|
expect(page).to have_content 'Account'
|
|
|
|
expect(page).to have_content 'Personal projects limit'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
describe 'remove users secondary email', :js do
|
2017-01-02 06:07:11 -05:00
|
|
|
let!(:secondary_email) do
|
|
|
|
create :email, email: 'secondary@example.com', user: user
|
|
|
|
end
|
|
|
|
|
|
|
|
it do
|
|
|
|
visit admin_user_path(user.username)
|
|
|
|
|
|
|
|
expect(page).to have_content("Secondary email: #{secondary_email.email}")
|
|
|
|
|
2017-09-27 07:34:41 -04:00
|
|
|
accept_confirm { find("#remove_email_#{secondary_email.id}").click }
|
2017-01-02 06:07:11 -05:00
|
|
|
|
|
|
|
expect(page).not_to have_content(secondary_email.email)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'show user keys' do
|
|
|
|
let!(:key1) do
|
|
|
|
create(:key, user: user, title: "ssh-rsa Key1", key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4FIEBXGi4bPU8kzxMefudPIJ08/gNprdNTaO9BR/ndy3+58s2HCTw2xCHcsuBmq+TsAqgEidVq4skpqoTMB+Uot5Uzp9z4764rc48dZiI661izoREoKnuRQSsRqUTHg5wrLzwxlQbl1MVfRWQpqiz/5KjBC7yLEb9AbusjnWBk8wvC1bQPQ1uLAauEA7d836tgaIsym9BrLsMVnR4P1boWD3Xp1B1T/ImJwAGHvRmP/ycIqmKdSpMdJXwxcb40efWVj0Ibbe7ii9eeoLdHACqevUZi6fwfbymdow+FeqlkPoHyGg3Cu4vD/D8+8cRc7mE/zGCWcQ15Var83Tczour Key1")
|
|
|
|
end
|
|
|
|
|
|
|
|
let!(:key2) do
|
|
|
|
create(:key, user: user, title: "ssh-rsa Key2", key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQSTWXhJAX/He+nG78MiRRRn7m0Pb0XbcgTxE0etArgoFoh9WtvDf36HG6tOSg/0UUNcp0dICsNAmhBKdncp6cIyPaXJTURPRAGvhI0/VDk4bi27bRnccGbJ/hDaUxZMLhhrzY0r22mjVf8PF6dvv5QUIQVm1/LeaWYsHHvLgiIjwrXirUZPnFrZw6VLREoBKG8uWvfSXw1L5eapmstqfsME8099oi+vWLR8MgEysZQmD28M73fgW4zek6LDQzKQyJx9nB+hJkKUDvcuziZjGmRFlNgSA2mguERwL1OXonD8WYUrBDGKroIvBT39zS5d9tQDnidEJZ9Y8gv5ViYP7x Key2")
|
|
|
|
end
|
|
|
|
|
|
|
|
it do
|
|
|
|
visit admin_users_path
|
|
|
|
|
|
|
|
click_link user.name
|
|
|
|
click_link 'SSH keys'
|
|
|
|
|
|
|
|
expect(page).to have_content(key1.title)
|
|
|
|
expect(page).to have_content(key2.title)
|
|
|
|
|
|
|
|
click_link key2.title
|
|
|
|
|
|
|
|
expect(page).to have_content(key2.title)
|
|
|
|
expect(page).to have_content(key2.key)
|
|
|
|
|
|
|
|
click_link 'Remove'
|
|
|
|
|
|
|
|
expect(page).not_to have_content(key2.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'show user identities' do
|
|
|
|
it 'shows user identities' do
|
|
|
|
visit admin_user_identities_path(user)
|
|
|
|
|
|
|
|
expect(page).to have_content(user.name)
|
|
|
|
expect(page).to have_content('twitter')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'update user identities' do
|
|
|
|
before do
|
2018-02-23 07:10:39 -05:00
|
|
|
allow(Gitlab::Auth::OAuth::Provider).to receive(:providers).and_return([:twitter, :twitter_updated])
|
2017-01-02 06:07:11 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'modifies twitter identity' do
|
|
|
|
visit admin_user_identities_path(user)
|
|
|
|
|
|
|
|
find('.table').find(:link, 'Edit').click
|
|
|
|
fill_in 'identity_extern_uid', with: '654321'
|
|
|
|
select 'twitter_updated', from: 'identity_provider'
|
|
|
|
click_button 'Save changes'
|
|
|
|
|
|
|
|
expect(page).to have_content(user.name)
|
|
|
|
expect(page).to have_content('twitter_updated')
|
|
|
|
expect(page).to have_content('654321')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'remove user with identities' do
|
|
|
|
it 'removes user with twitter identity' do
|
|
|
|
visit admin_user_identities_path(user)
|
|
|
|
|
|
|
|
click_link 'Delete'
|
|
|
|
|
|
|
|
expect(page).to have_content(user.name)
|
|
|
|
expect(page).not_to have_content('twitter')
|
|
|
|
end
|
|
|
|
end
|
2018-06-09 02:45:05 -04:00
|
|
|
|
|
|
|
def check_breadcrumb(content)
|
|
|
|
expect(find('.breadcrumbs-sub-title')).to have_content(content)
|
|
|
|
end
|
2018-11-29 07:00:20 -05:00
|
|
|
|
|
|
|
def sort_by(text)
|
|
|
|
page.within('.user-sort-dropdown') do
|
|
|
|
click_link text
|
|
|
|
end
|
|
|
|
end
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|