File: pool_entry_spec.rb

package info (click to toggle)
puppet-agent 8.10.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,404 kB
  • sloc: ruby: 286,820; sh: 492; xml: 116; makefile: 88; cs: 68
file content (49 lines) | stat: -rw-r--r-- 1,228 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require 'spec_helper'

require 'puppet/http'

describe Puppet::HTTP::PoolEntry do
  let(:connection) { double('connection') }
  let(:verifier) { double('verifier') }

  def create_session(connection, expiration_time = nil)
    expiration_time ||= Time.now + 60 * 60

    described_class.new(connection, verifier, expiration_time)
  end

  it 'provides access to its connection' do
    session = create_session(connection)

    expect(session.connection).to eq(connection)
  end

  it 'provides access to its verifier' do
    session = create_session(connection)

    expect(session.verifier).to eq(verifier)
  end

  it 'expires a connection whose expiration time is in the past' do
    now = Time.now
    past = now - 1

    session = create_session(connection, past)
    expect(session.expired?(now)).to be_truthy
  end

  it 'expires a connection whose expiration time is now' do
    now = Time.now

    session = create_session(connection, now)
    expect(session.expired?(now)).to be_truthy
  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)
    expect(session.expired?(now)).to be_falsey
  end
end