3 describe 'apt::source' do
4 GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'.freeze
14 context 'with defaults' do
15 context 'without location' do
18 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
20 lsbdistcodename: 'wheezy',
21 puppetversion: Puppet.version,
26 is_expected.to raise_error(Puppet::Error, %r{source entry without specifying a location})
29 context 'with location' do
32 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
34 lsbdistcodename: 'wheezy',
36 puppetversion: Puppet.version,
39 let(:params) { { location: 'hello.there' } }
42 is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{# my_source\ndeb-src hello.there wheezy main\n})
47 describe 'no defaults' do
50 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
52 lsbdistcodename: 'wheezy',
54 operatingsystem: 'Debian',
55 lsbdistrelease: '7.0',
56 puppetversion: Puppet.version,
60 context 'with complex pin' do
63 location: 'hello.there',
64 pin: { 'release' => 'wishwash',
65 'explanation' => 'wishwash',
71 is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{hello.there wheezy main\n})
74 it { is_expected.to contain_file('/etc/apt/sources.list.d/my_source.list').that_notifies('Class[Apt::Update]') }
77 is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
79 explanation: 'wishwash',
84 context 'with simple key' do
88 location: 'http://debian.mirror.iweb.ca/debian/',
93 architecture: 'x86_64',
99 is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n})
100 .without_content(%r{deb-src})
104 is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
106 origin: 'debian.mirror.iweb.ca')
110 is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
115 context 'with complex key' do
119 location: 'http://debian.mirror.iweb.ca/debian/',
122 key: { 'id' => GPG_KEY_ID, 'server' => 'pgp.mit.edu',
123 'content' => 'GPG key content',
124 'source' => 'http://apt.puppetlabs.com/pubkey.gpg' },
126 architecture: 'x86_64',
127 allow_unsigned: true,
132 is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n})
133 .without_content(%r{deb-src})
137 is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
139 origin: 'debian.mirror.iweb.ca')
143 is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
145 server: 'pgp.mit.edu',
146 content: 'GPG key content',
147 source: 'http://apt.puppetlabs.com/pubkey.gpg')
151 context 'with simple key' do
155 location: 'http://debian.mirror.iweb.ca/debian/',
160 architecture: 'x86_64',
161 allow_unsigned: true,
166 is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n})
167 .without_content(%r{deb-src})
171 is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
173 origin: 'debian.mirror.iweb.ca')
177 is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
183 context 'with allow_unsigned true' do
186 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
188 lsbdistcodename: 'wheezy',
190 puppetversion: Puppet.version,
195 location: 'hello.there',
196 allow_unsigned: true,
201 is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[trusted=yes\] hello.there wheezy main\n})
205 context 'with architecture equals x86_64' do
208 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
210 lsbdistcodename: 'wheezy',
212 puppetversion: Puppet.version,
217 location: 'hello.there',
218 include: { 'deb' => false, 'src' => true },
219 architecture: 'x86_64',
224 is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb-src \[arch=x86_64\] hello.there wheezy main\n})
228 context 'with architecture fact and unset architecture parameter' do
231 architecture: 'amd64',
232 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
234 lsbdistcodename: 'wheezy',
236 puppetversion: Puppet.version,
241 location: 'hello.there',
242 include: { 'deb' => false, 'src' => true },
247 is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb-src hello.there wheezy main\n})
251 context 'with include_src => true' do
254 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
256 lsbdistcodename: 'wheezy',
258 puppetversion: Puppet.version,
263 location: 'hello.there',
264 include: { 'src' => true },
269 is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb hello.there wheezy main\ndeb-src hello.there wheezy main\n})
273 context 'with include deb => false' do
276 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
278 lsbdistcodename: 'wheezy',
280 puppetversion: Puppet.version,
285 include: { 'deb' => false },
286 location: 'hello.there',
291 is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{deb-src hello.there wheezy main\n})
293 it { is_expected.to contain_apt__setting('list-my_source').without_content(%r{deb hello.there wheezy main\n}) }
296 context 'with include src => true and include deb => false' do
299 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
301 lsbdistcodename: 'wheezy',
303 puppetversion: Puppet.version,
308 include: { 'deb' => false, 'src' => true },
309 location: 'hello.there',
314 is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{deb-src hello.there wheezy main\n})
316 it { is_expected.to contain_apt__setting('list-my_source').without_content(%r{deb hello.there wheezy main\n}) }
319 context 'with ensure => absent' do
322 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
324 lsbdistcodename: 'wheezy',
326 puppetversion: Puppet.version,
336 is_expected.to contain_apt__setting('list-my_source').with(ensure: 'absent')
340 describe 'validation' do
341 context 'with no release' do
344 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
347 puppetversion: Puppet.version,
350 let(:params) { { location: 'hello.there' } }
353 is_expected.to raise_error(Puppet::Error, %r{lsbdistcodename fact not available: release parameter required})
357 context 'with release is empty string' do
360 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
363 puppetversion: Puppet.version,
366 let(:params) { { location: 'hello.there', release: '' } }
368 it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{hello\.there main}) }
371 context 'with invalid pin' do
374 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
376 lsbdistcodename: 'wheezy',
378 puppetversion: Puppet.version,
383 location: 'hello.there',
389 is_expected.to raise_error(Puppet::Error, %r{expects a value})
393 context 'with notify_update = undef (default)' do
396 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
398 lsbdistcodename: 'wheezy',
400 puppetversion: Puppet.version,
405 location: 'hello.there',
409 it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(true) }
412 context 'with notify_update = true' do
415 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
417 lsbdistcodename: 'wheezy',
419 puppetversion: Puppet.version,
424 location: 'hello.there',
429 it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(true) }
432 context 'with notify_update = false' do
435 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
437 lsbdistcodename: 'wheezy',
439 puppetversion: Puppet.version,
444 location: 'hello.there',
445 notify_update: false,
449 it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(false) }