diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 8b466cfb..6aaa603f 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -232,18 +232,21 @@ simple tests against it after applying the module. You can run this with: ```sh -BEAKER_setfile=debian11-64 bundle exec rake beaker +BEAKER_PUPPET_COLLECTION=puppet7 BEAKER_setfile=debian11-64 bundle exec rake beaker ``` -You can replace the string `debian10` with any common operating system. +You can replace the string `debian11` with any common operating system. The following strings are known to work: -* ubuntu1804 * ubuntu2004 -* debian10 +* ubuntu2204 * debian11 * centos7 * centos8 +* centos9 +* almalinux8 +* almalinux9 +* fedora36 For more information and tips & tricks, see [voxpupuli-acceptance's documentation](https://github.com/voxpupuli/voxpupuli-acceptance#running-tests). diff --git a/.msync.yml b/.msync.yml index b929160c..dd3e9572 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: '6.0.0' +modulesync_config_version: '7.0.0' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0d929049..9473316a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,22 @@ ---- +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2023-08-18 06:31:59 UTC using RuboCop version 1.50.2. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 24 +# Configuration parameters: . +# SupportedStyles: have_received, receive RSpec/MessageSpies: - Enabled: false + EnforcedStyle: receive +# Offense count: 12 RSpec/StubbedMock: - Enabled: false + Exclude: + - 'spec/functions/cert_aia_caissuers_spec.rb' + - 'spec/functions/cert_date_valid_spec.rb' + - 'spec/unit/puppet/provider/ssl_pkey/openssl_spec.rb' + - 'spec/unit/puppet/provider/x509_cert/openssl_spec.rb' + - 'spec/unit/puppet/provider/x509_request/openssl_spec.rb' diff --git a/Gemfile b/Gemfile index d83028fa..41637094 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :test do - gem 'voxpupuli-test', '~> 6.0', :require => false + gem 'voxpupuli-test', '~> 7.0', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false gem 'puppet_metadata', '~> 3.0', :require => false diff --git a/lib/facter/openssl_version.rb b/lib/facter/openssl_version.rb index 442385c3..c5d9c913 100644 --- a/lib/facter/openssl_version.rb +++ b/lib/facter/openssl_version.rb @@ -4,7 +4,7 @@ setcode do if Facter::Util::Resolution.which('openssl') openssl_version = Facter::Util::Resolution.exec('openssl version 2>&1') - matches = %r{^OpenSSL ([\w.\-]+)(\s+FIPS)?( +)([\d.]+)( +)([\w.]+)( +)([\d.]+)}.match(openssl_version) + matches = %r{^OpenSSL ([\w.-]+)(\s+FIPS)?( +)([\d.]+)( +)([\w.]+)( +)([\d.]+)}.match(openssl_version) matches[1] if matches end end diff --git a/lib/puppet/provider/cert_file/posix.rb b/lib/puppet/provider/cert_file/posix.rb index b25b3fa2..27401df8 100644 --- a/lib/puppet/provider/cert_file/posix.rb +++ b/lib/puppet/provider/cert_file/posix.rb @@ -22,13 +22,9 @@ def exists? def create case resource[:format] when :pem - File.open(resource[:path], 'wt') do |localcert_file| - localcert_file.write(remotecert.to_pem) - end + File.write(resource[:path], remotecert.to_pem) when :der - File.open(resource[:path], 'wb') do |localcert_file| - localcert_file.write(remotecert.to_der) - end + File.binwrite(resource[:path], remotecert.to_der) else raise ArgumentError, 'Output format not implemented.' end diff --git a/lib/puppet/provider/ssl_pkey/openssl.rb b/lib/puppet/provider/ssl_pkey/openssl.rb index b2b2cc7d..8ca7df99 100644 --- a/lib/puppet/provider/ssl_pkey/openssl.rb +++ b/lib/puppet/provider/ssl_pkey/openssl.rb @@ -39,9 +39,7 @@ def exists? def create key = self.class.generate_key(resource) pem = self.class.to_pem(resource, key) - File.open(resource[:path], 'w') do |f| - f.write(pem) - end + File.write(resource[:path], pem) end def destroy diff --git a/spec/functions/cert_aia_caissuers_spec.rb b/spec/functions/cert_aia_caissuers_spec.rb index 85ce66a9..45e20548 100644 --- a/spec/functions/cert_aia_caissuers_spec.rb +++ b/spec/functions/cert_aia_caissuers_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe 'openssl::cert_aia_caissuers' do - it { is_expected.not_to eq(nil) } + it { is_expected.not_to be_nil } it 'raises an error if called with no argument' do is_expected.to run.with_params.and_raise_error(StandardError) diff --git a/spec/functions/cert_date_valid_spec.rb b/spec/functions/cert_date_valid_spec.rb index 94bcb07e..6528d05f 100644 --- a/spec/functions/cert_date_valid_spec.rb +++ b/spec/functions/cert_date_valid_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe 'openssl::cert_date_valid' do - it { is_expected.not_to eq(nil) } + it { is_expected.not_to be_nil } it 'raises an error if called with no argument' do is_expected.to run.with_params.and_raise_error(StandardError) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6515b7bf..9efb4ae6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -17,3 +17,4 @@ add_custom_fact name.to_sym, value end end +Dir['./spec/support/spec/**/*.rb'].sort.each { |f| require f } diff --git a/spec/unit/puppet/provider/cert_file/posix_spec.rb b/spec/unit/puppet/provider/cert_file/posix_spec.rb index 34b41de3..03819e38 100644 --- a/spec/unit/puppet/provider/cert_file/posix_spec.rb +++ b/spec/unit/puppet/provider/cert_file/posix_spec.rb @@ -30,7 +30,7 @@ it 'exists? returns false on arbitraty path' do allow_any_instance_of(Pathname).to receive(:exist?).and_return(false) # rubocop:disable RSpec/AnyInstance - expect(resource.provider.exists?).to eq(false) + expect(resource.provider.exists?).to be(false) end it 'downloads a certificate and stores it' do diff --git a/spec/unit/puppet/provider/ssl_pkey/openssl_spec.rb b/spec/unit/puppet/provider/ssl_pkey/openssl_spec.rb index 8e1f7541..4ee19549 100644 --- a/spec/unit/puppet/provider/ssl_pkey/openssl_spec.rb +++ b/spec/unit/puppet/provider/ssl_pkey/openssl_spec.rb @@ -13,13 +13,13 @@ it 'exists? should return true if key exists' do expect(Pathname).to receive(:new).twice.with(path).and_return(pathname) expect(pathname).to receive(:exist?).and_return(true) - expect(resource.provider.exists?).to eq(true) + expect(resource.provider.exists?).to be(true) end it 'exists? should return false if certificate does not exist' do expect(Pathname).to receive(:new).twice.with(path).and_return(pathname) expect(pathname).to receive(:exist?).and_return(false) - expect(resource.provider.exists?).to eq(false) + expect(resource.provider.exists?).to be(false) end context 'when creating a key with defaults' do diff --git a/spec/unit/puppet/provider/x509_cert/openssl_spec.rb b/spec/unit/puppet/provider/x509_cert/openssl_spec.rb index 2ce29fb9..f9419dfe 100644 --- a/spec/unit/puppet/provider/x509_cert/openssl_spec.rb +++ b/spec/unit/puppet/provider/x509_cert/openssl_spec.rb @@ -17,12 +17,12 @@ allow_any_instance_of(Pathname).to receive(:exist?).and_return(true) # rubocop:disable RSpec/AnyInstance c = OpenSSL::X509::Certificate.new # Fake certificate for mocking allow(OpenSSL::X509::Certificate).to receive(:new).and_return(c) - expect(resource.provider.exists?).to eq(true) + expect(resource.provider.exists?).to be(true) end it 'exists? should return false if certificate does not exist' do allow_any_instance_of(Pathname).to receive(:exist?).and_return(false) # rubocop:disable RSpec/AnyInstance - expect(resource.provider.exists?).to eq(false) + expect(resource.provider.exists?).to be(false) end it 'creates a certificate with the proper options' do @@ -87,7 +87,7 @@ allow(OpenSSL::X509::Certificate).to receive(:new).and_return(cert) allow(OpenSSL::PKey::RSA).to receive(:new) expect(cert).to receive(:check_private_key).and_return(true) - expect(resource.provider.exists?).to eq(true) + expect(resource.provider.exists?).to be(true) end it 'exists? should return false if certificate exists and is not synced' do @@ -97,13 +97,13 @@ allow(OpenSSL::X509::Certificate).to receive(:new).and_return(cert) allow(OpenSSL::PKey::RSA).to receive(:new) expect(cert).to receive(:check_private_key).and_return(false) - expect(resource.provider.exists?).to eq(false) + expect(resource.provider.exists?).to be(false) end it 'exists? should return false if certificate does not exist' do resource[:force] = true allow_any_instance_of(Pathname).to receive(:exist?).and_return(false) # rubocop:disable RSpec/AnyInstance - expect(resource.provider.exists?).to eq(false) + expect(resource.provider.exists?).to be(false) end end diff --git a/spec/unit/puppet/provider/x509_request/openssl_spec.rb b/spec/unit/puppet/provider/x509_request/openssl_spec.rb index f1879542..74c44210 100644 --- a/spec/unit/puppet/provider/x509_request/openssl_spec.rb +++ b/spec/unit/puppet/provider/x509_request/openssl_spec.rb @@ -13,12 +13,12 @@ context 'when not forcing key' do it 'exists? should return true if csr exists' do allow_any_instance_of(Pathname).to receive(:exist?).and_return(true) # rubocop:disable RSpec/AnyInstance - expect(resource.provider.exists?).to eq(true) + expect(resource.provider.exists?).to be(true) end it 'exists? should return false if csr exists' do allow_any_instance_of(Pathname).to receive(:exist?).and_return(false) # rubocop:disable RSpec/AnyInstance - expect(resource.provider.exists?).to eq(false) + expect(resource.provider.exists?).to be(false) end it 'creates a certificate with the proper options' do @@ -54,7 +54,7 @@ allow(OpenSSL::X509::Request).to receive(:new).and_return(cert) allow(OpenSSL::PKey::RSA).to receive(:new) expect(cert).to receive(:verify).and_return(true) - expect(resource.provider.exists?).to eq(true) + expect(resource.provider.exists?).to be(true) end it 'exists? should return false if certificate exists and is not synced' do @@ -64,13 +64,13 @@ allow(OpenSSL::X509::Request).to receive(:new).and_return(cert) allow(OpenSSL::PKey::RSA).to receive(:new) expect(cert).to receive(:verify).and_return(false) - expect(resource.provider.exists?).to eq(false) + expect(resource.provider.exists?).to be(false) end it 'exists? should return false if certificate does not exist' do resource[:force] = true allow_any_instance_of(Pathname).to receive(:exist?).and_return(false) # rubocop:disable RSpec/AnyInstance - expect(resource.provider.exists?).to eq(false) + expect(resource.provider.exists?).to be(false) end end