Commit f5af8281 authored by James Edwards-Jones's avatar James Edwards-Jones

Adds QA for SAML test button

Checks the user is correctly redirected back to the settings page
and removes hacky RelayState test.
parent 15cd756f
- if saml_provider.persisted?
= saml_link_for_provider 'Test SAML SSO', saml_provider, redirect: request.url
= saml_link_for_provider 'Test SAML SSO', saml_provider, redirect: request.url, html_class: 'btn qa-saml-settings-test-button'
......@@ -34,18 +34,6 @@ module OmniAuth
def self.callback?(env)
env['PATH_INFO'] =~ Gitlab::PathRegex.saml_callback_regex
end
def mock_redirect_relay_state
setup_phase
redirect(request.params[relay_state_key])
end
private
def relay_state_key
options[:idp_sso_target_url_runtime_params].key(:RelayState) || 'RelayState'
end
end
end
end
......@@ -92,18 +92,6 @@ describe 'SAML provider settings' do
expect(current_path).to eq callback_path
end
it 'sets RelayState to redirect back to settings page' do
visit group_saml_providers_path(group)
allow_any_instance_of(OmniAuth::Strategies::GroupSaml).to receive(:mock_request_call) do |group_saml_strategy|
group_saml_strategy.mock_redirect_relay_state
end
test_sso
expect(current_path).to eq group_saml_providers_path(group)
end
end
end
......
......@@ -6,6 +6,7 @@ module QA
module Runtime
autoload :Env, 'qa/ee/runtime/env'
autoload :Geo, 'qa/ee/runtime/geo'
autoload :Saml, 'qa/ee/runtime/saml'
end
module Page
......
......@@ -12,6 +12,10 @@ module QA
element :save_changes_button
end
view 'ee/app/views/groups/saml_providers/_test_button.html.haml' do
element :saml_settings_test_button
end
view 'ee/app/views/groups/saml_providers/_info.html.haml' do
element :user_login_url_link
end
......@@ -28,6 +32,10 @@ module QA
click_element :save_changes_button
end
def click_test_button
click_element :saml_settings_test_button
end
def click_user_login_url_link
click_element :user_login_url_link
end
......
# frozen_string_literal: true
module QA
module EE
module Runtime
module Saml
def self.idp_sso_url
"https://#{QA::Runtime::Env.simple_saml_hostname || 'localhost'}:8443/simplesaml/saml2/idp/SSOService.php"
end
def self.idp_certificate_fingerprint
'119b9e027959cdb7c662cfd075d9e2ef384e445f'
end
end
end
end
end
......@@ -3,18 +3,20 @@
module QA
context :manage, :orchestrated, :group_saml do
describe 'Group SAML SSO' do
it 'User logs in to group with SAML SSO' do
before do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
Factory::Resource::Sandbox.fabricate!
end
it 'User logs in to group with SAML SSO' do
EE::Page::Group::Menu.act { go_to_saml_sso_group_settings }
EE::Page::Group::Settings::SamlSSO.act do
set_id_provider_sso_url("https://#{QA::Runtime::Env.simple_saml_hostname || 'localhost'}:8443/simplesaml/saml2/idp/SSOService.php")
set_cert_fingerprint('119b9e027959cdb7c662cfd075d9e2ef384e445f')
set_id_provider_sso_url(QA::EE::Runtime::Saml.idp_sso_url)
set_cert_fingerprint(QA::EE::Runtime::Saml.idp_certificate_fingerprint)
click_save_changes
click_user_login_url_link
end
......@@ -33,6 +35,22 @@ module QA
expect(page).to have_content("Signed in with SAML for #{Runtime::Env.sandbox_name}")
end
it 'Lets group admin test settings' do
EE::Page::Group::Menu.act { go_to_saml_sso_group_settings }
EE::Page::Group::Settings::SamlSSO.act do
set_id_provider_sso_url(QA::EE::Runtime::Saml.idp_sso_url)
set_cert_fingerprint(QA::EE::Runtime::Saml.idp_certificate_fingerprint)
click_save_changes
click_test_button
end
Vendor::SAMLIdp::Page::Login.act { login }
expect(page).to have_content("Test SAML SSO")
end
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