(MODULES-8081): hkps:// protocol is supported on Ubuntu 18.04 only
[puppet-modules/puppetlabs-apt.git] / spec / acceptance / apt_key_provider_spec.rb
index ae278fb6a94bf730f88391c206eaaff83398c3d5..b43dc15f6d59d9d0ed6386f09e801ecee000fed3 100644 (file)
@@ -478,6 +478,22 @@ hkp_pool_pp = <<-MANIFEST
         }
   MANIFEST
 
+if fact('operatingsystem') =~ %r{Ubuntu} and fact('operatingsystemrelease') =~ %r{^18\.04}
+  hkps_protocol_supported = true
+else
+  hkps_protocol_supported = false
+end
+
+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 +802,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|