diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 11:33:21 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 11:33:21 +0000 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /spec/features/admin | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) | |
download | gitlab-ce-7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0.tar.gz |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'spec/features/admin')
-rw-r--r-- | spec/features/admin/admin_dev_ops_reports_spec.rb | 4 | ||||
-rw-r--r-- | spec/features/admin/admin_hook_logs_spec.rb | 7 | ||||
-rw-r--r-- | spec/features/admin/admin_hooks_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/admin/admin_mode/workers_spec.rb | 54 | ||||
-rw-r--r-- | spec/features/admin/admin_runners_spec.rb | 15 | ||||
-rw-r--r-- | spec/features/admin/admin_settings_spec.rb | 18 | ||||
-rw-r--r-- | spec/features/admin/admin_users_impersonation_tokens_spec.rb | 31 | ||||
-rw-r--r-- | spec/features/admin/users/user_spec.rb | 79 |
8 files changed, 111 insertions, 99 deletions
diff --git a/spec/features/admin/admin_dev_ops_reports_spec.rb b/spec/features/admin/admin_dev_ops_reports_spec.rb index bf32819cb52..f65862c568f 100644 --- a/spec/features/admin/admin_dev_ops_reports_spec.rb +++ b/spec/features/admin/admin_dev_ops_reports_spec.rb @@ -9,9 +9,9 @@ RSpec.describe 'DevOps Report page', :js do gitlab_enable_admin_mode_sign_in(admin) end - context 'with devops_adoption feature flag disabled' do + context 'without licensed feature devops adoption' do before do - stub_feature_flags(devops_adoption: false) + stub_licensed_features(devops_adoption: false) end it 'has dismissable intro callout' do diff --git a/spec/features/admin/admin_hook_logs_spec.rb b/spec/features/admin/admin_hook_logs_spec.rb index 6caf2b24555..a2ee6343886 100644 --- a/spec/features/admin/admin_hook_logs_spec.rb +++ b/spec/features/admin/admin_hook_logs_spec.rb @@ -3,12 +3,11 @@ require 'spec_helper' RSpec.describe 'Admin::HookLogs' do - let(:project) { create(:project) } - let(:system_hook) { create(:system_hook) } - let(:hook_log) { create(:web_hook_log, web_hook: system_hook, internal_error_message: 'some error') } + let_it_be(:system_hook) { create(:system_hook) } + let_it_be(:hook_log) { create(:web_hook_log, web_hook: system_hook, internal_error_message: 'some error') } + let_it_be(:admin) { create(:admin) } before do - admin = create(:admin) sign_in(admin) gitlab_enable_admin_mode_sign_in(admin) end diff --git a/spec/features/admin/admin_hooks_spec.rb b/spec/features/admin/admin_hooks_spec.rb index 901315752d6..dc5b0ae009e 100644 --- a/spec/features/admin/admin_hooks_spec.rb +++ b/spec/features/admin/admin_hooks_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe 'Admin::Hooks' do include Spec::Support::Helpers::ModalHelpers - let(:user) { create(:admin) } + let_it_be(:user) { create(:admin) } before do sign_in(user) diff --git a/spec/features/admin/admin_mode/workers_spec.rb b/spec/features/admin/admin_mode/workers_spec.rb index 12f5e20e176..8405e9132b6 100644 --- a/spec/features/admin/admin_mode/workers_spec.rb +++ b/spec/features/admin/admin_mode/workers_spec.rb @@ -37,56 +37,26 @@ RSpec.describe 'Admin mode for workers', :request_store do gitlab_enable_admin_mode_sign_in(user) end - context 'when user_destroy_with_limited_execution_time_worker is enabled' do - it 'can delete user', :js do - visit admin_user_path(user_to_delete) - - click_action_in_user_dropdown(user_to_delete.id, 'Delete user') - - page.within '.modal-dialog' do - find("input[name='username']").send_keys(user_to_delete.name) - click_button 'Delete user' - - wait_for_requests - end - - expect(page).to have_content('The user is being deleted.') - - # Perform jobs while logged out so that admin mode is only enabled in job metadata - execute_jobs_signed_out(user) + it 'can delete user', :js do + visit admin_user_path(user_to_delete) - visit admin_user_path(user_to_delete) + click_action_in_user_dropdown(user_to_delete.id, 'Delete user') - expect(find('h1.page-title')).to have_content('(Blocked)') - end - end + page.within '.modal-dialog' do + find("input[name='username']").send_keys(user_to_delete.name) + click_button 'Delete user' - context 'when user_destroy_with_limited_execution_time_worker is disabled' do - before do - stub_feature_flags(user_destroy_with_limited_execution_time_worker: false) + wait_for_requests end - it 'can delete user', :js do - visit admin_user_path(user_to_delete) - - click_action_in_user_dropdown(user_to_delete.id, 'Delete user') - - page.within '.modal-dialog' do - find("input[name='username']").send_keys(user_to_delete.name) - click_button 'Delete user' - - wait_for_requests - end + expect(page).to have_content('The user is being deleted.') - expect(page).to have_content('The user is being deleted.') + # Perform jobs while logged out so that admin mode is only enabled in job metadata + execute_jobs_signed_out(user) - # Perform jobs while logged out so that admin mode is only enabled in job metadata - execute_jobs_signed_out(user) - - visit admin_user_path(user_to_delete) + visit admin_user_path(user_to_delete) - expect(page).to have_title('Not Found') - end + expect(find('h1.page-title')).to have_content('(Blocked)') end end end diff --git a/spec/features/admin/admin_runners_spec.rb b/spec/features/admin/admin_runners_spec.rb index 35e57213bdb..92a3b388994 100644 --- a/spec/features/admin/admin_runners_spec.rb +++ b/spec/features/admin/admin_runners_spec.rb @@ -72,19 +72,8 @@ RSpec.describe "Admin Runners" do expect(page).to have_text "#{s_('Runners|Stale')} 1" end - describe 'delete all runners in bulk' do - before do - check s_('Runners|Select all') - click_button s_('Runners|Delete selected') - - within_modal do - click_on 'Permanently delete 3 runners' - end - - wait_for_requests - end - - it_behaves_like 'shows no runners registered' + it_behaves_like 'deletes runners in bulk' do + let(:runner_count) { '3' } end end diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb index 94c5f397670..72c9053ba49 100644 --- a/spec/features/admin/admin_settings_spec.rb +++ b/spec/features/admin/admin_settings_spec.rb @@ -205,6 +205,22 @@ RSpec.describe 'Admin updates settings' do expect(page).to have_content "Application settings saved successfully" end end + + context 'Email confirmation settings' do + it "is set to 'hard' by default" do + expect(current_settings.email_confirmation_setting).to eq('off') + end + + it 'changes the setting', :js do + page.within('.as-signup') do + choose 'Hard' + click_button 'Save changes' + end + + expect(current_settings.email_confirmation_setting).to eq('hard') + expect(page).to have_content "Application settings saved successfully" + end + end end it 'change Sign-in restrictions' do @@ -304,10 +320,12 @@ RSpec.describe 'Admin updates settings' do it 'changes the setting' do page.within('#js-jira_connect-settings') do fill_in 'Jira Connect Application ID', with: '1234' + fill_in 'Jira Connect Proxy URL', with: 'https://example.com' click_button 'Save changes' end expect(current_settings.jira_connect_application_key).to eq('1234') + expect(current_settings.jira_connect_proxy_url).to eq('https://example.com') expect(page).to have_content "Application settings saved successfully" end end diff --git a/spec/features/admin/admin_users_impersonation_tokens_spec.rb b/spec/features/admin/admin_users_impersonation_tokens_spec.rb index 45dccf9921f..d93dac4834e 100644 --- a/spec/features/admin/admin_users_impersonation_tokens_spec.rb +++ b/spec/features/admin/admin_users_impersonation_tokens_spec.rb @@ -4,18 +4,11 @@ require 'spec_helper' RSpec.describe 'Admin > Users > Impersonation Tokens', :js do include Spec::Support::Helpers::ModalHelpers + include Spec::Support::Helpers::AccessTokenHelpers let(:admin) { create(:admin) } let!(:user) { create(:user) } - def active_impersonation_tokens - find("[data-testid='active-tokens']") - end - - def created_impersonation_token - find_field('new-access-token').value - end - before do sign_in(admin) gitlab_enable_admin_mode_sign_in(admin) @@ -39,12 +32,12 @@ RSpec.describe 'Admin > Users > Impersonation Tokens', :js do click_on "Create impersonation token" - expect(active_impersonation_tokens).to have_text(name) - expect(active_impersonation_tokens).to have_text('in') - expect(active_impersonation_tokens).to have_text('read_api') - expect(active_impersonation_tokens).to have_text('read_user') + expect(active_access_tokens).to have_text(name) + expect(active_access_tokens).to have_text('in') + expect(active_access_tokens).to have_text('read_api') + expect(active_access_tokens).to have_text('read_user') expect(PersonalAccessTokensFinder.new(impersonation: true).execute.count).to equal(1) - expect(created_impersonation_token).not_to be_empty + expect(created_access_token).to match(/[\w-]{20}/) end end @@ -55,16 +48,16 @@ RSpec.describe 'Admin > Users > Impersonation Tokens', :js do it 'only shows impersonation tokens' do visit admin_user_impersonation_tokens_path(user_id: user.username) - expect(active_impersonation_tokens).to have_text(impersonation_token.name) - expect(active_impersonation_tokens).not_to have_text(personal_access_token.name) - expect(active_impersonation_tokens).to have_text('in') + expect(active_access_tokens).to have_text(impersonation_token.name) + expect(active_access_tokens).not_to have_text(personal_access_token.name) + expect(active_access_tokens).to have_text('in') end it 'shows absolute times' do admin.update!(time_display_relative: false) visit admin_user_impersonation_tokens_path(user_id: user.username) - expect(active_impersonation_tokens).to have_text(personal_access_token.expires_at.strftime('%b %-d')) + expect(active_access_tokens).to have_text(personal_access_token.expires_at.strftime('%b %-d')) end end @@ -76,7 +69,7 @@ RSpec.describe 'Admin > Users > Impersonation Tokens', :js do accept_gl_confirm(button_text: 'Revoke') { click_on "Revoke" } - expect(active_impersonation_tokens).to have_text("This user has no active impersonation tokens.") + expect(active_access_tokens).to have_text("This user has no active impersonation tokens.") end it "removes expired tokens from 'active' section" do @@ -84,7 +77,7 @@ RSpec.describe 'Admin > Users > Impersonation Tokens', :js do visit admin_user_impersonation_tokens_path(user_id: user.username) - expect(active_impersonation_tokens).to have_text("This user has no active impersonation tokens.") + expect(active_access_tokens).to have_text("This user has no active impersonation tokens.") end end diff --git a/spec/features/admin/users/user_spec.rb b/spec/features/admin/users/user_spec.rb index 86acf5a05d4..35b5c755b66 100644 --- a/spec/features/admin/users/user_spec.rb +++ b/spec/features/admin/users/user_spec.rb @@ -150,13 +150,32 @@ RSpec.describe 'Admin::Users::User' do context 'before impersonating' do subject { visit admin_user_path(user_to_visit) } - let(:user_to_visit) { another_user } + let_it_be(:user_to_visit) { another_user } + + shared_examples "user that cannot be impersonated" do + it 'disables impersonate button' do + subject + + impersonate_btn = find('[data-testid="impersonate_user_link"]') + + expect(impersonate_btn).not_to be_nil + expect(impersonate_btn['disabled']).not_to be_nil + end + + it "shows tooltip with correct error message" do + subject + + expect(find("span[title='#{impersonation_error_msg}']")).not_to be_nil + end + end context 'for other users' do it 'shows impersonate button for other users' do subject expect(page).to have_content('Impersonate') + impersonate_btn = find('[data-testid="impersonate_user_link"]') + expect(impersonate_btn['disabled']).to be_nil end end @@ -171,15 +190,51 @@ RSpec.describe 'Admin::Users::User' do end context 'for blocked user' do - before do - another_user.block + let_it_be(:blocked_user) { create(:user, :blocked) } + let(:user_to_visit) { blocked_user } + let(:impersonation_error_msg) { _('You cannot impersonate a blocked user') } + + it_behaves_like "user that cannot be impersonated" + end + + context 'for user with expired password' do + let(:user_to_visit) do + another_user.update!(password_expires_at: Time.zone.now - 5.minutes) + another_user end - it 'does not show impersonate button for blocked user' do - subject + let(:impersonation_error_msg) { _("You cannot impersonate a user with an expired password") } - expect(page).not_to have_content('Impersonate') + it_behaves_like "user that cannot be impersonated" + end + + context 'for internal user' do + let_it_be(:internal_user) { create(:user, :bot) } + let(:user_to_visit) { internal_user } + let(:impersonation_error_msg) { _("You cannot impersonate an internal user") } + + it_behaves_like "user that cannot be impersonated" + end + + context 'for locked user' do + let_it_be(:locked_user) { create(:user, :locked) } + let(:user_to_visit) { locked_user } + let(:impersonation_error_msg) { _("You cannot impersonate a user who cannot log in") } + + it_behaves_like "user that cannot be impersonated" + end + + context 'when already impersonating another user' do + let_it_be(:admin_user) { create(:user, :admin) } + let(:impersonation_error_msg) { _("You are already impersonating another user") } + + subject do + visit admin_user_path(admin_user) + click_link 'Impersonate' + visit admin_user_path(another_user) end + + it_behaves_like "user that cannot be impersonated" end context 'when impersonation is disabled' do @@ -216,18 +271,6 @@ RSpec.describe 'Admin::Users::User' do icon = first('[data-testid="incognito-icon"]') expect(icon).not_to be nil end - - context 'a user with an expired password' do - before do - another_user.update!(password_expires_at: Time.zone.now - 5.minutes) - end - - it 'does not redirect to password change page' do - subject - - expect(page).to have_current_path('/') - end - end end context 'ending impersonation' do |