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 'include_src => true' do
243 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
244 :lsbdistid => 'Debian',
245 :lsbdistcodename => 'wheezy',
246 :osfamily => 'Debian',
247 :puppetversion => Puppet.version,
252 :location => 'hello.there',
253 :include_src => true,
257 it { is_expected.to contain_apt__setting('list-my_source').with({
258 :ensure => 'present',
259 }).with_content(/# my_source\ndeb hello.there wheezy main\ndeb-src hello.there wheezy main\n/)
263 context 'include_deb => false' do
266 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
267 :lsbdistid => 'debian',
268 :lsbdistcodename => 'wheezy',
269 :osfamily => 'debian',
270 :puppetversion => Puppet.version,
275 :location => 'hello.there',
276 :include_deb => false,
280 it { is_expected.to contain_apt__setting('list-my_source').with({
281 :ensure => 'present',
282 }).without_content(/deb-src hello.there wheezy main\n/)
284 it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) }
287 context 'include_src => true and 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 :location => 'hello.there',
300 :include_deb => false,
301 :include_src => true,
305 it { is_expected.to contain_apt__setting('list-my_source').with({
306 :ensure => 'present',
307 }).with_content(/deb-src hello.there wheezy main\n/)
309 it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) }
312 context 'include precedence' do
315 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
316 :lsbdistid => 'debian',
317 :lsbdistcodename => 'wheezy',
318 :osfamily => 'debian',
319 :puppetversion => Puppet.version,
324 :location => 'hello.there',
325 :include_deb => true,
326 :include_src => false,
327 :include => { 'deb' => false, 'src' => true },
331 it { is_expected.to contain_apt__setting('list-my_source').with({
332 :ensure => 'present',
333 }).with_content(/deb-src hello.there wheezy main\n/)
335 it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) }
338 context 'ensure => absent' do
341 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
342 :lsbdistid => 'Debian',
343 :lsbdistcodename => 'wheezy',
344 :osfamily => 'Debian',
345 :puppetversion => Puppet.version,
354 it { is_expected.to contain_apt__setting('list-my_source').with({
360 describe 'validation' do
361 context 'no release' do
364 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
365 :lsbdistid => 'Debian',
366 :osfamily => 'Debian',
367 :puppetversion => Puppet.version,
370 let(:params) { { :location => 'hello.there', } }
375 }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)
379 context 'invalid pin' do
382 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
383 :lsbdistid => 'Debian',
384 :lsbdistcodename => 'wheezy',
385 :osfamily => 'Debian',
386 :puppetversion => Puppet.version,
391 :location => 'hello.there',
399 }.to raise_error(Puppet::Error, /invalid value for pin/)
403 context "with notify_update = undef (default)" do
406 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
407 :lsbdistid => 'Debian',
408 :lsbdistcodename => 'wheezy',
409 :osfamily => 'Debian',
410 :puppetversion => Puppet.version,
415 :location => 'hello.there',
418 it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(true) }
421 context "with notify_update = true" do
424 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
425 :lsbdistid => 'Debian',
426 :lsbdistcodename => 'wheezy',
427 :osfamily => 'Debian',
428 :puppetversion => Puppet.version,
433 :location => 'hello.there',
434 :notify_update => true,
437 it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(true) }
440 context "with notify_update = false" do
443 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
444 :lsbdistid => 'Debian',
445 :lsbdistcodename => 'wheezy',
446 :osfamily => 'Debian',
447 :puppetversion => Puppet.version,
452 :location => 'hello.there',
453 :notify_update => false,
456 it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(false) }