Commit 1978e6d3 authored by James Edwards-Jones's avatar James Edwards-Jones

Adds Group SAML test button

Makes it easier to try out different configurations
while testing Group SAML settings.
parent 0ec8038a
......@@ -26,3 +26,5 @@
.form-actions
= f.submit _("Save changes"), class: 'btn btn-success qa-save-changes-button'
.pull-right
= render 'test_button', saml_provider: @saml_provider
- if saml_provider.persisted?
= saml_link_for_provider 'Test SAML SSO', saml_provider, redirect: request.url
---
title: Add test button to Group SAML settings
merge_request: 5622
author:
type: changed
......@@ -34,6 +34,18 @@ 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
......@@ -17,6 +17,10 @@ describe 'SAML provider settings' do
click_button('Save changes')
end
def test_sso
click_link('Test SAML SSO')
end
def stub_saml_config
stub_licensed_features(group_saml: true)
allow(Devise).to receive(:omniauth_providers).and_return(%i(group_saml))
......@@ -72,6 +76,35 @@ describe 'SAML provider settings' do
expect(login_url).to end_with "/groups/#{group.full_path}/-/saml/sso"
end
end
describe 'test button' do
let!(:saml_provider) { create(:saml_provider, group: group) }
before do
sign_in(user)
allow_any_instance_of(OmniAuth::Strategies::GroupSaml).to receive(:callback_url) { callback_path }
end
it 'POSTs to the SSO path for the group' do
visit group_saml_providers_path(group)
test_sso
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
describe '#sso' do
......
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