]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
MODULES-1661 Fix issue with apt_key destroy, also added mutliple deletes
authorTravis Fields <travis@puppetlabs.com>
Tue, 13 Jan 2015 23:54:10 +0000 (15:54 -0800)
committerTravis Fields <travis@puppetlabs.com>
Wed, 14 Jan 2015 01:40:18 +0000 (17:40 -0800)
lib/puppet/provider/apt_key/apt_key.rb
spec/acceptance/apt_key_provider_spec.rb

index c80f41f0dcf47bbbdb1f06b7a09e546530e73d59..201c022d99a76458ce005e5c3a15012f935e00ac 100644 (file)
@@ -50,7 +50,7 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do
 
       new(
         :name        => line_hash[:key_fingerprint],
-        :id          => line_hash[:key_fingerprint],
+        :id          => line_hash[:key_long],
         :fingerprint => line_hash[:key_fingerprint],
         :short       => line_hash[:key_short],
         :long        => line_hash[:key_long],
@@ -166,8 +166,10 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do
   end
 
   def destroy
-    #Currently del only removes the first key, we need to recursively list and ensure all with id are absent.
-    apt_key('del', resource[:id])
+    begin
+      apt_key('del', resource.provider.long)
+      r = execute(["#{command(:apt_key)} list | grep #{resource.provider.long}"], :failonfail => false)
+    end while r.exitstatus == 0
     @property_hash.clear
   end
 
index aa1e5a425ec0e49d680f649eae63b874cf5144c0..24277d237ad60fcf392332e7eedc4b3e7d6d6a95 100644 (file)
@@ -11,6 +11,8 @@ CENTOS_GPG_KEY_FINGERPRINT     = 'C1DAC52D1664E8A4386DBA430946FCA2C105B9DE'
 CENTOS_REPO_URL                = 'ftp.cvut.cz/centos'
 CENTOS_GPG_KEY_FILE            = 'RPM-GPG-KEY-CentOS-6'
 
+SHOULD_NEVER_EXIST_ID          = '4BD6EC30'
+
 KEY_CHECK_COMMAND              = "apt-key adv --list-keys --with-colons --fingerprint | grep "
 PUPPETLABS_KEY_CHECK_COMMAND   = "#{KEY_CHECK_COMMAND} #{PUPPETLABS_GPG_KEY_FINGERPRINT}"
 CENTOS_KEY_CHECK_COMMAND       = "#{KEY_CHECK_COMMAND} #{CENTOS_GPG_KEY_FINGERPRINT}"
@@ -351,7 +353,7 @@ ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU=
       it 'fails with a 550' do
         pp = <<-EOS
         apt_key { 'CentOS 6':
-          id     => '#{CENTOS_GPG_KEY_LONG_ID}',
+          id     => '#{SHOULD_NEVER_EXIST_ID}',
           ensure => 'present',
           source => 'ftp://#{CENTOS_REPO_URL}/herpderp.gpg',
         }
@@ -395,7 +397,7 @@ ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU=
       it 'fails with a 404' do
         pp = <<-EOS
         apt_key { 'puppetlabs':
-          id     => '4BD6EC30',
+          id     => '#{SHOULD_NEVER_EXIST_ID}',
           ensure => 'present',
           source => 'https://#{PUPPETLABS_APT_URL}/herpderp.gpg',
         }
@@ -409,7 +411,7 @@ ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU=
       it 'fails with a socket error' do
         pp = <<-EOS
         apt_key { 'puppetlabs':
-          id     => '4BD6EC30',
+          id     => '#{SHOULD_NEVER_EXIST_ID}',
           ensure => 'present',
           source => 'https://apt.puppetlabss.com/herpderp.gpg',
         }