2019-11-04 07:06:19 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-19 09:19:19 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 05:08:32 -04:00
|
|
|
RSpec.describe 'OmniAuth::Strategies::SAML', type: :strategy do
|
2019-08-19 09:19:19 -04:00
|
|
|
let(:idp_sso_target_url) { 'https://login.example.com/idp' }
|
|
|
|
let(:strategy) { [OmniAuth::Strategies::SAML, { idp_sso_target_url: idp_sso_target_url }] }
|
|
|
|
|
|
|
|
describe 'POST /users/auth/saml' do
|
2021-06-29 14:07:04 -04:00
|
|
|
it 'redirects to the provider login page', :aggregate_failures do
|
2019-08-19 09:19:19 -04:00
|
|
|
post '/users/auth/saml'
|
|
|
|
|
2021-06-29 14:07:04 -04:00
|
|
|
expect(last_response.status).to eq(302)
|
|
|
|
expect(last_response.location).to match(/\A#{Regexp.quote(idp_sso_target_url)}/)
|
2019-08-19 09:19:19 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'stores request ID during request phase' do
|
|
|
|
request_id = double
|
2019-11-20 01:06:16 -05:00
|
|
|
allow_next_instance_of(OneLogin::RubySaml::Authrequest) do |instance|
|
|
|
|
allow(instance).to receive(:uuid).and_return(request_id)
|
|
|
|
end
|
2019-08-19 09:19:19 -04:00
|
|
|
|
|
|
|
post '/users/auth/saml'
|
|
|
|
expect(session['last_authn_request_id']).to eq(request_id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|