(maint) - Moved i18n tests to new file (#794)
authorEimhin Laverty <eimlav@users.noreply.github.com>
Mon, 17 Sep 2018 14:25:25 +0000 (15:25 +0100)
committerPaula Muir <paula@puppet.com>
Mon, 17 Sep 2018 14:25:25 +0000 (15:25 +0100)
(maint) - Moved i18n tests to new file

lib/puppet/provider/apt_key/apt_key.rb
spec/acceptance/apt_key_provider_spec.rb
spec/acceptance/locales_spec.rb [new file with mode: 0644]

index fbf232a766b8f12caf22f8f3725af80bb44908ef..2646422a581d4e1bd3ae7f79a33f464f37978ab6 100644 (file)
@@ -170,7 +170,7 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do
           end
         end
         unless found_match
-          raise(_('The id in your manifest %{_resource} and the fingerprint from content/source don\'t match. Check for an error in the id and content/source is legitimate.') % { _name: resource[:name] }) # rubocop:disable Metrics/LineLength
+          raise(_('The id in your manifest %{_resource} and the fingerprint from content/source don\'t match. Check for an error in the id and content/source is legitimate.') % { _resource: resource[:name] }) # rubocop:disable Metrics/LineLength
         end
       else
         warning('/usr/bin/gpg cannot be found for verification of the id.')
index 712fa5a8715bb52e518c401b84a7a86e942b94b3..de3be330219b70358aacf582b7598d09d9f6e78b 100644 (file)
@@ -716,22 +716,6 @@ describe 'apt_key' do
           expect(r.stderr).to match(%r{could not resolve})
         end
       end
-
-      it 'fails with a socket error - i18n' do
-        hosts.each do |host|
-          on(host, "sed -i \"96i FastGettext.locale='ja'\" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb")
-          change_locale_on(host, 'ja_JP.utf-8')
-        end
-
-        apply_manifest(socket_error_pp, expect_failures: true) do |r|
-          expect(r.stderr).to match(%r{ƈǿŭŀḓ ƞǿŧ řḗşǿŀṽḗ})
-        end
-
-        hosts.each do |host|
-          on(host, 'sed -i "96d" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb')
-          change_locale_on(host, 'en_US')
-        end
-      end
     end
 
     # disabled when running in travis, security issues prevent FTP
@@ -757,22 +741,6 @@ describe 'apt_key' do
           expect(r.stderr).to match(%r{could not resolve})
         end
       end
-
-      it 'fails with a socket error - i18n' do
-        hosts.each do |host|
-          on(host, "sed -i \"96i FastGettext.locale='ja'\" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb")
-          change_locale_on(host, 'ja_JP.utf-8')
-        end
-
-        apply_manifest(ftp_socket_error_pp, expect_failures: true) do |r|
-          expect(r.stderr).to match(%r{ƈǿŭŀḓ ƞǿŧ řḗşǿŀṽḗ})
-        end
-
-        hosts.each do |host|
-          on(host, 'sed -i "96d" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb')
-          change_locale_on(host, 'en_US')
-        end
-      end
     end
 
     context 'with https://' do
@@ -797,22 +765,6 @@ describe 'apt_key' do
           expect(r.stderr).to match(%r{could not resolve})
         end
       end
-
-      it 'fails with a socket error - i18n' do
-        hosts.each do |host|
-          on(host, "sed -i \"96i FastGettext.locale='ja'\" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb")
-          change_locale_on(host, 'ja_JP.utf-8')
-        end
-
-        apply_manifest(https_socket_error_pp, expect_failures: true) do |r|
-          expect(r.stderr).to match(%r{ƈǿŭŀḓ ƞǿŧ řḗşǿŀṽḗ})
-        end
-
-        hosts.each do |host|
-          on(host, 'sed -i "96d" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb')
-          change_locale_on(host, 'en_US')
-        end
-      end
     end
 
     context 'with /path/that/exists' do
diff --git a/spec/acceptance/locales_spec.rb b/spec/acceptance/locales_spec.rb
new file mode 100644 (file)
index 0000000..eaf214d
--- /dev/null
@@ -0,0 +1,65 @@
+require 'spec_helper_acceptance'
+require 'beaker/i18n_helper'
+
+PUPPETLABS_GPG_KEY_LONG_ID     = '7F438280EF8D349F'.freeze
+PUPPETLABS_LONG_FINGERPRINT    = '123456781274D2C8A956789A456789A456789A9A'.freeze
+
+id_short_warning_pp = <<-MANIFEST
+        apt_key { 'puppetlabs':
+          id     => '#{PUPPETLABS_GPG_KEY_LONG_ID}',
+          ensure => 'present',
+          source => 'http://apt.puppetlabs.com/herpderp.gpg',
+        }
+  MANIFEST
+
+id_doesnt_match_fingerprint_pp = <<-MANIFEST
+        apt_key { '#{PUPPETLABS_LONG_FINGERPRINT}':
+          ensure => 'present',
+          content => '123456781274D2C8A956789A456789A456789A9B',
+        }
+  MANIFEST
+
+location_not_specified_fail_pp = <<-MANIFEST
+        apt::source { 'puppetlabs':
+          ensure => 'present',
+          repos    => 'main',
+          key      => {
+            id     => '6F6B15509CF8E59E6E469F327F438280EF8D349F',
+            server => 'hkps.pool.sks-keyservers.net',
+          },
+        }
+  MANIFEST
+
+describe 'apt', if: (fact('osfamily') == 'Debian' || fact('osfamily') == 'RedHat') && (Gem::Version.new(puppet_version) >= Gem::Version.new('4.10.5')) do
+  before :all do
+    hosts.each do |host|
+      on(host, "sed -i \"96i FastGettext.locale='ja'\" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb")
+      change_locale_on(host, 'ja_JP.utf-8')
+    end
+  end
+
+  describe 'i18n translations' do
+    it 'warns with shortened id' do
+      apply_manifest(id_short_warning_pp, catch_failures: true) do |r|
+        expect(r.stderr).to match(%r{Ŧħḗ īḓ şħǿŭŀḓ ƀḗ ȧ ƒŭŀŀ ƒīƞɠḗřƥřīƞŧ})
+      end
+    end
+    it 'fails with different id and fingerprint' do
+      apply_manifest(id_doesnt_match_fingerprint_pp, expect_failures: true) do |r|
+        expect(r.stderr).to match(%r{Ŧħḗ īḓ īƞ ẏǿŭř ḿȧƞīƒḗşŧ 123456781274D2C8A956789A456789A456789A9A})
+      end
+    end
+    it 'fails with no location' do
+      apply_manifest(location_not_specified_fail_pp, expect_failures: true) do |r|
+        expect(r.stderr).to match(%r{ƈȧƞƞǿŧ ƈřḗȧŧḗ ȧ şǿŭřƈḗ ḗƞŧřẏ ẇīŧħǿŭŧ şƥḗƈīƒẏīƞɠ ȧ ŀǿƈȧŧīǿƞ})
+      end
+    end
+  end
+
+  after :all do
+    hosts.each do |host|
+      on(host, 'sed -i "96d" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb')
+      change_locale_on(host, 'en_US')
+    end
+  end
+end