Commit a1ef1e6
Changed files (1)
spec
requests
spec/requests/sessions_controller_spec.rb
@@ -184,37 +184,40 @@ describe SessionsController do
end
end
- describe "#destroy" do
+ describe "DELETE /session" do
let(:post_binding) { Saml::Kit::Bindings::HttpPost.new(location: "/session/logout") }
- let(:user) { User.create!(email: FFaker::Internet.email, password: FFaker::Internet.password) }
+ let(:user) { create(:user) }
- it 'posts the response back to the service provider' do
- allow(registry).to receive(:metadata_for).with(issuer).and_return(sp_metadata)
- builder = Saml::Kit::LogoutRequest.builder(user) do |x|
- x.issuer = issuer
- x.embed_signature = false
- end
+ context "when receiving a logout request" do
+ before :each do
+ http_login(user)
- http_login(user)
+ allow(registry).to receive(:metadata_for).with(issuer).and_return(sp_metadata)
+ builder = Saml::Kit::LogoutRequest.builder(user) do |x|
+ x.issuer = issuer
+ x.embed_signature = false
+ end
+ url, saml_params = post_binding.serialize(builder)
+ post url, params: saml_params
+ end
- url, saml_params = post_binding.serialize(builder)
- post url, params: saml_params
- expect(response).to have_http_status(:ok)
- expect(response.body).to include("SAMLResponse")
- expect(response.body).to include(sp_metadata.single_logout_service_for(binding: :http_post).location)
+ specify { expect(response).to have_http_status(:ok) }
+ specify { expect(response.body).to include("SAMLResponse") }
+ specify { expect(response.body).to include(sp_metadata.single_logout_service_for(binding: :http_post).location) }
end
- it 'redirects to the login page' do
- allow(registry).to receive(:metadata_for).with(issuer).and_return(sp_metadata)
- authn_request = Saml::Kit::AuthenticationRequest.build
- builder = Saml::Kit::LogoutResponse.builder(authn_request) do |x|
- x.issuer = issuer
- x.embed_signature = false
+ context "when receiving a logout response" do
+ before :each do
+ allow(registry).to receive(:metadata_for).with(issuer).and_return(sp_metadata)
+ builder = Saml::Kit::LogoutResponse.builder(Saml::Kit::AuthenticationRequest.build) do |x|
+ x.issuer = issuer
+ x.embed_signature = false
+ end
+ url, saml_params = post_binding.serialize(builder)
+ post url, params: saml_params
end
- url, saml_params = post_binding.serialize(builder)
- post url, params: saml_params
- expect(response).to redirect_to(new_session_url)
+ specify { expect(response).to redirect_to(new_session_url) }
end
context "when logging out of the IDP only" do