3 describe 'apt::source' do
4 GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30'
15 context 'without location' do
18 :lsbdistid => 'Debian',
19 :lsbdistcodename => 'wheezy',
20 :osfamily => 'Debian',
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 :lsbdistid => 'Debian',
52 :lsbdistcodename => 'wheezy',
53 :osfamily => 'Debian',
54 :puppetversion => Puppet.version,
58 context 'with complex pin' do
61 :location => 'hello.there',
62 :pin => { 'release' => 'wishwash',
63 'explanation' => 'wishwash',
64 'priority' => 1001, },
68 it { is_expected.to contain_apt__setting('list-my_source').with({
70 }).with_content(/hello.there wheezy main\n/)
73 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
76 :explanation => 'wishwash',
77 :release => 'wishwash',
82 context 'with simple key' do
86 :location => 'http://debian.mirror.iweb.ca/debian/',
91 :architecture => 'x86_64',
92 :allow_unsigned => true,
96 it { is_expected.to contain_apt__setting('list-my_source').with({
98 }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
101 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
102 :ensure => 'present',
104 :origin => 'debian.mirror.iweb.ca',
108 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({
109 :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,
131 it { is_expected.to contain_apt__setting('list-my_source').with({
132 :ensure => 'present',
133 }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
136 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
137 :ensure => 'present',
139 :origin => 'debian.mirror.iweb.ca',
143 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({
144 :ensure => 'present',
146 :server => 'pgp.mit.edu',
147 :content => 'GPG key content',
148 :source => 'http://apt.puppetlabs.com/pubkey.gpg',
153 context 'with simple key' do
157 :location => 'http://debian.mirror.iweb.ca/debian/',
162 :architecture => 'x86_64',
163 :allow_unsigned => true,
167 it { is_expected.to contain_apt__setting('list-my_source').with({
168 :ensure => 'present',
169 }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
172 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
173 :ensure => 'present',
175 :origin => 'debian.mirror.iweb.ca',
179 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({
180 :ensure => 'present',
187 context 'allow_unsigned true' do
190 :lsbdistid => 'Debian',
191 :lsbdistcodename => 'wheezy',
192 :osfamily => 'Debian',
193 :puppetversion => Puppet.version,
198 :location => 'hello.there',
199 :allow_unsigned => true,
203 it { is_expected.to contain_apt__setting('list-my_source').with({
204 :ensure => 'present',
205 }).with_content(/# my_source\ndeb \[trusted=yes\] hello.there wheezy main\n/)
209 context 'architecture equals x86_64' do
212 :lsbdistid => 'Debian',
213 :lsbdistcodename => 'wheezy',
214 :osfamily => 'Debian',
215 :puppetversion => Puppet.version,
220 :location => 'hello.there',
221 :include => {'deb' => false, 'src' => true,},
222 :architecture => 'x86_64',
226 it { is_expected.to contain_apt__setting('list-my_source').with({
227 :ensure => 'present',
228 }).with_content(/# my_source\ndeb-src \[arch=x86_64 \] hello.there wheezy main\n/)
232 context 'include_src => true' do
235 :lsbdistid => 'Debian',
236 :lsbdistcodename => 'wheezy',
237 :osfamily => 'Debian',
238 :puppetversion => Puppet.version,
243 :location => 'hello.there',
244 :include_src => true,
248 it { is_expected.to contain_apt__setting('list-my_source').with({
249 :ensure => 'present',
250 }).with_content(/# my_source\ndeb hello.there wheezy main\ndeb-src hello.there wheezy main\n/)
254 context 'include_deb => false' do
257 :lsbdistid => 'debian',
258 :lsbdistcodename => 'wheezy',
259 :osfamily => 'debian',
260 :puppetversion => Puppet.version,
265 :location => 'hello.there',
266 :include_deb => false,
270 it { is_expected.to contain_apt__setting('list-my_source').with({
271 :ensure => 'present',
272 }).without_content(/deb-src hello.there wheezy main\n/)
274 it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) }
277 context 'include_src => true and include_deb => false' do
280 :lsbdistid => 'debian',
281 :lsbdistcodename => 'wheezy',
282 :osfamily => 'debian',
283 :puppetversion => Puppet.version,
288 :location => 'hello.there',
289 :include_deb => false,
290 :include_src => true,
294 it { is_expected.to contain_apt__setting('list-my_source').with({
295 :ensure => 'present',
296 }).with_content(/deb-src hello.there wheezy main\n/)
298 it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) }
301 context 'include precedence' do
304 :lsbdistid => 'debian',
305 :lsbdistcodename => 'wheezy',
306 :osfamily => 'debian',
307 :puppetversion => Puppet.version,
312 :location => 'hello.there',
313 :include_deb => true,
314 :include_src => false,
315 :include => { 'deb' => false, 'src' => true },
319 it { is_expected.to contain_apt__setting('list-my_source').with({
320 :ensure => 'present',
321 }).with_content(/deb-src hello.there wheezy main\n/)
323 it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) }
326 context 'ensure => absent' do
329 :lsbdistid => 'Debian',
330 :lsbdistcodename => 'wheezy',
331 :osfamily => 'Debian',
332 :puppetversion => Puppet.version,
341 it { is_expected.to contain_apt__setting('list-my_source').with({
347 describe 'validation' do
348 context 'no release' do
351 :lsbdistid => 'Debian',
352 :osfamily => 'Debian',
353 :puppetversion => Puppet.version,
356 let(:params) { { :location => 'hello.there', } }
361 }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)
365 context 'invalid pin' do
368 :lsbdistid => 'Debian',
369 :lsbdistcodename => 'wheezy',
370 :osfamily => 'Debian',
371 :puppetversion => Puppet.version,
376 :location => 'hello.there',
384 }.to raise_error(Puppet::Error, /invalid value for pin/)