-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #192 from ekohl/add-acceptance-tests
Add basic acceptance tests for the existing examples
- Loading branch information
Showing
7 changed files
with
58 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ Gemfile: | |
optional: | ||
':test': | ||
- gem: webmock | ||
spec/spec_helper_acceptance.rb: | ||
unmanaged: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper_acceptance' | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper_acceptance' | ||
|
||
# the openssl output changed and differs between EL9 vs older versions | ||
# https://github.com/mizzy/serverspec/commit/ac366dd40015f0b53e70a3ed881b931dfc83c603 might not be a correct fix | ||
# Ewoud is working on a fix in https://github.com/ekohl/serverspec/commit/64874e9c8cc70b097300c3a60281572a3528768e | ||
# in the meantime we won't use x509_certificate matcher | ||
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')) } | ||
|
||
describe x509_certificate('/tmp/foo.example.com.crt') do | ||
it { is_expected.to be_certificate } | ||
it { is_expected.to be_valid } | ||
its(:subject) { is_expected.to match_without_whitespace(%r{C = CH, O = Example.com, CN = foo.example.com}) } | ||
its(:keylength) { is_expected.to eq 3072 } | ||
end | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |
13 changes: 13 additions & 0 deletions
13
spec/support/acceptance/matchers/match_without_whitespace.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
# based on https://github.com/theforeman/puppet-certs/blob/master/spec/support/acceptance/matchers/match_without_whitespace.rb | ||
# https://github.com/theforeman/puppet-certs/commit/6b82334a5661a4e95b8c0604535ec39c991c9787 | ||
RSpec::Matchers.define :match_without_whitespace do |expected| | ||
match do |actual| | ||
actual.gsub(%r{\s*}, '').match?(Regexp.new(expected.source, Regexp::EXTENDED)) | ||
end | ||
|
||
failure_message do |actual| | ||
"Actual:\n\n\s\s#{actual.gsub(%r{\s*}, '')}\n\nExpected:\n\n\s\s#{expected.source}" | ||
end | ||
end |