Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
immerda
Puppet Modules
rpmkey
Commits
dcfcf234
Commit
dcfcf234
authored
Feb 03, 2015
by
Stefan Schulte
Browse files
Dont crash on unexpected rpm output
parent
69814831
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/puppet/provider/rpmkey/rpm.rb
View file @
dcfcf234
...
...
@@ -12,10 +12,11 @@ Puppet::Type.type(:rpmkey).provide(:rpm) do
end
rpm_query
.
each_line
do
|
line
|
line
.
chomp!
if
match
=
/^gpg-pubkey-([0-9a-f]*)-[0-9a-f]*/
.
match
(
line
)
keys
<<
new
(
:name
=>
match
.
captures
[
0
].
upcase
,
:ensure
=>
:present
)
else
warning
"Unexpected rpm output
#{
line
.
ex
pect
}
. Ignoring this line."
warning
"Unexpected rpm output
#{
line
.
ins
pect
}
. Ignoring this line."
end
end
keys
...
...
spec/fixtures/unit/provider/rpmkey/rpm/rpm_q_unexpected
0 → 100644
View file @
dcfcf234
gpg-pubkey-db42a60e-37ea5438
gpg-pubkey-4f2a6fd2-3f9d9d3b
gpg-pubkey-4f2a6fd3
gpg-pubkey-23a254d4-41ddbc46
spec/unit/provider/rpmkey/rpm_spec.rb
View file @
dcfcf234
...
...
@@ -26,6 +26,16 @@ describe Puppet::Type.type(:rpmkey).provider(:rpm) do
described_class
.
expects
(
:rpm
).
with
(
'-q'
,
'gpg-pubkey'
).
raises
Puppet
::
ExecutionFailure
,
'package gpg-pubkey is not installed'
expect
(
described_class
.
instances
).
to
be_empty
end
it
"should warn and ignore unexpected output"
do
described_class
.
expects
(
:rpm
).
with
(
'-q'
,
'gpg-pubkey'
).
returns
File
.
read
(
my_fixture
(
'rpm_q_unexpected'
))
described_class
.
expects
(
:warning
).
with
(
'Unexpected rpm output "gpg-pubkey-4f2a6fd3". Ignoring this line.'
)
expect
(
described_class
.
instances
.
map
(
&
:name
)).
to
eq
([
'DB42A60E'
,
'4F2A6FD2'
,
'23A254D4'
])
end
end
describe
"#exists?"
do
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment