X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Facceptance%2Fapt_key_provider_spec.rb;h=2c9934307077797734b783037fbbc045d65a1065;hb=refs%2Fheads%2Ftrusted-contributors;hp=ee4a4c8242ee196c508d4cf114b708d45771328a;hpb=32eec3baf6171d4f4aeb513f4e481f82a8a92338;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 ee4a4c8..2c99343 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -111,7 +111,7 @@ refresh_pp = <<-MANIFEST =cXcR -----END PGP PUBLIC KEY BLOCK-----' } - MANIFEST +MANIFEST gpg_key_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -170,7 +170,7 @@ gpg_key_pp = <<-MANIFEST =mMjt -----END PGP PUBLIC KEY BLOCK-----", } - MANIFEST +MANIFEST multiple_keys_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -423,7 +423,7 @@ multiple_keys_pp = <<-MANIFEST =TREp -----END PGP PUBLIC KEY BLOCK----- ", } - MANIFEST +MANIFEST bogus_key_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -431,7 +431,7 @@ bogus_key_pp = <<-MANIFEST ensure => 'present', content => 'For posterity: such content, much bogus, wow', } - MANIFEST +MANIFEST hkp_pool_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -439,7 +439,7 @@ hkp_pool_pp = <<-MANIFEST ensure => 'present', server => 'hkp://keyserver.ubuntu.com:80', } - MANIFEST +MANIFEST hkps_protocol_supported = host_inventory['facter']['os']['family'] =~ %r{Ubuntu}i && \ host_inventory['facter']['os']['release']['major'] =~ %r{^18\.04} @@ -451,7 +451,7 @@ if hkps_protocol_supported ensure => 'present', server => 'hkps://keyserver.ubuntu.com', } - MANIFEST + MANIFEST end nonexistant_key_server_pp = <<-MANIFEST @@ -460,7 +460,7 @@ nonexistant_key_server_pp = <<-MANIFEST ensure => 'present', server => 'nonexistant.key.server', } - MANIFEST +MANIFEST dot_server_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -468,7 +468,7 @@ dot_server_pp = <<-MANIFEST ensure => 'present', server => '.pgp.key.server', } - MANIFEST +MANIFEST http_works_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -476,7 +476,7 @@ http_works_pp = <<-MANIFEST ensure => 'present', source => 'http://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - MANIFEST +MANIFEST http_works_userinfo_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -484,7 +484,7 @@ http_works_userinfo_pp = <<-MANIFEST ensure => 'present', source => 'http://dummyuser:dummypassword@#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - MANIFEST +MANIFEST four_oh_four_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -492,7 +492,7 @@ four_oh_four_pp = <<-MANIFEST ensure => 'present', source => 'http://#{PUPPETLABS_APT_URL}/herpderp.gpg', } - MANIFEST +MANIFEST socket_error_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -500,7 +500,7 @@ socket_error_pp = <<-MANIFEST ensure => 'present', source => 'http://apt.puppetlabss.com/herpderp.gpg', } - MANIFEST +MANIFEST ftp_works_pp = <<-MANIFEST apt_key { 'CentOS 6': @@ -508,7 +508,7 @@ ftp_works_pp = <<-MANIFEST ensure => 'present', source => 'ftp://#{CENTOS_REPO_URL}/#{CENTOS_GPG_KEY_FILE}', } - MANIFEST +MANIFEST ftp_550_pp = <<-MANIFEST apt_key { 'CentOS 6': @@ -516,7 +516,7 @@ ftp_550_pp = <<-MANIFEST ensure => 'present', source => 'ftp://#{CENTOS_REPO_URL}/herpderp.gpg', } - MANIFEST +MANIFEST ftp_socket_error_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -524,7 +524,7 @@ ftp_socket_error_pp = <<-MANIFEST ensure => 'present', source => 'ftp://apt.puppetlabss.com/herpderp.gpg', } - MANIFEST +MANIFEST https_works_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -532,7 +532,7 @@ https_works_pp = <<-MANIFEST ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - MANIFEST +MANIFEST https_with_weak_ssl_works_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -541,7 +541,7 @@ https_with_weak_ssl_works_pp = <<-MANIFEST source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', weak_ssl => true, } - MANIFEST +MANIFEST https_userinfo_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -549,7 +549,7 @@ https_userinfo_pp = <<-MANIFEST ensure => 'present', source => 'https://dummyuser:dummypassword@#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - MANIFEST +MANIFEST https_404_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -557,7 +557,7 @@ https_404_pp = <<-MANIFEST ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/herpderp.gpg', } - MANIFEST +MANIFEST https_socket_error_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -565,7 +565,7 @@ https_socket_error_pp = <<-MANIFEST ensure => 'present', source => 'https://apt.puppetlabss.com/herpderp.gpg', } - MANIFEST +MANIFEST path_exists_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -573,7 +573,7 @@ path_exists_pp = <<-MANIFEST ensure => 'present', source => '/tmp/puppetlabs-pubkey.gpg', } - MANIFEST +MANIFEST path_does_not_exist_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -581,7 +581,7 @@ path_does_not_exist_pp = <<-MANIFEST ensure => 'present', source => '/tmp/totally_bogus.file', } - MANIFEST +MANIFEST path_bogus_content_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -589,7 +589,7 @@ path_bogus_content_pp = <<-MANIFEST ensure => 'present', source => '/tmp/fake-key.gpg', } - MANIFEST +MANIFEST debug_works_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -597,7 +597,7 @@ debug_works_pp = <<-MANIFEST ensure => 'present', options => 'debug', } - MANIFEST +MANIFEST fingerprint_match_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -605,7 +605,7 @@ fingerprint_match_pp = <<-MANIFEST ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - MANIFEST +MANIFEST fingerprint_does_not_match_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -613,7 +613,7 @@ fingerprint_does_not_match_pp = <<-MANIFEST ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - MANIFEST +MANIFEST refresh_true_pp = <<-MANIFEST apt_key { '#{PUPPETLABS_EXP_KEY_LONG_ID}': @@ -621,7 +621,7 @@ refresh_true_pp = <<-MANIFEST ensure => 'present', refresh => true, } - MANIFEST +MANIFEST refresh_false_pp = <<-MANIFEST apt_key { '#{PUPPETLABS_EXP_KEY_LONG_ID}': @@ -657,18 +657,19 @@ describe 'apt_key' do id => '#{CENTOS_GPG_KEY_LONG_ID}', ensure => 'present', } - MANIFEST + MANIFEST ensure_absent_pp = <<-MANIFEST apt_key { 'centos': id => '#{CENTOS_GPG_KEY_LONG_ID}', ensure => 'absent', } - MANIFEST + MANIFEST it 'add an apt_key resource' do apply_manifest_twice(ensure_present_pp) end + it 'remove the apt_key resource' do apply_manifest_twice(ensure_absent_pp) end @@ -676,7 +677,7 @@ describe 'apt_key' do describe 'content =>' do context 'with puppetlabs gpg key' do - it 'works' do + it 'applies without error' do # Apply the manifest (Retry if timeout error is received from key pool) retry_on_error_matching do apply_manifest(gpg_key_pp, catch_failures: true) @@ -705,7 +706,7 @@ describe 'apt_key' do describe 'server =>' do context 'with hkp://pgp.mit.edu:80' do - it 'works' do + it 'applies without error' do retry_on_error_matching do apply_manifest(hkp_pool_pp, catch_failures: true) end @@ -717,7 +718,7 @@ describe 'apt_key' do if hkps_protocol_supported context 'with hkps://keyserver.ubuntu.com' do - it 'works' do + it 'applies without error' do retry_on_error_matching do apply_manifest(hkps_ubuntu_pp, catch_failures: true) end @@ -747,7 +748,7 @@ describe 'apt_key' do describe 'source =>' do context 'with http://' do - it 'works' do + it 'applies without error' do apply_manifest_twice(http_works_pp) run_shell(PUPPETLABS_KEY_CHECK_COMMAND) end @@ -776,7 +777,7 @@ describe 'apt_key' do run_shell("apt-key del #{CENTOS_GPG_KEY_LONG_ID}", expect_failures: true) end - it 'works' do + it 'applies without error' do apply_manifest_twice(ftp_works_pp) run_shell(CENTOS_KEY_CHECK_COMMAND) end @@ -795,7 +796,7 @@ describe 'apt_key' do end context 'with https://' do - it 'works' do + it 'applies without error' do apply_manifest_twice(https_works_pp) run_shell(PUPPETLABS_KEY_CHECK_COMMAND) end @@ -833,7 +834,7 @@ describe 'apt_key' do run_shell('rm /tmp/puppetlabs-pubkey.gpg') end - it 'works' do + it 'applies without error' do apply_manifest_twice(path_exists_pp) run_shell(PUPPETLABS_KEY_CHECK_COMMAND) end @@ -855,6 +856,7 @@ describe 'apt_key' do after(:each) do run_shell('rm /tmp/fake-key.gpg') end + it 'fails' do apply_manifest(path_bogus_content_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{no valid OpenPGP data found}) @@ -865,7 +867,7 @@ describe 'apt_key' do describe 'options =>' do context 'with debug' do - it 'works' do + it 'applies without error' do apply_manifest_twice(debug_works_pp) run_shell(PUPPETLABS_KEY_CHECK_COMMAND) end @@ -874,13 +876,13 @@ describe 'apt_key' do describe 'fingerprint validation against source/content' do context 'with fingerprint in id matches fingerprint from remote key' do - it 'works' do + it 'applies without error' do apply_manifest_twice(fingerprint_match_pp) end end context 'with fingerprint in id does NOT match fingerprint from remote key' do - it 'works' do + it 'applies without error' do apply_manifest(fingerprint_does_not_match_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{don't match}) end @@ -897,6 +899,7 @@ describe 'apt_key' do apply_manifest(refresh_del_key_pp) apply_manifest(refresh_pp, catch_failures: true) end + context 'when refresh => true' do it 'updates an expired key' do apply_manifest(refresh_true_pp) @@ -904,6 +907,7 @@ describe 'apt_key' do run_shell(PUPPETLABS_EXP_CHECK_COMMAND.to_s) end end + context 'when refresh => false' do it 'does not replace an expired key' do apply_manifest(refresh_false_pp)