3 describe 'apt::source' do
4 GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'
15 context 'without location' do
18 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
19 :osfamily => 'Debian',
20 :lsbdistcodename => 'wheezy',
21 :puppetversion => Puppet.version,
27 }.to raise_error(Puppet::Error, /source entry without specifying a location/)
30 context 'with location' do
33 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
34 :lsbdistid => 'Debian',
35 :lsbdistcodename => 'wheezy',
36 :osfamily => 'Debian',
37 :puppetversion => Puppet.version,
40 let(:params) { { :location => 'hello.there', } }
42 it { is_expected.to contain_apt__setting('list-my_source').with({
44 }).without_content(/# 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' }},
53 :lsbdistid => 'Debian',
54 :lsbdistcodename => 'wheezy',
55 :osfamily => 'Debian',
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',
68 'priority' => 1001, },
72 it { is_expected.to contain_apt__setting('list-my_source').with({
74 }).with_content(/hello.there wheezy main\n/)
77 it { is_expected.to contain_file('/etc/apt/sources.list.d/my_source.list').that_notifies('Class[Apt::Update]')}
79 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
82 :explanation => 'wishwash',
83 :release => 'wishwash',
88 context 'with simple key' do
92 :location => 'http://debian.mirror.iweb.ca/debian/',
97 :architecture => 'x86_64',
98 :allow_unsigned => true,
102 it { is_expected.to contain_apt__setting('list-my_source').with({
103 :ensure => 'present',
104 }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
107 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
108 :ensure => 'present',
110 :origin => 'debian.mirror.iweb.ca',
114 it { 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({
115 :ensure => 'present',
121 context 'with complex key' do
125 :location => 'http://debian.mirror.iweb.ca/debian/',
128 :key => { 'id' => GPG_KEY_ID, 'server' => 'pgp.mit.edu',
129 'content' => 'GPG key content',
130 'source' => 'http://apt.puppetlabs.com/pubkey.gpg',},
132 :architecture => 'x86_64',
133 :allow_unsigned => true,
137 it { is_expected.to contain_apt__setting('list-my_source').with({
138 :ensure => 'present',
139 }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
142 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
143 :ensure => 'present',
145 :origin => 'debian.mirror.iweb.ca',
149 it { 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({
150 :ensure => 'present',
152 :server => 'pgp.mit.edu',
153 :content => 'GPG key content',
154 :source => 'http://apt.puppetlabs.com/pubkey.gpg',
159 context 'with simple key' do
163 :location => 'http://debian.mirror.iweb.ca/debian/',
168 :architecture => 'x86_64',
169 :allow_unsigned => true,
173 it { is_expected.to contain_apt__setting('list-my_source').with({
174 :ensure => 'present',
175 }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
178 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
179 :ensure => 'present',
181 :origin => 'debian.mirror.iweb.ca',
185 it { 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({
186 :ensure => 'present',
193 context 'allow_unsigned true' do
196 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
197 :lsbdistid => 'Debian',
198 :lsbdistcodename => 'wheezy',
199 :osfamily => 'Debian',
200 :puppetversion => Puppet.version,
205 :location => 'hello.there',
206 :allow_unsigned => true,
210 it { is_expected.to contain_apt__setting('list-my_source').with({
211 :ensure => 'present',
212 }).with_content(/# my_source\ndeb \[trusted=yes\] hello.there wheezy main\n/)
216 context 'architecture equals x86_64' do
219 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
220 :lsbdistid => 'Debian',
221 :lsbdistcodename => 'wheezy',
222 :osfamily => 'Debian',
223 :puppetversion => Puppet.version,
228 :location => 'hello.there',
229 :include => {'deb' => false, 'src' => true},
230 :architecture => 'x86_64',
234 it { is_expected.to contain_apt__setting('list-my_source').with({
235 :ensure => 'present',
236 }).with_content(/# my_source\ndeb-src \[arch=x86_64\] hello.there wheezy main\n/)
240 context 'with architecture fact and unset architecture parameter' do
243 :architecture => 'amd64',
244 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
245 :lsbdistid => 'Debian',
246 :lsbdistcodename => 'wheezy',
247 :osfamily => 'Debian',
248 :puppetversion => Puppet.version,
253 :location => 'hello.there',
254 :include => {'deb' => false, 'src' => true,},
258 it { is_expected.to contain_apt__setting('list-my_source').with({
259 :ensure => 'present',
260 }).with_content(/# my_source\ndeb-src hello.there wheezy main\n/)
264 context 'include_src => true' do
267 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
268 :lsbdistid => 'Debian',
269 :lsbdistcodename => 'wheezy',
270 :osfamily => 'Debian',
271 :puppetversion => Puppet.version,
276 :location => 'hello.there',
277 :include => {'src' => true},
281 it { is_expected.to contain_apt__setting('list-my_source').with({
282 :ensure => 'present',
283 }).with_content(/# my_source\ndeb hello.there wheezy main\ndeb-src hello.there wheezy main\n/)
287 context 'include deb => false' do
290 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
291 :lsbdistid => 'debian',
292 :lsbdistcodename => 'wheezy',
293 :osfamily => 'debian',
294 :puppetversion => Puppet.version,
299 :include => { 'deb' => false },
300 :location => 'hello.there',
304 it { is_expected.to contain_apt__setting('list-my_source').with({
305 :ensure => 'present',
306 }).without_content(/deb-src hello.there wheezy main\n/)
308 it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) }
311 context 'include src => true and include deb => false' do
314 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
315 :lsbdistid => 'debian',
316 :lsbdistcodename => 'wheezy',
317 :osfamily => 'debian',
318 :puppetversion => Puppet.version,
323 :include => { 'deb' => false, 'src' => true },
324 :location => 'hello.there',
328 it { is_expected.to contain_apt__setting('list-my_source').with({
329 :ensure => 'present',
330 }).with_content(/deb-src hello.there wheezy main\n/)
332 it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) }
335 context 'ensure => absent' do
338 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
339 :lsbdistid => 'Debian',
340 :lsbdistcodename => 'wheezy',
341 :osfamily => 'Debian',
342 :puppetversion => Puppet.version,
351 it { is_expected.to contain_apt__setting('list-my_source').with({
357 describe 'validation' do
358 context 'no release' do
361 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
362 :lsbdistid => 'Debian',
363 :osfamily => 'Debian',
364 :puppetversion => Puppet.version,
367 let(:params) { { :location => 'hello.there', } }
372 }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)
376 context 'release is empty string' do
379 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
380 :lsbdistid => 'Debian',
381 :osfamily => 'Debian',
382 :puppetversion => Puppet.version,
385 let(:params) { { :location => 'hello.there', :release => '' } }
387 it { is_expected.to contain_apt__setting('list-my_source').with_content(/hello\.there main/) }
390 context 'invalid pin' do
393 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
394 :lsbdistid => 'Debian',
395 :lsbdistcodename => 'wheezy',
396 :osfamily => 'Debian',
397 :puppetversion => Puppet.version,
402 :location => 'hello.there',
410 }.to raise_error(Puppet::Error, /invalid value for pin/)
414 context "with notify_update = undef (default)" do
417 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
418 :lsbdistid => 'Debian',
419 :lsbdistcodename => 'wheezy',
420 :osfamily => 'Debian',
421 :puppetversion => Puppet.version,
426 :location => 'hello.there',
429 it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(true) }
432 context "with notify_update = true" do
435 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
436 :lsbdistid => 'Debian',
437 :lsbdistcodename => 'wheezy',
438 :osfamily => 'Debian',
439 :puppetversion => Puppet.version,
444 :location => 'hello.there',
445 :notify_update => true,
448 it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(true) }
451 context "with notify_update = false" do
454 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
455 :lsbdistid => 'Debian',
456 :lsbdistcodename => 'wheezy',
457 :osfamily => 'Debian',
458 :puppetversion => Puppet.version,
463 :location => 'hello.there',
464 :notify_update => false,
467 it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(false) }