@@ -338,15 +338,32 @@ class RequestTest < Minitest::Test
338338 assert auth_doc . to_s =~ /<saml:AuthnContextDeclRef>example\/ decl\/ ref<\/ saml:AuthnContextDeclRef>/
339339 end
340340
341- it " create samlp:Extensions correctly in AuthRequest" do
341+ it ' create samlp:Extensions correctly in AuthRequest' do
342342 settings . extensions [ :sptype ] = 'public'
343343 settings . extensions [ :requested_attributes ] = [
344- OneLogin ::RubySaml ::RequestedAttribute . new ( { :Name => " http://eidas.europa.eu/attributes/naturalperson/DateOfBirth" } , settings )
344+ OneLogin ::RubySaml ::RequestedAttribute . new ( { :Name => ' http://eidas.europa.eu/attributes/naturalperson/DateOfBirth' } , settings )
345345 ]
346346 auth_doc = OneLogin ::RubySaml ::Authrequest . new . create_authentication_xml_doc ( settings )
347347 assert auth_doc . to_s =~ /<samlp:Extensions/
348348 assert auth_doc . to_s =~ /<eidas:SPType/
349349 assert auth_doc . to_s =~ /<eidas:RequestedAttributes/
350350 end
351+
352+ it 'no extensions in output if no extensions configuration is provided' do
353+ auth_doc = OneLogin ::RubySaml ::Authrequest . new . create_authentication_xml_doc ( settings )
354+ assert_nil auth_doc . to_s =~ /<samlp:Extensions/
355+ assert_nil auth_doc . to_s =~ /<eidas:SPType/
356+ assert_nil auth_doc . to_s =~ /<eidas:RequestedAttributes/
357+ end
358+
359+ it 'only sptype is provided if no requested_attributes configuration' do
360+ settings . extensions [ :sptype ] = 'public'
361+ auth_doc = OneLogin ::RubySaml ::Authrequest . new . create_authentication_xml_doc ( settings )
362+
363+ assert auth_doc . to_s =~ /<samlp:Extensions/
364+ assert auth_doc . to_s =~ /<eidas:SPType/
365+ assert_nil auth_doc . to_s =~ /<eidas:RequestedAttributes/
366+ end
367+
351368 end
352369end
0 commit comments