+ describe 'proxy=' do
+ context 'host=localhost' do
+ let(:params) { { :proxy => { 'host' => 'localhost'} } }
+ it { is_expected.to contain_apt__setting('conf-proxy').with({
+ :priority => '01',
+ }).with_content(
+ /Acquire::http::proxy "http:\/\/localhost:8080\/";/
+ ).without_content(
+ /Acquire::https::proxy/
+ )}
+ end
+
+ context 'host=localhost and port=8180' do
+ let(:params) { { :proxy => { 'host' => 'localhost', 'port' => 8180} } }
+ it { is_expected.to contain_apt__setting('conf-proxy').with({
+ :priority => '01',
+ }).with_content(
+ /Acquire::http::proxy "http:\/\/localhost:8180\/";/
+ ).without_content(
+ /Acquire::https::proxy/
+ )}
+ end
+
+ context 'host=localhost and https=true' do
+ let(:params) { { :proxy => { 'host' => 'localhost', 'https' => true} } }
+ it { is_expected.to contain_apt__setting('conf-proxy').with({
+ :priority => '01',
+ }).with_content(
+ /Acquire::http::proxy "http:\/\/localhost:8080\/";/
+ ).with_content(
+ /Acquire::https::proxy "https:\/\/localhost:8080\/";/
+ )}
+ end
+ end
+ context 'lots of non-defaults' do
+ let :params do
+ {
+ :always_apt_update => true,
+ :purge => { 'sources.list' => false, 'sources.list.d' => false,
+ 'preferences' => false, 'preferences.d' => false, },
+ :update_timeout => '1',
+ :update_tries => '3',
+ }
+ end
+
+ it { is_expected.to contain_file('sources.list').without({
+ :content => "# Repos managed by puppet.\n",
+ })}
+
+ it { is_expected.to contain_file('sources.list.d').with({
+ :purge => false,
+ :recurse => false,
+ })}
+
+ it { is_expected.to contain_file('preferences').with({
+ :ensure => 'file',
+ })}
+
+ it { is_expected.to contain_file('preferences.d').with({
+ :purge => false,
+ :recurse => false,
+ })}
+
+ it { is_expected.to contain_exec('apt_update').with({
+ :refreshonly => 'false',
+ :timeout => '1',
+ :tries => '3',
+ })}
+
+ end
+
+ context 'with sources defined on valid osfamily' do
+ let :facts do
+ { :osfamily => 'Debian',
+ :lsbdistcodename => 'precise',
+ :lsbdistid => 'Debian',
+ }
+ end
+ let(:params) { { :sources => {
+ 'debian_unstable' => {
+ 'location' => 'http://debian.mirror.iweb.ca/debian/',
+ 'release' => 'unstable',
+ 'repos' => 'main contrib non-free',
+ 'key' => '55BE302B',
+ 'key_server' => 'subkeys.pgp.net',
+ 'pin' => '-10',
+ 'include_src' => true,
+ },
+ 'puppetlabs' => {
+ 'location' => 'http://apt.puppetlabs.com',
+ 'repos' => 'main',
+ 'key' => '4BD6EC30',
+ 'key_server' => 'pgp.mit.edu',
+ }
+ } } }
+
+ it {
+ is_expected.to contain_apt__setting('list-debian_unstable').with({
+ :ensure => 'present',
+ })