diff options
-rw-r--r-- | qa/README.md | 8 | ||||
-rw-r--r-- | qa/qa/page/main/login.rb | 13 | ||||
-rw-r--r-- | qa/qa/runtime/env.rb | 22 | ||||
-rw-r--r-- | qa/qa/runtime/user.rb | 18 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/1_manage/login/log_into_gitlab_via_ldap_spec.rb | 4 | ||||
-rw-r--r-- | qa/spec/runtime/env_spec.rb | 21 |
6 files changed, 37 insertions, 49 deletions
diff --git a/qa/README.md b/qa/README.md index f8a5c00efd4..746bd5cf94b 100644 --- a/qa/README.md +++ b/qa/README.md @@ -78,13 +78,7 @@ If your user doesn't have permission to default sandbox group GITLAB_USERNAME=jsmith GITLAB_PASSWORD=password GITLAB_SANDBOX_NAME=jsmith-qa-sandbox bin/qa Test::Instance::All https://gitlab.example.com ``` -In addition, the `GITLAB_USER_TYPE` can be set to "ldap" to sign in as an LDAP user: - -``` -GITLAB_USER_TYPE=ldap GITLAB_USERNAME=jsmith GITLAB_PASSWORD=password GITLAB_SANDBOX_NAME=jsmith-qa-sandbox bin/qa Test::Instance::All https://gitlab.example.com -``` - -All [supported environment variables are here](https://gitlab.com/gitlab-org/gitlab-qa#supported-environment-variables). +All [supported environment variables are here](https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/what_tests_can_be_run.md#supported-environment-variables). ### Building a Docker image to test diff --git a/qa/qa/page/main/login.rb b/qa/qa/page/main/login.rb index 3fb5e6cbdc4..08cf8da34fd 100644 --- a/qa/qa/page/main/login.rb +++ b/qa/qa/page/main/login.rb @@ -59,6 +59,19 @@ module QA Page::Menu::Main.act { has_personal_area? } end + def sign_in_using_admin_credentials + admin = QA::Factory::Resource::User.new.tap do |user| + user.username = QA::Runtime::User.admin_username + user.password = QA::Runtime::User.admin_password + end + + using_wait_time 0 do + sign_in_using_gitlab_credentials(admin) + end + + Page::Menu::Main.act { has_personal_area? } + end + def self.path '/users/sign_in' end diff --git a/qa/qa/runtime/env.rb b/qa/qa/runtime/env.rb index 841c959045f..27ba915961d 100644 --- a/qa/qa/runtime/env.rb +++ b/qa/qa/runtime/env.rb @@ -3,8 +3,6 @@ module QA module Env extend self - attr_writer :user_type - # set to 'false' to have Chrome run visibly instead of headless def chrome_headless? (ENV['CHROME_HEADLESS'] =~ /^(false|no|0)$/i) != 0 @@ -19,18 +17,6 @@ module QA ENV['PERSONAL_ACCESS_TOKEN'] end - # By default, "standard" denotes a standard GitLab user login. - # Set this to "ldap" if the user should be logged in via LDAP. - def user_type - return @user_type if defined?(@user_type) # rubocop:disable Gitlab/ModuleWithInstanceVariables - - ENV.fetch('GITLAB_USER_TYPE', 'standard').tap do |type| - unless %w(ldap standard).include?(type) - raise ArgumentError.new("Invalid user type '#{type}': must be 'ldap' or 'standard'") - end - end - end - def user_username ENV['GITLAB_USERNAME'] end @@ -39,6 +25,14 @@ module QA ENV['GITLAB_PASSWORD'] end + def admin_username + ENV['GITLAB_ADMIN_USERNAME'] + end + + def admin_password + ENV['GITLAB_ADMIN_PASSWORD'] + end + def forker? forker_username && forker_password end diff --git a/qa/qa/runtime/user.rb b/qa/qa/runtime/user.rb index b016777c987..5eb7a210fce 100644 --- a/qa/qa/runtime/user.rb +++ b/qa/qa/runtime/user.rb @@ -7,25 +7,37 @@ module QA 'root' end + def default_password + '5iveL!fe' + end + def username Runtime::Env.user_username || default_username end def password - Runtime::Env.user_password || '5iveL!fe' + Runtime::Env.user_password || default_password end def ldap_user? - Runtime::Env.user_type == 'ldap' + Runtime::Env.ldap_username && Runtime::Env.ldap_password end def ldap_username - Runtime::Env.ldap_username || name + Runtime::Env.ldap_username || username end def ldap_password Runtime::Env.ldap_password || password end + + def admin_username + Runtime::Env.admin_username || default_username + end + + def admin_password + Runtime::Env.admin_password || default_password + end end end end diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/log_into_gitlab_via_ldap_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/log_into_gitlab_via_ldap_spec.rb index c9958917be9..c296296def6 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/login/log_into_gitlab_via_ldap_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/login/log_into_gitlab_via_ldap_spec.rb @@ -3,10 +3,6 @@ module QA context :manage, :orchestrated, :ldap do describe 'LDAP login' do - before do - Runtime::Env.user_type = 'ldap' - end - it 'user logs into GitLab using LDAP credentials' do Runtime::Browser.visit(:gitlab, Page::Main::Login) Page::Main::Login.act { sign_in_using_credentials } diff --git a/qa/spec/runtime/env_spec.rb b/qa/spec/runtime/env_spec.rb index 5493a33cd2a..d889d185a45 100644 --- a/qa/spec/runtime/env_spec.rb +++ b/qa/spec/runtime/env_spec.rb @@ -56,27 +56,6 @@ describe QA::Runtime::Env do end end - describe '.user_type' do - it 'returns standard if not defined' do - expect(described_class.user_type).to eq('standard') - end - - it 'returns standard as defined' do - stub_env('GITLAB_USER_TYPE', 'standard') - expect(described_class.user_type).to eq('standard') - end - - it 'returns ldap as defined' do - stub_env('GITLAB_USER_TYPE', 'ldap') - expect(described_class.user_type).to eq('ldap') - end - - it 'returns an error if invalid user type' do - stub_env('GITLAB_USER_TYPE', 'foobar') - expect { described_class.user_type }.to raise_error(ArgumentError) - end - end - describe '.forker?' do it 'returns false if no forker credentials are defined' do expect(described_class).not_to be_forker |