]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
(MODULES-7540) add apt-transport-https with https
authortphoney <tp@puppet.com>
Fri, 27 Jul 2018 10:04:44 +0000 (11:04 +0100)
committertphoney <tp@puppet.com>
Fri, 27 Jul 2018 11:09:56 +0000 (12:09 +0100)
manifests/source.pp
spec/defines/source_spec.rb

index afbb27ae178b9620af10c5a75eb8c3c3ec61311c..724f5f36d3417b9f1503e5321a86704f89db11e6 100644 (file)
@@ -32,6 +32,11 @@ define apt::source(
     if ! $location {
       fail('cannot create a source entry without specifying a location')
     }
+    # Newer oses, do not need the package for HTTPS transport.
+    $_transport_https_releases = [ 'wheezy', 'jessie', 'stretch', 'trusty', 'xenial' ]
+    if $_release in $_transport_https_releases and $location =~ /(?i:^https:\/\/)/ {
+      ensure_packages('apt-transport-https')
+    }
   }
 
   $includes = merge($::apt::include_defaults, $include)
index ee881324436b4bbef6f2ddf81115e9809f81717c..38f5b9d2cd1f196d06863fe04ffe9300b46b9556 100644 (file)
@@ -40,6 +40,7 @@ describe 'apt::source' do
 
       it {
         is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{# my_source\ndeb-src hello.there wheezy main\n})
+        is_expected.not_to contain_package('apt-transport-https')
       }
     end
   end
@@ -202,6 +203,50 @@ describe 'apt::source' do
     }
   end
 
+  context 'with a https location, install apt-transport-https' do
+    let :facts do
+      {
+        os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
+        lsbdistid: 'Debian',
+        lsbdistcodename: 'jessie',
+        osfamily: 'Debian',
+        puppetversion: Puppet.version,
+      }
+    end
+    let :params do
+      {
+        location: 'HTTPS://foo.bar',
+        allow_unsigned: false,
+      }
+    end
+
+    it {
+      is_expected.to contain_package('apt-transport-https')
+    }
+  end
+
+  context 'with a https location, do not install apt-transport-https on oses not in list eg buster' do
+    let :facts do
+      {
+        os: { family: 'Debian', name: 'Debian', release: { major: '10', full: '10.0' } },
+        lsbdistid: 'Debian',
+        lsbdistcodename: 'buster',
+        osfamily: 'Debian',
+        puppetversion: Puppet.version,
+      }
+    end
+    let :params do
+      {
+        location: 'https://foo.bar',
+        allow_unsigned: false,
+      }
+    end
+
+    it {
+      is_expected.not_to contain_package('apt-transport-https')
+    }
+  end
+
   context 'with architecture equals x86_64' do
     let :facts do
       {