diff --git a/lib/puppet/provider/gnupg_key/gnupg.rb b/lib/puppet/provider/gnupg_key/gnupg.rb index 23284ec..0f357c6 100644 --- a/lib/puppet/provider/gnupg_key/gnupg.rb +++ b/lib/puppet/provider/gnupg_key/gnupg.rb @@ -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 @@ -103,4 +105,4 @@ def create def destroy remove_public_key() end -end \ No newline at end of file +end diff --git a/spec/classes/gnupg_init_spec.rb b/spec/classes/gnupg_init_spec.rb index c8ce785..1a70221 100644 --- a/spec/classes/gnupg_init_spec.rb +++ b/spec/classes/gnupg_init_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'gnupg', :type => :class do - + context 'on unsupported distributions' do let(:facts) {{ :osfamily => 'Unsupported' }} @@ -9,16 +9,16 @@ 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 @@ -26,22 +26,22 @@ :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 diff --git a/spec/spec_helper_system.rb b/spec/spec_helper_system.rb index 12e7ada..e37e880 100644 --- a/spec/spec_helper_system.rb +++ b/spec/spec_helper_system.rb @@ -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 @@ -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 diff --git a/spec/system/gnupg_key_install_spec.rb b/spec/system/gnupg_key_install_spec.rb index f3ab9be..875eb73 100644 --- a/spec/system/gnupg_key_install_spec.rb +++ b/spec/system/gnupg_key_install_spec.rb @@ -125,4 +125,4 @@ r.exit_code.should == 4 end end -end \ No newline at end of file +end diff --git a/spec/unit/puppet/type/gnupg_key_spec.rb b/spec/unit/puppet/type/gnupg_key_spec.rb index 18085fe..ec80757 100644 --- a/spec/unit/puppet/type/gnupg_key_spec.rb +++ b/spec/unit/puppet/type/gnupg_key_spec.rb @@ -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') @@ -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