Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rubocop corrections for rubocop 1.22.3 #83

Merged
merged 3 commits into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
3 changes: 3 additions & 0 deletions .puppet-lint.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--fail-on-warnings
--no-parameter_documentation-check
--no-parameter_types-check
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 2 additions & 0 deletions lib/facter/certissuer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# == Fact: certissuer
# From fetchcrl module.
# Fact supplies the issuer of grid grid certificate if it exists.
Expand Down
4 changes: 3 additions & 1 deletion lib/facter/trustedca.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# == Fact: trustedcas
# From fetchcrl module.
# Fact supplies the issuer of grid grid certificate if it exists.
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion spec/acceptance/fetchcrl_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'fetchcrl' do
Expand All @@ -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 \* \* \*.*$} }
Expand All @@ -23,6 +26,7 @@
end
end
end

context 'with fetchcrl and ipv6 and cas' do
let(:pp) do
'
Expand Down
19 changes: 15 additions & 4 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper'
describe 'fetchcrl', type: 'class' do
on_supported_os.each do |os, facts|
Expand All @@ -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']]
Expand All @@ -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
{
Expand All @@ -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' },
Expand All @@ -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',
Expand All @@ -98,6 +105,7 @@
}
end
end

context 'with boolean params parameters set true' do
let(:params) do
{
Expand All @@ -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') }
Expand All @@ -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
{
Expand All @@ -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') }
Expand Down
5 changes: 5 additions & 0 deletions spec/defines/ca_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'fetchcrl::ca' do
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand Down
10 changes: 5 additions & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

Expand Down
2 changes: 2 additions & 0 deletions spec/support/acceptance/prepare_host.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

def prepare_host
shell('yum install -y epel-release') if fact('os.name') == 'CentOS'
end
5 changes: 5 additions & 0 deletions spec/unit/facter/trustedca_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'trustedca' do
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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