forked from theforeman/puppet-dns
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdns_init_spec.rb
More file actions
208 lines (180 loc) · 7.54 KB
/
dns_init_spec.rb
File metadata and controls
208 lines (180 loc) · 7.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
require 'spec_helper'
describe 'dns' do
describe 'on RedHat with no custom parameters' do
let(:facts) do
{
:clientcert => 'puppetmaster.example.com',
:concat_basedir => '/doesnotexist',
:fqdn => 'puppetmaster.example.com',
:osfamily => 'RedHat',
}
end
describe 'with no custom parameters' do
it { should contain_class('dns::install') }
it { should contain_class('dns::config') }
it { should contain_class('dns::service') }
it { should contain_package('bind').with_ensure('present') }
it { should contain_concat('/etc/named/options.conf') }
it { verify_concat_fragment_contents(catalogue, 'options.conf+10-main.dns', [
'directory "/var/named";',
'recursion yes;',
'allow-query { any; };',
'dnssec-enable yes;',
'dnssec-validation yes;',
'empty-zones-enable yes;',
'listen-on-v6 { any; };',
'allow-recursion { localnets; localhost; };'
])}
it { should contain_concat('/etc/named.conf') }
it { verify_concat_fragment_exact_contents(catalogue, 'named.conf+10-main.dns', [
'// named.conf',
'include "/etc/rndc.key";',
'controls {',
' inet 127.0.0.1 port 953 allow { 127.0.0.1; } keys { "rndc-key"; };',
'};',
'options {',
' include "/etc/named/options.conf";',
'};',
'include "/etc/named.rfc1912.zones";',
'// Public view read by Server Admin',
'include "/etc/named/zones.conf";'
])}
it { should contain_file('/var/named/dynamic').with_ensure('directory') }
it { should contain_exec('create-rndc.key').
with_command("/usr/sbin/rndc-confgen -r /dev/urandom -a -c /etc/rndc.key") }
it { should contain_service('named').with_ensure('running').with_enable(true) }
end
describe 'with ipv6 disabled' do
let(:params) { {:listen_on_v6 => 'none'} }
it { should contain_concat('/etc/named/options.conf') }
it { verify_concat_fragment_contents(catalogue, 'options.conf+10-main.dns', [
'listen-on-v6 { none; };',
])}
end
describe 'with empty zones disabled' do
let(:params) { {:empty_zones_enable => 'no'} }
it { should contain_concat('/etc/named/options.conf') }
it { verify_concat_fragment_contents(catalogue, 'options.conf+10-main.dns', [
'empty-zones-enable no;',
])}
end
describe 'with dns_notify disabled' do
let(:params) { {:dns_notify => 'no' } }
it { should contain_concat('/etc/named/options.conf') }
it { verify_concat_fragment_contents(catalogue, 'options.conf+10-main.dns', [
'notify no;',
])}
end
describe 'with forward only' do
let(:params) { {:forward => 'only'} }
it { should contain_concat('/etc/named/options.conf') }
it { verify_concat_fragment_contents(catalogue, 'options.conf+10-main.dns', [
'forward only;',
])}
end
describe 'with undef forward' do
let(:params) { {:forward => :undef} }
it { should contain_concat('/etc/named/options.conf') }
it { should contain_concat_fragment('options.conf+10-main.dns').without_content('/forward ;/') }
end
describe 'with false listen_on_v6' do
let(:params) { {:listen_on_v6 => false} }
it { should contain_concat('/etc/named/options.conf') }
it { should contain_concat_fragment('options.conf+10-main.dns').without_content('/listen_on_v6/') }
end
describe 'with service_ensure stopped' do
let(:params) { {:service_ensure => 'stopped'} }
it { should contain_service('named').with_ensure('stopped').with_enable(true) }
end
describe 'with service_enable false' do
let(:params) { {:service_enable => false} }
it { should contain_service('named').with_ensure('running').with_enable(false) }
end
describe 'with acls set' do
let(:params) { {:acls => { 'trusted_nets' => [ '127.0.0.1/24', '127.0.1.0/24' ] } } }
it { verify_concat_fragment_exact_contents(catalogue, 'named.conf+10-main.dns', [
'// named.conf',
'include "/etc/rndc.key";',
'controls {',
' inet 127.0.0.1 port 953 allow { 127.0.0.1; } keys { "rndc-key"; };',
'};',
'options {',
' include "/etc/named/options.conf";',
'};',
'include "/etc/named.rfc1912.zones";',
'acl "trusted_nets" {',
' 127.0.0.1/24;',
' 127.0.1.0/24;',
'};',
'// Public view read by Server Admin',
'include "/etc/named/zones.conf";'
])}
end
describe 'with additional options' do
let(:params) { { :additional_options => { 'max-cache-ttl' => 3600, 'max-ncache-ttl' => 3600 } } }
it { verify_concat_fragment_contents(catalogue, 'options.conf+10-main.dns', [
'directory "/var/named";',
'recursion yes;',
'allow-query { any; };',
'dnssec-enable yes;',
'dnssec-validation yes;',
'empty-zones-enable yes;',
'listen-on-v6 { any; };',
'allow-recursion { localnets; localhost; };',
'max-cache-ttl 3600;',
'max-ncache-ttl 3600;'
])}
end
end
describe 'on FreeBSD with no custom parameters' do
let(:facts) do
{
:clientcert => 'puppetmaster.example.com',
:concat_basedir => '/doesnotexist',
:fqdn => 'puppetmaster.example.com',
:osfamily => 'FreeBSD',
}
end
describe 'with no custom parameters' do
it { should contain_class('dns::install') }
it { should contain_class('dns::config') }
it { should contain_class('dns::service') }
it { should contain_package('bind910').with_ensure('present') }
it { should contain_concat('/usr/local/etc/namedb/options.conf') }
it { verify_concat_fragment_contents(catalogue, 'options.conf+10-main.dns', [
'recursion yes;',
'allow-query { any; };',
'dnssec-enable yes;',
'dnssec-validation yes;',
'empty-zones-enable yes;',
'listen-on-v6 { any; };',
'allow-recursion { localnets; localhost; };'
])}
it { should contain_concat('/usr/local/etc/namedb/named.conf') }
it { verify_concat_fragment_exact_contents(catalogue, 'named.conf+10-main.dns', [
'// named.conf',
'include "/usr/local/etc/namedb/rndc.key";',
'controls {',
' inet 127.0.0.1 port 953 allow { 127.0.0.1; } keys { "rndc-key"; };',
'};',
'options {',
' include "/usr/local/etc/namedb/options.conf";',
'};',
'// Public view read by Server Admin',
'include "/usr/local/etc/namedb/zones.conf";'
])}
it { should contain_file('/usr/local/etc/namedb/dynamic').with_ensure('directory') }
it { should contain_exec('create-rndc.key').
with_command("/usr/local/sbin/rndc-confgen -r /dev/urandom -a -c /usr/local/etc/namedb/rndc.key") }
it { should contain_service('named').with_ensure('running').with_enable(true) }
end
describe 'with service_ensure stopped' do
let(:params) { {:service_ensure => 'stopped'} }
it { should contain_service('named').with_ensure('stopped').with_enable(true) }
end
describe 'with service_enable false' do
let(:params) { {:service_enable => false} }
it { should contain_service('named').with_ensure('running').with_enable(false) }
end
end
end