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(/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 /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 /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 /Acquire::http::proxy "http:\/\/localhost:8080\/";/,
99 /Acquire::https::proxy "https:\/\/localhost:8080\/";/,
104 context 'ensure=absent' do
105 let(:params) { { proxy: { 'ensure' => 'absent' } } }
108 is_expected.to contain_apt__setting('conf-proxy').with(ensure: 'absent',
113 context 'lots of non-defaults' do
116 update: { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 },
117 purge: { 'sources.list' => false, 'sources.list.d' => false,
118 'preferences' => false, 'preferences.d' => false },
123 is_expected.to contain_file('sources.list').with(content: nil)
127 is_expected.to contain_file('sources.list.d').with(purge: false,
132 is_expected.to contain_file('preferences').with(ensure: 'file')
136 is_expected.to contain_file('preferences.d').with(purge: false,
141 is_expected.to contain_exec('apt_update').with(refreshonly: false,
147 context 'with sources defined on valid osfamily' do
149 { os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04' } },
151 lsbdistcodename: 'precise',
153 lsbdistrelease: '12.04',
154 puppetversion: Puppet.version }
158 'debian_unstable' => {
159 'location' => 'http://debian.mirror.iweb.ca/debian/',
160 'release' => 'unstable',
161 'repos' => 'main contrib non-free',
162 'key' => { 'id' => '150C8614919D8446E01E83AF9AA38DCD55BE302B', 'server' => 'subkeys.pgp.net' },
164 'include' => { 'src' => true },
167 'location' => 'http://apt.puppetlabs.com',
169 'key' => { 'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', 'server' => 'pgp.mit.edu' },
175 is_expected.to contain_apt__setting('list-debian_unstable').with(ensure: 'present')
178 it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(/^deb http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
179 it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(/^deb-src http:\/\/debian.mirror.iweb.ca\/debian\/ unstable main contrib non-free$/) }
182 is_expected.to contain_apt__setting('list-puppetlabs').with(ensure: 'present')
185 it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) }
188 context 'with confs defined on valid osfamily' do
191 os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04.5' } },
193 lsbdistcodename: 'precise',
195 puppetversion: Puppet.version,
210 is_expected.to contain_apt__conf('foo').with(content: 'foo')
214 is_expected.to contain_apt__conf('bar').with(content: 'bar')
218 context 'with keys defined on valid osfamily' do
221 os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04.5' } },
223 lsbdistcodename: 'precise',
225 puppetversion: Puppet.version,
231 'server' => 'subkeys.pgp.net',
234 'server' => 'pgp.mit.edu',
240 is_expected.to contain_apt__key('55BE302B').with(server: 'subkeys.pgp.net')
244 is_expected.to contain_apt__key('EF8D349F').with(server: 'pgp.mit.edu')
248 context 'with ppas defined on valid osfamily' do
251 os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04.5' } },
253 lsbdistcodename: 'precise',
255 lsbdistrelease: '12.04',
256 puppetversion: Puppet.version,
261 'ppa:drizzle-developers/ppa' => {},
262 'ppa:nginx/stable' => {},
266 it { is_expected.to contain_apt__ppa('ppa:drizzle-developers/ppa') }
267 it { is_expected.to contain_apt__ppa('ppa:nginx/stable') }
270 context 'with settings defined on valid osfamily' do
273 os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04.5' } },
275 lsbdistcodename: 'precise',
277 puppetversion: Puppet.version,
282 'conf-banana' => { 'content' => 'banana' },
283 'pref-banana' => { 'content' => 'banana' },
287 it { is_expected.to contain_apt__setting('conf-banana') }
288 it { is_expected.to contain_apt__setting('pref-banana') }
291 context 'with pins defined on valid osfamily' do
294 os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04.5' } },
296 lsbdistcodename: 'precise',
298 puppetversion: Puppet.version,
303 'stable' => { 'priority' => 600, 'order' => 50 },
304 'testing' => { 'priority' => 700, 'order' => 100 },
308 it { is_expected.to contain_apt__pin('stable') }
309 it { is_expected.to contain_apt__pin('testing') }
312 describe 'failing tests' do
313 context "purge['sources.list']=>'banana'" do
314 let(:params) { { purge: { 'sources.list' => 'banana' } } }
319 }.to raise_error(Puppet::Error)
323 context "purge['sources.list.d']=>'banana'" do
324 let(:params) { { purge: { 'sources.list.d' => 'banana' } } }
329 }.to raise_error(Puppet::Error)
333 context "purge['preferences']=>'banana'" do
334 let(:params) { { purge: { 'preferences' => 'banana' } } }
339 }.to raise_error(Puppet::Error)
343 context "purge['preferences.d']=>'banana'" do
344 let(:params) { { purge: { 'preferences.d' => 'banana' } } }
349 }.to raise_error(Puppet::Error)