|
| 1 | +override_facts = { |
| 2 | + root_home: '/root' |
| 3 | +} |
| 4 | + |
1 | 5 | require 'spec_helper'
|
2 |
| -describe 'powerdns', :type => :class do |
| 6 | +describe 'powerdns', type: :class do |
3 | 7 | context 'supported operating systems' do
|
4 | 8 | on_supported_os.each do |os, facts|
|
5 | 9 | context "on #{os}" do
|
6 | 10 | let(:facts) do
|
7 |
| - facts |
8 |
| - |
9 |
| - facts.merge({ |
10 |
| - :root_home => '/root', |
11 |
| - }) |
| 11 | + facts.merge(override_facts) |
12 | 12 | end
|
13 | 13 |
|
14 | 14 | case facts[:osfamily]
|
|
18 | 18 | authoritative_config = '/etc/pdns/pdns.conf'
|
19 | 19 | recursor_package_name = 'pdns-recursor'
|
20 | 20 | recursor_service_name = 'pdns-recursor'
|
21 |
| - recursor_config = '/etc/pdns-recursor/recursor.conf' |
22 | 21 | when 'Debian'
|
23 | 22 | authoritative_package_name = 'pdns-server'
|
24 | 23 | authoritative_service_name = 'pdns'
|
25 | 24 | authoritative_config = '/etc/powerdns/pdns.conf'
|
26 | 25 | recursor_package_name = 'pdns-recursor'
|
27 | 26 | recursor_service_name = 'pdns-recursor'
|
28 |
| - recursor_config = '/etc/powerdns/recursor.conf' |
29 | 27 | end
|
30 | 28 |
|
31 |
| - context "powerdns class without parameters" do |
| 29 | + context 'powerdns class without parameters' do |
32 | 30 | it 'fails' do
|
33 | 31 | expect { subject.call } .to raise_error(/Database root password can't be empty/)
|
34 | 32 | end
|
35 | 33 | end
|
36 | 34 |
|
37 |
| - context "powerdns class with parameters" do |
38 |
| - let(:params) {{ |
39 |
| - :db_root_password => 'foobar', |
40 |
| - :db_username => 'foo', |
41 |
| - :db_password => 'bar' |
42 |
| - }} |
| 35 | + context 'powerdns class with parameters' do |
| 36 | + let(:params) do |
| 37 | + { |
| 38 | + db_root_password: 'foobar', |
| 39 | + db_username: 'foo', |
| 40 | + db_password: 'bar' |
| 41 | + } |
| 42 | + end |
43 | 43 |
|
44 | 44 | it { is_expected.to compile.with_all_deps }
|
45 | 45 | it { is_expected.to contain_class('powerdns::params') }
|
|
65 | 65 | it { is_expected.to contain_package(authoritative_package_name).with('ensure' => 'installed') }
|
66 | 66 | it { is_expected.to contain_service(authoritative_service_name).with('ensure' => 'running') }
|
67 | 67 | it { is_expected.to contain_service(authoritative_service_name).with('enable' => 'true') }
|
68 |
| - it { is_expected.to contain_service(authoritative_service_name).that_requires('Package[%s]' % [authoritative_package_name]) } |
| 68 | + it { is_expected.to contain_service(authoritative_service_name).that_requires(format('Package[%s]', authoritative_package_name)) } |
69 | 69 | end
|
70 | 70 |
|
71 |
| - context "powerdns class with mysql backend" do |
72 |
| - let(:params) {{ |
73 |
| - :db_root_password => 'foobar', |
74 |
| - :db_username => 'foo', |
75 |
| - :db_password => 'bar', |
76 |
| - :backend => 'mysql' |
77 |
| - }} |
| 71 | + context 'powerdns class with mysql backend' do |
| 72 | + let(:params) do |
| 73 | + { |
| 74 | + db_root_password: 'foobar', |
| 75 | + db_username: 'foo', |
| 76 | + db_password: 'bar', |
| 77 | + backend: 'mysql' |
| 78 | + } |
| 79 | + end |
78 | 80 |
|
79 | 81 | it { is_expected.to contain_class('powerdns::backends::mysql') }
|
80 | 82 | it { is_expected.to contain_package('pdns-backend-mysql').with('ensure' => 'installed') }
|
81 |
| - it { is_expected.to contain_mysql__db('powerdns').with( |
82 |
| - 'user' => 'foo', |
83 |
| - 'password' => 'bar', |
84 |
| - 'host' => 'localhost' |
85 |
| - ) } |
| 83 | + it { is_expected.to contain_mysql__db('powerdns').with('user' => 'foo', 'password' => 'bar', 'host' => 'localhost') } |
86 | 84 |
|
87 | 85 | # We expect the following tables to be created
|
88 | 86 | it { is_expected.to contain_powerdns__backends__mysql__create_table('comments') }
|
|
116 | 114 | it { is_expected.to contain_powerdns__config('gmysql-user').with('value' => 'foo') }
|
117 | 115 | it { is_expected.to contain_powerdns__config('launch').with('value' => 'gmysql') }
|
118 | 116 |
|
119 |
| - it { is_expected.to contain_file_line('powerdns-config-gmysql-dbname-%s' % [ authoritative_config ]) } |
120 |
| - it { is_expected.to contain_file_line('powerdns-config-gmysql-password-%s' % [ authoritative_config ]) } |
121 |
| - it { is_expected.to contain_file_line('powerdns-config-gmysql-user-%s' % [ authoritative_config ]) } |
122 |
| - it { is_expected.to contain_file_line('powerdns-config-launch-%s' % [ authoritative_config ]) } |
123 |
| - |
| 117 | + it { is_expected.to contain_file_line(format('powerdns-config-gmysql-dbname-%s', authoritative_config)) } |
| 118 | + it { is_expected.to contain_file_line(format('powerdns-config-gmysql-password-%s', authoritative_config)) } |
| 119 | + it { is_expected.to contain_file_line(format('powerdns-config-gmysql-user-%s', authoritative_config)) } |
| 120 | + it { is_expected.to contain_file_line(format('powerdns-config-launch-%s', authoritative_config)) } |
124 | 121 | end
|
125 | 122 |
|
126 | 123 | # Test the recursor
|
127 |
| - context "powerdns class with the recursor enabled and the authoritative server disabled" do |
128 |
| - let(:params) {{ |
129 |
| - :db_root_password => 'foobar', |
130 |
| - :db_username => 'foo', |
131 |
| - :db_password => 'bar', |
132 |
| - :recursor => true, |
133 |
| - :authoritative => false, |
134 |
| - }} |
| 124 | + context 'powerdns class with the recursor enabled and the authoritative server disabled' do |
| 125 | + let(:params) do |
| 126 | + { |
| 127 | + db_root_password: 'foobar', |
| 128 | + db_username: 'foo', |
| 129 | + db_password: 'bar', |
| 130 | + recursor: true, |
| 131 | + authoritative: false |
| 132 | + } |
| 133 | + end |
135 | 134 |
|
136 | 135 | it { is_expected.to compile.with_all_deps }
|
137 | 136 | it { is_expected.to contain_class('powerdns::params') }
|
|
141 | 140 | it { is_expected.to contain_package(recursor_package_name).with('ensure' => 'installed') }
|
142 | 141 | it { is_expected.to contain_service(recursor_service_name).with('ensure' => 'running') }
|
143 | 142 | it { is_expected.to contain_service(recursor_service_name).with('enable' => 'true') }
|
144 |
| - it { is_expected.to contain_service(recursor_service_name).that_requires('Package[%s]' % [recursor_package_name]) } |
| 143 | + it { is_expected.to contain_service(recursor_service_name).that_requires(format('Package[%s]', recursor_package_name)) } |
145 | 144 | end
|
146 | 145 |
|
147 | 146 | # Test errors
|
148 |
| - context "powerdns class with an empty database username" do |
149 |
| - let(:params) {{ |
150 |
| - :db_root_password => 'foobar', |
151 |
| - :db_username => '', |
152 |
| - :db_password => 'bar' |
153 |
| - }} |
| 147 | + context 'powerdns class with an empty database username' do |
| 148 | + let(:params) do |
| 149 | + { |
| 150 | + db_root_password: 'foobar', |
| 151 | + db_username: '', |
| 152 | + db_password: 'bar' |
| 153 | + } |
| 154 | + end |
154 | 155 |
|
155 | 156 | it 'fails' do
|
156 | 157 | expect { subject.call } .to raise_error(/Database username can't be empty/)
|
157 | 158 | end
|
158 | 159 | end
|
159 | 160 |
|
160 |
| - context "powerdns class without database password" do |
161 |
| - let(:params) {{ |
162 |
| - :db_root_password => 'foobar', |
163 |
| - :db_username => 'foo' |
164 |
| - }} |
| 161 | + context 'powerdns class without database password' do |
| 162 | + let(:params) do |
| 163 | + { |
| 164 | + db_root_password: 'foobar', |
| 165 | + db_username: 'foo' |
| 166 | + } |
| 167 | + end |
165 | 168 |
|
166 | 169 | it 'fails' do
|
167 | 170 | expect { subject.call } .to raise_error(/Database password can't be empty/)
|
168 | 171 | end
|
169 | 172 | end
|
170 | 173 |
|
171 |
| - context "powerdns class with an unsupported backend" do |
172 |
| - let(:params) {{ |
173 |
| - :db_root_password => 'foobar', |
174 |
| - :db_username => 'foo', |
175 |
| - :db_password => 'bar', |
176 |
| - :backend => 'awesomedb' |
177 |
| - }} |
| 174 | + context 'powerdns class with an unsupported backend' do |
| 175 | + let(:params) do |
| 176 | + { |
| 177 | + db_root_password: 'foobar', |
| 178 | + db_username: 'foo', |
| 179 | + db_password: 'bar', |
| 180 | + backend: 'awesomedb' |
| 181 | + } |
| 182 | + end |
178 | 183 |
|
179 | 184 | it 'fails' do
|
180 | 185 | expect { subject.call } .to raise_error(/is not supported/)
|
|
0 commit comments