File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed
Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -136,16 +136,19 @@ def create_xml_document(settings)
136136 }
137137
138138 if settings . authn_context != nil
139- authn_contexts = settings . authn_context . is_a? ( Array ) ? settings . authn_context : [ settings . authn_context ]
140- authn_contexts . each do |authn_context |
139+ authn_contexts_class_ref = settings . authn_context . is_a? ( Array ) ? settings . authn_context : [ settings . authn_context ]
140+ authn_contexts_class_ref . each do |authn_context_class_ref |
141141 class_ref = requested_context . add_element "saml:AuthnContextClassRef"
142- class_ref . text = authn_context
142+ class_ref . text = authn_context_class_ref
143143 end
144144 end
145- # add saml:AuthnContextDeclRef element
145+
146146 if settings . authn_context_decl_ref != nil
147- class_ref = requested_context . add_element "saml:AuthnContextDeclRef"
148- class_ref . text = settings . authn_context_decl_ref
147+ authn_contexts_decl_refs = settings . authn_context_decl_ref . is_a? ( Array ) ? settings . authn_context_decl_ref : [ settings . authn_context_decl_ref ]
148+ authn_contexts_decl_refs . each do |authn_context_decl_ref |
149+ decl_ref = requested_context . add_element "saml:AuthnContextDeclRef"
150+ decl_ref . text = authn_context_decl_ref
151+ end
149152 end
150153 end
151154
Original file line number Diff line number Diff line change @@ -285,5 +285,12 @@ class RequestTest < Minitest::Test
285285 auth_doc = OneLogin ::RubySaml ::Authrequest . new . create_authentication_xml_doc ( settings )
286286 assert auth_doc . to_s =~ /<saml:AuthnContextDeclRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport<\/ saml:AuthnContextDeclRef>/
287287 end
288+
289+ it "create multiple saml:AuthnContextDeclRef elements correctly " do
290+ settings . authn_context_decl_ref = [ 'name/password/uri' , 'example/decl/ref' ]
291+ auth_doc = OneLogin ::RubySaml ::Authrequest . new . create_authentication_xml_doc ( settings )
292+ assert auth_doc . to_s =~ /<saml:AuthnContextDeclRef>name\/ password\/ uri<\/ saml:AuthnContextDeclRef>/
293+ assert auth_doc . to_s =~ /<saml:AuthnContextDeclRef>example\/ decl\/ ref<\/ saml:AuthnContextDeclRef>/
294+ end
288295 end
289296end
You can’t perform that action at this time.
0 commit comments