diff options
Diffstat (limited to 'qa/qa/specs/features/browser_ui/1_manage/login')
5 files changed, 113 insertions, 37 deletions
diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/2fa_recovery_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/2fa_recovery_spec.rb index 163469e1e88..e38a9f47bd6 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/login/2fa_recovery_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/login/2fa_recovery_spec.rb @@ -81,7 +81,7 @@ module QA recovery_code = two_fa_auth.recovery_codes.sample - two_fa_auth.click_proceed_button + two_fa_auth.click_copy_and_proceed recovery_code end diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/2fa_ssh_recovery_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/2fa_ssh_recovery_spec.rb index 7f3c3049499..f6d2492c011 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/login/2fa_ssh_recovery_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/login/2fa_ssh_recovery_spec.rb @@ -56,7 +56,7 @@ module QA otp = QA::Support::OTP.new(two_fa_auth.otp_secret_content) two_fa_auth.set_pin_code(otp.fresh_otp) two_fa_auth.click_register_2fa_app_button - two_fa_auth.click_proceed_button + two_fa_auth.click_copy_and_proceed end end end diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/log_in_with_2fa_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/log_in_with_2fa_spec.rb index 12a1b419f8b..f81dfe4b5c8 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/login/log_in_with_2fa_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/login/log_in_with_2fa_spec.rb @@ -99,9 +99,9 @@ module QA two_fa_auth.set_pin_code(@otp.fresh_otp) two_fa_auth.click_register_2fa_app_button - expect(two_fa_auth).to have_text('Congratulations! You have enabled Two-factor Authentication!') + two_fa_auth.click_copy_and_proceed - two_fa_auth.click_proceed_button + expect(two_fa_auth).to have_text('Congratulations! You have enabled Two-factor Authentication!') end end end diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/login_via_instance_wide_saml_sso_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/login_via_instance_wide_saml_sso_spec.rb index e4ac59cf5e0..6cd486bc84b 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/login/login_via_instance_wide_saml_sso_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/login/login_via_instance_wide_saml_sso_spec.rb @@ -3,7 +3,7 @@ module QA RSpec.describe 'Manage', :orchestrated, :instance_saml do describe 'Instance wide SAML SSO' do - it 'User logs in to gitlab with SAML SSO', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/671' do + it 'user logs in to gitlab with SAML SSO', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/671' do Runtime::Browser.visit(:gitlab, Page::Main::Login) Page::Main::Login.perform(&:sign_in_with_saml) diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb index 2bb03b6154f..d58857f6da2 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb @@ -26,7 +26,7 @@ module QA ldap_username = Runtime::Env.ldap_username Runtime::Env.ldap_username = nil - disable_require_admin_approval_after_user_signup + set_require_admin_approval_after_user_signup_via_api(false) Runtime::Env.ldap_username = ldap_username end @@ -39,60 +39,136 @@ module QA end describe 'standard', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/936' do - before(:all) do - disable_require_admin_approval_after_user_signup - end + context 'when admin approval is not required' do + before(:all) do + set_require_admin_approval_after_user_signup_via_api(false) + end - it_behaves_like 'registration and login' + it_behaves_like 'registration and login' + + context 'when user account is deleted' do + let(:user) do + Resource::User.fabricate_via_api! do |resource| + resource.api_client = admin_api_client + end + end + + before do + # Use the UI instead of API to delete the account since + # this is the only test that exercise this UI. + # Other tests should use the API for this purpose. + Flow::Login.sign_in(as: user) + Page::Main::Menu.perform(&:click_settings_link) + Page::Profile::Menu.perform(&:click_account) + Page::Profile::Accounts::Show.perform do |show| + show.delete_account(user.password) + end + end + + it 'allows recreating with same credentials', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/937' do + expect(Page::Main::Menu.perform(&:signed_in?)).to be_falsy + + Flow::Login.sign_in(as: user, skip_page_validation: true) - context 'when user account is deleted' do - let(:user) do - Resource::User.fabricate_via_api! do |resource| - resource.api_client = admin_api_client + expect(page).to have_text("Invalid Login or password") + + @recreated_user = Resource::User.fabricate_via_browser_ui! do |resource| + resource.name = user.name + resource.username = user.username + resource.email = user.email + end + + expect(Page::Main::Menu.perform(&:signed_in?)).to be_truthy + end + + after do + @recreated_user.remove_via_api! + end + + def admin_api_client + @admin_api_client ||= Runtime::API::Client.as_admin end end + end + + context 'when admin approval is required' do + let(:signed_up_waiting_approval_text) { 'You have signed up successfully. However, we could not sign you in because your account is awaiting approval from your GitLab administrator.' } + let(:pending_approval_blocked_text) { 'Your account is pending approval from your GitLab administrator and hence blocked. Please contact your GitLab administrator if you think this is an error.' } before do - # Use the UI instead of API to delete the account since - # this is the only test that exercise this UI. - # Other tests should use the API for this purpose. - Flow::Login.sign_in(as: user) - Page::Main::Menu.perform(&:click_settings_link) - Page::Profile::Menu.perform(&:click_account) - Page::Profile::Accounts::Show.perform do |show| - show.delete_account(user.password) + enable_require_admin_approval_after_user_signup_via_ui + + @user = Resource::User.fabricate_via_browser_ui! do |user| + user.expect_fabrication_success = false end end - it 'allows recreating with same credentials', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/937' do - expect(Page::Main::Menu.perform(&:signed_in?)).to be_falsy + it 'allows user login after approval', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1076' do + expect(page).to have_text(signed_up_waiting_approval_text) - Flow::Login.sign_in(as: user, skip_page_validation: true) + Flow::Login.sign_in(as: @user, skip_page_validation: true) - expect(page).to have_text("Invalid Login or password") + expect(page).to have_text(pending_approval_blocked_text) - @recreated_user = Resource::User.fabricate_via_browser_ui! do |resource| - resource.name = user.name - resource.username = user.username - resource.email = user.email - end + approve_user(@user) + + Flow::Login.sign_in(as: @user, skip_page_validation: true) + + Page::Registration::Welcome.perform(&:click_get_started_button_if_available) - expect(Page::Main::Menu.perform(&:signed_in?)).to be_truthy + Page::Main::Menu.perform do |menu| + expect(menu).to have_personal_area + end end after do - @recreated_user.remove_via_api! + set_require_admin_approval_after_user_signup_via_api(false) + @user.remove_via_api! if @user + end + end + end + + def approve_user(user) + Flow::Login.while_signed_in_as_admin do + Page::Main::Menu.perform(&:go_to_admin_area) + Page::Admin::Menu.perform(&:go_to_users_overview) + Page::Admin::Overview::Users::Index.perform do |index| + index.click_pending_approval_tab + index.search_user(user.username) + index.click_user(user.username) end - def admin_api_client - @admin_api_client ||= Runtime::API::Client.as_admin + Page::Admin::Overview::Users::Show.perform do |show| + user.id = show.user_id.to_i + show.approve_user end + + expect(page).to have_text('Successfully approved') end end - def disable_require_admin_approval_after_user_signup - Runtime::ApplicationSettings.set_application_settings(require_admin_approval_after_user_signup: false) + def set_require_admin_approval_after_user_signup_via_api(enable_or_disable) + return if Runtime::ApplicationSettings.get_application_settings[:require_admin_approval_after_user_signup] == enable_or_disable + + Runtime::ApplicationSettings.set_application_settings(require_admin_approval_after_user_signup: enable_or_disable) + sleep 10 # It takes a moment for the setting to come into effect end + + def enable_require_admin_approval_after_user_signup_via_ui + unless Runtime::ApplicationSettings.get_application_settings[:require_admin_approval_after_user_signup] + Flow::Login.while_signed_in_as_admin do + Page::Main::Menu.perform(&:go_to_admin_area) + QA::Page::Admin::Menu.perform(&:go_to_general_settings) + Page::Admin::Settings::General.perform do |setting| + setting.expand_sign_up_restrictions do |settings| + settings.require_admin_approval_after_user_signup + end + end + end + + sleep 10 # It takes a moment for the setting to come into effect + end + end end end |