From: Travis Fields Date: Fri, 14 Nov 2014 04:25:46 +0000 (-0800) Subject: MODULES-1119 Fixed to now have username and passwords passed in again X-Git-Tag: 1.8.0~34^2^2^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=559787268aa19c7c3f01d9597392bddfe5162a97;hp=8fa73ac96fda8af4360e71b41c0a3e514f28080a;p=puppet-modules%2Fpuppetlabs-apt.git MODULES-1119 Fixed to now have username and passwords passed in again --- diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index e5020fe..075fb6f 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -108,12 +108,13 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do end def source_to_file(value) - if URI::parse(value).scheme.nil? + parsedValue = URI::parse(value) + if parsedValue.scheme.nil? fail("The file #{value} does not exist") unless File.exists?(value) value else begin - key = open(value, :ftp_active_mode => false).read + key = parsedValue.read rescue OpenURI::HTTPError, Net::FTPPermError => e fail("#{e.message} for #{resource[:source]}") rescue SocketError @@ -158,6 +159,7 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do end def destroy + #Currently del only removes the first key, we need to recursively list and ensure all with id are absent. apt_key('del', resource[:id]) @property_hash.clear end diff --git a/spec/unit/puppet/type/apt_key_spec.rb b/spec/unit/puppet/type/apt_key_spec.rb index c29f82b..0e9aaa2 100644 --- a/spec/unit/puppet/type/apt_key_spec.rb +++ b/spec/unit/puppet/type/apt_key_spec.rb @@ -82,7 +82,7 @@ describe Puppet::Type::type(:apt_key) do resource[:source].should eq 'http://apt.puppetlabs.com/pubkey.gpg' end end - + context 'with content' do let(:resource) { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30', @@ -93,7 +93,7 @@ describe Puppet::Type::type(:apt_key) do resource[:content].should eq 'http://apt.puppetlabs.com/pubkey.gpg' end end - + context 'with keyserver' do let(:resource) { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30', @@ -143,6 +143,13 @@ describe Puppet::Type::type(:apt_key) do )}.to_not raise_error end + it 'allows the https URI with username and password' do + expect { Puppet::Type.type(:apt_key).new( + :id => '4BD6EC30', + :source => 'https://testme:Password2@pgp.mit.edu' + )}.to_not raise_error + end + it 'allows the ftp URI scheme in source' do expect { Puppet::Type.type(:apt_key).new( :id => '4BD6EC30',