+ 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
+
+ context 'ensure=absent' do
+ let(:params) { { :proxy => { 'ensure' => 'absent'} } }
+ it { is_expected.to contain_apt__setting('conf-proxy').with({
+ :ensure => 'absent',
+ :priority => '01',
+ })}
+ end
+ end
+ context 'lots of non-defaults' do
+ let :params do
+ {
+ :update => { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 },
+ :purge => { 'sources.list' => false, 'sources.list.d' => false,
+ 'preferences' => false, 'preferences.d' => false, },
+ }
+ end
+
+ it { is_expected.to contain_file('sources.list').with({
+ :content => nil,
+ })}
+
+ 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
+ { :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '12', :full => '12.04' }},
+ :osfamily => 'Debian',
+ :lsbdistcodename => 'precise',
+ :lsbdistid => 'Ubuntu',
+ :lsbdistrelease => '12.04',
+ :puppetversion => Puppet.version,
+ }
+ end
+ let(:params) { { :sources => {
+ 'debian_unstable' => {
+ 'location' => 'http://debian.mirror.iweb.ca/debian/',
+ 'release' => 'unstable',
+ 'repos' => 'main contrib non-free',
+ 'key' => { 'id' => '150C8614919D8446E01E83AF9AA38DCD55BE302B', 'server' => 'subkeys.pgp.net' },
+ 'pin' => '-10',
+ 'include' => {'src' => true,},
+ },
+ 'puppetlabs' => {
+ 'location' => 'http://apt.puppetlabs.com',
+ 'repos' => 'main',
+ 'key' => { 'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', 'server' => 'pgp.mit.edu' },
+ }
+ } } }
+
+ it {
+ is_expected.to contain_apt__setting('list-debian_unstable').with({
+ :ensure => 'present',
+ })