Skip to content

Commit 2f9cbc3

Browse files
committed
Reduce acceptance test duplication
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.
1 parent 841f5c7 commit 2f9cbc3

File tree

6 files changed

+30
-79
lines changed

6 files changed

+30
-79
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
letsencrypt::email: '[email protected]'
3+
letsencrypt::config:
4+
server: 'https://acme-staging-v02.api.letsencrypt.org/directory'

spec/acceptance/letsencrypt_plugin_dns_cloudflare_spec.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@
66
it_behaves_like 'an idempotent resource' do
77
let(:manifest) do
88
<<-PUPPET
9-
class { 'letsencrypt' :
10-
email => '[email protected]',
11-
config => {
12-
'server' => 'https://acme-staging-v02.api.letsencrypt.org/directory',
13-
},
14-
}
9+
include letsencrypt
1510
class { 'letsencrypt::plugin::dns_cloudflare':
1611
api_token => 'dummy-cloudflare-api-token',
1712
}

spec/acceptance/letsencrypt_plugin_dns_rfc2136_spec.rb

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,23 @@
33
require 'spec_helper_acceptance'
44

55
describe 'letsencrypt::plugin::dns_rfc2136' do
6-
context 'with defaults values' do
7-
pp = <<-PUPPET
8-
class { 'letsencrypt' :
9-
email => '[email protected]',
10-
config => {
11-
'server' => 'https://acme-staging-v02.api.letsencrypt.org/directory',
12-
},
13-
}
6+
it_behaves_like 'an idempotent resource' do
7+
let(:manifest) do
8+
<<-PUPPET
9+
include letsencrypt
1410
class { 'letsencrypt::plugin::dns_rfc2136':
1511
server => '192.0.2.1',
1612
key_name => 'certbot',
1713
key_secret => 'secret',
1814
}
19-
PUPPET
20-
21-
it 'installs letsencrypt and dns rfc2136 plugin without error' do
22-
apply_manifest(pp, catch_failures: true)
23-
end
24-
25-
it 'installs letsencrypt and dns rfc2136 idempotently' do
26-
apply_manifest(pp, catch_changes: true)
15+
PUPPET
2716
end
17+
end
2818

29-
describe file('/etc/letsencrypt/dns-rfc2136.ini') do
30-
it { is_expected.to be_file }
31-
it { is_expected.to be_owned_by 'root' }
32-
it { is_expected.to be_grouped_into 'root' }
33-
it { is_expected.to be_mode 400 }
34-
end
19+
describe file('/etc/letsencrypt/dns-rfc2136.ini') do
20+
it { is_expected.to be_file }
21+
it { is_expected.to be_owned_by 'root' }
22+
it { is_expected.to be_grouped_into 'root' }
23+
it { is_expected.to be_mode 400 }
3524
end
3625
end

spec/acceptance/letsencrypt_plugin_dns_route53_spec.rb

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,12 @@
33
require 'spec_helper_acceptance'
44

55
describe 'letsencrypt::plugin::dns_route53' do
6-
context 'with defaults values' do
7-
pp = <<-PUPPET
8-
class { 'letsencrypt' :
9-
email => '[email protected]',
10-
config => {
11-
'server' => 'https://acme-staging-v02.api.letsencrypt.org/directory',
12-
},
13-
}
14-
class { 'letsencrypt::plugin::dns_route53':
15-
}
16-
PUPPET
17-
18-
it 'installs letsencrypt and dns route53 plugin without error' do
19-
apply_manifest(pp, catch_failures: true)
20-
end
21-
22-
it 'installs letsencrypt and dns route53 idempotently' do
23-
apply_manifest(pp, catch_changes: true)
6+
it_behaves_like 'an idempotent resource' do
7+
let(:manifest) do
8+
<<-PUPPET
9+
include letsencrypt
10+
include letsencrypt::plugin::dns_route53
11+
PUPPET
2412
end
2513
end
2614
end

spec/acceptance/letsencrypt_plugin_nginx_spec.rb

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,12 @@
33
require 'spec_helper_acceptance'
44

55
describe 'letsencrypt::plugin::nginx' do
6-
context 'with default values' do
7-
pp = <<-PUPPET
8-
class { 'letsencrypt' :
9-
email => '[email protected]',
10-
config => {
11-
'server' => 'https://acme-staging.api.letsencrypt.org/directory',
12-
},
13-
}
14-
class { 'letsencrypt::plugin::nginx':
15-
}
16-
PUPPET
17-
18-
it 'installs letsencrypt and nginx plugin without error' do
19-
apply_manifest(pp, catch_failures: true)
20-
end
21-
22-
it 'installs letsencrypt and nginx idempotently' do
23-
apply_manifest(pp, catch_changes: true)
6+
it_behaves_like 'an idempotent resource' do
7+
let(:manifest) do
8+
<<-PUPPET
9+
include letsencrypt
10+
include letsencrypt::plugin::nginx
11+
PUPPET
2412
end
2513
end
2614
end

spec/acceptance/letsencrypt_spec.rb

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,8 @@
44

55
describe 'letsencrypt' do
66
context 'with defaults values' do
7-
pp = %(
8-
class { 'letsencrypt' :
9-
email => '[email protected]',
10-
config => {
11-
'server' => 'https://acme-staging-v02.api.letsencrypt.org/directory',
12-
},
13-
}
14-
)
15-
16-
it 'installs letsencrypt without error' do
17-
apply_manifest(pp, catch_failures: true)
18-
end
19-
20-
it 'installs letsencrypt idempotently' do
21-
apply_manifest(pp, catch_changes: true)
7+
it_behaves_like 'an idempotent resource' do
8+
let(:manifest) { 'include letsencrypt' }
229
end
2310

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

0 commit comments

Comments
 (0)