3 describe 'apt::source' do
4 GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30'
15 context 'without location' do
18 :lsbdistid => 'Debian',
19 :lsbdistcodename => 'wheezy',
25 is_expected.to compile
26 }.to raise_error(Puppet::Error, /source entry without specifying a location/)
29 context 'with location' do
32 :lsbdistid => 'Debian',
33 :lsbdistcodename => 'wheezy',
37 let(:params) { { :location => 'hello.there', } }
39 it { is_expected.to contain_apt__setting('list-my_source').with({
41 }).without_content(/# my_source\ndeb-src hello.there wheezy main\n/)
46 describe 'no defaults' do
49 :lsbdistid => 'Debian',
50 :lsbdistcodename => 'wheezy',
55 context 'with complex pin' do
58 :location => 'hello.there',
59 :pin => { 'release' => 'wishwash',
60 'explanation' => 'wishwash',
61 'priority' => 1001, },
65 it { is_expected.to contain_apt__setting('list-my_source').with({
67 }).with_content(/hello.there wheezy main\n/)
70 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
73 :explanation => 'wishwash',
74 :release => 'wishwash',
79 context 'with simple key' do
83 :location => 'http://debian.mirror.iweb.ca/debian/',
88 :architecture => 'x86_64',
89 :allow_unsigned => true,
93 it { is_expected.to contain_apt__setting('list-my_source').with({
95 }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
98 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
101 :origin => 'debian.mirror.iweb.ca',
105 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({
106 :ensure => 'present',
112 context 'with complex key' do
116 :location => 'http://debian.mirror.iweb.ca/debian/',
119 :key => { 'id' => GPG_KEY_ID, 'server' => 'pgp.mit.edu',
120 'content' => 'GPG key content',
121 'source' => 'http://apt.puppetlabs.com/pubkey.gpg',},
123 :architecture => 'x86_64',
124 :allow_unsigned => true,
128 it { is_expected.to contain_apt__setting('list-my_source').with({
129 :ensure => 'present',
130 }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
133 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
134 :ensure => 'present',
136 :origin => 'debian.mirror.iweb.ca',
140 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({
141 :ensure => 'present',
143 :server => 'pgp.mit.edu',
144 :content => 'GPG key content',
145 :source => 'http://apt.puppetlabs.com/pubkey.gpg',
150 context 'with simple key' do
154 :location => 'http://debian.mirror.iweb.ca/debian/',
159 :architecture => 'x86_64',
160 :allow_unsigned => true,
164 it { is_expected.to contain_apt__setting('list-my_source').with({
165 :ensure => 'present',
166 }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
169 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
170 :ensure => 'present',
172 :origin => 'debian.mirror.iweb.ca',
176 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({
177 :ensure => 'present',
184 context 'allow_unsigned true' do
187 :lsbdistid => 'Debian',
188 :lsbdistcodename => 'wheezy',
189 :osfamily => 'Debian'
194 :location => 'hello.there',
195 :allow_unsigned => true,
199 it { is_expected.to contain_apt__setting('list-my_source').with({
200 :ensure => 'present',
201 }).with_content(/# my_source\ndeb \[trusted=yes\] hello.there wheezy main\n/)
205 context 'architecture equals x86_64' do
208 :lsbdistid => 'Debian',
209 :lsbdistcodename => 'wheezy',
210 :osfamily => 'Debian'
215 :location => 'hello.there',
216 :include => {'deb' => false, 'src' => true,},
217 :architecture => 'x86_64',
221 it { is_expected.to contain_apt__setting('list-my_source').with({
222 :ensure => 'present',
223 }).with_content(/# my_source\ndeb-src \[arch=x86_64 \] hello.there wheezy main\n/)
227 context 'ensure => absent' do
230 :lsbdistid => 'Debian',
231 :lsbdistcodename => 'wheezy',
232 :osfamily => 'Debian'
241 it { is_expected.to contain_apt__setting('list-my_source').with({
247 describe 'validation' do
248 context 'no release' do
251 :lsbdistid => 'Debian',
252 :osfamily => 'Debian'
255 let(:params) { { :location => 'hello.there', } }
259 is_expected.to compile
260 }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)
264 context 'invalid pin' do
267 :lsbdistid => 'Debian',
268 :lsbdistcodename => 'wheezy',
269 :osfamily => 'Debian'
274 :location => 'hello.there',
281 is_expected.to compile
282 }.to raise_error(Puppet::Error, /invalid value for pin/)