Skip to content

Commit 90d7f66

Browse files
committed
Fix failing tests
* consider nested descriptors * old ruby compatibility
1 parent 7230bc1 commit 90d7f66

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/onelogin/ruby-saml/idp_metadata_parser.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ def idp_name_id_format
228228
# @return [String|nil] 'validUntil' attribute of metadata
229229
#
230230
def valid_until
231-
@idpsso_descriptor.parent&.attributes&.[]('validUntil')
231+
root = @idpsso_descriptor.root
232+
root.attributes['validUntil'] if root && root.attributes
232233
end
233234

234235
# @param binding_priority [Array]

test/idp_metadata_parser_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def initialize; end
278278
assert_equal "https://hello.example.com/access/saml/logout", parsed_metadata[:idp_slo_target_url]
279279
assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified", parsed_metadata[:name_identifier_format]
280280
assert_equal ["AuthToken", "SSOStartPage"], parsed_metadata[:idp_attribute_names]
281-
assert_equal '2014-04-17T18:02:33.910Z', settings.valid_until
281+
assert_equal '2014-04-17T18:02:33.910Z', parsed_metadata[:valid_until]
282282
assert_equal OpenSSL::SSL::VERIFY_PEER, @http.verify_mode
283283
end
284284

@@ -352,10 +352,10 @@ def initialize; end
352352
settings = @idp_metadata_parser.parse_to_array(@idp_metadata)
353353
assert_equal "https://foo.example.com/access/saml/idp.xml", settings.first[:idp_entity_id]
354354
assert_equal "F1:3C:6B:80:90:5A:03:0E:6C:91:3E:5D:15:FA:DD:B0:16:45:48:72", settings.first[:idp_cert_fingerprint]
355-
assert_equal '2014-04-17T18:02:33.910Z', settings.first.valid_until
355+
assert_equal '2014-04-17T18:02:33.910Z', settings.first[:valid_until]
356356
assert_equal "https://bar.example.com/access/saml/idp.xml", settings.last[:idp_entity_id]
357357
assert_equal "08:EB:6E:60:A2:14:4E:89:EC:FA:05:74:9D:72:BF:5D:BE:54:F0:1A", settings.last[:idp_cert_fingerprint]
358-
assert_equal '2014-04-17T18:02:33.910Z', settings.last.valid_until
358+
assert_equal '2014-04-17T18:02:33.910Z', settings.last[:valid_until]
359359
end
360360
end
361361

0 commit comments

Comments
 (0)