]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Merge pull request #628 from cpavanrun/master
authorDavid Schmitt <david.schmitt@puppet.com>
Tue, 11 Oct 2016 09:42:45 +0000 (10:42 +0100)
committerGitHub <noreply@github.com>
Tue, 11 Oct 2016 09:42:45 +0000 (10:42 +0100)
Undef default for $notify_update in source.pp results in problem with Puppet 3.7.2

lib/puppet/provider/apt_key/apt_key.rb
spec/acceptance/apt_key_provider_spec.rb
spec/unit/puppet/type/apt_key_spec.rb

index a6d68b1732dd4c0be547c0ce3bfe604aeae5ed04..d7e85dafaf5a1e6ab762153f137394a49cc52d47 100644 (file)
@@ -127,7 +127,9 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do
       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
index 5b69905f57df8bc71d505e356a1b8f06422cecc2..274df5e3bd477f7b64c3dcea29f44002c85859b6 100644 (file)
@@ -553,6 +553,20 @@ FPfZDNCu/TXoqyJk7434jJrcHgPryzrHFBLfEmc=
         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':
@@ -646,6 +660,20 @@ FPfZDNCu/TXoqyJk7434jJrcHgPryzrHFBLfEmc=
         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':
index 7cd80c689f5e7b63b9ede57bca22f890f7393f80..9c2dd91a4f5faf72fc84f31e108ff0c73dbf8542 100644 (file)
@@ -136,6 +136,13 @@ describe Puppet::Type::type(:apt_key) do
       )}.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      => 'EF8D349F',