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
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
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',
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',
)}.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',