Commit ef957da

mo <mo@mokhan.ca>
2018-03-16 20:35:06
move .present? to XmlParseable.
1 parent 2fc8182
Changed files (2)
lib/saml/kit/concerns/xml_parseable.rb
@@ -32,6 +32,10 @@ module Saml
         Nokogiri::XML(to_xml, &:noblanks).to_xhtml
       end
 
+      def present?
+        to_nokogiri.present?
+      end
+
       # @!visibility private
       def to_nokogiri
         @to_nokogiri ||= Nokogiri::XML(to_s)
@@ -39,7 +43,7 @@ module Saml
 
       # @!visibility private
       def at_xpath(xpath)
-        return unless to_nokogiri
+        return unless present?
         to_nokogiri.at_xpath(xpath, NAMESPACES)
       end
 
lib/saml/kit/assertion.rb
@@ -72,11 +72,11 @@ module Saml
       end
 
       def started_at
-        parse_date(at_xpath('./saml:Conditions/@NotBefore').try(:value))
+        parse_iso8601(at_xpath('./saml:Conditions/@NotBefore').try(:value))
       end
 
       def expired_at
-        parse_date(at_xpath('./saml:Conditions/@NotOnOrAfter').try(:value))
+        parse_iso8601(at_xpath('./saml:Conditions/@NotOnOrAfter').try(:value))
       end
 
       def audiences
@@ -93,10 +93,6 @@ module Saml
         !@cannot_decrypt
       end
 
-      def present?
-        @node.present?
-      end
-
       def to_s
         @node.to_s
       end
@@ -115,7 +111,7 @@ module Saml
         Saml::Kit.logger.error(error)
       end
 
-      def parse_date(value)
+      def parse_iso8601(value)
         DateTime.parse(value)
       rescue StandardError => error
         Saml::Kit.logger.error(error)