|
2 | 2 |
|
3 | 3 | describe 'letsencrypt::plugin::dns_rfc2136' do |
4 | 4 | on_supported_os.each do |os, facts| |
5 | | - let(:facts) do |
6 | | - facts |
7 | | - end |
8 | | - |
9 | | - let(:params) { default_params.merge(required_params).merge(additional_params) } |
10 | | - let(:default_params) do |
11 | | - { key_algorithm: 'HMAC-SHA512', |
12 | | - port: 53, |
13 | | - manage_package: true, |
14 | | - config_dir: '/etc/letsencrypt', |
15 | | - propagation_seconds: 10 } |
16 | | - end |
17 | | - let(:required_params) { {} } |
18 | | - let(:additional_params) { {} } |
19 | | - |
20 | | - context 'without required parameters' do |
21 | | - it { is_expected.not_to compile } |
22 | | - end |
23 | | - |
24 | 5 | context "on #{os} based operating systems" do |
25 | | - let(:required_params) do |
26 | | - { server: '1.2.3.4', |
27 | | - key_name: 'certbot', |
28 | | - key_secret: 'secret' } |
29 | | - end |
| 6 | + let(:facts) { facts } |
| 7 | + let(:params) { {} } |
30 | 8 | let(:pre_condition) do |
31 | | - "class { letsencrypt: |
32 | | - |
33 | | - config_dir => '/etc/letsencrypt', |
34 | | - package_command => 'letsencrypt', |
35 | | - }" |
| 9 | + <<-PUPPET |
| 10 | + class { 'letsencrypt': |
| 11 | + |
| 12 | + } |
| 13 | + PUPPET |
| 14 | + end |
| 15 | + let(:package_name) do |
| 16 | + case facts[:osfamily] |
| 17 | + when 'Debian' |
| 18 | + 'python3-certbot-dns-rfc2136' |
| 19 | + when 'RedHat' |
| 20 | + facts[:operatingsystem] == 'Fedora' ? 'python3-certbot-dns-rfc2136' : 'python2-certbot-dns-rfc2136' |
| 21 | + end |
36 | 22 | end |
37 | 23 |
|
38 | | - it { is_expected.to compile.with_all_deps } |
| 24 | + context 'without required parameters' do |
| 25 | + it { is_expected.not_to compile } |
| 26 | + end |
39 | 27 |
|
40 | | - describe 'with manage_package => true' do |
41 | | - let(:additional_params) { { manage_package: true } } |
| 28 | + context 'with required parameters' do |
| 29 | + let(:params) do |
| 30 | + super().merge( |
| 31 | + server: '192.0.2.1', |
| 32 | + key_name: 'certbot', |
| 33 | + key_secret: 'secret' |
| 34 | + ) |
| 35 | + end |
42 | 36 |
|
43 | | - it { is_expected.to contain_package('python2-certbot-dns-rfc2136').with_ensure('installed') } |
44 | | - end |
| 37 | + it do |
| 38 | + if package_name.nil? |
| 39 | + is_expected.not_to compile |
| 40 | + else |
| 41 | + is_expected.to compile.with_all_deps |
45 | 42 |
|
46 | | - describe 'with manage_package => false' do |
47 | | - let(:additional_params) { { manage_package: false } } |
| 43 | + is_expected.to contain_file('/etc/letsencrypt/dns-rfc2136.ini'). |
| 44 | + with_ensure('file'). |
| 45 | + with_owner('root'). |
| 46 | + with_group('root'). |
| 47 | + with_mode('0400'). |
| 48 | + with_content(%r{^.*dns_rfc2136_server.*$}) |
| 49 | + end |
| 50 | + end |
48 | 51 |
|
49 | | - it { is_expected.not_to contain_package('python2-certbot-dns-rfc2136') } |
50 | | - end |
| 52 | + describe 'with manage_package => true' do |
| 53 | + let(:params) { super().merge(manage_package: true) } |
| 54 | + |
| 55 | + it do |
| 56 | + if package_name.nil? |
| 57 | + is_expected.not_to compile |
| 58 | + else |
| 59 | + is_expected.to contain_class('letsencrypt::plugin::dns_rfc2136').with_package_name(package_name) |
| 60 | + is_expected.to contain_package(package_name).with_ensure('installed') |
| 61 | + end |
| 62 | + end |
| 63 | + end |
| 64 | + |
| 65 | + describe 'with manage_package => false' do |
| 66 | + let(:params) { super().merge(manage_package: false, package_name: 'dns-rfc2136-package') } |
51 | 67 |
|
52 | | - it do |
53 | | - is_expected.to contain_file('/etc/letsencrypt/dns-rfc2136.ini').with( |
54 | | - ensure: 'file', |
55 | | - owner: 'root', |
56 | | - group: 'root', |
57 | | - mode: '0400' |
58 | | - ).with_content(%r{^.*dns_rfc2136_server.*$}) |
| 68 | + it { is_expected.not_to contain_package('dns-rfc2136-package') } |
| 69 | + end |
59 | 70 | end |
60 | 71 | end |
61 | 72 | end |
|
0 commit comments