Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorSanad Liaquat <sliaquat@gitlab.com>2019-02-01 08:48:13 +0300
committerSanad Liaquat <sliaquat@gitlab.com>2019-02-01 08:50:24 +0300
commite8f8adfe27505a2a5feb665b680227ba5da07945 (patch)
treeebe54613ef092c69113b4adbcb150a7196d5525e /qa
parentc12863322595e77b03a5a089ff079bf13574a57b (diff)
Add e2e QA test for logging in using GitHub OAuth
Adds the test itself and the vendor page object model for GitHub login pages.
Diffstat (limited to 'qa')
-rw-r--r--qa/qa.rb8
-rw-r--r--qa/qa/page/main/login.rb18
-rw-r--r--qa/qa/runtime/env.rb8
-rw-r--r--qa/qa/scenario/test/integration/oauth.rb13
-rw-r--r--qa/qa/specs/features/browser_ui/1_manage/login/login_via_oauth_spec.rb16
-rw-r--r--qa/qa/vendor/github/page/base.rb14
-rw-r--r--qa/qa/vendor/github/page/login.rb23
-rw-r--r--qa/spec/scenario/test/integration/oauth_spec.rb9
8 files changed, 103 insertions, 6 deletions
diff --git a/qa/qa.rb b/qa/qa.rb
index 355034daec9..c851524bb75 100644
--- a/qa/qa.rb
+++ b/qa/qa.rb
@@ -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