X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Facceptance%2Fapt_key_provider_spec.rb;h=fdb2ec63d0f35bc02b1234ff461b96d0aa99ded1;hb=c84e842467742f31fba17f243d4c75f9edbc14a9;hp=ae278fb6a94bf730f88391c206eaaff83398c3d5;hpb=9f2fd0cb6d191e7883a140fb160d8fefaa685a66;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb index ae278fb..fdb2ec6 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -13,7 +13,7 @@ CENTOS_GPG_KEY_FILE = 'RPM-GPG-KEY-CentOS-6'.freeze PUPPETLABS_EXP_KEY_LONG_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30'.freeze PUPPETLABS_EXP_KEY_DATES = 'pub:e:4096:1:1054B7A24BD6EC30:2010-07-10:2017-01-05::-:Puppet Labs Release Key'.freeze SHOULD_NEVER_EXIST_ID = 'EF8D349F'.freeze -KEY_CHECK_COMMAND = 'apt-key adv --list-keys --with-colons --fingerprint | grep '.freeze +KEY_CHECK_COMMAND = 'apt-key adv --no-tty --list-keys --with-colons --fingerprint | grep '.freeze PUPPETLABS_KEY_CHECK_COMMAND = "#{KEY_CHECK_COMMAND} #{PUPPETLABS_GPG_KEY_FINGERPRINT}".freeze CENTOS_KEY_CHECK_COMMAND = "#{KEY_CHECK_COMMAND} #{CENTOS_GPG_KEY_FINGERPRINT}".freeze PUPPETLABS_EXP_CHECK_COMMAND = "#{KEY_CHECK_COMMAND} '#{PUPPETLABS_EXP_KEY_DATES}'".freeze @@ -31,7 +31,7 @@ end def install_key(key) retry_on_error_matching do - shell("apt-key adv --keyserver pgp.mit.edu --recv-keys #{key}") + shell("apt-key adv --no-tty --keyserver pgp.mit.edu --recv-keys #{key}") end end @@ -478,6 +478,19 @@ hkp_pool_pp = <<-MANIFEST } MANIFEST +hkps_protocol_supported = fact('operatingsystem') =~ %r{Ubuntu} && \ + fact('operatingsystemrelease') =~ %r{^18\.04} + +if hkps_protocol_supported + hkps_ubuntu_pp = <<-MANIFEST + apt_key { 'puppetlabs': + id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', + ensure => 'present', + server => 'hkps://keyserver.ubuntu.com', + } + MANIFEST +end + nonexistant_key_server_pp = <<-MANIFEST apt_key { 'puppetlabs': id => '#{PUPPETLABS_GPG_KEY_LONG_ID}', @@ -786,6 +799,19 @@ describe 'apt_key' do end end + if hkps_protocol_supported + context 'with hkps://keyserver.ubuntu.com' do + it 'works' do + retry_on_error_matching do + apply_manifest(hkps_ubuntu_pp, catch_failures: true) + end + + apply_manifest(hkps_ubuntu_pp, catch_changes: true) + shell(PUPPETLABS_KEY_CHECK_COMMAND) + end + end + end + context 'with nonexistant.key.server' do it 'fails' do apply_manifest(nonexistant_key_server_pp, expect_failures: true) do |r| @@ -954,8 +980,6 @@ describe 'apt_key' do if fact('lsbdistcodename') == 'stretch' || fact('lsbdistcodename') == 'bionic' # Ensure dirmngr package is installed apply_manifest(refresh_check_for_dirmngr_pp, acceptable_exit_codes: [0, 2]) - # Export environment variable to disable apt-key warning when using grep - shell('export APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1') end # Delete the Puppet Labs Release Key and install an expired version of the key apply_manifest(refresh_del_key_pp)