Skip to content

Commit

Permalink
Merge pull request SAML-Toolkits#638 from agrobbin/metadata-validunti…
Browse files Browse the repository at this point in the history
…l-strftime

Output a valid XML `dateTime` for the `validUntil` metadata property
  • Loading branch information
pitbulk authored Jan 2, 2023
2 parents 74bde7f + 12450cd commit ca2acbf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/onelogin/ruby-saml/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def add_root_element(meta_doc, settings, valid_until, cache_duration)
root = meta_doc.add_element("md:EntityDescriptor", namespaces)
root.attributes["ID"] = OneLogin::RubySaml::Utils.uuid
root.attributes["entityID"] = settings.sp_entity_id if settings.sp_entity_id
root.attributes["validUntil"] = valid_until.strftime('%Y-%m-%dT%H:%M:%S%z') if valid_until
root.attributes["validUntil"] = valid_until.utc.strftime('%Y-%m-%dT%H:%M:%SZ') if valid_until
root.attributes["cacheDuration"] = "PT" + cache_duration.to_s + "S" if cache_duration
root
end
Expand Down
2 changes: 1 addition & 1 deletion test/metadata_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class MetadataTest < Minitest::Test
assert_equal xml_metadata[0..start.length-1],start

doc_metadata = REXML::Document.new(xml_metadata)
assert_equal valid_until.strftime('%Y-%m-%dT%H:%M:%S%z'), REXML::XPath.first(doc_metadata, "//md:EntityDescriptor").attribute("validUntil").value
assert_equal valid_until.strftime('%Y-%m-%dT%H:%M:%SZ'), REXML::XPath.first(doc_metadata, "//md:EntityDescriptor").attribute("validUntil").value
assert_equal "PT604800S", REXML::XPath.first(doc_metadata, "//md:EntityDescriptor").attribute("cacheDuration").value
end

Expand Down

0 comments on commit ca2acbf

Please sign in to comment.