3 describe 'apt::source' do
4 GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'
15 context 'without location' do
18 :os => { :family => 'Debian' },
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 :lsbdistid => 'Debian',
34 :lsbdistcodename => 'wheezy',
35 :osfamily => 'Debian',
36 :puppetversion => Puppet.version,
39 let(:params) { { :location => 'hello.there', } }
41 it { is_expected.to contain_apt__setting('list-my_source').with({
43 }).without_content(/# my_source\ndeb-src hello.there wheezy main\n/)
48 describe 'no defaults' do
51 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
52 :lsbdistid => 'Debian',
53 :lsbdistcodename => 'wheezy',
54 :osfamily => 'Debian',
55 :operatingsystem => 'Debian',
56 :lsbdistrelease => '7.0',
57 :puppetversion => Puppet.version,
61 context 'with complex pin' do
64 :location => 'hello.there',
65 :pin => { 'release' => 'wishwash',
66 'explanation' => 'wishwash',
67 'priority' => 1001, },
71 it { is_expected.to contain_apt__setting('list-my_source').with({
73 }).with_content(/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]')}
78 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
81 :explanation => 'wishwash',
82 :release => 'wishwash',
87 context 'with simple key' do
91 :location => 'http://debian.mirror.iweb.ca/debian/',
96 :architecture => 'x86_64',
97 :allow_unsigned => true,
101 it { is_expected.to contain_apt__setting('list-my_source').with({
102 :ensure => 'present',
103 }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
106 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
107 :ensure => 'present',
109 :origin => 'debian.mirror.iweb.ca',
113 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({
114 :ensure => 'present',
120 context 'with complex key' do
124 :location => 'http://debian.mirror.iweb.ca/debian/',
127 :key => { 'id' => GPG_KEY_ID, 'server' => 'pgp.mit.edu',
128 'content' => 'GPG key content',
129 'source' => 'http://apt.puppetlabs.com/pubkey.gpg',},
131 :architecture => 'x86_64',
132 :allow_unsigned => true,
136 it { is_expected.to contain_apt__setting('list-my_source').with({
137 :ensure => 'present',
138 }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
141 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
142 :ensure => 'present',
144 :origin => 'debian.mirror.iweb.ca',
148 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({
149 :ensure => 'present',
151 :server => 'pgp.mit.edu',
152 :content => 'GPG key content',
153 :source => 'http://apt.puppetlabs.com/pubkey.gpg',
158 context 'with simple key' do
162 :location => 'http://debian.mirror.iweb.ca/debian/',
167 :architecture => 'x86_64',
168 :allow_unsigned => true,
172 it { is_expected.to contain_apt__setting('list-my_source').with({
173 :ensure => 'present',
174 }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
177 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
178 :ensure => 'present',
180 :origin => 'debian.mirror.iweb.ca',
184 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({
185 :ensure => 'present',
192 context 'allow_unsigned true' do
195 :lsbdistid => 'Debian',
196 :lsbdistcodename => 'wheezy',
197 :osfamily => 'Debian',
198 :puppetversion => Puppet.version,
203 :location => 'hello.there',
204 :allow_unsigned => true,
208 it { is_expected.to contain_apt__setting('list-my_source').with({
209 :ensure => 'present',
210 }).with_content(/# my_source\ndeb \[trusted=yes\] hello.there wheezy main\n/)
214 context 'architecture equals x86_64' do
217 :lsbdistid => 'Debian',
218 :lsbdistcodename => 'wheezy',
219 :osfamily => 'Debian',
220 :puppetversion => Puppet.version,
225 :location => 'hello.there',
226 :include => {'deb' => false, 'src' => true,},
227 :architecture => 'x86_64',
231 it { is_expected.to contain_apt__setting('list-my_source').with({
232 :ensure => 'present',
233 }).with_content(/# my_source\ndeb-src \[arch=x86_64\] hello.there wheezy main\n/)
237 context 'include_src => true' do
240 :lsbdistid => 'Debian',
241 :lsbdistcodename => 'wheezy',
242 :osfamily => 'Debian',
243 :puppetversion => Puppet.version,
248 :location => 'hello.there',
249 :include_src => true,
253 it { is_expected.to contain_apt__setting('list-my_source').with({
254 :ensure => 'present',
255 }).with_content(/# my_source\ndeb hello.there wheezy main\ndeb-src hello.there wheezy main\n/)
259 context 'include_deb => false' do
262 :lsbdistid => 'debian',
263 :lsbdistcodename => 'wheezy',
264 :osfamily => 'debian',
265 :puppetversion => Puppet.version,
270 :location => 'hello.there',
271 :include_deb => false,
275 it { is_expected.to contain_apt__setting('list-my_source').with({
276 :ensure => 'present',
277 }).without_content(/deb-src hello.there wheezy main\n/)
279 it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) }
282 context 'include_src => true and include_deb => false' do
285 :lsbdistid => 'debian',
286 :lsbdistcodename => 'wheezy',
287 :osfamily => 'debian',
288 :puppetversion => Puppet.version,
293 :location => 'hello.there',
294 :include_deb => false,
295 :include_src => true,
299 it { is_expected.to contain_apt__setting('list-my_source').with({
300 :ensure => 'present',
301 }).with_content(/deb-src hello.there wheezy main\n/)
303 it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) }
306 context 'include precedence' do
309 :lsbdistid => 'debian',
310 :lsbdistcodename => 'wheezy',
311 :osfamily => 'debian',
312 :puppetversion => Puppet.version,
317 :location => 'hello.there',
318 :include_deb => true,
319 :include_src => false,
320 :include => { 'deb' => false, 'src' => true },
324 it { is_expected.to contain_apt__setting('list-my_source').with({
325 :ensure => 'present',
326 }).with_content(/deb-src hello.there wheezy main\n/)
328 it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) }
331 context 'ensure => absent' do
334 :lsbdistid => 'Debian',
335 :lsbdistcodename => 'wheezy',
336 :osfamily => 'Debian',
337 :puppetversion => Puppet.version,
346 it { is_expected.to contain_apt__setting('list-my_source').with({
352 describe 'validation' do
353 context 'no release' do
356 :lsbdistid => 'Debian',
357 :osfamily => 'Debian',
358 :puppetversion => Puppet.version,
361 let(:params) { { :location => 'hello.there', } }
366 }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)
370 context 'invalid pin' do
373 :lsbdistid => 'Debian',
374 :lsbdistcodename => 'wheezy',
375 :osfamily => 'Debian',
376 :puppetversion => Puppet.version,
381 :location => 'hello.there',
389 }.to raise_error(Puppet::Error, /invalid value for pin/)
393 context "with notify_update = undef (default)" do
396 :lsbdistid => 'Debian',
397 :lsbdistcodename => 'wheezy',
398 :osfamily => 'Debian',
399 :puppetversion => Puppet.version,
404 :location => 'hello.there',
407 it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(true) }
410 context "with notify_update = true" do
413 :lsbdistid => 'Debian',
414 :lsbdistcodename => 'wheezy',
415 :osfamily => 'Debian',
416 :puppetversion => Puppet.version,
421 :location => 'hello.there',
422 :notify_update => true,
425 it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(true) }
428 context "with notify_update = false" do
431 :lsbdistid => 'Debian',
432 :lsbdistcodename => 'wheezy',
433 :osfamily => 'Debian',
434 :puppetversion => Puppet.version,
439 :location => 'hello.there',
440 :notify_update => false,
443 it { is_expected.to contain_apt__setting("list-#{title}").with_notify_update(false) }