Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 33 additions & 31 deletions spec/omniauth/strategies/saml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,21 @@ def post_xml(xml = :example_response, opts = {})
end
end

end

describe 'POST /auth/saml/slo' do
before do
saml_options[:sp_entity_id] = "https://idp.sso.example.com/metadata/29490"
end

context "when response is a logout response" do
before :each do
saml_options[:sp_entity_id] = "https://idp.sso.example.com/metadata/29490"

post "/auth/saml/slo", {
SAMLResponse: load_xml(:example_logout_response),
RelayState: "https://example.com/",
}, "rack.session" => {"saml_transaction_id" => "_3fef1069-d0c6-418a-b68d-6f008a4787e9"}
end

it "should redirect to relaystate" do
expect(last_response).to be_redirect
expect(last_response.location).to match /https:\/\/example.com\//
Expand All @@ -287,10 +293,6 @@ def post_xml(xml = :example_response, opts = {})
context "when request is a logout request" do
subject { post "/auth/saml/slo", params, "rack.session" => { "saml_uid" => "[email protected]" } }

before :each do
saml_options[:sp_entity_id] = "https://idp.sso.example.com/metadata/29490"
end

let(:params) do
{
"SAMLRequest" => load_xml(:example_logout_request),
Expand Down Expand Up @@ -331,40 +333,40 @@ def post_xml(xml = :example_response, opts = {})
end
end
end
end

context "when sp initiated SLO" do
def test_default_relay_state(static_default_relay_state = nil, &block_default_relay_state)
saml_options["slo_default_relay_state"] = static_default_relay_state || block_default_relay_state
post "/auth/saml/spslo"
describe 'POST /auth/saml/spslo' do
def test_default_relay_state(static_default_relay_state = nil, &block_default_relay_state)
saml_options["slo_default_relay_state"] = static_default_relay_state || block_default_relay_state
post "/auth/saml/spslo"

expect(last_response).to be_redirect
expect(last_response.location).to match /https:\/\/idp.sso.example.com\/signoff\/29490/
expect(last_response.location).to match /RelayState=https%3A%2F%2Fexample.com%2F/
end
expect(last_response).to be_redirect
expect(last_response.location).to match /https:\/\/idp.sso.example.com\/signoff\/29490/
expect(last_response.location).to match /RelayState=https%3A%2F%2Fexample.com%2F/
end

it "should redirect to logout request" do
test_default_relay_state("https://example.com/")
end
it "should redirect to logout request" do
test_default_relay_state("https://example.com/")
end

it "should redirect to logout request with a block" do
test_default_relay_state do
"https://example.com/"
end
it "should redirect to logout request with a block" do
test_default_relay_state do
"https://example.com/"
end
end

it "should redirect to logout request with a block with a request parameter" do
test_default_relay_state do |request|
"https://example.com/"
end
it "should redirect to logout request with a block with a request parameter" do
test_default_relay_state do |request|
"https://example.com/"
end
end

it "should give not implemented without an idp_slo_service_url" do
saml_options.delete(:idp_slo_service_url)
post "/auth/saml/spslo"
it "should give not implemented without an idp_slo_service_url" do
saml_options.delete(:idp_slo_service_url)
post "/auth/saml/spslo"

expect(last_response.status).to eq 501
expect(last_response.body).to match /Not Implemented/
end
expect(last_response.status).to eq 501
expect(last_response.body).to match /Not Implemented/
end
end

Expand Down