Sha256: 7378dc1b3cbddc04a8b7d6be80da9902e9552cb0f0c2c89135391809baa38003

Contents?: true

Size: 541 Bytes

Versions: 6

Compression:

Stored size: 541 Bytes

Contents

require 'authmac/timestamp_checker'

module Authmac
  describe TimestampChecker do
    let(:checker) { TimestampChecker.new(15*60, 5*60) }

    it 'returns true if timestamp is recent' do
      expect(checker.validate(Time.now.to_i)).to be_truthy
    end

    it 'returns false if timestamp is too old' do
      expect(checker.validate(Time.now.to_i - (15*60 + 1))).to be_falsey
    end

    it 'returns false if timestamp is too far in the future' do
      expect(checker.validate(Time.now.to_i + (5*60 + 1))).to be_falsey
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
authmac-2.0.2 spec/authmac/timestamp_checker_spec.rb
authmac-2.0.1 spec/authmac/timestamp_checker_spec.rb
authmac-2.0.0 spec/authmac/timestamp_checker_spec.rb
authmac-1.0.4 spec/authmac/timestamp_checker_spec.rb
authmac-1.0.3 spec/authmac/timestamp_checker_spec.rb
authmac-1.0.1 spec/authmac/timestamp_checker_spec.rb