3 describe 'apt::source' do
4 GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'.freeze
15 context 'without location' do
18 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
20 lsbdistcodename: 'wheezy',
21 puppetversion: Puppet.version,
28 }.to raise_error(Puppet::Error, %r{source entry without specifying a location})
31 context 'with location' do
34 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
36 lsbdistcodename: 'wheezy',
38 puppetversion: Puppet.version,
41 let(:params) { { location: 'hello.there' } }
44 is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{# my_source\ndeb-src hello.there wheezy main\n})
49 describe 'no defaults' do
52 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
54 lsbdistcodename: 'wheezy',
56 operatingsystem: 'Debian',
57 lsbdistrelease: '7.0',
58 puppetversion: Puppet.version,
62 context 'with complex pin' do
65 location: 'hello.there',
66 pin: { 'release' => 'wishwash',
67 'explanation' => 'wishwash',
73 is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{hello.there wheezy main\n})
76 it { is_expected.to contain_file('/etc/apt/sources.list.d/my_source.list').that_notifies('Class[Apt::Update]') }
79 is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
81 explanation: 'wishwash',
86 context 'with simple key' do
90 location: 'http://debian.mirror.iweb.ca/debian/',
95 architecture: 'x86_64',
101 is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(%r{deb-src}) # rubocop:disable Metrics/LineLength
105 is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
107 origin: 'debian.mirror.iweb.ca')
111 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',
116 context 'with complex key' do
120 location: 'http://debian.mirror.iweb.ca/debian/',
123 key: { 'id' => GPG_KEY_ID, 'server' => 'pgp.mit.edu',
124 'content' => 'GPG key content',
125 'source' => 'http://apt.puppetlabs.com/pubkey.gpg' },
127 architecture: 'x86_64',
128 allow_unsigned: true,
133 is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(%r{deb-src}) # rubocop:disable Metrics/LineLength
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(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(%r{deb-src}) # rubocop:disable Metrics/LineLength
170 is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present',
172 origin: 'debian.mirror.iweb.ca')
176 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',
182 context 'allow_unsigned true' do
185 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
187 lsbdistcodename: 'wheezy',
189 puppetversion: Puppet.version,
194 location: 'hello.there',
195 allow_unsigned: true,
200 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})
204 context 'architecture equals x86_64' do
207 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
209 lsbdistcodename: 'wheezy',
211 puppetversion: Puppet.version,
216 location: 'hello.there',
217 include: { 'deb' => false, 'src' => true },
218 architecture: 'x86_64',
223 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})
227 context 'with architecture fact and unset architecture parameter' do
230 architecture: 'amd64',
231 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
233 lsbdistcodename: 'wheezy',
235 puppetversion: Puppet.version,
240 location: 'hello.there',
241 include: { 'deb' => false, 'src' => true },
246 is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb-src hello.there wheezy main\n})
250 context 'include_src => true' do
253 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
255 lsbdistcodename: 'wheezy',
257 puppetversion: Puppet.version,
262 location: 'hello.there',
263 include: { 'src' => true },
268 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})
272 context 'include deb => false' do
275 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
277 lsbdistcodename: 'wheezy',
279 puppetversion: Puppet.version,
284 include: { 'deb' => false },
285 location: 'hello.there',
290 is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{deb-src hello.there wheezy main\n})
292 it { is_expected.to contain_apt__setting('list-my_source').without_content(%r{deb hello.there wheezy main\n}) }
295 context 'include src => true and include deb => false' do
298 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
300 lsbdistcodename: 'wheezy',
302 puppetversion: Puppet.version,
307 include: { 'deb' => false, 'src' => true },
308 location: 'hello.there',
313 is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{deb-src hello.there wheezy main\n})
315 it { is_expected.to contain_apt__setting('list-my_source').without_content(%r{deb hello.there wheezy main\n}) }
318 context 'ensure => absent' do
321 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
323 lsbdistcodename: 'wheezy',
325 puppetversion: Puppet.version,
335 is_expected.to contain_apt__setting('list-my_source').with(ensure: 'absent')
339 describe 'validation' do
340 context 'no release' do
343 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
346 puppetversion: Puppet.version,
349 let(:params) { { location: 'hello.there' } }
354 }.to raise_error(Puppet::Error, %r{lsbdistcodename fact not available: release parameter required})
358 context 'release is empty string' do
361 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
364 puppetversion: Puppet.version,
367 let(:params) { { location: 'hello.there', release: '' } }
369 it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{hello\.there main}) }
372 context 'invalid pin' do
375 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
377 lsbdistcodename: 'wheezy',
379 puppetversion: Puppet.version,
384 location: 'hello.there',
392 }.to raise_error(Puppet::Error, %r{expects a value})
396 context 'with notify_update = undef (default)' do
399 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
401 lsbdistcodename: 'wheezy',
403 puppetversion: Puppet.version,
408 location: 'hello.there',
412 it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(true) }
415 context 'with notify_update = true' do
418 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
420 lsbdistcodename: 'wheezy',
422 puppetversion: Puppet.version,
427 location: 'hello.there',
432 it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(true) }
435 context 'with notify_update = false' do
438 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
440 lsbdistcodename: 'wheezy',
442 puppetversion: Puppet.version,
447 location: 'hello.there',
448 notify_update: false,
452 it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(false) }