Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce acceptance test duplication #282

Merged
merged 1 commit into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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