Merge pull request #207 from apenney/add-params
Add additional acceptance testing.
This commit is contained in:
commit
ec3ddbe372
10 changed files with 1886 additions and 85 deletions
|
@ -1,14 +1,6 @@
|
|||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'apt::key' do
|
||||
|
||||
context 'reset' do
|
||||
it 'clean up keys' do
|
||||
shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
|
||||
shell('apt-key del D50582E6', :acceptable_exit_codes => [0,1,2])
|
||||
end
|
||||
end
|
||||
|
||||
context 'apt::key' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
|
@ -24,18 +16,47 @@ describe 'apt::key' do
|
|||
}
|
||||
EOS
|
||||
|
||||
shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
|
||||
shell('apt-key del D50582E6', :acceptable_exit_codes => [0,1,2])
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe 'keys should exist' do
|
||||
it 'finds puppetlabs key' do
|
||||
shell('apt-key list | grep 4BD6EC30') do |r|
|
||||
expect(r.exit_code).to be_zero
|
||||
end
|
||||
shell('apt-key list | grep 4BD6EC30')
|
||||
end
|
||||
it 'finds jenkins key' do
|
||||
shell('apt-key list | grep D50582E6') do |r|
|
||||
expect(r.exit_code).to be_zero
|
||||
shell('apt-key list | grep D50582E6')
|
||||
end
|
||||
end
|
||||
end
|
||||
context 'ensure' do
|
||||
context 'absent' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::key { 'puppetlabs':
|
||||
ensure => absent,
|
||||
key => '4BD6EC30',
|
||||
key_server => 'pgp.mit.edu',
|
||||
}
|
||||
|
||||
apt::key { 'jenkins':
|
||||
ensure => absent,
|
||||
key => 'D50582E6',
|
||||
key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key',
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe 'keys shouldnt exist' do
|
||||
it 'fails' do
|
||||
shell('apt-key list | grep 4BD6EC30', :acceptable_exit_codes => [1])
|
||||
end
|
||||
it 'fails' do
|
||||
shell('apt-key list | grep D50582E6', :acceptable_exit_codes => [1])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -43,8 +64,136 @@ describe 'apt::key' do
|
|||
|
||||
context 'reset' do
|
||||
it 'clean up keys' do
|
||||
shell('apt-key del 4BD6EC30')
|
||||
shell('apt-key del D50582E6')
|
||||
shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
|
||||
shell('apt-key del D50582E6', :acceptable_exit_codes => [0,1,2])
|
||||
end
|
||||
end
|
||||
|
||||
context 'key options' do
|
||||
context 'key_content' do
|
||||
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::key { 'puppetlabs':
|
||||
key => '4BD6EC30',
|
||||
key_content => '-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
Version: GnuPG v1.4.12 (GNU/Linux)
|
||||
Comment: GPGTools - http://gpgtools.org
|
||||
|
||||
mQINBEw3u0ABEAC1+aJQpU59fwZ4mxFjqNCgfZgDhONDSYQFMRnYC1dzBpJHzI6b
|
||||
fUBQeaZ8rh6N4kZ+wq1eL86YDXkCt4sCvNTP0eF2XaOLbmxtV9bdpTIBep9bQiKg
|
||||
5iZaz+brUZlFk/MyJ0Yz//VQ68N1uvXccmD6uxQsVO+gx7rnarg/BGuCNaVtGwy+
|
||||
S98g8Begwxs9JmGa8pMCcSxtC7fAfAEZ02cYyrw5KfBvFI3cHDdBqrEJQKwKeLKY
|
||||
GHK3+H1TM4ZMxPsLuR/XKCbvTyl+OCPxU2OxPjufAxLlr8BWUzgJv6ztPe9imqpH
|
||||
Ppp3KuLFNorjPqWY5jSgKl94W/CO2x591e++a1PhwUn7iVUwVVe+mOEWnK5+Fd0v
|
||||
VMQebYCXS+3dNf6gxSvhz8etpw20T9Ytg4EdhL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NHiYTRE/m9VAk
|
||||
ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU=
|
||||
=a34C
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
',
|
||||
}
|
||||
EOS
|
||||
|
||||
shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
end
|
||||
describe 'keys should exist' do
|
||||
it 'finds puppetlabs key' do
|
||||
shell('apt-key list | grep 4BD6EC30')
|
||||
end
|
||||
end
|
||||
|
||||
context 'key_source' do
|
||||
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::key { 'puppetlabs':
|
||||
key => '4BD6EC30',
|
||||
key_source => 'http://apt.puppetlabs.com/pubkey.gpg',
|
||||
}
|
||||
EOS
|
||||
|
||||
shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe 'keys should exist' do
|
||||
it 'finds puppetlabs key' do
|
||||
shell('apt-key list | grep 4BD6EC30')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'key_options' do
|
||||
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::key { 'puppetlabs':
|
||||
key => '4BD6EC30',
|
||||
key_source => 'http://apt.puppetlabs.com/pubkey.gpg',
|
||||
key_options => 'debug'
|
||||
}
|
||||
EOS
|
||||
|
||||
shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe 'keys should exist' do
|
||||
it 'finds puppetlabs key' do
|
||||
shell('apt-key list | grep 4BD6EC30')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,53 +1,140 @@
|
|||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'apt::ppa' do
|
||||
if fact('operatingsystem') == 'Ubuntu'
|
||||
describe 'apt::ppa' do
|
||||
|
||||
context 'reset' do
|
||||
it 'removes ppa' do
|
||||
shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0,1,2])
|
||||
shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*', :acceptable_exit_codes => [0,1,2])
|
||||
end
|
||||
end
|
||||
|
||||
context 'adding a ppa that doesnt exist' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::ppa { 'ppa:canonical-kernel-team/ppa': }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe 'contains the source file' do
|
||||
it 'contains a kernel ppa source' do
|
||||
shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0])
|
||||
context 'reset' do
|
||||
it 'removes ppa' do
|
||||
shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0,1,2])
|
||||
shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*', :acceptable_exit_codes => [0,1,2])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'readding a removed ppa.' do
|
||||
it 'setup' do
|
||||
shell('add-apt-repository -y ppa:raravena80/collectd5')
|
||||
# This leaves a blank file
|
||||
shell('add-apt-repository --remove ppa:raravena80/collectd5')
|
||||
context 'adding a ppa that doesnt exist' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::ppa { 'ppa:canonical-kernel-team/ppa': }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe 'contains the source file' do
|
||||
it 'contains a kernel ppa source' do
|
||||
shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it 'should readd it successfully' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::ppa { 'ppa:raravena80/collectd5': }
|
||||
EOS
|
||||
context 'readding a removed ppa.' do
|
||||
it 'setup' do
|
||||
shell('add-apt-repository -y ppa:raravena80/collectd5')
|
||||
# This leaves a blank file
|
||||
shell('add-apt-repository --remove ppa:raravena80/collectd5')
|
||||
end
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
it 'should readd it successfully' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::ppa { 'ppa:raravena80/collectd5': }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'reset' do
|
||||
it 'removes added ppas' do
|
||||
shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*')
|
||||
shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*')
|
||||
context 'reset' do
|
||||
it 'removes added ppas' do
|
||||
shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*')
|
||||
shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'ensure' do
|
||||
context 'present' do
|
||||
it 'works without failure' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => present }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe 'contains the source file' do
|
||||
it 'contains a kernel ppa source' do
|
||||
shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'ensure' do
|
||||
context 'absent' do
|
||||
it 'works without failure' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => absent }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe 'doesnt contain the source file' do
|
||||
it 'fails' do
|
||||
shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [2])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'release' do
|
||||
context 'precise' do
|
||||
it 'works without failure' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::ppa { 'ppa:canonical-kernel-team/ppa':
|
||||
ensure => present,
|
||||
release => precise,
|
||||
}
|
||||
EOS
|
||||
|
||||
shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2])
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do
|
||||
it { should be_file }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'options' do
|
||||
context '-y' do
|
||||
it 'works without failure' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::ppa { 'ppa:canonical-kernel-team/ppa':
|
||||
ensure => present,
|
||||
release => precise,
|
||||
options => '-y',
|
||||
}
|
||||
EOS
|
||||
|
||||
shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2])
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do
|
||||
it { should be_file }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'reset' do
|
||||
it { shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,48 +2,325 @@ require 'spec_helper_acceptance'
|
|||
|
||||
describe 'apt::source' do
|
||||
|
||||
context 'reset' do
|
||||
it 'clean up puppetlabs repo' do
|
||||
shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
|
||||
shell('rm /etc/apt/sources.list.d/puppetlabs.list', :acceptable_exit_codes => [0,1,2])
|
||||
end
|
||||
end
|
||||
|
||||
context 'apt::source' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::source { 'puppetlabs':
|
||||
location => 'http://apt.puppetlabs.com',
|
||||
repos => 'main',
|
||||
key => '4BD6EC30',
|
||||
key_server => 'pgp.mit.edu',
|
||||
}
|
||||
EOS
|
||||
context 'ensure => present' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::source { 'puppetlabs':
|
||||
ensure => present,
|
||||
location => 'http://apt.puppetlabs.com',
|
||||
repos => 'main',
|
||||
key => '4BD6EC30',
|
||||
key_server => 'pgp.mit.edu',
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
|
||||
shell('rm /etc/apt/sources.list.d/puppetlabs.list', :acceptable_exit_codes => [0,1,2])
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe 'key should exist' do
|
||||
it 'finds puppetlabs key' do
|
||||
shell('apt-key list | grep 4BD6EC30') do |r|
|
||||
expect(r.exit_code).to be_zero
|
||||
describe 'key should exist' do
|
||||
it 'finds puppetlabs key' do
|
||||
shell('apt-key list | grep 4BD6EC30', :acceptable_exit_codes => [0])
|
||||
end
|
||||
end
|
||||
|
||||
describe file('/etc/apt/sources.list.d/puppetlabs.list') do
|
||||
it { should be_file }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'source should exist' do
|
||||
context 'ensure => absent' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::source { 'puppetlabs':
|
||||
ensure => absent,
|
||||
location => 'http://apt.puppetlabs.com',
|
||||
repos => 'main',
|
||||
key => '4BD6EC30',
|
||||
key_server => 'pgp.mit.edu',
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
# The key should remain -we don't delete those when deleting a source.
|
||||
describe 'key should exist' do
|
||||
it 'finds puppetlabs key' do
|
||||
shell('apt-key list | grep 4BD6EC30', :acceptable_exit_codes => [0])
|
||||
end
|
||||
end
|
||||
describe file('/etc/apt/sources.list.d/puppetlabs.list') do
|
||||
it { should_not be_file }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'release' do
|
||||
context 'test' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::source { 'puppetlabs':
|
||||
ensure => present,
|
||||
location => 'http://apt.puppetlabs.com',
|
||||
repos => 'main',
|
||||
key => '4BD6EC30',
|
||||
key_server => 'pgp.mit.edu',
|
||||
release => 'precise',
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/sources.list.d/puppetlabs.list') do
|
||||
it { should be_file }
|
||||
it { should contain 'deb http://apt.puppetlabs.com precise main' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'include_src' do
|
||||
context 'true' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::source { 'puppetlabs':
|
||||
ensure => present,
|
||||
location => 'http://apt.puppetlabs.com',
|
||||
repos => 'main',
|
||||
key => '4BD6EC30',
|
||||
key_server => 'pgp.mit.edu',
|
||||
include_src => true,
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/sources.list.d/puppetlabs.list') do
|
||||
it { should be_file }
|
||||
it { should contain 'deb-src http://apt.puppetlabs.com' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'false' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::source { 'puppetlabs':
|
||||
ensure => present,
|
||||
location => 'http://apt.puppetlabs.com',
|
||||
repos => 'main',
|
||||
key => '4BD6EC30',
|
||||
key_server => 'pgp.mit.edu',
|
||||
include_src => false,
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/sources.list.d/puppetlabs.list') do
|
||||
it { should be_file }
|
||||
it { should_not contain 'deb-src http://apt.puppetlabs.com' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'required_packages' do
|
||||
context 'vim' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::source { 'puppetlabs':
|
||||
ensure => present,
|
||||
location => 'http://apt.puppetlabs.com',
|
||||
repos => 'main',
|
||||
key => '4BD6EC30',
|
||||
key_server => 'pgp.mit.edu',
|
||||
required_packages => 'vim',
|
||||
}
|
||||
EOS
|
||||
|
||||
shell('apt-get -y remove vim')
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe package('vim') do
|
||||
it { should be_installed }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'key content' do
|
||||
context 'giant key' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::source { 'puppetlabs':
|
||||
ensure => present,
|
||||
location => 'http://apt.puppetlabs.com',
|
||||
repos => 'main',
|
||||
key => '4BD6EC30',
|
||||
key_content => '-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
Version: GnuPG v1.4.12 (GNU/Linux)
|
||||
Comment: GPGTools - http://gpgtools.org
|
||||
|
||||
mQINBEw3u0ABEAC1+aJQpU59fwZ4mxFjqNCgfZgDhONDSYQFMRnYC1dzBpJHzI6b
|
||||
fUBQeaZ8rh6N4kZ+wq1eL86YDXkCt4sCvN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xLlTZKcdSqo0/qmS2A863Y
|
||||
ZQ0ZBe+Xyf5OI33+y+Mry+vl6Lre2VfPm3udgR10E4tWXJ9Q2CmG+zNPWt73U1FD
|
||||
7xBI7PPvOlyzCX4QJhy2Fn/fvzaNjHp4/FSiCw0HvX01epcersyun3xxPkRIjwwR
|
||||
M9m5MJ0o4hhPfa97zibXSh8XXBnosBQxeg6nEnb26eorVQbqGx0ruu/W2m5/JpUf
|
||||
REsFmNOBUbi8xlKNS5CZypH3Zh88EZiTFolOMEh+hT6s0l6znBAGGZ4m/Unacm5y
|
||||
DHmg7unCk4JyVopQ2KHMoqG886elu+rm0ASkhyqBAk9sWKptMl3NHiYTRE/m9VAk
|
||||
ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU=
|
||||
=a34C
|
||||
-----END PGP PUBLIC KEY BLOCK-----',
|
||||
}
|
||||
EOS
|
||||
|
||||
shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/sources.list.d/puppetlabs.list') do
|
||||
it { should be_file }
|
||||
end
|
||||
describe 'keys should exist' do
|
||||
it 'finds puppetlabs key' do
|
||||
shell('apt-key list | grep 4BD6EC30')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'key_source' do
|
||||
context 'http://apt.puppetlabs.com/pubkey.gpg' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::source { 'puppetlabs':
|
||||
ensure => present,
|
||||
location => 'http://apt.puppetlabs.com',
|
||||
release => 'precise',
|
||||
repos => 'main',
|
||||
key => '4BD6EC30',
|
||||
key_source => 'http://apt.puppetlabs.com/pubkey.gpg',
|
||||
}
|
||||
EOS
|
||||
|
||||
shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2])
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/sources.list.d/puppetlabs.list') do
|
||||
it { should be_file }
|
||||
it { should contain 'deb http://apt.puppetlabs.com precise main' }
|
||||
end
|
||||
describe 'keys should exist' do
|
||||
it 'finds puppetlabs key' do
|
||||
shell('apt-key list | grep 4BD6EC30')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'pin' do
|
||||
context 'false' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::source { 'puppetlabs':
|
||||
ensure => present,
|
||||
location => 'http://apt.puppetlabs.com',
|
||||
repos => 'main',
|
||||
key => '4BD6EC30',
|
||||
key_server => 'pgp.mit.edu',
|
||||
pin => false,
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/preferences.d/puppetlabs.pref') do
|
||||
it { should_not be_file }
|
||||
end
|
||||
end
|
||||
context 'true' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::source { 'puppetlabs':
|
||||
ensure => present,
|
||||
location => 'http://apt.puppetlabs.com',
|
||||
repos => 'main',
|
||||
key => '4BD6EC30',
|
||||
key_server => 'pgp.mit.edu',
|
||||
pin => true,
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/preferences.d/puppetlabs.pref') do
|
||||
it { should be_file }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'reset' do
|
||||
it 'clean up puppetlabs repo' do
|
||||
shell('apt-key del 4BD6EC30')
|
||||
shell('rm /etc/apt/sources.list.d/puppetlabs.list')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
233
spec/acceptance/apt_spec.rb
Normal file
233
spec/acceptance/apt_spec.rb
Normal file
|
@ -0,0 +1,233 @@
|
|||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'apt class' do
|
||||
|
||||
context 'reset' do
|
||||
it 'fixes the sources.list' do
|
||||
shell('cp /etc/apt/sources.list /tmp')
|
||||
end
|
||||
end
|
||||
|
||||
context 'always_apt_update => true' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
class { 'apt': always_apt_update => true }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/apt_update/)
|
||||
end
|
||||
end
|
||||
end
|
||||
context 'always_apt_update => false' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
class { 'apt': always_apt_update => false }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to_not match(/apt_update/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# disable_keys drops in a 99unauth file to ignore keys in
|
||||
# other files.
|
||||
context 'disable_keys => true' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
class { 'apt': disable_keys => true }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/99unauth') do
|
||||
it { should be_file }
|
||||
it { should contain 'APT::Get::AllowUnauthenticated 1;' }
|
||||
end
|
||||
end
|
||||
context 'disable_keys => false' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
class { 'apt': disable_keys => false }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/99unauth') do
|
||||
it { should_not be_file }
|
||||
end
|
||||
end
|
||||
|
||||
# proxy_host sets the proxy to use for transfers.
|
||||
# proxy_port sets the proxy port to use.
|
||||
context 'proxy settings' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
class { 'apt':
|
||||
proxy_host => 'localhost',
|
||||
proxy_port => '8080',
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/proxy') do
|
||||
it { should be_file }
|
||||
it { should contain 'Acquire::http::Proxy "http://localhost:8080\";' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'purge_sources' do
|
||||
it 'creates a fake apt file' do
|
||||
shell('touch /etc/apt/sources.list.d/fake.list')
|
||||
shell('echo "deb fake" >> /etc/apt/sources.list')
|
||||
end
|
||||
it 'purge_sources_list and purge_sources_list_d => true' do
|
||||
pp = <<-EOS
|
||||
class { 'apt':
|
||||
purge_sources_list => true,
|
||||
purge_sources_list_d => true,
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/sources.list') do
|
||||
it { should_not contain 'deb fake' }
|
||||
end
|
||||
|
||||
describe file('/etc/apt/sources.list.d/fake.list') do
|
||||
it { should_not be_file }
|
||||
end
|
||||
end
|
||||
context 'proxy settings' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
class { 'apt':
|
||||
proxy_host => 'localhost',
|
||||
proxy_port => '8080',
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/proxy') do
|
||||
it { should be_file }
|
||||
it { should contain 'Acquire::http::Proxy "http://localhost:8080\";' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'purge_sources' do
|
||||
context 'false' do
|
||||
it 'creates a fake apt file' do
|
||||
shell('touch /etc/apt/sources.list.d/fake.list')
|
||||
shell('echo "deb fake" >> /etc/apt/sources.list')
|
||||
end
|
||||
it 'purge_sources_list and purge_sources_list_d => false' do
|
||||
pp = <<-EOS
|
||||
class { 'apt':
|
||||
purge_sources_list => false,
|
||||
purge_sources_list_d => false,
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => false)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/sources.list') do
|
||||
it { should contain 'deb fake' }
|
||||
end
|
||||
|
||||
describe file('/etc/apt/sources.list.d/fake.list') do
|
||||
it { should be_file }
|
||||
end
|
||||
end
|
||||
|
||||
context 'true' do
|
||||
it 'creates a fake apt file' do
|
||||
shell('touch /etc/apt/sources.list.d/fake.list')
|
||||
shell('echo "deb fake" >> /etc/apt/sources.list')
|
||||
end
|
||||
it 'purge_sources_list and purge_sources_list_d => true' do
|
||||
pp = <<-EOS
|
||||
class { 'apt':
|
||||
purge_sources_list => true,
|
||||
purge_sources_list_d => true,
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/sources.list') do
|
||||
it { should_not contain 'deb fake' }
|
||||
end
|
||||
|
||||
describe file('/etc/apt/sources.list.d/fake.list') do
|
||||
it { should_not be_file }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'purge_preferences_d' do
|
||||
context 'false' do
|
||||
it 'creates a preferences file' do
|
||||
shell('touch /etc/apt/preferences.d/test')
|
||||
end
|
||||
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
class { 'apt': purge_preferences_d => false }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/preferences.d/test') do
|
||||
it { should be_file }
|
||||
end
|
||||
end
|
||||
context 'true' do
|
||||
it 'creates a preferences file' do
|
||||
shell('touch /etc/apt/preferences.d/test')
|
||||
end
|
||||
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
class { 'apt': purge_preferences_d => true }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/preferences.d/test') do
|
||||
it { should_not be_file }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'update_timeout' do
|
||||
context '5000' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
class { 'apt': update_timeout => '5000' }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'reset' do
|
||||
it 'fixes the sources.list' do
|
||||
shell('cp /tmp/sources.list /etc/apt')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
59
spec/acceptance/backports_spec.rb
Normal file
59
spec/acceptance/backports_spec.rb
Normal file
|
@ -0,0 +1,59 @@
|
|||
require 'spec_helper_acceptance'
|
||||
|
||||
codename = fact('lsbdistcodename')
|
||||
case fact('operatingsystem')
|
||||
when 'Ubuntu'
|
||||
repos = 'main universe multiverse restricted'
|
||||
when 'Debian'
|
||||
repos = 'main contrib non-free'
|
||||
end
|
||||
|
||||
describe 'apt::backports class' do
|
||||
context 'defaults' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
class { 'apt::backports': }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
end
|
||||
|
||||
context 'release' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
class { 'apt::backports': release => '#{codename}' }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/sources.list.d/backports.list') do
|
||||
it { should be_file }
|
||||
it { should contain "#{codename}-backports #{repos}" }
|
||||
end
|
||||
end
|
||||
|
||||
context 'location' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
class { 'apt::backports': release => 'precise', location => 'http://localhost/ubuntu' }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/sources.list.d/backports.list') do
|
||||
it { should be_file }
|
||||
it { should contain "deb http://localhost/ubuntu precise-backports #{repos}" }
|
||||
end
|
||||
end
|
||||
|
||||
context 'reset' do
|
||||
it 'deletes backport files' do
|
||||
shell('rm -rf /etc/apt/sources.list.d/backports.list')
|
||||
shell('rm -rf /etc/apt/preferences.d/backports.pref')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
66
spec/acceptance/conf_spec.rb
Normal file
66
spec/acceptance/conf_spec.rb
Normal file
|
@ -0,0 +1,66 @@
|
|||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'apt::conf define' do
|
||||
context 'defaults' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
apt::conf { 'test':
|
||||
content => 'test',
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/50test') do
|
||||
it { should be_file }
|
||||
it { should contain 'test' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'ensure' do
|
||||
context 'absent' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
apt::conf { 'test':
|
||||
ensure => absent,
|
||||
content => 'test',
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/50test') do
|
||||
it { should_not be_file }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'priority' do
|
||||
context '99' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
apt::conf { 'test':
|
||||
ensure => present,
|
||||
content => 'test',
|
||||
priority => '99',
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/99test') do
|
||||
it { should be_file }
|
||||
it { should contain 'test' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'cleanup' do
|
||||
it 'deletes 99test' do
|
||||
shell ('rm -rf /etc/apt/apt.conf.d/99test')
|
||||
end
|
||||
end
|
||||
end
|
76
spec/acceptance/force_spec.rb
Normal file
76
spec/acceptance/force_spec.rb
Normal file
|
@ -0,0 +1,76 @@
|
|||
require 'spec_helper_acceptance'
|
||||
|
||||
codename = fact('lsbdistcodename')
|
||||
|
||||
describe 'apt::force define' do
|
||||
context 'defaults' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
apt::force { 'vim': }
|
||||
EOS
|
||||
|
||||
shell('apt-get remove -y vim')
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe package('vim') do
|
||||
it { should be_installed }
|
||||
end
|
||||
end
|
||||
|
||||
context 'release' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
apt::force { 'vim': release => '#{codename}' }
|
||||
EOS
|
||||
|
||||
shell('apt-get remove -y vim')
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/apt-get -y -t #{codename} install vim/)
|
||||
end
|
||||
end
|
||||
|
||||
describe package('vim') do
|
||||
it { should be_installed }
|
||||
end
|
||||
end
|
||||
|
||||
context 'version' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
apt::force { 'vim': version => '1.1.1' }
|
||||
EOS
|
||||
|
||||
shell('apt-get remove -y vim')
|
||||
apply_manifest(pp, :catch_failures => false) do |r|
|
||||
expect(r.stdout).to match(/apt-get -y install vim=1.1.1/)
|
||||
end
|
||||
end
|
||||
|
||||
describe package('vim') do
|
||||
it { should_not be_installed }
|
||||
end
|
||||
end
|
||||
|
||||
context 'timeout' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
apt::force { 'vim': timeout => '1' }
|
||||
EOS
|
||||
|
||||
shell('apt-get clean')
|
||||
apply_manifest(pp, :expect_failures => true) do |r|
|
||||
expect(r.stderr).to match(/Error: Command exceeded timeout/)
|
||||
end
|
||||
end
|
||||
|
||||
describe package('vim') do
|
||||
it { should_not be_installed }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
266
spec/acceptance/pin_spec.rb
Normal file
266
spec/acceptance/pin_spec.rb
Normal file
|
@ -0,0 +1,266 @@
|
|||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'apt::pin define' do
|
||||
context 'defaults' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
apt::pin { 'vim-puppet': }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/preferences.d/vim-puppet.pref') do
|
||||
it { should be_file }
|
||||
it { should contain 'Pin: release a=vim-puppet' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'ensure' do
|
||||
context 'present' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
apt::pin { 'vim-puppet': ensure => present }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/preferences.d/vim-puppet.pref') do
|
||||
it { should be_file }
|
||||
it { should contain 'Pin: release a=vim-puppet' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'absent' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
apt::pin { 'vim-puppet': ensure => absent }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/preferences.d/vim-puppet.pref') do
|
||||
it { should_not be_file }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'order' do
|
||||
context '99' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
apt::pin { 'vim-puppet':
|
||||
ensure => present,
|
||||
order => '99',
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/preferences.d/99-vim-puppet.pref') do
|
||||
it { should be_file }
|
||||
it { should contain 'Pin: release a=vim-puppet' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'packages' do
|
||||
context 'test' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
apt::pin { 'vim-puppet':
|
||||
ensure => present,
|
||||
packages => 'test',
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/preferences.d/vim-puppet.pref') do
|
||||
it { should be_file }
|
||||
it { should contain 'Package: test' }
|
||||
it { should contain 'Pin: release a=vim-puppet' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'release' do
|
||||
context 'testrelease' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
apt::pin { 'vim-puppet':
|
||||
ensure => present,
|
||||
release => 'testrelease',
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/preferences.d/vim-puppet.pref') do
|
||||
it { should be_file }
|
||||
it { should contain 'Pin: release a=testrelease' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'origin' do
|
||||
context 'testrelease' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
apt::pin { 'vim-puppet':
|
||||
ensure => present,
|
||||
origin => 'testrelease',
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/preferences.d/vim-puppet.pref') do
|
||||
it { should be_file }
|
||||
it { should contain 'Pin: origin "testrelease"' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'version' do
|
||||
context '1.0.0' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
apt::pin { 'vim-puppet':
|
||||
ensure => present,
|
||||
packages => 'test',
|
||||
version => '1.0.0',
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/preferences.d/vim-puppet.pref') do
|
||||
it { should be_file }
|
||||
it { should contain 'Package: test' }
|
||||
it { should contain 'Pin: version 1.0.0' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'codename' do
|
||||
context 'testname' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
apt::pin { 'vim-puppet':
|
||||
ensure => present,
|
||||
codename => 'testname',
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/preferences.d/vim-puppet.pref') do
|
||||
it { should be_file }
|
||||
it { should contain 'Pin: release n=testname' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'release_version' do
|
||||
context '1.1.1' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
apt::pin { 'vim-puppet':
|
||||
ensure => present,
|
||||
release_version => '1.1.1',
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/preferences.d/vim-puppet.pref') do
|
||||
it { should be_file }
|
||||
it { should contain 'Pin: release v=1.1.1' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'component' do
|
||||
context 'testcomponent' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
apt::pin { 'vim-puppet':
|
||||
ensure => present,
|
||||
component => 'testcomponent',
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/preferences.d/vim-puppet.pref') do
|
||||
it { should be_file }
|
||||
it { should contain 'Pin: release c=testcomponent' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'originator' do
|
||||
context 'testorigin' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
apt::pin { 'vim-puppet':
|
||||
ensure => present,
|
||||
originator => 'testorigin',
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/preferences.d/vim-puppet.pref') do
|
||||
it { should be_file }
|
||||
it { should contain 'Pin: release o=testorigin' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'label' do
|
||||
context 'testlabel' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
apt::pin { 'vim-puppet':
|
||||
ensure => present,
|
||||
label => 'testlabel',
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/preferences.d/vim-puppet.pref') do
|
||||
it { should be_file }
|
||||
it { should contain 'Pin: release l=testlabel' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
26
spec/acceptance/release_spec.rb
Normal file
26
spec/acceptance/release_spec.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'apt::release class' do
|
||||
context 'release_id' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::release': release_id => 'precise', }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/01release') do
|
||||
it { should be_file }
|
||||
it { should contain 'APT::Default-Release "precise";' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'reset' do
|
||||
it 'cleans up' do
|
||||
shell('rm -rf /etc/apt/apt.conf.d/01release')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
562
spec/acceptance/unattended_upgrade_spec.rb
Normal file
562
spec/acceptance/unattended_upgrade_spec.rb
Normal file
|
@ -0,0 +1,562 @@
|
|||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'apt::unattended_upgrades class' do
|
||||
context 'defaults' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
include apt::unattended_upgrades
|
||||
EOS
|
||||
|
||||
# Attempted workaround for problems seen on debian with
|
||||
# something holding the package database open.
|
||||
#shell('killall -9 apt-get')
|
||||
#shell('killall -9 dpkg')
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/10periodic') do
|
||||
it { should be_file }
|
||||
end
|
||||
describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
|
||||
it { should be_file }
|
||||
end
|
||||
end
|
||||
|
||||
context 'origins' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
origins => ['${distro_id}:${distro_codename}-test'],
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
|
||||
it { should be_file }
|
||||
it { should contain '${distro_id}:${distro_codename}-test' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'blacklist' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
blacklist => ['puppet']
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
|
||||
it { should be_file }
|
||||
it { should contain 'puppet' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'update' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
update => '99'
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/10periodic') do
|
||||
it { should be_file }
|
||||
it { should contain 'APT::Periodic::Update-Package-Lists "99";' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'download' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
download => '99'
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/10periodic') do
|
||||
it { should be_file }
|
||||
it { should contain 'APT::Periodic::Download-Upgradeable-Packages "99";' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'upgrade' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
upgrade => '99'
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/10periodic') do
|
||||
it { should be_file }
|
||||
it { should contain 'APT::Periodic::Unattended-Upgrade "99";' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'autoclean' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
autoclean => '99'
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/10periodic') do
|
||||
it { should be_file }
|
||||
it { should contain 'APT::Periodic::AutocleanInterval "99";' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'auto_fix' do
|
||||
context 'true' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
auto_fix => true
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
|
||||
it { should be_file }
|
||||
it { should contain 'Unattended-Upgrade::AutoFixInterruptedDpkg "true";' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'false' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
auto_fix => false
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
|
||||
it { should be_file }
|
||||
it { should contain 'Unattended-Upgrade::AutoFixInterruptedDpkg "false";' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'minimal_steps' do
|
||||
context 'true' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
minimal_steps => true
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
|
||||
it { should be_file }
|
||||
it { should contain 'Unattended-Upgrade::MinimalSteps "true";' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'false' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
minimal_steps => false
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
|
||||
it { should be_file }
|
||||
it { should contain 'Unattended-Upgrade::MinimalSteps "false";' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'install_on_shutdown' do
|
||||
context 'true' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
install_on_shutdown => true
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
|
||||
it { should be_file }
|
||||
it { should contain 'Unattended-Upgrade::InstallOnShutdown "true";' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'false' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
install_on_shutdown => false
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
|
||||
it { should be_file }
|
||||
it { should contain 'Unattended-Upgrade::InstallOnShutdown "false";' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'mail_to' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
mail_to => 'test@example.com'
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
|
||||
it { should be_file }
|
||||
it { should contain 'Unattended-Upgrade::Mail "test@example.com";' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'mail_only_on_error' do
|
||||
context 'true' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
mail_to => 'test@example.com',
|
||||
mail_only_on_error => true
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
|
||||
it { should be_file }
|
||||
it { should contain 'Unattended-Upgrade::MailOnlyOnError "true";' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'false' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
mail_to => 'test@example.com',
|
||||
mail_only_on_error => false,
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
|
||||
it { should be_file }
|
||||
it { should contain 'Unattended-Upgrade::MailOnlyOnError "false";' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'mail_to missing' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
mail_only_on_error => true,
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
|
||||
it { should be_file }
|
||||
it { should_not contain 'Unattended-Upgrade::MailOnlyOnError "true";' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'remove_unused' do
|
||||
context 'true' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
remove_unused => true
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
|
||||
it { should be_file }
|
||||
it { should contain 'Unattended-Upgrade::Remove-Unused-Dependencies "true";' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'false' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
remove_unused => false,
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
|
||||
it { should be_file }
|
||||
it { should contain 'Unattended-Upgrade::Remove-Unused-Dependencies "false";' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'auto_reboot' do
|
||||
context 'true' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
auto_reboot => true
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
|
||||
it { should be_file }
|
||||
it { should contain 'Unattended-Upgrade::Automatic-Reboot "true";' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'false' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
auto_reboot => false,
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
|
||||
it { should be_file }
|
||||
it { should contain 'Unattended-Upgrade::Automatic-Reboot "false";' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'dl_limit' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
dl_limit => '99'
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do
|
||||
it { should be_file }
|
||||
it { should contain 'Acquire::http::Dl-Limit "99"' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'enable' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
enable => '2'
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/10periodic') do
|
||||
it { should be_file }
|
||||
it { should contain 'APT::Periodic::Enable "2"' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'backup_interval' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
backup_interval => '2'
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/10periodic') do
|
||||
it { should be_file }
|
||||
it { should contain 'APT::Periodic::BackUpArchiveInterval "2";' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'backup_level' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
backup_level => '2'
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/10periodic') do
|
||||
it { should be_file }
|
||||
it { should contain 'APT::Periodic::BackUpLevel "2";' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'max_age' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
max_age => '2'
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/10periodic') do
|
||||
it { should be_file }
|
||||
it { should contain 'APT::Periodic::MaxAge "2";' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'min_age' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
min_age => '2'
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/10periodic') do
|
||||
it { should be_file }
|
||||
it { should contain 'APT::Periodic::MinAge "2";' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'max_size' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
max_size => '2'
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/10periodic') do
|
||||
it { should be_file }
|
||||
it { should contain 'APT::Periodic::MaxSize "2";' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'download_delta' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
download_delta => '2'
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/10periodic') do
|
||||
it { should be_file }
|
||||
it { should contain 'APT::Periodic::Download-Upgradeable-Packages-Debdelta "2";' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'verbose' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include apt
|
||||
class { 'apt::unattended_upgrades':
|
||||
verbose => '2'
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
describe file('/etc/apt/apt.conf.d/10periodic') do
|
||||
it { should be_file }
|
||||
it { should contain 'APT::Periodic::Verbose "2";' }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in a new issue