Comparing changes

v1.0.5 v1.0.6
3 commits 2 files changed

Commits

99fbb0a bump version. mo 2018-02-12 22:04:49
9afceb1 forward the custom time. mo 2018-02-12 22:02:30
Changed files (2)
lib/saml/kit/assertion.rb
@@ -7,11 +7,13 @@ module Saml
       validate :must_match_issuer
       validate :must_be_active_session
       attr_reader :name
+      attr_accessor :occurred_at
 
       def initialize(xml_hash, configuration: Saml::Kit.configuration)
         @name = "Assertion"
         @xml_hash = xml_hash
         @configuration = configuration
+        @occurred_at = Time.current
       end
 
       def issuer
@@ -31,13 +33,13 @@ module Saml
         xml_hash ? Signature.new(xml_hash) : nil
       end
 
-      def expired?(now = Time.current)
+      def expired?(now = occurred_at)
         now > expired_at
       end
 
-      def active?(now = Time.current)
+      def active?(now = occurred_at)
         drifted_started_at = started_at - configuration.clock_drift.to_i.seconds
-        now > drifted_started_at && !expired?
+        now > drifted_started_at && !expired?(now)
       end
 
       def attributes
lib/saml/kit/version.rb
@@ -1,5 +1,5 @@
 module Saml
   module Kit
-    VERSION = "1.0.5"
+    VERSION = "1.0.6"
   end
 end