Skip to content

Commit

Permalink
Merge pull request #168 from voxpupuli/modulesync
Browse files Browse the repository at this point in the history
modulesync 7.0.0
  • Loading branch information
bastelfreak authored Aug 18, 2023
2 parents 1b6ae9a + ab91462 commit 1b41c6e
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 34 deletions.
11 changes: 7 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
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: '6.0.0'
modulesync_config_version: '7.0.0'
22 changes: 19 additions & 3 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -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'
2 changes: 1 addition & 1 deletion 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', '~> 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
Expand Down
2 changes: 1 addition & 1 deletion lib/facter/openssl_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions lib/puppet/provider/cert_file/posix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions lib/puppet/provider/ssl_pkey/openssl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/functions/cert_aia_caissuers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion spec/functions/cert_date_valid_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
add_custom_fact name.to_sym, value
end
end
Dir['./spec/support/spec/**/*.rb'].sort.each { |f| require f }
2 changes: 1 addition & 1 deletion spec/unit/puppet/provider/cert_file/posix_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/puppet/provider/ssl_pkey/openssl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions spec/unit/puppet/provider/x509_cert/openssl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
10 changes: 5 additions & 5 deletions spec/unit/puppet/provider/x509_request/openssl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 1b41c6e

Please sign in to comment.