Skip to content

Commit

Permalink
Reduce acceptance test duplication
Browse files Browse the repository at this point in the history
This uses Hiera in the acceptance tests to reduce duplication in the
manifests. To reduce the spec duplications it uses a shared example
provided by voxpupuli-acceptance.
  • Loading branch information
ekohl committed Apr 22, 2022
1 parent 841f5c7 commit 2f9cbc3
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 79 deletions.
4 changes: 4 additions & 0 deletions spec/acceptance/hieradata/common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
letsencrypt::email: '[email protected]'
letsencrypt::config:
server: 'https://acme-staging-v02.api.letsencrypt.org/directory'
7 changes: 1 addition & 6 deletions spec/acceptance/letsencrypt_plugin_dns_cloudflare_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
class { 'letsencrypt' :
email => '[email protected]',
config => {
'server' => 'https://acme-staging-v02.api.letsencrypt.org/directory',
},
}
include letsencrypt
class { 'letsencrypt::plugin::dns_cloudflare':
api_token => 'dummy-cloudflare-api-token',
}
Expand Down
33 changes: 11 additions & 22 deletions spec/acceptance/letsencrypt_plugin_dns_rfc2136_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,23 @@
require 'spec_helper_acceptance'

describe 'letsencrypt::plugin::dns_rfc2136' do
context 'with defaults values' do
pp = <<-PUPPET
class { 'letsencrypt' :
email => '[email protected]',
config => {
'server' => 'https://acme-staging-v02.api.letsencrypt.org/directory',
},
}
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
include letsencrypt
class { 'letsencrypt::plugin::dns_rfc2136':
server => '192.0.2.1',
key_name => 'certbot',
key_secret => 'secret',
}
PUPPET

it 'installs letsencrypt and dns rfc2136 plugin without error' do
apply_manifest(pp, catch_failures: true)
end

it 'installs letsencrypt and dns rfc2136 idempotently' do
apply_manifest(pp, catch_changes: true)
PUPPET
end
end

describe file('/etc/letsencrypt/dns-rfc2136.ini') do
it { is_expected.to be_file }
it { is_expected.to be_owned_by 'root' }
it { is_expected.to be_grouped_into 'root' }
it { is_expected.to be_mode 400 }
end
describe file('/etc/letsencrypt/dns-rfc2136.ini') do
it { is_expected.to be_file }
it { is_expected.to be_owned_by 'root' }
it { is_expected.to be_grouped_into 'root' }
it { is_expected.to be_mode 400 }
end
end
24 changes: 6 additions & 18 deletions spec/acceptance/letsencrypt_plugin_dns_route53_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,12 @@
require 'spec_helper_acceptance'

describe 'letsencrypt::plugin::dns_route53' do
context 'with defaults values' do
pp = <<-PUPPET
class { 'letsencrypt' :
email => '[email protected]',
config => {
'server' => 'https://acme-staging-v02.api.letsencrypt.org/directory',
},
}
class { 'letsencrypt::plugin::dns_route53':
}
PUPPET

it 'installs letsencrypt and dns route53 plugin without error' do
apply_manifest(pp, catch_failures: true)
end

it 'installs letsencrypt and dns route53 idempotently' do
apply_manifest(pp, catch_changes: true)
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
include letsencrypt
include letsencrypt::plugin::dns_route53
PUPPET
end
end
end
24 changes: 6 additions & 18 deletions spec/acceptance/letsencrypt_plugin_nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,12 @@
require 'spec_helper_acceptance'

describe 'letsencrypt::plugin::nginx' do
context 'with default values' do
pp = <<-PUPPET
class { 'letsencrypt' :
email => '[email protected]',
config => {
'server' => 'https://acme-staging.api.letsencrypt.org/directory',
},
}
class { 'letsencrypt::plugin::nginx':
}
PUPPET

it 'installs letsencrypt and nginx plugin without error' do
apply_manifest(pp, catch_failures: true)
end

it 'installs letsencrypt and nginx idempotently' do
apply_manifest(pp, catch_changes: true)
it_behaves_like 'an idempotent resource' do
let(:manifest) do
<<-PUPPET
include letsencrypt
include letsencrypt::plugin::nginx
PUPPET
end
end
end
17 changes: 2 additions & 15 deletions spec/acceptance/letsencrypt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,8 @@

describe 'letsencrypt' do
context 'with defaults values' do
pp = %(
class { 'letsencrypt' :
email => '[email protected]',
config => {
'server' => 'https://acme-staging-v02.api.letsencrypt.org/directory',
},
}
)

it 'installs letsencrypt without error' do
apply_manifest(pp, catch_failures: true)
end

it 'installs letsencrypt idempotently' do
apply_manifest(pp, catch_changes: true)
it_behaves_like 'an idempotent resource' do
let(:manifest) { 'include letsencrypt' }
end

describe file('/etc/letsencrypt/cli.ini') do
Expand Down

0 comments on commit 2f9cbc3

Please sign in to comment.