diff options
-rw-r--r-- | app/helpers/auth_helper.rb | 7 | ||||
-rw-r--r-- | app/views/devise/shared/_omniauth_box.html.haml | 2 | ||||
-rw-r--r-- | qa/qa.rb | 8 | ||||
-rw-r--r-- | qa/qa/page/main/login.rb | 18 | ||||
-rw-r--r-- | qa/qa/runtime/env.rb | 8 | ||||
-rw-r--r-- | qa/qa/scenario/test/integration/oauth.rb | 13 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/1_manage/login/login_via_oauth_spec.rb | 16 | ||||
-rw-r--r-- | qa/qa/vendor/github/page/base.rb | 14 | ||||
-rw-r--r-- | qa/qa/vendor/github/page/login.rb | 23 | ||||
-rw-r--r-- | qa/spec/scenario/test/integration/oauth_spec.rb | 9 |
10 files changed, 111 insertions, 7 deletions
diff --git a/app/helpers/auth_helper.rb b/app/helpers/auth_helper.rb index 01a0fb34484..2b1d6f49878 100644 --- a/app/helpers/auth_helper.rb +++ b/app/helpers/auth_helper.rb @@ -16,6 +16,13 @@ module AuthHelper PROVIDERS_WITH_ICONS.include?(name.to_s) end + def qa_class_for_provider(provider) + { + saml: 'qa-saml-login-button', + github: 'qa-github-login-button' + }[provider.to_sym] + end + def auth_providers Gitlab::Auth::OAuth::Provider.providers end diff --git a/app/views/devise/shared/_omniauth_box.html.haml b/app/views/devise/shared/_omniauth_box.html.haml index 12271ee5adb..1b583ea85d6 100644 --- a/app/views/devise/shared/_omniauth_box.html.haml +++ b/app/views/devise/shared/_omniauth_box.html.haml @@ -5,7 +5,7 @@ .d-flex.justify-content-between.flex-wrap - providers.each do |provider| - has_icon = provider_has_icon?(provider) - = link_to omniauth_authorize_path(:user, provider), method: :post, class: 'btn d-flex align-items-center omniauth-btn text-left oauth-login qa-saml-login-button', id: "oauth-login-#{provider}" do + = link_to omniauth_authorize_path(:user, provider), method: :post, class: "btn d-flex align-items-center omniauth-btn text-left oauth-login #{qa_class_for_provider(provider)}", id: "oauth-login-#{provider}" do - if has_icon = provider_image_tag(provider) %span @@ -99,6 +99,7 @@ module QA autoload :LDAPNoTLS, 'qa/scenario/test/integration/ldap_no_tls' autoload :LDAPTLS, 'qa/scenario/test/integration/ldap_tls' autoload :InstanceSAML, 'qa/scenario/test/integration/instance_saml' + autoload :OAuth, 'qa/scenario/test/integration/oauth' autoload :Kubernetes, 'qa/scenario/test/integration/kubernetes' autoload :Mattermost, 'qa/scenario/test/integration/mattermost' autoload :ObjectStorage, 'qa/scenario/test/integration/object_storage' @@ -342,6 +343,13 @@ module QA autoload :Login, 'qa/vendor/saml_idp/page/login' end end + + module Github + module Page + autoload :Base, 'qa/vendor/github/page/base' + autoload :Login, 'qa/vendor/github/page/login' + end + end end # Classes that provide support to other parts of the framework. diff --git a/qa/qa/page/main/login.rb b/qa/qa/page/main/login.rb index cb83ace20b6..d5377f1d1c1 100644 --- a/qa/qa/page/main/login.rb +++ b/qa/qa/page/main/login.rb @@ -31,8 +31,9 @@ module QA element :register_tab end - view 'app/views/devise/shared/_omniauth_box.html.haml' do + view 'app/helpers/auth_helper.rb' do element :saml_login_button + element :github_login_button end view 'app/views/layouts/devise.html.haml' do @@ -132,6 +133,16 @@ module QA click_element :standard_tab end + def sign_in_with_github + set_initial_password_if_present + click_element :github_login_button + end + + def sign_in_with_saml + set_initial_password_if_present + click_element :saml_login_button + end + private def sign_in_using_ldap_credentials @@ -142,11 +153,6 @@ module QA click_element :sign_in_button end - def sign_in_with_saml - set_initial_password_if_present - click_element :saml_login_button - end - def sign_in_using_gitlab_credentials(user) switch_to_sign_in_tab if has_sign_in_tab? switch_to_standard_tab if has_standard_tab? diff --git a/qa/qa/runtime/env.rb b/qa/qa/runtime/env.rb index 23a2ace6a55..dd0ddbdbd6b 100644 --- a/qa/qa/runtime/env.rb +++ b/qa/qa/runtime/env.rb @@ -100,6 +100,14 @@ module QA ENV['GITLAB_ADMIN_PASSWORD'] end + def github_username + ENV['GITHUB_USERNAME'] + end + + def github_password + ENV['GITHUB_PASSWORD'] + end + def forker? !!(forker_username && forker_password) end diff --git a/qa/qa/scenario/test/integration/oauth.rb b/qa/qa/scenario/test/integration/oauth.rb new file mode 100644 index 00000000000..912156fbc29 --- /dev/null +++ b/qa/qa/scenario/test/integration/oauth.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module QA + module Scenario + module Test + module Integration + class OAuth < Test::Instance::All + tags :oauth + end + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/login_via_oauth_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/login_via_oauth_spec.rb new file mode 100644 index 00000000000..a118176eb8a --- /dev/null +++ b/qa/qa/specs/features/browser_ui/1_manage/login/login_via_oauth_spec.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module QA + context 'Manage', :orchestrated, :oauth do + describe 'OAuth login' do + it 'User logs in to GitLab with GitHub OAuth' do + Runtime::Browser.visit(:gitlab, Page::Main::Login) + + Page::Main::Login.perform(&:sign_in_with_github) + Vendor::Github::Page::Login.perform(&:login) + + expect(page).to have_content('Welcome to GitLab') + end + end + end +end diff --git a/qa/qa/vendor/github/page/base.rb b/qa/qa/vendor/github/page/base.rb new file mode 100644 index 00000000000..3b96180afe9 --- /dev/null +++ b/qa/qa/vendor/github/page/base.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module QA + module Vendor + module Github + module Page + class Base + include Capybara::DSL + include Scenario::Actable + end + end + end + end +end diff --git a/qa/qa/vendor/github/page/login.rb b/qa/qa/vendor/github/page/login.rb new file mode 100644 index 00000000000..6d8f9aa7c12 --- /dev/null +++ b/qa/qa/vendor/github/page/login.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'capybara/dsl' + +module QA + module Vendor + module Github + module Page + class Login < Page::Base + def login + fill_in 'login', with: QA::Runtime::Env.github_username + fill_in 'password', with: QA::Runtime::Env.github_password + click_on 'Sign in' + + unless has_no_text?("Authorize GitLab-OAuth") + click_on 'Authorize gitlab-qa' if has_button?('Authorize gitlab-qa') + end + end + end + end + end + end +end diff --git a/qa/spec/scenario/test/integration/oauth_spec.rb b/qa/spec/scenario/test/integration/oauth_spec.rb new file mode 100644 index 00000000000..c1c320be576 --- /dev/null +++ b/qa/spec/scenario/test/integration/oauth_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +describe QA::Scenario::Test::Integration::OAuth do + context '#perform' do + it_behaves_like 'a QA scenario class' do + let(:tags) { [:oauth] } + end + end +end |