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