2012-01-23 22:08:00 +01:00
|
|
|
require 'spec_helper'
|
2014-02-20 16:18:37 +01:00
|
|
|
|
2015-02-28 17:35:25 +01:00
|
|
|
describe 'apt::source' do
|
2014-09-04 04:00:57 +02:00
|
|
|
GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30'
|
|
|
|
|
2015-02-18 20:43:50 +01:00
|
|
|
let :pre_condition do
|
|
|
|
'class { "apt": }'
|
|
|
|
end
|
2014-02-20 16:18:37 +01:00
|
|
|
|
2012-01-23 22:08:00 +01:00
|
|
|
let :title do
|
|
|
|
'my_source'
|
|
|
|
end
|
|
|
|
|
2015-03-05 17:37:51 +01:00
|
|
|
context 'defaults' do
|
2014-08-01 00:11:57 +02:00
|
|
|
let :facts do
|
|
|
|
{
|
|
|
|
:lsbdistid => 'Debian',
|
|
|
|
:lsbdistcodename => 'wheezy',
|
2014-08-18 22:12:55 +02:00
|
|
|
:osfamily => 'Debian'
|
2014-08-01 00:11:57 +02:00
|
|
|
}
|
|
|
|
end
|
2012-01-23 22:08:00 +01:00
|
|
|
|
2015-02-26 21:44:06 +01:00
|
|
|
it { is_expected.to contain_apt__setting('list-my_source').with({
|
2015-03-05 17:37:51 +01:00
|
|
|
:ensure => 'present',
|
|
|
|
}).without_content(/# my_source\ndeb-src wheezy main\n/)
|
2012-01-23 22:08:00 +01:00
|
|
|
}
|
2014-08-01 00:11:57 +02:00
|
|
|
end
|
2012-01-23 22:08:00 +01:00
|
|
|
|
2015-02-28 18:02:23 +01:00
|
|
|
describe 'no defaults' do
|
2014-08-01 00:11:57 +02:00
|
|
|
let :facts do
|
|
|
|
{
|
|
|
|
:lsbdistid => 'Debian',
|
|
|
|
:lsbdistcodename => 'wheezy',
|
2014-08-18 22:12:55 +02:00
|
|
|
:osfamily => 'Debian'
|
2014-08-01 00:11:57 +02:00
|
|
|
}
|
|
|
|
end
|
2015-02-28 18:02:23 +01:00
|
|
|
context 'with simple key' do
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
:comment => 'foo',
|
|
|
|
:location => 'http://debian.mirror.iweb.ca/debian/',
|
|
|
|
:release => 'sid',
|
|
|
|
:repos => 'testing',
|
|
|
|
:key => GPG_KEY_ID,
|
|
|
|
:pin => '10',
|
|
|
|
:architecture => 'x86_64',
|
2015-03-05 20:23:38 +01:00
|
|
|
:allow_unsigned => true,
|
2015-02-28 18:02:23 +01:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to contain_apt__setting('list-my_source').with({
|
|
|
|
:ensure => 'present',
|
|
|
|
}).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
|
|
|
|
}
|
|
|
|
|
|
|
|
it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
|
|
|
|
:ensure => 'present',
|
|
|
|
:priority => '10',
|
|
|
|
:origin => 'debian.mirror.iweb.ca',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
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({
|
|
|
|
:ensure => 'present',
|
2015-03-01 14:18:48 +01:00
|
|
|
:id => GPG_KEY_ID,
|
2015-02-28 18:02:23 +01:00
|
|
|
})
|
2014-08-01 00:11:57 +02:00
|
|
|
}
|
|
|
|
end
|
2012-02-24 23:03:51 +01:00
|
|
|
|
2015-02-28 18:02:23 +01:00
|
|
|
context 'with complex key' do
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
:comment => 'foo',
|
|
|
|
:location => 'http://debian.mirror.iweb.ca/debian/',
|
|
|
|
:release => 'sid',
|
|
|
|
:repos => 'testing',
|
|
|
|
:key => { 'id' => GPG_KEY_ID, 'server' => 'pgp.mit.edu',
|
|
|
|
'content' => 'GPG key content',
|
|
|
|
'source' => 'http://apt.puppetlabs.com/pubkey.gpg',},
|
|
|
|
:pin => '10',
|
|
|
|
:architecture => 'x86_64',
|
2015-03-05 20:23:38 +01:00
|
|
|
:allow_unsigned => true,
|
2015-02-28 18:02:23 +01:00
|
|
|
}
|
|
|
|
end
|
2012-01-23 22:08:00 +01:00
|
|
|
|
2015-02-28 18:02:23 +01:00
|
|
|
it { is_expected.to contain_apt__setting('list-my_source').with({
|
|
|
|
:ensure => 'present',
|
|
|
|
}).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
|
|
|
|
}
|
2012-01-23 22:08:00 +01:00
|
|
|
|
2015-02-28 18:02:23 +01:00
|
|
|
it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
|
|
|
|
:ensure => 'present',
|
|
|
|
:priority => '10',
|
|
|
|
:origin => 'debian.mirror.iweb.ca',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
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({
|
|
|
|
:ensure => 'present',
|
2015-03-01 14:18:48 +01:00
|
|
|
:id => GPG_KEY_ID,
|
2015-02-28 18:02:23 +01:00
|
|
|
:server => 'pgp.mit.edu',
|
|
|
|
:content => 'GPG key content',
|
|
|
|
:source => 'http://apt.puppetlabs.com/pubkey.gpg',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with simple key' do
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
:comment => 'foo',
|
|
|
|
:location => 'http://debian.mirror.iweb.ca/debian/',
|
|
|
|
:release => 'sid',
|
|
|
|
:repos => 'testing',
|
|
|
|
:key => GPG_KEY_ID,
|
|
|
|
:pin => '10',
|
|
|
|
:architecture => 'x86_64',
|
2015-03-05 20:23:38 +01:00
|
|
|
:allow_unsigned => true,
|
2015-02-28 18:02:23 +01:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to contain_apt__setting('list-my_source').with({
|
|
|
|
:ensure => 'present',
|
|
|
|
}).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
|
|
|
|
}
|
|
|
|
|
|
|
|
it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
|
|
|
|
:ensure => 'present',
|
|
|
|
:priority => '10',
|
|
|
|
:origin => 'debian.mirror.iweb.ca',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
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({
|
|
|
|
:ensure => 'present',
|
|
|
|
:id => GPG_KEY_ID,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
end
|
2014-08-01 00:11:57 +02:00
|
|
|
end
|
2012-01-23 22:08:00 +01:00
|
|
|
|
2015-03-05 20:23:38 +01:00
|
|
|
context 'allow_unsigned true' do
|
2015-01-13 16:27:03 +01:00
|
|
|
let :facts do
|
|
|
|
{
|
|
|
|
:lsbdistid => 'Debian',
|
|
|
|
:lsbdistcodename => 'wheezy',
|
|
|
|
:osfamily => 'Debian'
|
|
|
|
}
|
|
|
|
end
|
|
|
|
let :params do
|
|
|
|
{
|
2015-03-05 20:23:38 +01:00
|
|
|
:allow_unsigned => true,
|
2015-01-13 16:27:03 +01:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2015-02-26 21:44:06 +01:00
|
|
|
it { is_expected.to contain_apt__setting('list-my_source').with({
|
2015-02-28 18:02:23 +01:00
|
|
|
:ensure => 'present',
|
2014-08-31 15:46:57 +02:00
|
|
|
}).with_content(/# my_source\ndeb \[trusted=yes\] wheezy main\n/)
|
2015-01-13 16:27:03 +01:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'architecture equals x86_64' do
|
|
|
|
let :facts do
|
|
|
|
{
|
|
|
|
:lsbdistid => 'Debian',
|
|
|
|
:lsbdistcodename => 'wheezy',
|
|
|
|
:osfamily => 'Debian'
|
|
|
|
}
|
|
|
|
end
|
|
|
|
let :params do
|
|
|
|
{
|
2015-03-05 17:37:51 +01:00
|
|
|
:include => {'deb' => false, 'src' => true,},
|
2015-02-28 18:02:23 +01:00
|
|
|
:architecture => 'x86_64',
|
2015-01-13 16:27:03 +01:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2015-02-26 21:44:06 +01:00
|
|
|
it { is_expected.to contain_apt__setting('list-my_source').with({
|
2015-02-28 18:02:23 +01:00
|
|
|
:ensure => 'present',
|
2014-08-31 15:46:57 +02:00
|
|
|
}).with_content(/# my_source\ndeb-src \[arch=x86_64 \] wheezy main\n/)
|
2015-01-13 16:27:03 +01:00
|
|
|
}
|
|
|
|
end
|
2015-02-28 17:35:25 +01:00
|
|
|
|
2014-08-01 00:11:57 +02:00
|
|
|
context 'ensure => absent' do
|
|
|
|
let :facts do
|
|
|
|
{
|
|
|
|
:lsbdistid => 'Debian',
|
|
|
|
:lsbdistcodename => 'wheezy',
|
2014-08-18 22:12:55 +02:00
|
|
|
:osfamily => 'Debian'
|
2012-01-23 22:08:00 +01:00
|
|
|
}
|
2014-08-01 00:11:57 +02:00
|
|
|
end
|
|
|
|
let :params do
|
|
|
|
{
|
2015-02-28 18:02:23 +01:00
|
|
|
:ensure => 'absent',
|
2012-01-23 22:08:00 +01:00
|
|
|
}
|
2014-08-01 00:11:57 +02:00
|
|
|
end
|
2012-01-23 22:08:00 +01:00
|
|
|
|
2015-02-26 21:44:06 +01:00
|
|
|
it { is_expected.to contain_apt__setting('list-my_source').with({
|
2015-02-28 18:02:23 +01:00
|
|
|
:ensure => 'absent'
|
2014-08-01 00:11:57 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
end
|
2012-01-23 22:08:00 +01:00
|
|
|
|
2014-08-01 00:11:57 +02:00
|
|
|
describe 'validation' do
|
|
|
|
context 'no release' do
|
|
|
|
let :facts do
|
|
|
|
{
|
|
|
|
:lsbdistid => 'Debian',
|
2014-08-18 22:12:55 +02:00
|
|
|
:osfamily => 'Debian'
|
2014-08-01 00:11:57 +02:00
|
|
|
}
|
|
|
|
end
|
2012-01-23 22:08:00 +01:00
|
|
|
|
2014-08-01 00:11:57 +02:00
|
|
|
it do
|
|
|
|
expect {
|
2015-02-24 22:20:29 +01:00
|
|
|
is_expected.to compile
|
2014-08-01 00:11:57 +02:00
|
|
|
}.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)
|
|
|
|
end
|
2012-01-23 22:08:00 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|