Merge pull request #682 from eputnam/fail_message
authorHunter Haugen <hunter@puppet.com>
Thu, 1 Jun 2017 17:36:29 +0000 (10:36 -0700)
committerHunter Haugen <hunter@puppet.com>
Thu, 1 Jun 2017 17:36:29 +0000 (10:36 -0700)
this failure is related to os.name, not os.release.full

lib/puppet/provider/apt_key/apt_key.rb
manifests/source.pp
spec/defines/source_spec.rb

index d7e85dafaf5a1e6ab762153f137394a49cc52d47..668fd0f18d2ee35c0addb98e1bd365956d7f2a11 100644 (file)
@@ -127,9 +127,15 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do
       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
index a9769ea890c39bcdf098db2fac8e1d043c0a24ae..be743eb26ca207fc9a3c2b09f82a52caff3ae494 100644 (file)
@@ -19,7 +19,7 @@ define apt::source(
 
   $_before = Apt::Setting["list-${title}"]
 
-  if ! $release {
+  if !$release {
     if $facts['lsbdistcodename'] {
       $_release = $facts['lsbdistcodename']
     } else {
index c224668f4791bf350145bc391dd07ad0d39beaf0..79cc11b990d782ec58ef7f9e84a4c352a3ce0e3d 100644 (file)
@@ -373,6 +373,20 @@ describe 'apt::source' do
       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
         {