(maint) - Moved i18n tests to new file (#794)
[puppet-modules/puppetlabs-apt.git] / spec / acceptance / locales_spec.rb
1 require 'spec_helper_acceptance'
2 require 'beaker/i18n_helper'
3
4 PUPPETLABS_GPG_KEY_LONG_ID     = '7F438280EF8D349F'.freeze
5 PUPPETLABS_LONG_FINGERPRINT    = '123456781274D2C8A956789A456789A456789A9A'.freeze
6
7 id_short_warning_pp = <<-MANIFEST
8         apt_key { 'puppetlabs':
9           id     => '#{PUPPETLABS_GPG_KEY_LONG_ID}',
10           ensure => 'present',
11           source => 'http://apt.puppetlabs.com/herpderp.gpg',
12         }
13   MANIFEST
14
15 id_doesnt_match_fingerprint_pp = <<-MANIFEST
16         apt_key { '#{PUPPETLABS_LONG_FINGERPRINT}':
17           ensure => 'present',
18           content => '123456781274D2C8A956789A456789A456789A9B',
19         }
20   MANIFEST
21
22 location_not_specified_fail_pp = <<-MANIFEST
23         apt::source { 'puppetlabs':
24           ensure => 'present',
25           repos    => 'main',
26           key      => {
27             id     => '6F6B15509CF8E59E6E469F327F438280EF8D349F',
28             server => 'hkps.pool.sks-keyservers.net',
29           },
30         }
31   MANIFEST
32
33 describe 'apt', if: (fact('osfamily') == 'Debian' || fact('osfamily') == 'RedHat') && (Gem::Version.new(puppet_version) >= Gem::Version.new('4.10.5')) do
34   before :all do
35     hosts.each do |host|
36       on(host, "sed -i \"96i FastGettext.locale='ja'\" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb")
37       change_locale_on(host, 'ja_JP.utf-8')
38     end
39   end
40
41   describe 'i18n translations' do
42     it 'warns with shortened id' do
43       apply_manifest(id_short_warning_pp, catch_failures: true) do |r|
44         expect(r.stderr).to match(%r{Ŧħḗ īḓ şħǿŭŀḓ ƀḗ ȧ ƒŭŀŀ ƒīƞɠḗřƥřīƞŧ})
45       end
46     end
47     it 'fails with different id and fingerprint' do
48       apply_manifest(id_doesnt_match_fingerprint_pp, expect_failures: true) do |r|
49         expect(r.stderr).to match(%r{Ŧħḗ īḓ īƞ ẏǿŭř ḿȧƞīƒḗşŧ 123456781274D2C8A956789A456789A456789A9A})
50       end
51     end
52     it 'fails with no location' do
53       apply_manifest(location_not_specified_fail_pp, expect_failures: true) do |r|
54         expect(r.stderr).to match(%r{ƈȧƞƞǿŧ ƈřḗȧŧḗ ȧ şǿŭřƈḗ ḗƞŧřẏ ẇīŧħǿŭŧ şƥḗƈīƒẏīƞɠ ȧ ŀǿƈȧŧīǿƞ})
55       end
56     end
57   end
58
59   after :all do
60     hosts.each do |host|
61       on(host, 'sed -i "96d" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb')
62       change_locale_on(host, 'en_US')
63     end
64   end
65 end