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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
#! /usr/bin/env ruby
require 'spec_helper'
require 'puppet/network/http'
describe Puppet::Network::HTTP::Factory do
before :each do
Puppet::SSL::Key.indirection.terminus_class = :memory
Puppet::SSL::CertificateRequest.indirection.terminus_class = :memory
end
let(:site) { Puppet::Network::HTTP::Site.new('https', 'www.example.com', 443) }
def create_connection(site)
factory = Puppet::Network::HTTP::Factory.new
factory.create_connection(site)
end
it 'creates a connection for the site' do
conn = create_connection(site)
expect(conn.use_ssl?).to be_true
expect(conn.address).to eq(site.host)
expect(conn.port).to eq(site.port)
end
it 'creates a connection that has not yet been started' do
conn = create_connection(site)
expect(conn).to_not be_started
end
it 'creates a connection supporting at least HTTP 1.1' do
conn = create_connection(site)
expect(any_of(conn.class.version_1_1?, conn.class.version_1_1?)).to be_true
end
context "proxy settings" do
let(:proxy_host) { 'myhost' }
let(:proxy_port) { 432 }
it "should not set a proxy if the value is 'none'" do
Puppet[:http_proxy_host] = 'none'
conn = create_connection(site)
expect(conn.proxy_address).to be_nil
end
it 'sets proxy_address' do
Puppet[:http_proxy_host] = proxy_host
conn = create_connection(site)
expect(conn.proxy_address).to eq(proxy_host)
end
it 'sets proxy address and port' do
Puppet[:http_proxy_host] = proxy_host
Puppet[:http_proxy_port] = proxy_port
conn = create_connection(site)
expect(conn.proxy_port).to eq(proxy_port)
end
context 'socket timeouts' do
let(:timeout) { 5 }
it 'sets open timeout' do
Puppet[:configtimeout] = timeout
conn = create_connection(site)
expect(conn.open_timeout).to eq(timeout)
end
it 'sets read timeout' do
Puppet[:configtimeout] = timeout
conn = create_connection(site)
expect(conn.read_timeout).to eq(timeout)
end
end
end
end
|