X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Facceptance%2Fapt_key_provider_spec.rb;h=3f2536c7f09819760b723da13535ab5abf4d6ff1;hb=553e3004ba3468a0a9fd316bd2141a8cc452e897;hp=497c6edb53d2bdb80d1af336975ab52663360d79;hpb=239232bbd44c6dabc3f305bd23b354481d9f8a71;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb index 497c6ed..3f2536c 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -1,14 +1,19 @@ 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' +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 @@ -36,7 +41,7 @@ describe 'apt_key' do 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 @@ -59,6 +64,32 @@ describe 'apt_key' do 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': @@ -69,12 +100,12 @@ describe 'apt_key' do # 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]) @@ -153,7 +184,7 @@ ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU= 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 @@ -187,7 +218,7 @@ ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU= 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 @@ -203,7 +234,7 @@ ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU= 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 @@ -253,7 +284,7 @@ ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU= 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 @@ -302,7 +333,7 @@ ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU= 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 @@ -346,7 +377,7 @@ ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU= 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 @@ -399,7 +430,7 @@ ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU= 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 @@ -456,7 +487,7 @@ ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU= 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 @@ -469,6 +500,7 @@ ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU= } 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