Skip to content

Commit

Permalink
Add basic acceptance tests for the existing examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ekohl committed May 23, 2024
1 parent cf8ef94 commit cfda87d
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ concurrency:
jobs:
puppet:
name: Puppet
uses: voxpupuli/gha-puppet/.github/workflows/basic.yml@v2
uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v2
2 changes: 2 additions & 0 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ Gemfile:
optional:
':test':
- gem: webmock
spec/spec_helper_acceptance.rb:
unmanaged: false
6 changes: 3 additions & 3 deletions examples/x509_cert.pp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
openssl::certificate::x509 { 'foo.bar':
openssl::certificate::x509 { 'foo.example.com':
ensure => present,
country => 'CH',
organization => 'Example.com',
commonname => $fqdn,
commonname => 'foo.example.com',
base_dir => '/tmp',
owner => 'www-data',
owner => 'nobody',
password => 'mahje1Qu',
}
7 changes: 7 additions & 0 deletions spec/acceptance/dhparam_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'spec_helper_acceptance'

Check failure on line 1 in spec/acceptance/dhparam_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

Style/FrozenStringLiteralComment: Missing frozen string literal comment.

describe 'x509_cert example' do
it_behaves_like 'the example', 'dhparam.pp' do
it { expect(file('/etc/ssl/certs/dhparam.pem')).to be_file }
end
end
11 changes: 11 additions & 0 deletions spec/acceptance/x509_cert_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'spec_helper_acceptance'

Check failure on line 1 in spec/acceptance/x509_cert_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

Style/FrozenStringLiteralComment: Missing frozen string literal comment.

describe 'x509_cert example' do
it_behaves_like 'the example', 'x509_cert.pp' do
it { expect(file('/tmp/foo.example.com.crt')).to be_file.and(have_attributes(owner: 'nobody')) }
it { expect(x509_certificate('/tmp/foo.example.com.crt')).to be_certificate.and(have_attributes(subject: 'C = CH, O = Example.com, CN = foo.example.com')) }

it { expect(file('/tmp/foo.example.com.key')).to be_file.and(have_attributes(owner: 'nobody', mode: '600')) }
it { expect(x509_private_key('/tmp/foo.example.com.key', passin: 'pass:mahje1Qu')).to have_matching_certificate('/tmp/foo.example.com.crt') }
end
end
23 changes: 6 additions & 17 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
# frozen_string_literal: true

require 'beaker-pe'
require 'beaker-puppet'
require 'puppet'
require 'beaker-rspec/spec_helper'
require 'beaker-rspec/helpers/serverspec'
require 'beaker/puppet_install_helper'
require 'beaker/module_install_helper'
require 'beaker-task_helper'
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

run_puppet_install_helper
configure_type_defaults_on(hosts)
install_ca_certs unless pe_install?
# install_bolt_on(hosts) unless pe_install?
install_module_on(hosts)
install_module_dependencies_on(hosts)
require 'voxpupuli/acceptance/spec_helper_acceptance'

RSpec.configure do |c|
c.formatter = :documentation
end
configure_beaker(modules: :metadata)

Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f }

0 comments on commit cfda87d

Please sign in to comment.