Commit 6a15db32 authored by Stefan Schulte's avatar Stefan Schulte
Browse files

Handle the case where no key is installed

If there is currently no key present in the RPM keyring rpm -q returns
with a non-zero exitcode. This case is now handled properly so no
error message is shown when running puppet.
parent 320758b6
......@@ -4,7 +4,14 @@ Puppet::Type.type(:rpmkey).provide(:rpm) do
def self.instances
keys = []
rpm('-q','gpg-pubkey').each_line do |line|
begin
rpm_query = rpm('-q','gpg-pubkey')
rescue Puppet::ExecutionFailure
return []
end
rpm_query.each_line do |line|
if match = /^gpg-pubkey-([0-9a-f]*)-[0-9a-f]*/.match(line)
keys << new(:name => match.captures[0].upcase, :ensure => :present)
else
......
......@@ -21,6 +21,11 @@ describe Puppet::Type.type(:rpmkey).provider(:rpm) do
'23A254D4'
]
end
it "should return an empty list if no key is installed" do
described_class.expects(:rpm).with('-q', 'gpg-pubkey').raises Puppet::ExecutionFailure, 'package gpg-pubkey is not installed'
described_class.instances.should be_empty
end
end
describe "#exists?" do
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment