forked from voxpupuli/puppet-icingaweb2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathicingaweb2_spec.rb
239 lines (215 loc) · 8.38 KB
/
icingaweb2_spec.rb
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
require 'spec_helper'
describe('icingaweb2', type: :class) do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts
end
context "#{os} with db_type 'mysql'" do
let(:params) { { db_type: 'mysql' } }
it { is_expected.to compile }
it { is_expected.to contain_class('icingaweb2::config') }
it { is_expected.to contain_class('icingaweb2::install') }
it { is_expected.not_to contain_class('icinga::repos') }
it { is_expected.to contain_package('icingaweb2').with('ensure' => 'installed') }
[ '/etc/icingaweb2/modules',
'/etc/icingaweb2/enabledModules',
'/etc/icingaweb2/navigation',
'/etc/icingaweb2/preferences',
'/etc/icingaweb2/dashboards',
'/var/lib/icingaweb2/certs' ].each do |file|
it {
is_expected.to contain_file(file)
.with_ensure('directory')
.with_mode('2770')
.with_owner('root')
.with_group('icingaweb2')
}
end
it {
is_expected.to contain_icingaweb2__inisection('config-logging')
.with_section_name('logging')
.with_target('/etc/icingaweb2/config.ini')
.with_settings(
{
'log' => 'syslog',
'file' => '/var/log/icingaweb2/icingaweb2.log',
'level' => 'INFO',
'facility' => 'user',
'application' => 'icingaweb2',
},
)
}
it {
is_expected.to contain_icingaweb2__inisection('config-global')
.with_section_name('global')
.with_target('/etc/icingaweb2/config.ini')
.with_settings(
{
'show_stacktraces' => false,
'module_path' => '/usr/share/icingaweb2/modules',
'config_resource' => 'icingaweb2',
},
)
}
it {
is_expected.to contain_icingaweb2__inisection('config-themes')
.with_section_name('themes')
.with_target('/etc/icingaweb2/config.ini')
.with_settings(
{
'default' => 'Icinga',
'disabled' => false,
},
)
}
it { is_expected.not_to contain_icingaweb2__inisection('config-authentication') }
it { is_expected.not_to contain_icingaweb2__inisection('config-security') }
it { is_expected.not_to contain_icingaweb2__inisection('config-cookie') }
it {
is_expected.to contain_icingaweb2__resource__database('icingaweb2')
.with_type('mysql')
.with_host('localhost')
.with_port(3306)
.with_database('icingaweb2')
.with_username('icingaweb2')
}
it {
is_expected.to contain_icingaweb2__config__authmethod('Icinga Web 2')
.with_backend('db')
.with_resource('icingaweb2')
}
it {
is_expected.to contain_icingaweb2__config__groupbackend('Icinga Web 2')
.with_backend('db')
.with_resource('icingaweb2')
}
it { is_expected.not_to contain_exec('import schema') }
it { is_expected.not_to contain_exec('create default admin user') }
it { is_expected.not_to contain_icingaweb2__config__role('default admin user') }
end
context "#{os} with manage_package 'false', cookie_path '/foo/bar', default_domain 'foobar'" do
let(:params) do
{
manage_package: false,
cookie_path: '/foo/bar',
default_domain: 'foobar',
db_type: 'mysql',
}
end
it { is_expected.not_to contain_package('icinga2').with('ensure' => 'installed') }
it {
is_expected.to contain_icingaweb2__inisection('config-cookie')
.with_section_name('cookie')
.with_target('/etc/icingaweb2/config.ini')
.with_settings({ 'path' => '/foo/bar' })
}
it {
is_expected.to contain_icingaweb2__inisection('config-authentication')
.with_section_name('authentication')
.with_target('/etc/icingaweb2/config.ini')
.with_settings({ 'default_domain' => 'foobar' })
}
end
context "#{os} with use_strict_csp 'true'" do
let(:params) do
{
use_strict_csp: true,
db_type: 'mysql',
}
end
it {
is_expected.to contain_icingaweb2__inisection('config-security')
.with_section_name('security')
.with_target('/etc/icingaweb2/config.ini')
.with_settings({ 'use_strict_csp' => true })
}
end
context "#{os} with use_strict_csp 'false'" do
let(:params) do
{
use_strict_csp: false,
db_type: 'mysql',
}
end
it {
is_expected.to contain_icingaweb2__inisection('config-security')
.with_section_name('security')
.with_target('/etc/icingaweb2/config.ini')
.with_settings({ 'use_strict_csp' => false })
}
end
context "#{os} with default_auth_backend 'false', additional resources, user and group backend" do
let(:params) do
{
db_type: 'mysql',
resources: {
foo: { type: 'ldap' },
baz: { type: 'pgsql', host: 'localhost', database: 'baz', port: 5432 },
},
default_auth_backend: false,
user_backends: {
bar: { backend: 'ldap', resource: 'foo' },
},
group_backends: {
bar: { backend: 'ldap', resource: 'foo' },
},
}
end
it { is_expected.not_to contain_icingaweb2__config__authmethod('Icinga Web 2') }
it { is_expected.not_to contain_icingaweb2__config__groupbackend('Icinga Web 2') }
it { is_expected.to contain_icingaweb2__resource__ldap('foo') }
it { is_expected.to contain_icingaweb2__resource__database('baz').with('type' => 'pgsql') }
it { is_expected.to contain_icingaweb2__config__authmethod('bar').with('resource' => 'foo') }
it { is_expected.to contain_icingaweb2__config__groupbackend('bar').with('resource' => 'foo') }
end
context "#{os} with db_type 'mysql', import_schema 'true'" do
let(:params) { { import_schema: true, db_type: 'mysql' } }
it { is_expected.to contain_icingaweb2__resource__database('icingaweb2') }
it { is_expected.to contain_icingaweb2__config__role('default admin user') }
it { is_expected.to contain_exec('import schema') }
it { is_expected.to contain_exec('create default admin user') }
end
context "#{os} with db_type 'pgsql', db_resource_name 'foobar', import_schema 'true', default_auth_backend 'foobaz'" do
let(:params) do
{
db_type: 'pgsql',
import_schema: true,
db_resource_name: 'foobar',
default_auth_backend: 'foobaz',
}
end
it {
is_expected.to contain_icingaweb2__inisection('config-global')
.with_section_name('global')
.with_target('/etc/icingaweb2/config.ini')
.with_settings(
{
'show_stacktraces' => false,
'module_path' => '/usr/share/icingaweb2/modules',
'config_resource' => 'foobar',
},
)
}
it {
is_expected.to contain_icingaweb2__config__authmethod('foobaz')
.with_backend('db')
.with_resource('foobar')
}
it {
is_expected.to contain_icingaweb2__config__groupbackend('foobaz')
.with_backend('db')
.with_resource('foobar')
}
it { is_expected.to contain_icingaweb2__config__role('default admin user') }
it { is_expected.to contain_icingaweb2__resource__database('foobar') }
it { is_expected.to contain_exec('import schema') }
it { is_expected.to contain_exec('create default admin user') }
end
context "#{os} with import_schema 'true' and admin_role 'false'" do
let(:params) { { import_schema: true, db_type: 'mysql', admin_role: false } }
it { is_expected.not_to contain_icingaweb2__config__role('default admin user') }
end
end
end
end