Commit 5b6b2871 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'qa-257-instance-wide-saml-sso' into 'master'

Instance SAML SSO e2e test

Closes gitlab-qa#257

See merge request gitlab-org/gitlab-ce!22271
parents 681df101 154ce29d
...@@ -84,6 +84,7 @@ Naming/FileName: ...@@ -84,6 +84,7 @@ Naming/FileName:
- EE - EE
- JSON - JSON
- LDAP - LDAP
- SAML
- IO - IO
- HMAC - HMAC
- QA - QA
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
.d-flex.justify-content-between.flex-wrap .d-flex.justify-content-between.flex-wrap
- providers.each do |provider| - providers.each do |provider|
- has_icon = provider_has_icon?(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', 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-saml-login-button', id: "oauth-login-#{provider}" do
- if has_icon - if has_icon
= provider_image_tag(provider) = provider_image_tag(provider)
%span %span
......
...@@ -97,6 +97,7 @@ module QA ...@@ -97,6 +97,7 @@ module QA
module Integration module Integration
autoload :Github, 'qa/scenario/test/integration/github' autoload :Github, 'qa/scenario/test/integration/github'
autoload :LDAP, 'qa/scenario/test/integration/ldap' autoload :LDAP, 'qa/scenario/test/integration/ldap'
autoload :InstanceSAML, 'qa/scenario/test/integration/instance_saml'
autoload :Kubernetes, 'qa/scenario/test/integration/kubernetes' autoload :Kubernetes, 'qa/scenario/test/integration/kubernetes'
autoload :Mattermost, 'qa/scenario/test/integration/mattermost' autoload :Mattermost, 'qa/scenario/test/integration/mattermost'
autoload :ObjectStorage, 'qa/scenario/test/integration/object_storage' autoload :ObjectStorage, 'qa/scenario/test/integration/object_storage'
...@@ -302,6 +303,18 @@ module QA ...@@ -302,6 +303,18 @@ module QA
autoload :Config, 'qa/specs/config' autoload :Config, 'qa/specs/config'
autoload :Runner, 'qa/specs/runner' autoload :Runner, 'qa/specs/runner'
end end
##
# Classes that describe the structure of vendor/third party application pages
#
module Vendor
module SAMLIdp
module Page
autoload :Base, 'qa/vendor/saml_idp/page/base'
autoload :Login, 'qa/vendor/saml_idp/page/login'
end
end
end
end end
QA::Runtime::Release.extend_autoloads! QA::Runtime::Release.extend_autoloads!
...@@ -31,6 +31,10 @@ module QA ...@@ -31,6 +31,10 @@ module QA
element :register_tab element :register_tab
end end
view 'app/views/devise/shared/_omniauth_box.html.haml' do
element :saml_login_button
end
def initialize def initialize
# The login page is usually the entry point for all the scenarios so # The login page is usually the entry point for all the scenarios so
# we need to wait for the instance to start. That said, in some cases # we need to wait for the instance to start. That said, in some cases
...@@ -130,6 +134,11 @@ module QA ...@@ -130,6 +134,11 @@ module QA
click_element :sign_in_button click_element :sign_in_button
end end
def sign_in_with_saml
set_initial_password_if_present
click_element :saml_login_button
end
def sign_in_using_gitlab_credentials(user) def sign_in_using_gitlab_credentials(user)
switch_to_sign_in_tab if has_sign_in_tab? switch_to_sign_in_tab if has_sign_in_tab?
switch_to_standard_tab if has_standard_tab? switch_to_standard_tab if has_standard_tab?
......
...@@ -51,6 +51,10 @@ module QA ...@@ -51,6 +51,10 @@ module QA
} }
) )
if QA::Runtime::Env.accept_insecure_certs?
capabilities['acceptInsecureCerts'] = true
end
options = Selenium::WebDriver::Chrome::Options.new options = Selenium::WebDriver::Chrome::Options.new
options.add_argument("window-size=1240,1680") options.add_argument("window-size=1240,1680")
......
...@@ -8,6 +8,10 @@ module QA ...@@ -8,6 +8,10 @@ module QA
enabled?(ENV['CHROME_HEADLESS']) enabled?(ENV['CHROME_HEADLESS'])
end end
def accept_insecure_certs?
enabled?(ENV['ACCEPT_INSECURE_CERTS'])
end
def running_in_ci? def running_in_ci?
ENV['CI'] || ENV['CI_SERVER'] ENV['CI'] || ENV['CI_SERVER']
end end
......
# frozen_string_literal: true
module QA
module Scenario
module Test
module Integration
class InstanceSAML < Test::Instance::All
tags :instance_saml
end
end
end
end
end
# frozen_string_literal: true
module QA
context :manage, :orchestrated, :instance_saml do
describe 'Instance wide SAML SSO' do
it 'User logs in to gitlab with SAML SSO' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_with_saml }
Vendor::SAMLIdp::Page::Login.act { login }
expect(page).to have_content('Welcome to GitLab')
end
end
end
end
# frozen_string_literal: true
module QA
module Vendor
module SAMLIdp
module Page
class Base
include Capybara::DSL
include Scenario::Actable
end
end
end
end
end
# frozen_string_literal: true
require 'capybara/dsl'
module QA
module Vendor
module SAMLIdp
module Page
class Login < Page::Base
def login
fill_in 'username', with: 'user1'
fill_in 'password', with: 'user1pass'
click_on 'Login'
end
end
end
end
end
end
# frozen_string_literal: true
describe QA::Scenario::Test::Integration::InstanceSAML do
context '#perform' do
it_behaves_like 'a QA scenario class' do
let(:tags) { [:instance_saml] }
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment