Skip to content

Commit 265f8fe

Browse files
committed
(antonlindstrom#15) Allow only-notify with empty value
1 parent 013dc50 commit 265f8fe

File tree

2 files changed

+123
-1
lines changed

2 files changed

+123
-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 can't be empty.") }
1010
if $setting == 'gmysql-dnssec' { $line = $setting }
1111
else { $line = "${setting}=${value}" }
1212

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

0 commit comments

Comments
 (0)