]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Merge branch 'master' into remove_ppa_source
authordavid22swan <david.swan@puppet.com>
Thu, 23 Aug 2018 15:02:02 +0000 (16:02 +0100)
committerGitHub <noreply@github.com>
Thu, 23 Aug 2018 15:02:02 +0000 (16:02 +0100)
16 files changed:
.gitignore
.pdkignore
.rubocop.yml
.sync.yml
.travis.yml
CHANGELOG.md
Gemfile
README.md
Rakefile
manifests/params.pp
manifests/ppa.pp
manifests/source.pp
metadata.json
spec/defines/ppa_spec.rb
spec/defines/source_spec.rb
spec/spec_helper.rb

index 49bc2a40140e2bff6b74d81ffaacd7cce0fac4a9..650022e58e7fcced551fb38f7bfdf73e65cb3e84 100644 (file)
@@ -1,3 +1,4 @@
+.git/
 .*.sw[op]
 .metadata
 .yardoc
index 49bc2a40140e2bff6b74d81ffaacd7cce0fac4a9..650022e58e7fcced551fb38f7bfdf73e65cb3e84 100644 (file)
@@ -1,3 +1,4 @@
+.git/
 .*.sw[op]
 .metadata
 .yardoc
index 7ed6225c7d1406fceafc68b90288f8eb93c37b1e..54d1597aaa1a34941d39d88a8bb3be165ed01e64 100644 (file)
@@ -71,6 +71,7 @@ RSpec/MessageSpies:
 Style/Documentation:
   Exclude:
   - lib/puppet/parser/functions/**/*
+  - spec/**/*
 Style/WordArray:
   EnforcedStyle: brackets
 Style/CollectionMethods:
@@ -81,6 +82,8 @@ Style/StringMethods:
   Enabled: true
 Layout/EndOfLine:
   Enabled: false
+Layout/IndentHeredoc:
+  Enabled: false
 Metrics/AbcSize:
   Enabled: false
 Metrics/BlockLength:
index 7bfce72c70551ca47c1dc3a564dc522a81dbe710..e79ce867e2ba6b8da797c8f24b758352ca52b65d 100644 (file)
--- a/.sync.yml
+++ b/.sync.yml
@@ -19,17 +19,6 @@ Gemfile:
           - mswin
           - mingw
           - x64_mingw
-      - gem: beaker
-        version: '~> 3.13'
-        from_env: BEAKER_VERSION
-      - gem: beaker-abs
-        from_env: BEAKER_ABS_VERSION
-        version: '~> 0.1'
-      - gem: beaker-pe
-      - gem: beaker-hostgenerator
-        from_env: BEAKER_HOSTGENERATOR_VERSION
-      - gem: beaker-rspec
-        from_env: BEAKER_RSPEC_VERSION
 
 appveyor.yml:
   delete: true
index 256d5c5fd43bd19c309301d013ee811d4e882da2..e0df4ea5c93aea0cbbb673b3982ce1479b99f0bb 100644 (file)
@@ -13,7 +13,7 @@ script:
   - 'bundle exec rake $CHECK'
 bundler_args: --without system_tests
 rvm:
-  - 2.4.1
+  - 2.4.4
 env:
   global:
     - BEAKER_PUPPET_COLLECTION=puppet5 PUPPET_GEM_VERSION="~> 5.0"
@@ -23,16 +23,16 @@ matrix:
     -
       bundler_args: 
       dist: trusty
-      env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_set=docker/debian-8
-      rvm: 2.4.1
+      env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_set=docker/debian-8 BEAKER_TESTMODE=apply
+      rvm: 2.4.4
       script: bundle exec rake beaker
       services: docker
       sudo: required
     -
       bundler_args: 
       dist: trusty
-      env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_set=docker/ubuntu-14.04
-      rvm: 2.4.1
+      env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_set=docker/ubuntu-14.04 BEAKER_TESTMODE=apply
+      rvm: 2.4.4
       script: bundle exec rake beaker
       services: docker
       sudo: required
index cc0169f15c705dda5b77d8231d0245164c0ec8ed..5be5e4ca37bd1b8b5dc004bde71bf4421b4a8d8a 100644 (file)
@@ -1,7 +1,37 @@
-# Changelog
+# Change log
 
-All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
-and this project adheres to [Semantic Versioning](http://semver.org).
+All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).
+
+## [5.0.1](https://github.com/puppetlabs/puppetlabs-apt/tree/5.0.1) (2018-07-27)
+
+[Full Changelog](https://github.com/puppetlabs/puppetlabs-apt/compare/5.0.0...5.0.1)
+
+### Fixed
+
+- \(MODULES-7540\) - add apt-transport-https with https [\#775](https://github.com/puppetlabs/puppetlabs-apt/pull/775) ([tphoney](https://github.com/tphoney))
+
+## [5.0.0](https://github.com/puppetlabs/puppetlabs-apt/tree/5.0.0) (2018-07-18)
+
+[Full Changelog](https://github.com/puppetlabs/puppetlabs-apt/compare/4.5.1...5.0.0)
+
+### Changed
+
+- \[FM-6956\] Removal of unsupported Debian 7 from apt [\#760](https://github.com/puppetlabs/puppetlabs-apt/pull/760) ([david22swan](https://github.com/david22swan))
+
+### Added
+
+- \(MODULES-7467\) Update apt to support Ubuntu 18.04 [\#769](https://github.com/puppetlabs/puppetlabs-apt/pull/769) ([david22swan](https://github.com/david22swan))
+- Support managing login configurations in /etc/apt/auth.conf [\#752](https://github.com/puppetlabs/puppetlabs-apt/pull/752) ([antaflos](https://github.com/antaflos))
+
+### Fixed
+
+- \(MODULES-7327\) - Update README with supported OS [\#767](https://github.com/puppetlabs/puppetlabs-apt/pull/767) ([pmcmaw](https://github.com/pmcmaw))
+- \(bugfix\) Dont run ftp tests in travis [\#766](https://github.com/puppetlabs/puppetlabs-apt/pull/766) ([tphoney](https://github.com/tphoney))
+- \(maint\) make apt testing more stable, cleanup [\#764](https://github.com/puppetlabs/puppetlabs-apt/pull/764) ([tphoney](https://github.com/tphoney))
+- Remove .length from variable $pin\_release in app [\#754](https://github.com/puppetlabs/puppetlabs-apt/pull/754) ([paladox](https://github.com/paladox))
+- Replace UTF-8 whitespace in comment [\#748](https://github.com/puppetlabs/puppetlabs-apt/pull/748) ([bernhardschmidt](https://github.com/bernhardschmidt))
+- Fix "E: Unable to locate package  -y" [\#747](https://github.com/puppetlabs/puppetlabs-apt/pull/747) ([aboks](https://github.com/aboks))
+- Fix automatic coercion warning [\#743](https://github.com/puppetlabs/puppetlabs-apt/pull/743) ([smortex](https://github.com/smortex))
 
 ## Supported Release [4.5.1]
 ### Summary
@@ -656,8 +686,14 @@ This release includes Ubuntu 12.10 (Quantal) support for PPAs.
 * 87777d8 Typo in README
 * f848bac First commit
 
+[5.0.1]:https://github.com/puppetlabs/puppetlabs-apt/compare/5.0.0...5.0.1
+[5.0.0]:https://github.com/puppetlabs/puppetlabs-apt/compare/4.5.1...5.0.0
+[4.5.1]:https://github.com/puppetlabs/puppetlabs-apt/compare/4.5.0...4.5.1
 [4.5.0]:https://github.com/puppetlabs/puppetlabs-apt/compare/4.4.1...4.5.0
 [4.4.1]:https://github.com/puppetlabs/puppetlabs-apt/compare/4.4.0...4.4.1
 [4.4.0]:https://github.com/puppetlabs/puppetlabs-apt/compare/4.3.0...4.4.0
 [4.3.0]:https://github.com/puppetlabs/puppetlabs-apt/compare/4.2.0...4.3.0
 [4.2.0]:https://github.com/puppetlabs/puppetlabs-apt/compare/4.1.0...4.2.0
+
+
+\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
diff --git a/Gemfile b/Gemfile
index a7ec8208c87b09f474d1b60c900bdd36b444ca42..d1932e62c59b082ce45f58f6332b73191884214c 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -33,16 +33,10 @@ group :development do
   gem "puppet-module-posix-dev-r#{minor_version}",     require: false, platforms: [:ruby]
   gem "puppet-module-win-default-r#{minor_version}",   require: false, platforms: [:mswin, :mingw, :x64_mingw]
   gem "puppet-module-win-dev-r#{minor_version}",       require: false, platforms: [:mswin, :mingw, :x64_mingw]
-  gem "puppet-blacksmith", '~> 3.4',                   require: false, platforms: [:ruby]
 end
 group :system_tests do
-  gem "puppet-module-posix-system-r#{minor_version}",                            require: false, platforms: [:ruby]
-  gem "puppet-module-win-system-r#{minor_version}",                              require: false, platforms: [:mswin, :mingw, :x64_mingw]
-  gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 3.13')
-  gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1')
-  gem "beaker-pe",                                                               require: false
-  gem "beaker-hostgenerator"
-  gem "beaker-rspec"
+  gem "puppet-module-posix-system-r#{minor_version}", require: false, platforms: [:ruby]
+  gem "puppet-module-win-system-r#{minor_version}",   require: false, platforms: [:mswin, :mingw, :x64_mingw]
 end
 
 puppet_version = ENV['PUPPET_GEM_VERSION']
index 7fafd799e40082654acc58b8d5cf840d56affb8c..9af6b9af8b32935fe99c436a46ef152b2fcf7b59 100644 (file)
--- a/README.md
+++ b/README.md
@@ -228,18 +228,18 @@ apt::source { "archive.ubuntu.com-${lsbdistcodename}-backports":
 
 ### Manage login configuration settings for an APT source or proxy in `/etc/apt/auth.conf`
 
-Starting with APT version 1.5 you can define login configuration settings (like
-username and password) for APT sources or proxies that require authentication
-in the file `/etc/apt/auth.conf`. This is preferable to embedding login
-information directly in `source.list` entries which are usually world-readable.
+Starting with APT version 1.5, you can define login configuration settings, such as
+username and password, for APT sources or proxies that require authentication
+in the `/etc/apt/auth.conf` file. This is preferable to embedding login
+information directly in `source.list` entries, which are usually world-readable.
 
-The file `/etc/apt/auth.conf` follows the format of netrc (as used by ftp or
+The `/etc/apt/auth.conf` file follows the format of netrc (used by ftp or
 curl) and has restrictive file permissions. See
 https://manpages.debian.org/testing/apt/apt_auth.conf.5.en.html for details.
 
 Use the optional `apt::auth_conf_entries` parameter to specify an array of
 hashes containing login configuration settings. These hashes may only contain
-the keys `machine`, `login` and `password`.
+the `machine`, `login` and `password` keys.
 
 ```puppet
 class { 'apt':
@@ -556,10 +556,10 @@ All parameters are optional.
 
 ## Limitations
 
-This module is tested and officially supported on Debian 8 and 9 and Ubuntu 14.04, and 16.04. Testing on other platforms has been light and cannot be guaranteed.
-
 This module is not designed to be split across [run stages](https://docs.puppetlabs.com/puppet/latest/reference/lang_run_stages.html).
 
+For an extensive list of supported operating systems, see [metadata.json](https://github.com/puppetlabs/puppetlabs-apt/blob/master/metadata.json)
+
 ### Adding new sources or PPAs
 
 If you are adding a new source or PPA and trying to install packages from the new source or PPA on the same Puppet run, your `package` resource should depend on `Class['apt::update']`, in addition to depending on the `Apt::Source` or the `Apt::Ppa`. You can also add [collectors](https://docs.puppetlabs.com/puppet/latest/reference/lang_collectors.html) to ensure that all packages happen after `apt::update`, but this can lead to dependency cycles and has implications for [virtual resources](https://docs.puppetlabs.com/puppet/latest/reference/lang_collectors.html#behavior).
index d4e36dadfd3a36312b46fb3bf972ed0fb00c6a69..204fb18cdc93921bd5fd42edf660b53e874f7ef8 100644 (file)
--- a/Rakefile
+++ b/Rakefile
@@ -1,6 +1,75 @@
 require 'puppetlabs_spec_helper/rake_tasks'
 require 'puppet-syntax/tasks/puppet-syntax'
 require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
+require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any?
+
+def changelog_user
+  return unless Rake.application.top_level_tasks.include? "changelog"
+  returnVal = nil || JSON.load(File.read('metadata.json'))['author']
+  raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil?
+  puts "GitHubChangelogGenerator user:#{returnVal}"
+  returnVal
+end
+
+def changelog_project
+  return unless Rake.application.top_level_tasks.include? "changelog"
+  returnVal = nil || JSON.load(File.read('metadata.json'))['name']
+  raise "unable to find the changelog_project in .sync.yml or the name in metadata.json" if returnVal.nil?
+  puts "GitHubChangelogGenerator project:#{returnVal}"
+  returnVal
+end
+
+def changelog_future_release
+  return unless Rake.application.top_level_tasks.include? "changelog"
+  returnVal = JSON.load(File.read('metadata.json'))['version']
+  raise "unable to find the future_release (version) in metadata.json" if returnVal.nil?
+  puts "GitHubChangelogGenerator future_release:#{returnVal}"
+  returnVal
+end
 
 PuppetLint.configuration.send('disable_relative')
 
+if Bundler.rubygems.find_name('github_changelog_generator').any?
+  GitHubChangelogGenerator::RakeTask.new :changelog do |config|
+    raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil?
+    config.user = "#{changelog_user}"
+    config.project = "#{changelog_project}"
+    config.future_release = "#{changelog_future_release}"
+    config.exclude_labels = ['maintenance']
+    config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)."
+    config.add_pr_wo_labels = true
+    config.issues = false
+    config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM"
+    config.configure_sections = {
+      "Changed" => {
+        "prefix" => "### Changed",
+        "labels" => ["backwards-incompatible"],
+      },
+      "Added" => {
+        "prefix" => "### Added",
+        "labels" => ["feature", "enhancement"],
+      },
+      "Fixed" => {
+        "prefix" => "### Fixed",
+        "labels" => ["bugfix"],
+      },
+    }
+  end
+else
+  desc 'Generate a Changelog from GitHub'
+  task :changelog do
+    raise <<EOM
+The changelog tasks depends on unreleased features of the github_changelog_generator gem.
+Please manually add it to your .sync.yml for now, and run `pdk update`:
+---
+Gemfile:
+  optional:
+    ':development':
+      - gem: 'github_changelog_generator'
+        git: 'https://github.com/skywinder/github-changelog-generator'
+        ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018'
+        condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')"
+EOM
+  end
+end
+
index b0ad60c71ada96d8aa812aa5518c353c0b8155b9..479ac122358b44bc0aff9639d336904b33a65e94 100644 (file)
@@ -9,6 +9,7 @@ class apt::params {
   $provider       = '/usr/bin/apt-get'
   $sources_list   = "${root}/sources.list"
   $sources_list_d = "${root}/sources.list.d"
+  $trusted_gpg_d  = "${root}/trusted.gpg.d"
   $conf_d         = "${root}/apt.conf.d"
   $preferences    = "${root}/preferences"
   $preferences_d  = "${root}/preferences.d"
index 4ee08ba3c49526edd332f7e82eb339b687f31132..99af21937529d983cfa4e590ef8e48c7bd3285a9 100644 (file)
@@ -16,14 +16,25 @@ define apt::ppa(
 
   if versioncmp($facts['lsbdistrelease'], '15.10') >= 0 {
     $distid = downcase($facts['lsbdistid'])
-    $filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1-${distid}-\\2-${release}")
+    $dash_filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1-${distid}-\\2")
+    $underscore_filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1_${distid}_\\2")
   } else {
-    $filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1-\\2-${release}")
+    $dash_filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1-\\2")
+    $underscore_filename = regsubst($name, '^ppa:([^/]+)/(.+)$', "\\1_\\2")
   }
 
-  $filename_no_slashes      = regsubst($filename, '/', '-', 'G')
-  $filename_no_specialchars = regsubst($filename_no_slashes, '[\.\+]', '_', 'G')
-  $sources_list_d_filename  = "${filename_no_specialchars}.list"
+  $dash_filename_no_slashes      = regsubst($dash_filename, '/', '-', 'G')
+  $dash_filename_no_specialchars = regsubst($dash_filename_no_slashes, '[\.\+]', '_', 'G')
+  $underscore_filename_no_slashes      = regsubst($underscore_filename, '/', '-', 'G')
+  $underscore_filename_no_specialchars = regsubst($underscore_filename_no_slashes, '[\.\+]', '_', 'G')
+
+  $sources_list_d_filename  = "${dash_filename_no_specialchars}-${release}.list"
+
+  if versioncmp($facts['lsbdistrelease'], '15.10') >= 0 {
+    $trusted_gpg_d_filename = "${underscore_filename_no_specialchars}.gpg"
+  } else {
+    $trusted_gpg_d_filename = "${dash_filename_no_specialchars}.gpg"
+  }
 
   if $ensure == 'present' {
     if $package_manage {
@@ -47,7 +58,7 @@ define apt::ppa(
     exec { "add-apt-repository-${name}":
       environment => $_proxy_env,
       command     => "/usr/bin/add-apt-repository ${options} ${name} || (rm ${::apt::sources_list_d}/${sources_list_d_filename} && false)",
-      unless      => "/usr/bin/test -f ${::apt::sources_list_d}/${sources_list_d_filename}",
+      unless      => "/usr/bin/test -f ${::apt::sources_list_d}/${sources_list_d_filename} && /usr/bin/test -f ${::apt::trusted_gpg_d}/${trusted_gpg_d_filename}",
       user        => 'root',
       logoutput   => 'on_failure',
       notify      => Class['apt::update'],
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 11b2b0237d5518106ce4a171119be3165744054c..4f33f080b06305d99a10176a4701cc30da92b588 100644 (file)
@@ -1,6 +1,6 @@
 {
   "name": "puppetlabs-apt",
-  "version": "4.5.1",
+  "version": "5.0.1",
   "author": "Puppet Labs",
   "summary": "Provides an interface for managing Apt source, key, and definitions with Puppet",
   "license": "Apache-2.0",
       "operatingsystem": "Ubuntu",
       "operatingsystemrelease": [
         "14.04",
-        "16.04"
+        "16.04",
+        "18.04"
       ]
     }
   ],
   "requirements": [
     {
       "name": "puppet",
-      "version_requirement": ">= 4.7.0 < 6.0.0"
+      "version_requirement": ">= 4.8.0 < 6.0.0"
     }
   ],
   "template-url": "https://github.com/puppetlabs/pdk-templates",
-  "template-ref": "heads/master-0-g34e3266",
-  "pdk-version": "1.5.0"
+  "template-ref": "1.7.0-0-g57412ed",
+  "pdk-version": "1.7.0"
 }
index 984c3e872ca6ccf5b34b7d42b1fb5020b2205b56..fa893b6997272429aac97883c1cd48328edbd368 100644 (file)
@@ -23,7 +23,7 @@ describe 'apt::ppa' do
     it {
       is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow+type').that_notifies('Class[Apt::Update]').with(environment: [],
                                                                                                                                       command: '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow+type || (rm /etc/apt/sources.list.d/needs-such_substitution-wow_type-trusty.list && false)', # rubocop:disable Metrics/LineLength
-                                                                                                                                      unless: '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow_type-trusty.list', # rubocop:disable Metrics/LineLength
+                                                                                                                                      unless: '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow_type-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/needs-such_substitution-wow_type.gpg', # rubocop:disable Metrics/LineLength
                                                                                                                                       user: 'root',
                                                                                                                                       logoutput: 'on_failure')
     }
@@ -47,7 +47,7 @@ describe 'apt::ppa' do
     it {
       is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with(environment: [],
                                                                                                               command: '/usr/bin/add-apt-repository -y ppa:user/foo || (rm /etc/apt/sources.list.d/user-ubuntu-foo-wily.list && false)', # rubocop:disable Metrics/LineLength
-                                                                                                              unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-ubuntu-foo-wily.list',
+                                                                                                              unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-ubuntu-foo-wily.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user_ubuntu_foo.gpg', # rubocop:disable Metrics/LineLength
                                                                                                               user: 'root',
                                                                                                               logoutput: 'on_failure')
     }
@@ -81,7 +81,7 @@ describe 'apt::ppa' do
     it {
       is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with('environment' => [],
                                                                                                                                  'command'     => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow || (rm /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && false)', # rubocop:disable Metrics/LineLength
-                                                                                                                                 'unless'      => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list', # rubocop:disable Metrics/LineLength
+                                                                                                                                 'unless'      => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/needs-such_substitution-wow.gpg', # rubocop:disable Metrics/LineLength
                                                                                                                                  'user'        => 'root',
                                                                                                                                  'logoutput'   => 'on_failure')
     }
@@ -118,7 +118,7 @@ describe 'apt::ppa' do
     it {
       is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with('environment' => [],
                                                                                                                                  'command'     => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow || (rm /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && false)', # rubocop:disable Metrics/LineLength
-                                                                                                                                 'unless'      => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list', # rubocop:disable Metrics/LineLength
+                                                                                                                                 'unless'      => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/needs-such_substitution-wow.gpg', # rubocop:disable Metrics/LineLength
                                                                                                                                  'user'        => 'root',
                                                                                                                                  'logoutput'   => 'on_failure')
     }
@@ -159,7 +159,7 @@ describe 'apt::ppa' do
     it {
       is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with(environment: [],
                                                                                                               command: '/usr/bin/add-apt-repository  ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Metrics/LineLength
-                                                                                                              unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list',
+                                                                                                              unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Metrics/LineLength
                                                                                                               user: 'root',
                                                                                                               logoutput: 'on_failure')
     }
@@ -194,7 +194,7 @@ describe 'apt::ppa' do
     it {
       is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with(environment: ['http_proxy=http://localhost:8080'],
                                                                                                               command: '/usr/bin/add-apt-repository  ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Metrics/LineLength
-                                                                                                              unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list',
+                                                                                                              unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Metrics/LineLength
                                                                                                               user: 'root',
                                                                                                               logoutput: 'on_failure')
     }
@@ -229,7 +229,7 @@ describe 'apt::ppa' do
     it {
       is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with(environment: ['http_proxy=http://localhost:8180'],
                                                                                                               command: '/usr/bin/add-apt-repository  ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Metrics/LineLength
-                                                                                                              unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list',
+                                                                                                              unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Metrics/LineLength
                                                                                                               user: 'root',
                                                                                                               logoutput: 'on_failure')
     }
@@ -264,7 +264,7 @@ describe 'apt::ppa' do
     it {
       is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with(environment: ['http_proxy=http://localhost:8180', 'https_proxy=https://localhost:8180'],
                                                                                                               command: '/usr/bin/add-apt-repository  ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Metrics/LineLength
-                                                                                                              unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list',
+                                                                                                              unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Metrics/LineLength
                                                                                                               user: 'root',
                                                                                                               logoutput: 'on_failure')
     }
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
       {
index e117192684d1d907d001bf542592bdea4f0e470e..5e721b7ff4d57a0388bb30676ba8ccc3cf5dd477 100644 (file)
@@ -1,4 +1,3 @@
-
 require 'puppetlabs_spec_helper/module_spec_helper'
 require 'rspec-puppet-facts'
 
@@ -34,3 +33,12 @@ RSpec.configure do |c|
     Puppet.settings[:strict] = :warning
   end
 end
+
+def ensure_module_defined(module_name)
+  module_name.split('::').reduce(Object) do |last_module, next_module|
+    last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module)
+    last_module.const_get(next_module)
+  end
+end
+
+# 'spec_overrides' from sync.yml will appear below this line