5 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
8 lsbdistcodename: 'wheezy',
9 puppetversion: Puppet.version,
15 is_expected.to contain_file('sources.list').that_notifies('Class[Apt::Update]').only_with(ensure: 'file',
16 path: '/etc/apt/sources.list',
20 notify: 'Class[Apt::Update]')
24 is_expected.to contain_file('sources.list.d').that_notifies('Class[Apt::Update]').only_with(ensure: 'directory',
25 path: '/etc/apt/sources.list.d',
31 notify: 'Class[Apt::Update]')
35 is_expected.to contain_file('preferences').that_notifies('Class[Apt::Update]').only_with(ensure: 'file',
36 path: '/etc/apt/preferences',
40 notify: 'Class[Apt::Update]')
44 is_expected.to contain_file('preferences.d').that_notifies('Class[Apt::Update]').only_with(ensure: 'directory',
45 path: '/etc/apt/preferences.d',
51 notify: 'Class[Apt::Update]')
54 it 'lays down /etc/apt/apt.conf.d/15update-stamp' do
55 is_expected.to contain_file('/etc/apt/apt.conf.d/15update-stamp').with(group: 'root',
57 owner: 'root').with_content(%r{APT::Update::Post-Invoke-Success {"touch /var/lib/apt/periodic/update-success-stamp 2>/dev/null || true";};}) # rubocop:disable Metrics/LineLength
61 is_expected.to contain_exec('apt_update').with(refreshonly: 'true')
64 it { is_expected.not_to contain_apt__setting('conf-proxy') }
68 context 'host=localhost' do
69 let(:params) { { proxy: { 'host' => 'localhost' } } }
72 is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
73 %r{Acquire::http::proxy "http://localhost:8080/";},
75 %r{Acquire::https::proxy},
80 context 'host=localhost and port=8180' do
81 let(:params) { { proxy: { 'host' => 'localhost', 'port' => 8180 } } }
84 is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
85 %r{Acquire::http::proxy "http://localhost:8180/";},
87 %r{Acquire::https::proxy},
92 context 'host=localhost and https=true' do
93 let(:params) { { proxy: { 'host' => 'localhost', 'https' => true } } }
96 is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
97 %r{Acquire::http::proxy "http://localhost:8080/";},
99 %r{Acquire::https::proxy "https://localhost:8080/";},
104 context 'host=localhost and direct=true' do
105 let(:params) { { proxy: { 'host' => 'localhost', 'direct' => true } } }
108 is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
109 %r{Acquire::http::proxy "http://localhost:8080/";},
111 %r{Acquire::https::proxy "DIRECT";},
116 context 'host=localhost and https=true and direct=true' do
117 let(:params) { { proxy: { 'host' => 'localhost', 'https' => true, 'direct' => true } } }
120 is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
121 %r{Acquire::http::proxy "http://localhost:8080/";},
123 %r{Acquire::https::proxy "https://localhost:8080/";},
127 is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content(
128 %r{Acquire::http::proxy "http://localhost:8080/";},
130 %r{Acquire::https::proxy "DIRECT";},
135 context 'ensure=absent' do
136 let(:params) { { proxy: { 'ensure' => 'absent' } } }
139 is_expected.to contain_apt__setting('conf-proxy').with(ensure: 'absent',
144 context 'lots of non-defaults' do
147 update: { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 },
148 purge: { 'sources.list' => false, 'sources.list.d' => false,
149 'preferences' => false, 'preferences.d' => false },
154 is_expected.to contain_file('sources.list').with(content: nil)
158 is_expected.to contain_file('sources.list.d').with(purge: false,
163 is_expected.to contain_file('preferences').with(ensure: 'file')
167 is_expected.to contain_file('preferences.d').with(purge: false,
172 is_expected.to contain_exec('apt_update').with(refreshonly: false,
178 context 'with sources defined on valid osfamily' do
180 { os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04' } },
182 lsbdistcodename: 'precise',
184 lsbdistrelease: '12.04',
185 puppetversion: Puppet.version }
189 'debian_unstable' => {
190 'location' => 'http://debian.mirror.iweb.ca/debian/',
191 'release' => 'unstable',
192 'repos' => 'main contrib non-free',
193 'key' => { 'id' => '150C8614919D8446E01E83AF9AA38DCD55BE302B', 'server' => 'subkeys.pgp.net' },
195 'include' => { 'src' => true },
198 'location' => 'http://apt.puppetlabs.com',
200 'key' => { 'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', 'server' => 'pgp.mit.edu' },
206 is_expected.to contain_apt__setting('list-debian_unstable').with(ensure: 'present')
209 it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(%r{^deb http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free$}) }
210 it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(%r{^deb-src http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free$}) }
213 is_expected.to contain_apt__setting('list-puppetlabs').with(ensure: 'present')
216 it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(%r{^deb http://apt.puppetlabs.com precise main$}) }
219 context 'with confs defined on valid osfamily' do
222 os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04.5' } },
224 lsbdistcodename: 'precise',
226 puppetversion: Puppet.version,
241 is_expected.to contain_apt__conf('foo').with(content: 'foo')
245 is_expected.to contain_apt__conf('bar').with(content: 'bar')
249 context 'with keys defined on valid osfamily' do
252 os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04.5' } },
254 lsbdistcodename: 'precise',
256 puppetversion: Puppet.version,
262 'server' => 'subkeys.pgp.net',
265 'server' => 'pgp.mit.edu',
271 is_expected.to contain_apt__key('55BE302B').with(server: 'subkeys.pgp.net')
275 is_expected.to contain_apt__key('EF8D349F').with(server: 'pgp.mit.edu')
279 context 'with ppas defined on valid osfamily' do
282 os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04.5' } },
284 lsbdistcodename: 'precise',
286 lsbdistrelease: '12.04',
287 puppetversion: Puppet.version,
292 'ppa:drizzle-developers/ppa' => {},
293 'ppa:nginx/stable' => {},
297 it { is_expected.to contain_apt__ppa('ppa:drizzle-developers/ppa') }
298 it { is_expected.to contain_apt__ppa('ppa:nginx/stable') }
301 context 'with settings defined on valid osfamily' do
304 os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04.5' } },
306 lsbdistcodename: 'precise',
308 puppetversion: Puppet.version,
313 'conf-banana' => { 'content' => 'banana' },
314 'pref-banana' => { 'content' => 'banana' },
318 it { is_expected.to contain_apt__setting('conf-banana') }
319 it { is_expected.to contain_apt__setting('pref-banana') }
322 context 'with pins defined on valid osfamily' do
325 os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04.5' } },
327 lsbdistcodename: 'precise',
329 puppetversion: Puppet.version,
334 'stable' => { 'priority' => 600, 'order' => 50 },
335 'testing' => { 'priority' => 700, 'order' => 100 },
339 it { is_expected.to contain_apt__pin('stable') }
340 it { is_expected.to contain_apt__pin('testing') }
343 describe 'failing tests' do
344 context "purge['sources.list']=>'banana'" do
345 let(:params) { { purge: { 'sources.list' => 'banana' } } }
350 }.to raise_error(Puppet::Error)
354 context "purge['sources.list.d']=>'banana'" do
355 let(:params) { { purge: { 'sources.list.d' => 'banana' } } }
360 }.to raise_error(Puppet::Error)
364 context "purge['preferences']=>'banana'" do
365 let(:params) { { purge: { 'preferences' => 'banana' } } }
370 }.to raise_error(Puppet::Error)
374 context "purge['preferences.d']=>'banana'" do
375 let(:params) { { purge: { 'preferences.d' => 'banana' } } }
380 }.to raise_error(Puppet::Error)