diff --git a/.msync.yml b/.msync.yml index 43966c2..a83abd9 100644 --- a/.msync.yml +++ b/.msync.yml @@ -2,4 +2,4 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -modulesync_config_version: '4.2.0' +modulesync_config_version: '5.1.0' diff --git a/.puppet-lint.rc b/.puppet-lint.rc new file mode 100644 index 0000000..dd8272c --- /dev/null +++ b/.puppet-lint.rc @@ -0,0 +1,3 @@ +--fail-on-warnings +--no-parameter_documentation-check +--no-parameter_types-check diff --git a/Gemfile b/Gemfile index e43173e..113a361 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" group :test do - gem 'voxpupuli-test', '~> 2.5', :require => false + gem 'voxpupuli-test', '~> 5.0', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false gem 'puppet_metadata', '~> 1.0', :require => false @@ -22,7 +22,7 @@ end group :release do gem 'github_changelog_generator', '>= 1.16.1', :require => false if RUBY_VERSION >= '2.5' - gem 'voxpupuli-release', '>= 1.0.2', :require => false + gem 'voxpupuli-release', '>= 1.2.0', :require => false gem 'puppet-strings', '>= 2.2', :require => false end diff --git a/Rakefile b/Rakefile index 80b799d..f92f051 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,7 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -# Attempt to load voxupuli-test (which pulls in puppetlabs_spec_helper), +# Attempt to load voxpupuli-test (which pulls in puppetlabs_spec_helper), # otherwise attempt to load it directly. begin require 'voxpupuli/test/rake' diff --git a/lib/facter/certissuer.rb b/lib/facter/certissuer.rb index dc20ca3..2d6b4c1 100644 --- a/lib/facter/certissuer.rb +++ b/lib/facter/certissuer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # == Fact: certissuer # From fetchcrl module. # Fact supplies the issuer of grid grid certificate if it exists. diff --git a/lib/facter/trustedca.rb b/lib/facter/trustedca.rb index d9a0839..5572044 100644 --- a/lib/facter/trustedca.rb +++ b/lib/facter/trustedca.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # == Fact: trustedcas # From fetchcrl module. # Fact supplies the issuer of grid grid certificate if it exists. @@ -9,7 +11,7 @@ Dir.glob('/etc/grid-security/certificates/*.pem').each do |pem| begin cert = OpenSSL::X509::Certificate.new(File.read(pem)) - rescue + rescue StandardError next end subject = cert.subject.to_a diff --git a/spec/acceptance/fetchcrl_spec.rb b/spec/acceptance/fetchcrl_spec.rb index 70687be..6829b03 100644 --- a/spec/acceptance/fetchcrl_spec.rb +++ b/spec/acceptance/fetchcrl_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper_acceptance' describe 'fetchcrl' do @@ -14,7 +16,8 @@ shell('fetch-crl', acceptable_exit_codes: [0, 1]) shell('ls /etc/grid-security/certificates/*.r0', acceptable_exit_codes: 0) end - describe file('/etc/cron.d/fetch-crl') do + + describe file('/etc/cron.d/fetch-crl') do # rubocop:disable RSpec/EmptyExampleGroup Do not understand case [fact('os.name'), fact('os.release.major')] when %w[CentOS 7], ['Ubuntu', '18.04'], %w[Debian 10] its(:content) { is_expected.to match %r{^([0-9]|[1-5][0-9]) [0-5]-23/6 \* \* \*.*$} } @@ -23,6 +26,7 @@ end end end + context 'with fetchcrl and ipv6 and cas' do let(:pp) do ' diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 63f99ec..c3817ad 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'fetchcrl', type: 'class' do on_supported_os.each do |os, facts| @@ -16,26 +18,29 @@ it { is_expected.to contain_file('/etc/fetch-crl.conf').without_content(%r{noerrors}) } it { is_expected.to contain_file('/etc/fetch-crl.conf').without_content(%r{inet6glue}) } it { is_expected.to have_fetchcrl__ca_resource_count(0) } + case facts[:os]['family'] when 'Debian' it { - is_expected.to contain_apt__source('carepo').with( + expect(subject).to contain_apt__source('carepo').with( { location: 'https://repository.egi.eu/sw/production/cas/1/current/', key: { 'ensure' => 'refreshed', 'id' => 'D12E922822BE64D50146188BC32D99C83CDBBC71', 'source' => 'https://dist.eugridpma.info/distribution/igtf/current/GPG-KEY-EUGridPMA-RPM-3' }, } ) } + it { is_expected.not_to contain_yumrepo('carepo') } else it { - is_expected.to contain_yumrepo('carepo').with( + expect(subject).to contain_yumrepo('carepo').with( { baseurl: 'https://repository.egi.eu/sw/production/cas/1/current/', gpgkey: 'https://dist.eugridpma.info/distribution/igtf/current/GPG-KEY-EUGridPMA-RPM-3', } ) } + it { is_expected.not_to contain_apt__source('carepo') } end case [facts[:os]['name'], facts[:os]['release']['major']] @@ -54,6 +59,7 @@ it { is_expected.to contain_service('fetch-crl.timer').with_enable(true) } end end + context 'with all parameters set' do let(:params) do { @@ -77,10 +83,11 @@ it { is_expected.to contain_package('def').with_ensure('present') } it { is_expected.to contain_fetchcrl__ca('EDG').with_agingtolerance(168) } it { is_expected.to contain_fetchcrl__ca('MD').with_noerrors(true) } + case facts[:os]['family'] when 'Debian' it { - is_expected.to contain_apt__source('carepo').with( + expect(subject).to contain_apt__source('carepo').with( { location: 'https://example.org/foo', key: { 'ensure' => 'refreshed', 'id' => 'D12E922822BE64D50146188BC32D99C83CDBBC71', 'source' => 'https://example.org/foo.gpg' }, @@ -89,7 +96,7 @@ } when 'RedHat' it { - is_expected.to contain_yumrepo('carepo').with( + expect(subject).to contain_yumrepo('carepo').with( { baseurl: 'https://example.org/foo', gpgkey: 'https://example.org/foo.gpg', @@ -98,6 +105,7 @@ } end end + context 'with boolean params parameters set true' do let(:params) do { @@ -120,6 +128,7 @@ end it { is_expected.to contain_file('/etc/fetch-crl.conf').with_content(%r{^noerrors$}) } it { is_expected.to contain_file('/etc/fetch-crl.conf').with_content(%r{^inet6glue$}) } + case [facts[:os]['name'], facts[:os]['release']['major']] when %w[RedHat 7], %w[CentOS 7], %w[Debian 10], ['Ubuntu', '18.04'] it { is_expected.to contain_augeas('randomise_cron').with_incl('/etc/cron.d/fetch-crl') } @@ -135,6 +144,7 @@ it { is_expected.to contain_service('fetch-crl.timer').with_enable(true) } end end + context 'with boolean params parameters set false' do let(:params) do { @@ -150,6 +160,7 @@ it { is_expected.not_to contain_apt__source('carepo') } it { is_expected.to contain_file('/etc/fetch-crl.conf').without_content(%r{^noerrors$}) } it { is_expected.not_to contain_augeas('randomise_cron') } + case [facts[:os]['name'], facts[:os]['release']['major']] when %w[RedHat 7], %w[CentOS 7], %w[Debian 10], ['Ubuntu', '18.04'] it { is_expected.not_to contain_service('fetch-crl.timer') } diff --git a/spec/defines/ca_spec.rb b/spec/defines/ca_spec.rb index f5af27b..f20c64b 100644 --- a/spec/defines/ca_spec.rb +++ b/spec/defines/ca_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'fetchcrl::ca' do @@ -21,6 +23,7 @@ it { is_expected.to contain_file('/etc/foo.d/myinstance.conf').without_content(%r{^noerrors$}) } it { is_expected.to contain_file('/etc/foo.d/myinstance.conf').without_content(%r{^httptimeout$}) } it { is_expected.to contain_file('/etc/foo.d/myinstance.conf').without_content(%r{^crl_url$}) } + context 'with all booleans false' do let(:params) do { @@ -32,6 +35,7 @@ it { is_expected.to contain_file('/etc/foo.d/myinstance.conf').without_content(%r{^nowarnings$}) } it { is_expected.to contain_file('/etc/foo.d/myinstance.conf').without_content(%r{^noerrors$}) } end + context 'with all booleans true' do let(:params) do { @@ -43,6 +47,7 @@ it { is_expected.to contain_file('/etc/foo.d/myinstance.conf').with_content(%r{^nowarnings$}) } it { is_expected.to contain_file('/etc/foo.d/myinstance.conf').with_content(%r{^noerrors$}) } end + context 'with all parameters set' do let(:params) do { diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index fb5f0cb..4d617f3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,17 +1,17 @@ +# frozen_string_literal: true + # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ # puppetlabs_spec_helper will set up coverage if the env variable is set. # We want to do this if lib exists and it hasn't been explicitly set. -ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../../lib', __FILE__)) +ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../lib', __dir__)) require 'voxpupuli/test/spec_helper' if File.exist?(File.join(__dir__, 'default_module_facts.yml')) facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml'))) - if facts - facts.each do |name, value| - add_custom_fact name.to_sym, value - end + facts&.each do |name, value| + add_custom_fact name.to_sym, value end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index d3b906b..d3a6e23 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ diff --git a/spec/support/acceptance/prepare_host.rb b/spec/support/acceptance/prepare_host.rb index 2ae6c35..f4fe83d 100644 --- a/spec/support/acceptance/prepare_host.rb +++ b/spec/support/acceptance/prepare_host.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + def prepare_host shell('yum install -y epel-release') if fact('os.name') == 'CentOS' end diff --git a/spec/unit/facter/trustedca_spec.rb b/spec/unit/facter/trustedca_spec.rb index 84f51d8..f72d3b6 100644 --- a/spec/unit/facter/trustedca_spec.rb +++ b/spec/unit/facter/trustedca_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'trustedca' do @@ -17,6 +19,7 @@ ) allow(File).to receive(:read).with('/etc/grid-security/certificates/CERN-GridCA.pem').and_return(cern) end + it { expect(Facter.fact(:trustedca).value).to eq ['CN=CERN Grid Certification Authority,DC=cern,DC=ch'] } end @@ -30,6 +33,7 @@ ) allow(File).to receive(:read).with('/etc/grid-security/certificates/ARC-TestCA-6a8cca22-key.pem').and_return(arc) end + it { expect(Facter.fact(:trustedca).value).to eq [] } end @@ -48,6 +52,7 @@ allow(File).to receive(:read).with('/etc/grid-security/certificates/ARC-TestCA-6a8cca22-key.pem').and_return(arc) allow(File).to receive(:read).with('/etc/grid-security/certificates/CERN-GridCA.pem').and_return(cern) end + it { expect(Facter.fact(:trustedca).value).to eq ['CN=CERN Grid Certification Authority,DC=cern,DC=ch'] } end end