require 'spec_helper_acceptance'
-PUPPETLABS_GPG_KEY_ID = '4BD6EC30'
-PUPPETLABS_APT_URL = 'apt.puppetlabs.com'
-PUPPETLABS_GPG_KEY_FILE = 'pubkey.gpg'
-CENTOS_GPG_KEY_ID = 'C105B9DE'
-CENTOS_REPO_URL = 'ftp.cvut.cz/centos'
-CENTOS_GPG_KEY_FILE = 'RPM-GPG-KEY-CentOS-6'
-
-describe 'apt_key', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
+PUPPETLABS_GPG_KEY_ID = '4BD6EC30'
+PUPPETLABS_GPG_LONG_KEY_ID = '1054B7A24BD6EC30'
+PUPPETLABS_APT_URL = 'apt.puppetlabs.com'
+PUPPETLABS_GPG_KEY_FILE = 'pubkey.gpg'
+CENTOS_GPG_KEY_ID = 'C105B9DE'
+CENTOS_REPO_URL = 'ftp.cvut.cz/centos'
+CENTOS_GPG_KEY_FILE = 'RPM-GPG-KEY-CentOS-6'
+
+describe 'apt_key' do
before(:each) do
+ # Delete twice to make sure everything is cleaned
+ # up after the short key collision
+ shell("apt-key del #{PUPPETLABS_GPG_KEY_ID}",
+ :acceptable_exit_codes => [0,1,2])
shell("apt-key del #{PUPPETLABS_GPG_KEY_ID}",
:acceptable_exit_codes => [0,1,2])
end
EOS
apply_manifest(pp, :catch_failures => true)
- expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+ apply_manifest(pp, :catch_changes => true)
shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
end
end
describe 'ensure =>' do
context 'absent' do
+ it 'is removed' do
+ pp = <<-EOS
+ apt_key { 'centos':
+ id => '#{CENTOS_GPG_KEY_ID}',
+ ensure => 'absent',
+ }
+ EOS
+
+ # Install the key first
+ shell("apt-key adv --keyserver keyserver.ubuntu.com \
+ --recv-keys #{CENTOS_GPG_KEY_ID}")
+ shell("apt-key list | grep #{CENTOS_GPG_KEY_ID}")
+
+ # Time to remove it using Puppet
+ apply_manifest(pp, :catch_failures => true)
+ apply_manifest(pp, :catch_failures => true)
+
+ shell("apt-key list | grep #{CENTOS_GPG_KEY_ID}",
+ :acceptable_exit_codes => [1])
+
+ shell("apt-key adv --keyserver keyserver.ubuntu.com \
+ --recv-keys #{CENTOS_GPG_KEY_ID}")
+ end
+ end
+
+ context 'absent, added with long key', :unless => (fact('operatingsystem') == 'Debian' and fact('operatingsystemmajrelease') == '6') do
it 'is removed' do
pp = <<-EOS
apt_key { 'puppetlabs':
# Install the key first
shell("apt-key adv --keyserver keyserver.ubuntu.com \
- --recv-keys #{PUPPETLABS_GPG_KEY_ID}")
+ --recv-keys #{PUPPETLABS_GPG_LONG_KEY_ID}")
shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
# Time to remove it using Puppet
apply_manifest(pp, :catch_failures => true)
- expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+ apply_manifest(pp, :catch_failures => true)
shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}",
:acceptable_exit_codes => [1])
EOS
apply_manifest(pp, :catch_failures => true)
- expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+ apply_manifest(pp, :catch_failures => true)
shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
end
end
EOS
apply_manifest(pp, :catch_failures => true)
- expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+ apply_manifest(pp, :catch_failures => true)
shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
end
end
EOS
apply_manifest(pp, :catch_failures => true)
- expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+ apply_manifest(pp, :catch_failures => true)
shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
end
end
EOS
apply_manifest(pp, :catch_failures => true)
- expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+ apply_manifest(pp, :catch_failures => true)
shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
end
EOS
apply_manifest(pp, :catch_failures => true)
- expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+ apply_manifest(pp, :catch_failures => true)
shell("apt-key list | grep #{CENTOS_GPG_KEY_ID}")
end
EOS
apply_manifest(pp, :catch_failures => true)
- expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+ apply_manifest(pp, :catch_failures => true)
shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
end
EOS
apply_manifest(pp, :catch_failures => true)
- expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+ apply_manifest(pp, :catch_failures => true)
shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
end
end
EOS
apply_manifest(pp, :catch_failures => true)
- expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
+ apply_manifest(pp, :catch_failures => true)
shell("apt-key list | grep #{PUPPETLABS_GPG_KEY_ID}")
end
}
EOS
+ shell("apt-key del #{PUPPETLABS_GPG_KEY_ID}", :acceptable_exit_codes => [0,1,2])
apply_manifest(pp, :expect_failures => true) do |r|
expect(r.stderr).to match(/--keyserver-options this is totally/)
end