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_file('/etc/apt/sources.list.d/my_source.list').that_notifies('Class[Apt::Update]')}
75 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
78 :explanation => 'wishwash',
79 :release => 'wishwash',
84 context 'with simple key' do
88 :location => 'http://debian.mirror.iweb.ca/debian/',
93 :architecture => 'x86_64',
94 :allow_unsigned => true,
98 it { is_expected.to contain_apt__setting('list-my_source').with({
100 }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
103 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
104 :ensure => 'present',
106 :origin => 'debian.mirror.iweb.ca',
110 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({
111 :ensure => 'present',
117 context 'with complex key' do
121 :location => 'http://debian.mirror.iweb.ca/debian/',
124 :key => { 'id' => GPG_KEY_ID, 'server' => 'pgp.mit.edu',
125 'content' => 'GPG key content',
126 'source' => 'http://apt.puppetlabs.com/pubkey.gpg',},
128 :architecture => 'x86_64',
129 :allow_unsigned => true,
133 it { is_expected.to contain_apt__setting('list-my_source').with({
134 :ensure => 'present',
135 }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
138 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
139 :ensure => 'present',
141 :origin => 'debian.mirror.iweb.ca',
145 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({
146 :ensure => 'present',
148 :server => 'pgp.mit.edu',
149 :content => 'GPG key content',
150 :source => 'http://apt.puppetlabs.com/pubkey.gpg',
155 context 'with simple key' do
159 :location => 'http://debian.mirror.iweb.ca/debian/',
164 :architecture => 'x86_64',
165 :allow_unsigned => true,
169 it { is_expected.to contain_apt__setting('list-my_source').with({
170 :ensure => 'present',
171 }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
174 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
175 :ensure => 'present',
177 :origin => 'debian.mirror.iweb.ca',
181 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({
182 :ensure => 'present',
189 context 'allow_unsigned true' do
192 :lsbdistid => 'Debian',
193 :lsbdistcodename => 'wheezy',
194 :osfamily => 'Debian',
195 :puppetversion => Puppet.version,
200 :location => 'hello.there',
201 :allow_unsigned => true,
205 it { is_expected.to contain_apt__setting('list-my_source').with({
206 :ensure => 'present',
207 }).with_content(/# my_source\ndeb \[trusted=yes\] hello.there wheezy main\n/)
211 context 'architecture equals x86_64' do
214 :lsbdistid => 'Debian',
215 :lsbdistcodename => 'wheezy',
216 :osfamily => 'Debian',
217 :puppetversion => Puppet.version,
222 :location => 'hello.there',
223 :include => {'deb' => false, 'src' => true,},
224 :architecture => 'x86_64',
228 it { is_expected.to contain_apt__setting('list-my_source').with({
229 :ensure => 'present',
230 }).with_content(/# my_source\ndeb-src \[arch=x86_64 \] hello.there wheezy main\n/)
234 context 'include_src => true' do
237 :lsbdistid => 'Debian',
238 :lsbdistcodename => 'wheezy',
239 :osfamily => 'Debian',
240 :puppetversion => Puppet.version,
245 :location => 'hello.there',
246 :include_src => true,
250 it { is_expected.to contain_apt__setting('list-my_source').with({
251 :ensure => 'present',
252 }).with_content(/# my_source\ndeb hello.there wheezy main\ndeb-src hello.there wheezy main\n/)
256 context 'include_deb => false' do
259 :lsbdistid => 'debian',
260 :lsbdistcodename => 'wheezy',
261 :osfamily => 'debian',
262 :puppetversion => Puppet.version,
267 :location => 'hello.there',
268 :include_deb => false,
272 it { is_expected.to contain_apt__setting('list-my_source').with({
273 :ensure => 'present',
274 }).without_content(/deb-src hello.there wheezy main\n/)
276 it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) }
279 context 'include_src => true and include_deb => false' do
282 :lsbdistid => 'debian',
283 :lsbdistcodename => 'wheezy',
284 :osfamily => 'debian',
285 :puppetversion => Puppet.version,
290 :location => 'hello.there',
291 :include_deb => false,
292 :include_src => true,
296 it { is_expected.to contain_apt__setting('list-my_source').with({
297 :ensure => 'present',
298 }).with_content(/deb-src hello.there wheezy main\n/)
300 it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) }
303 context 'include precedence' do
306 :lsbdistid => 'debian',
307 :lsbdistcodename => 'wheezy',
308 :osfamily => 'debian',
309 :puppetversion => Puppet.version,
314 :location => 'hello.there',
315 :include_deb => true,
316 :include_src => false,
317 :include => { 'deb' => false, 'src' => true },
321 it { is_expected.to contain_apt__setting('list-my_source').with({
322 :ensure => 'present',
323 }).with_content(/deb-src hello.there wheezy main\n/)
325 it { is_expected.to contain_apt__setting('list-my_source').without_content(/deb hello.there wheezy main\n/) }
328 context 'ensure => absent' do
331 :lsbdistid => 'Debian',
332 :lsbdistcodename => 'wheezy',
333 :osfamily => 'Debian',
334 :puppetversion => Puppet.version,
343 it { is_expected.to contain_apt__setting('list-my_source').with({
349 describe 'validation' do
350 context 'no release' do
353 :lsbdistid => 'Debian',
354 :osfamily => 'Debian',
355 :puppetversion => Puppet.version,
358 let(:params) { { :location => 'hello.there', } }
363 }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)
367 context 'invalid pin' do
370 :lsbdistid => 'Debian',
371 :lsbdistcodename => 'wheezy',
372 :osfamily => 'Debian',
373 :puppetversion => Puppet.version,
378 :location => 'hello.there',
386 }.to raise_error(Puppet::Error, /invalid value for pin/)