forked from evolvingweb/puppet-apt
-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial commit for gpg version checking
better attempt at gpg version checking adding in key length warning
- Loading branch information
tphoney
committed
Mar 10, 2015
1 parent
b473af1
commit 00e51eb
Showing
4 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require 'facter' | ||
|
||
Facter.add("apt_gpgversion") do | ||
confine :osfamily => 'Debian' | ||
setcode do | ||
if File.executable? "/usr/bin/gpg" | ||
Facter::Util::Resolution.exec("/usr/bin/gpg --version | head -n 1 | awk '{print $NF}'") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require 'spec_helper' | ||
|
||
describe 'apt_gpg fact' do | ||
subject { Facter.fact(:apt_gpgversion).value } | ||
after(:each) { Facter.clear } | ||
|
||
describe 'on non-Debian distro' do | ||
before { | ||
Facter.fact(:osfamily).expects(:value).at_least(1).returns 'RedHat' | ||
} | ||
it { should be_nil } | ||
end | ||
|
||
describe 'on Debian based distro, missing gpg' do | ||
before { | ||
Facter.fact(:osfamily).expects(:value).at_least(1).returns 'Debian' | ||
File.stubs(:executable?) # Stub all other calls | ||
File.expects(:executable?).with('/usr/bin/gpg').returns false | ||
} | ||
it { should be_nil } | ||
end | ||
|
||
describe 'on Debian based distro with an old gpg' do | ||
before { | ||
Facter.fact(:osfamily).expects(:value).at_least(1).returns 'Debian' | ||
File.stubs(:executable?) # Stub all other calls | ||
Facter::Util::Resolution.stubs(:exec) # Catch all other calls | ||
File.expects(:executable?).with('/usr/bin/gpg').returns true | ||
Facter::Util::Resolution.expects(:exec).with("/usr/bin/gpg --version | head -n 1 | awk '{print $NF}'").returns "1.0.0" | ||
} | ||
it { should eq "1.0.0" } | ||
end | ||
|
||
describe 'on Debian based distro with a new gpg' do | ||
before { | ||
Facter.fact(:osfamily).expects(:value).at_least(1).returns 'Debian' | ||
File.stubs(:executable?) # Stub all other calls | ||
Facter::Util::Resolution.stubs(:exec) # Catch all other calls | ||
File.expects(:executable?).with('/usr/bin/gpg').returns true | ||
Facter::Util::Resolution.expects(:exec).with("/usr/bin/gpg --version | head -n 1 | awk '{print $NF}'").returns "4.0.0" | ||
} | ||
it { should eq "4.0.0" } | ||
end | ||
end | ||
|