f
else
begin
- key = parsedValue.read
+ user_pass = parsedValue.userinfo.nil? ? nil : parsedValue.userinfo.split(':')
+ parsedValue.userinfo = ''
+ key = open(parsedValue, :http_basic_authentication => user_pass).read
rescue OpenURI::HTTPError, Net::FTPPermError => e
fail("#{e.message} for #{resource[:source]}")
rescue SocketError
shell(PUPPETLABS_KEY_CHECK_COMMAND)
end
+ it 'works with userinfo' do
+ pp = <<-EOS
+ apt_key { 'puppetlabs':
+ id => '#{PUPPETLABS_GPG_KEY_LONG_ID}',
+ ensure => 'present',
+ source => 'http://dummyuser:dummypassword@#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}',
+ }
+ EOS
+
+ apply_manifest(pp, :catch_failures => true)
+ apply_manifest(pp, :catch_failures => true)
+ shell(PUPPETLABS_KEY_CHECK_COMMAND)
+ end
+
it 'fails with a 404' do
pp = <<-EOS
apt_key { 'puppetlabs':
shell(PUPPETLABS_KEY_CHECK_COMMAND)
end
+ it 'works with userinfo' do
+ pp = <<-EOS
+ apt_key { 'puppetlabs':
+ id => '#{PUPPETLABS_GPG_KEY_LONG_ID}',
+ ensure => 'present',
+ source => 'https://dummyuser:dummypassword@#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}',
+ }
+ EOS
+
+ apply_manifest(pp, :catch_failures => true)
+ apply_manifest(pp, :catch_failures => true)
+ shell(PUPPETLABS_KEY_CHECK_COMMAND)
+ end
+
it 'fails with a 404' do
pp = <<-EOS
apt_key { 'puppetlabs':
)}.to_not raise_error
end
+ it 'allows the http URI with username and password' do
+ expect { Puppet::Type.type(:apt_key).new(
+ :id => '4BD6EC30',
+ :source => 'http://testme:Password2@pgp.mit.edu'
+ )}.to_not raise_error
+ end
+
it 'allows the https URI scheme in source' do
expect { Puppet::Type.type(:apt_key).new(
:id => '4BD6EC30',