-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
ssl_spec.rb
257 lines (243 loc) · 8.72 KB
/
ssl_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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
require 'spec_helper'
describe 'apache::mod::ssl', :type => :class do
it_behaves_like "a mod class, without including apache"
context 'on an unsupported OS' do
let :facts do
{
:osfamily => 'Magic',
:operatingsystemrelease => '0',
:concat_basedir => '/dne',
:operatingsystem => 'Magic',
:id => 'root',
:kernel => 'Linux',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:is_pe => false,
}
end
it { expect { catalogue }.to raise_error(Puppet::Error, /Unsupported osfamily:/) }
end
context 'on a RedHat OS' do
let :facts do
{
:osfamily => 'RedHat',
:operatingsystemrelease => '6',
:concat_basedir => '/dne',
:operatingsystem => 'RedHat',
:id => 'root',
:kernel => 'Linux',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:is_pe => false,
}
end
it { is_expected.to contain_class('apache::params') }
it { is_expected.to contain_apache__mod('ssl') }
it { is_expected.to contain_package('mod_ssl') }
context 'with a custom package_name parameter' do
let :params do
{ :package_name => 'httpd24-mod_ssl' }
end
it { is_expected.to contain_class('apache::params') }
it { is_expected.to contain_apache__mod('ssl') }
it { is_expected.to contain_package('httpd24-mod_ssl') }
it { is_expected.not_to contain_package('mod_ssl') }
it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLSessionCache "shmcb:/var/cache/mod_ssl/scache\(512000\)"$})}
end
end
context 'on a Debian OS' do
let :facts do
{
:osfamily => 'Debian',
:operatingsystemrelease => '6',
:concat_basedir => '/dne',
:lsbdistcodename => 'squeeze',
:operatingsystem => 'Debian',
:id => 'root',
:kernel => 'Linux',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:is_pe => false,
}
end
it { is_expected.to contain_class('apache::params') }
it { is_expected.to contain_apache__mod('ssl') }
it { is_expected.not_to contain_package('libapache2-mod-ssl') }
end
context 'on a FreeBSD OS' do
let :facts do
{
:osfamily => 'FreeBSD',
:operatingsystemrelease => '9',
:concat_basedir => '/dne',
:operatingsystem => 'FreeBSD',
:id => 'root',
:kernel => 'FreeBSD',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:is_pe => false,
}
end
it { is_expected.to contain_class('apache::params') }
it { is_expected.to contain_apache__mod('ssl') }
end
context 'on a Gentoo OS' do
let :facts do
{
:osfamily => 'Gentoo',
:operatingsystem => 'Gentoo',
:operatingsystemrelease => '3.16.1-gentoo',
:concat_basedir => '/dne',
:id => 'root',
:kernel => 'Linux',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin',
:is_pe => false,
}
end
it { is_expected.to contain_class('apache::params') }
it { is_expected.to contain_apache__mod('ssl') }
it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLSessionCache "shmcb:/var/run/ssl_scache\(512000\)"$})}
end
context 'on a Suse OS' do
let :facts do
{
:osfamily => 'Suse',
:operatingsystem => 'SLES',
:operatingsystemrelease => '12',
:concat_basedir => '/dne',
:id => 'root',
:kernel => 'Linux',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin',
:is_pe => false,
}
end
it { is_expected.to contain_class('apache::params') }
it { is_expected.to contain_apache__mod('ssl') }
it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLSessionCache "shmcb:/var/lib/apache2/ssl_scache\(512000\)"$})}
end
# Template config doesn't vary by distro
context "on all distros" do
let :facts do
{
:osfamily => 'RedHat',
:operatingsystem => 'CentOS',
:operatingsystemrelease => '6',
:kernel => 'Linux',
:id => 'root',
:concat_basedir => '/dne',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
:is_pe => false,
}
end
context 'not setting ssl_pass_phrase_dialog' do
it { is_expected.to contain_file('ssl.conf').with_content(/^ SSLPassPhraseDialog builtin$/)}
end
context "with Apache version < 2.4" do
let :params do
{
:apache_version => '2.2',
}
end
context 'ssl_compression with default value' do
it { is_expected.not_to contain_file('ssl.conf').with_content(/^ SSLCompression Off$/)}
end
context 'setting ssl_compression to true' do
let :params do
{
:ssl_compression => true,
}
end
it { is_expected.not_to contain_file('ssl.conf').with_content(/^ SSLCompression On$/)}
end
context 'setting ssl_stapling to true' do
let :params do
{
:ssl_stapling => true,
}
end
it { is_expected.not_to contain_file('ssl.conf').with_content(/^ SSLUseStapling/)}
end
end
context "with Apache version >= 2.4" do
let :params do
{
:apache_version => '2.4',
}
end
context 'ssl_compression with default value' do
it { is_expected.not_to contain_file('ssl.conf').with_content(/^ SSLCompression Off$/)}
end
context 'setting ssl_compression to true' do
let :params do
{
:apache_version => '2.4',
:ssl_compression => true,
}
end
it { is_expected.to contain_file('ssl.conf').with_content(/^ SSLCompression On$/)}
end
context 'setting ssl_stapling to true' do
let :params do
{
:apache_version => '2.4',
:ssl_stapling => true,
}
end
it { is_expected.to contain_file('ssl.conf').with_content(/^ SSLUseStapling On$/)}
end
context 'setting ssl_stapling_return_errors to true' do
let :params do
{
:apache_version => '2.4',
:ssl_stapling_return_errors => true,
}
end
it { is_expected.to contain_file('ssl.conf').with_content(/^ SSLStaplingReturnResponderErrors On$/)}
end
end
context 'setting ssl_pass_phrase_dialog' do
let :params do
{
:ssl_pass_phrase_dialog => 'exec:/path/to/program',
}
end
it { is_expected.to contain_file('ssl.conf').with_content(/^ SSLPassPhraseDialog exec:\/path\/to\/program$/)}
end
context 'setting ssl_random_seed_bytes' do
let :params do
{
:ssl_random_seed_bytes => '1024',
}
end
it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLRandomSeed startup file:/dev/urandom 1024$})}
end
context 'setting ssl_openssl_conf_cmd' do
let :params do
{
:ssl_openssl_conf_cmd => 'DHParameters "foo.pem"',
}
end
it { is_expected.to contain_file('ssl.conf').with_content(/^\s+SSLOpenSSLConfCmd DHParameters "foo.pem"$/)}
end
context 'setting ssl_mutex' do
let :params do
{
:ssl_mutex => 'posixsem',
}
end
it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLMutex posixsem$})}
end
context 'setting ssl_sessioncache' do
let :params do
{
:ssl_sessioncache => '/tmp/customsessioncache(51200)',
}
end
it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLSessionCache "shmcb:/tmp/customsessioncache\(51200\)"$})}
end
context 'setting ssl_proxy_protocol' do
let :params do
{
:ssl_proxy_protocol => [ '-ALL', '+TLSv1'],
}
end
it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLProxyProtocol -ALL \+TLSv1$})}
end
end
end