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 => '3.5.0',
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 => '3.5.0',
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 => '3.5.0',
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 => '3.5.0',
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 => '3.5.0',
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 'ensure => absent' do
235 :lsbdistid => 'Debian',
236 :lsbdistcodename => 'wheezy',
237 :osfamily => 'Debian',
238 :puppetversion => '3.5.0',
247 it { is_expected.to contain_apt__setting('list-my_source').with({
253 describe 'validation' do
254 context 'no release' do
257 :lsbdistid => 'Debian',
258 :osfamily => 'Debian',
259 :puppetversion => '3.5.0',
262 let(:params) { { :location => 'hello.there', } }
267 }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)
271 context 'invalid pin' do
274 :lsbdistid => 'Debian',
275 :lsbdistcodename => 'wheezy',
276 :osfamily => 'Debian',
277 :puppetversion => '3.5.0',
282 :location => 'hello.there',
290 }.to raise_error(Puppet::Error, /invalid value for pin/)