Skip to content

Commit 5caffe7

Browse files
authored
Merge pull request antonlindstrom#16 from sensson/empty-only-notify
Allow only-notify to be empty
2 parents 013dc50 + a4a7bc6 commit 5caffe7

File tree

2 files changed

+124
-1
lines changed

2 files changed

+124
-1
lines changed

manifests/config.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
$type = 'authoritative'
77
) {
88

9-
if $value == '' and $setting != 'gmysql-dnssec' { fail("Value can't be empty.") }
9+
if $value == '' and ! ($setting in [ 'gmysql-dnssec', 'only-notify' ]) { fail("Value for ${setting} can't be empty.") }
1010
if $setting == 'gmysql-dnssec' { $line = $setting }
1111
else { $line = "${setting}=${value}" }
1212

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
require 'spec_helper'
2+
describe 'powerdns::config' do
3+
context 'supported operating systems' do
4+
on_supported_os.each do |os, facts|
5+
context "on #{os}" do
6+
let(:facts) do
7+
facts
8+
9+
facts.merge({
10+
:root_home => '/root',
11+
})
12+
end
13+
14+
let :title do
15+
'foo'
16+
end
17+
18+
let(:pre_condition) do
19+
'class { "::powerdns":
20+
db_root_password => "foobar",
21+
db_username => "foo",
22+
db_password => "bar",
23+
recursor => true,
24+
}'
25+
end
26+
27+
case facts[:osfamily]
28+
when 'RedHat'
29+
authoritative_package_name = 'pdns'
30+
authoritative_service_name = 'pdns'
31+
authoritative_config = '/etc/pdns/pdns.conf'
32+
recursor_package_name = 'pdns-recursor'
33+
recursor_service_name = 'pdns-recursor'
34+
recursor_config = '/etc/pdns-recursor/recursor.conf'
35+
when 'Debian'
36+
authoritative_package_name = 'pdns-server'
37+
authoritative_service_name = 'pdns'
38+
authoritative_config = '/etc/powerdns/pdns.conf'
39+
recursor_package_name = 'pdns-recursor'
40+
recursor_service_name = 'pdns-recursor'
41+
recursor_config = '/etc/powerdns/recursor.conf'
42+
end
43+
44+
#
45+
context 'powerdns::config with parameters' do
46+
let(:params) do
47+
{
48+
setting: 'foo',
49+
value: 'bar'
50+
}
51+
end
52+
53+
it { is_expected.to contain_file_line('powerdns-config-foo-%s' % [ authoritative_config ]) }
54+
it { is_expected.to contain_file_line('powerdns-config-foo-%s' % [ authoritative_config ]).with_ensure('present') }
55+
it { is_expected.to contain_file_line('powerdns-config-foo-%s' % [ authoritative_config ]).with_path(authoritative_config) }
56+
it { is_expected.to contain_file_line('powerdns-config-foo-%s' % [ authoritative_config ]).with_line('foo=bar') }
57+
it { is_expected.to contain_file_line('powerdns-config-foo-%s' % [ authoritative_config ]).with_match('^foo=') }
58+
it { is_expected.to contain_file_line('powerdns-config-foo-%s' % [ authoritative_config ]).that_notifies('Service[%s]' % authoritative_service_name) }
59+
end
60+
61+
context 'powerdns::config with recursor type' do
62+
let(:params) do
63+
{
64+
setting: 'foo',
65+
value: 'bar',
66+
type: 'recursor'
67+
}
68+
end
69+
70+
it { is_expected.to contain_file_line('powerdns-config-foo-%s' % [ recursor_config ]) }
71+
end
72+
73+
# Test for empty values
74+
context 'powerdns::config with empty value for gmysql-dnssec' do
75+
let(:params) do
76+
{
77+
setting: 'gmysql-dnssec',
78+
}
79+
end
80+
81+
it { is_expected.to contain_file_line('powerdns-config-gmysql-dnssec-%s' % [ authoritative_config ]) }
82+
end
83+
84+
context 'powerdns::config with empty value for only-notify' do
85+
let(:params) do
86+
{
87+
setting: 'only-notify',
88+
}
89+
end
90+
91+
it { is_expected.to contain_file_line('powerdns-config-only-notify-%s' % [ authoritative_config ]) }
92+
end
93+
94+
context 'powerdns::config with empty value' do
95+
let(:params) do
96+
{
97+
setting: 'empty',
98+
}
99+
end
100+
101+
it 'fails' do
102+
expect { subject.call } .to raise_error(/Value for empty can't be empty./)
103+
end
104+
end
105+
106+
# Test incorrect service type
107+
context 'powerdns::config with wrong type' do
108+
let(:params) do
109+
{
110+
setting: 'foo',
111+
value: 'bar',
112+
type: 'something'
113+
}
114+
end
115+
116+
it 'fails' do
117+
expect { subject.call } .to raise_error(/is not supported as config type/)
118+
end
119+
end
120+
end
121+
end
122+
end
123+
end

0 commit comments

Comments
 (0)