Skip to content

Commit

Permalink
Merge pull request #1 from mklette/master
Browse files Browse the repository at this point in the history
handle https:// key_sources
  • Loading branch information
dgolja committed Oct 3, 2014
2 parents 8558b0d + 29f633c commit 3173c20
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
6 changes: 4 additions & 2 deletions lib/puppet/provider/gnupg_key/gnupg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def add_public_key
else
uri = URI.parse(URI.escape(resource[:key_source]))
case uri.scheme
when /https?/
when /https/
command = "wget -O- #{resource[:key_source]} | gpg --import"
when /http/
command = "gpg --fetch-keys #{resource[:key_source]}"
when 'puppet'
Puppet::Util::SUIDManager.asuser(user_id) do
Expand Down Expand Up @@ -103,4 +105,4 @@ def create
def destroy
remove_public_key()
end
end
end
16 changes: 8 additions & 8 deletions spec/classes/gnupg_init_spec.rb
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
require 'spec_helper'

describe 'gnupg', :type => :class do

context 'on unsupported distributions' do
let(:facts) {{ :osfamily => 'Unsupported' }}

it 'we fail' do
expect { subject }.to raise_error(/Osfamily Unsupported is not supported/)
end
end

['RedHat', 'Debian', 'Linux'].each do |system|
if system == 'Linux'
let(:facts) {{ :osfamily => 'Linux', :operatingsystem => 'Amazon' }}
else
let(:facts) {{ :osfamily => system }}
end

it { should contain_class('gnupg::install') }

describe "gnupg on system #{system}" do

context "when enabled" do
let(:params) {{
:package_ensure => 'present',
:package_name => 'gnupg'
}}

it { should contain_package('gnupg').with({
'ensure' => 'present'})
}
end

context 'when disabled' do
let(:params) {{
:package_ensure => 'absent',
:package_name => 'gnupg'
}}

it { should contain_package('gnupg').with({
'ensure' => 'absent'})
}
end
end
end
end
end
8 changes: 4 additions & 4 deletions spec/spec_helper_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ def gpg(gpg_cmd, user = 'root', &block)

# Enable colour
c.tty = true
# Include in our local helpers, because some puppet images run

# Include in our local helpers, because some puppet images run
# as diffrent users
c.include ::LocalHelpers

# Puppet helpers
c.include RSpecSystemPuppet::Helpers
c.extend RSpecSystemPuppet::Helpers
Expand All @@ -48,7 +48,7 @@ def gpg(gpg_cmd, user = 'root', &block)
puppet_module_install(:source => proj_root, :module_name => 'gnupg')
shell 'whoami'
shell 'puppet module list'

# disable hiera warnings
file = Tempfile.new('foo')
begin
Expand Down
2 changes: 1 addition & 1 deletion spec/system/gnupg_key_install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@
r.exit_code.should == 4
end
end
end
end
6 changes: 3 additions & 3 deletions spec/unit/puppet/type/gnupg_key_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'puppet'
require 'puppet/type/gnupg_key'
require 'puppet'
require 'puppet/type/gnupg_key'
describe Puppet::Type.type(:gnupg_key) do
before :each do
@gnupg_key = Puppet::Type.type(:gnupg_key).new(:name => 'foo')
Expand Down Expand Up @@ -32,7 +32,7 @@
@gnupg_key[:key_server] = val
@gnupg_key[:key_server].should == val.to_s
end
end
end
['puppet:///modules/gnupg/random.key', 'http://www.puppetlabs.com/key.key', 'https://www.puppetlabs.com/key.key', 'file:///etc/foo.key', '/etc/foo.key'].each do |val|
it "should accept key_source #{val}" do
@gnupg_key[:key_source] = val
Expand Down

0 comments on commit 3173c20

Please sign in to comment.