diff options
author | Stig Sandbeck Mathisen <ssm@debian.org> | 2014-09-07 10:14:36 +0200 |
---|---|---|
committer | Stig Sandbeck Mathisen <ssm@debian.org> | 2014-09-07 10:14:36 +0200 |
commit | d4b83be375ac1dead058e091191ee7c7b7c24c8a (patch) | |
tree | dc825687392ae3068de5b764be60c53122d9e02a /spec/unit/network/http/session_spec.rb | |
parent | 229cbb976fe0f70f5f30548b83517b415840f9bb (diff) | |
parent | 1681684857c6e39d60d87b0b3520d8783977ceff (diff) | |
download | puppet-upstream/3.7.0.tar.gz |
Imported Upstream version 3.7.0upstream/3.7.0
Diffstat (limited to 'spec/unit/network/http/session_spec.rb')
-rwxr-xr-x | spec/unit/network/http/session_spec.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/unit/network/http/session_spec.rb b/spec/unit/network/http/session_spec.rb new file mode 100755 index 000000000..4eba67d7d --- /dev/null +++ b/spec/unit/network/http/session_spec.rb @@ -0,0 +1,43 @@ +#! /usr/bin/env ruby +require 'spec_helper' + +require 'puppet/network/http' + +describe Puppet::Network::HTTP::Session do + let(:connection) { stub('connection') } + + def create_session(connection, expiration_time = nil) + expiration_time ||= Time.now + 60 * 60 + + Puppet::Network::HTTP::Session.new(connection, expiration_time) + end + + it 'provides access to its connection' do + session = create_session(connection) + + session.connection.should == connection + end + + it 'expires a connection whose expiration time is in the past' do + now = Time.now + past = now - 1 + + session = create_session(connection, past) + session.expired?(now).should be_true + end + + it 'expires a connection whose expiration time is now' do + now = Time.now + + session = create_session(connection, now) + session.expired?(now).should be_true + end + + it 'does not expire a connection whose expiration time is in the future' do + now = Time.now + future = now + 1 + + session = create_session(connection, future) + session.expired?(now).should be_false + end +end |