@@ -269,15 +269,21 @@ def post_xml(xml = :example_response, opts = {})
269269 end
270270 end
271271
272+ end
273+
274+ describe 'POST /auth/saml/slo' do
275+ before do
276+ saml_options [ :sp_entity_id ] = "https://idp.sso.example.com/metadata/29490"
277+ end
278+
272279 context "when response is a logout response" do
273280 before :each do
274- saml_options [ :sp_entity_id ] = "https://idp.sso.example.com/metadata/29490"
275-
276281 post "/auth/saml/slo" , {
277282 SAMLResponse : load_xml ( :example_logout_response ) ,
278283 RelayState : "https://example.com/" ,
279284 } , "rack.session" => { "saml_transaction_id" => "_3fef1069-d0c6-418a-b68d-6f008a4787e9" }
280285 end
286+
281287 it "should redirect to relaystate" do
282288 expect ( last_response ) . to be_redirect
283289 expect ( last_response . location ) . to match /https:\/ \/ example.com\/ /
@@ -287,10 +293,6 @@ def post_xml(xml = :example_response, opts = {})
287293 context "when request is a logout request" do
288294 subject { post "/auth/saml/slo" , params , "rack.session" => { "saml_uid" => "[email protected] " } } 289295
290- before :each do
291- saml_options [ :sp_entity_id ] = "https://idp.sso.example.com/metadata/29490"
292- end
293-
294296 let ( :params ) do
295297 {
296298 "SAMLRequest" => load_xml ( :example_logout_request ) ,
@@ -331,40 +333,40 @@ def post_xml(xml = :example_response, opts = {})
331333 end
332334 end
333335 end
336+ end
334337
335- context "when sp initiated SLO" do
336- def test_default_relay_state ( static_default_relay_state = nil , &block_default_relay_state )
337- saml_options [ "slo_default_relay_state" ] = static_default_relay_state || block_default_relay_state
338- post "/auth/saml/spslo"
338+ describe 'POST /auth/saml/spslo' do
339+ def test_default_relay_state ( static_default_relay_state = nil , &block_default_relay_state )
340+ saml_options [ "slo_default_relay_state" ] = static_default_relay_state || block_default_relay_state
341+ post "/auth/saml/spslo"
339342
340- expect ( last_response ) . to be_redirect
341- expect ( last_response . location ) . to match /https:\/ \/ idp.sso.example.com\/ signoff\/ 29490/
342- expect ( last_response . location ) . to match /RelayState=https%3A%2F%2Fexample.com%2F/
343- end
343+ expect ( last_response ) . to be_redirect
344+ expect ( last_response . location ) . to match /https:\/ \/ idp.sso.example.com\/ signoff\/ 29490/
345+ expect ( last_response . location ) . to match /RelayState=https%3A%2F%2Fexample.com%2F/
346+ end
344347
345- it "should redirect to logout request" do
346- test_default_relay_state ( "https://example.com/" )
347- end
348+ it "should redirect to logout request" do
349+ test_default_relay_state ( "https://example.com/" )
350+ end
348351
349- it "should redirect to logout request with a block" do
350- test_default_relay_state do
351- "https://example.com/"
352- end
352+ it "should redirect to logout request with a block" do
353+ test_default_relay_state do
354+ "https://example.com/"
353355 end
356+ end
354357
355- it "should redirect to logout request with a block with a request parameter" do
356- test_default_relay_state do |request |
357- "https://example.com/"
358- end
358+ it "should redirect to logout request with a block with a request parameter" do
359+ test_default_relay_state do |request |
360+ "https://example.com/"
359361 end
362+ end
360363
361- it "should give not implemented without an idp_slo_service_url" do
362- saml_options . delete ( :idp_slo_service_url )
363- post "/auth/saml/spslo"
364+ it "should give not implemented without an idp_slo_service_url" do
365+ saml_options . delete ( :idp_slo_service_url )
366+ post "/auth/saml/spslo"
364367
365- expect ( last_response . status ) . to eq 501
366- expect ( last_response . body ) . to match /Not Implemented/
367- end
368+ expect ( last_response . status ) . to eq 501
369+ expect ( last_response . body ) . to match /Not Implemented/
368370 end
369371 end
370372
0 commit comments