main
1require_relative './principal'
2
3RSpec.describe "Logout Request" do
4 let(:user) { Principal.new(id: SecureRandom.uuid, email: "hello@example.com") }
5
6 it 'produces a SAMLRequest' do
7 xml = Saml::Kit::Metadata.build_xml do |builder|
8 builder.contact_email = 'hi@example.com'
9 builder.organization_name = "Acme, Inc"
10 builder.organization_url = 'https://www.example.com'
11 builder.build_identity_provider do |x|
12 x.add_single_sign_on_service('https://www.example.com/login', binding: :http_post)
13 x.add_single_sign_on_service('https://www.example.com/login', binding: :http_redirect)
14 x.add_single_logout_service('https://www.example.com/logout', binding: :http_post)
15 x.name_id_formats = [ Saml::Kit::Namespaces::EMAIL_ADDRESS ]
16 x.attributes << :id
17 x.attributes << :email
18 end
19 builder.build_service_provider do |x|
20 x.add_assertion_consumer_service('https://www.example.com/consume', binding: :http_post)
21 x.add_single_logout_service('https://www.example.com/logout', binding: :http_post)
22 end
23 end
24
25 sp = Saml::Kit::IdentityProviderMetadata.new(xml)
26 url, saml_params = sp.logout_request_for(user, binding: :http_post)
27 expect(url).to eql("https://www.example.com/logout")
28 expect(saml_params['SAMLRequest']).to be_present
29 end
30end