Skip to content

Commit 1d6a0a5

Browse files
Merge pull request #5 from gerardo-navarro/gerardo-navarro-add-tests-for-slo-disabled-scenario
Add Not Implemented handling when SLO disabled
2 parents 4e1733d + d0f418d commit 1d6a0a5

2 files changed

Lines changed: 28 additions & 8 deletions

File tree

lib/omniauth/strategies/saml.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,12 @@ def other_phase
7474
if on_subpath?(:metadata)
7575
other_phase_for_metadata
7676
elsif on_subpath?(:slo)
77+
return slo_disabled_response unless slo_enabled?
78+
7779
other_phase_for_slo
7880
elsif on_subpath?(:spslo)
81+
return slo_disabled_response unless slo_enabled?
82+
7983
other_phase_for_spslo
8084
else
8185
call_app!

spec/omniauth/strategies/saml_spec.rb

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,6 @@ def post_xml(xml = :example_response, opts = {})
276276
end
277277

278278
context "when response is a logout response" do
279-
before do
280-
saml_options[:slo_enabled] = true
281-
end
282-
283279
before :each do
284280
post "/auth/saml/slo", {
285281
SAMLResponse: load_xml(:example_logout_response),
@@ -336,13 +332,21 @@ def post_xml(xml = :example_response, opts = {})
336332
end
337333
end
338334
end
339-
end
340335

341-
describe 'POST /auth/saml/spslo' do
342-
before do
343-
saml_options[:slo_enabled] = true
336+
context "when SLO is disabled" do
337+
before do
338+
saml_options[:slo_enabled] = false
339+
post "/auth/saml/slo"
340+
end
341+
342+
it "should return not implemented" do
343+
expect(last_response.status).to eq 501
344+
expect(last_response.body).to eq "Not Implemented"
345+
end
344346
end
347+
end
345348

349+
describe 'POST /auth/saml/spslo' do
346350
def test_default_relay_state(static_default_relay_state = nil, &block_default_relay_state)
347351
saml_options["slo_default_relay_state"] = static_default_relay_state || block_default_relay_state
348352
post "/auth/saml/spslo"
@@ -375,6 +379,18 @@ def test_default_relay_state(static_default_relay_state = nil, &block_default_re
375379
expect(last_response.status).to eq 501
376380
expect(last_response.body).to match /Not Implemented/
377381
end
382+
383+
context "when SLO is disabled" do
384+
before do
385+
saml_options[:slo_enabled] = false
386+
post "/auth/saml/spslo"
387+
end
388+
389+
it "should return not implemented" do
390+
expect(last_response.status).to eq 501
391+
expect(last_response.body).to eq "Not Implemented"
392+
end
393+
end
378394
end
379395

380396
describe 'POST /auth/saml/metadata' do

0 commit comments

Comments
 (0)