Merge pull request #483 from mhaskel/examples
[puppet-modules/puppetlabs-apt.git] / spec / acceptance / apt_key_provider_spec.rb
index 24277d237ad60fcf392332e7eedc4b3e7d6d6a95..b098e82fc008deab10063ad2f41a3aca22dfc642 100644 (file)
@@ -488,14 +488,14 @@ ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU=
     end
   end
 
-  describe 'keyserver_options =>' do
+  describe 'options =>' do
     context 'debug' do
       it 'works' do
         pp = <<-EOS
         apt_key { 'puppetlabs':
-          id                => '#{PUPPETLABS_GPG_KEY_LONG_ID}',
-          ensure            => 'present',
-          keyserver_options => 'debug',
+          id      => '#{PUPPETLABS_GPG_KEY_LONG_ID}',
+          ensure  => 'present',
+          options => 'debug',
         }
         EOS
 
@@ -507,9 +507,9 @@ ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU=
       it 'fails on invalid options' do
         pp = <<-EOS
         apt_key { 'puppetlabs':
-          id                => '#{PUPPETLABS_GPG_KEY_LONG_ID}',
-          ensure            => 'present',
-          keyserver_options => 'this is totally bonkers',
+          id      => '#{PUPPETLABS_GPG_KEY_LONG_ID}',
+          ensure  => 'present',
+          options => 'this is totally bonkers',
         }
         EOS
 
@@ -520,4 +520,38 @@ ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU=
       end
     end
   end
+
+  describe 'fingerprint validation against source/content' do
+    context 'fingerprint in id matches fingerprint from remote key' do
+      it 'works' do
+        pp = <<-EOS
+        apt_key { 'puppetlabs':
+          id      => '#{PUPPETLABS_GPG_KEY_FINGERPRINT}',
+          ensure  => 'present',
+          source  => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}',
+        }
+        EOS
+
+        apply_manifest(pp, :catch_failures => true)
+        apply_manifest(pp, :catch_failures => true)
+      end
+    end
+
+    context 'fingerprint in id does NOT match fingerprint from remote key' do
+      it 'works' do
+        pp = <<-EOS
+        apt_key { 'puppetlabs':
+          id      => '47B320EB4C7C375AA9DAE1A01054B7A24BD6E666',
+          ensure  => 'present',
+          source  => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}',
+        }
+        EOS
+
+        apply_manifest(pp, :expect_failures => true) do |r|
+          expect(r.stderr).to match(/do not match/)
+        end
+      end
+    end
+  end
+
 end