f
else
begin
- user_pass = parsedValue.userinfo.nil? ? nil : parsedValue.userinfo.split(':')
- parsedValue.userinfo = ''
- key = open(parsedValue, :http_basic_authentication => user_pass).read
+ # Only send basic auth if URL contains userinfo
+ # Some webservers (e.g. Amazon S3) return code 400 if empty basic auth is sent
+ if parsedValue.userinfo.nil?
+ key = parsedValue.read
+ else
+ user_pass = parsedValue.userinfo.split(':')
+ parsedValue.userinfo = ''
+ key = open(parsedValue, :http_basic_authentication => user_pass).read
+ end
rescue OpenURI::HTTPError, Net::FTPPermError => e
fail("#{e.message} for #{resource[:source]}")
rescue SocketError
end
end
+ context 'release is empty string' do
+ let :facts do
+ {
+ :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
+ :lsbdistid => 'Debian',
+ :osfamily => 'Debian',
+ :puppetversion => Puppet.version,
+ }
+ end
+ let(:params) { { :location => 'hello.there', :release => '' } }
+
+ it { is_expected.to contain_apt__setting('list-my_source').with_content(/hello\.there main/) }
+ end
+
context 'invalid pin' do
let :facts do
{