comparison modules/apache/spec/acceptance/vhost_spec.rb @ 36:37675581a273 puppet-3.6

Update Puppet module for Apache (pulls in concat module)
author IBBoard <dev@ibboard.co.uk>
date Sat, 14 Mar 2015 20:07:04 +0000
parents 956e484adc12
children 675c1cc61eaf
comparison
equal deleted inserted replaced
35:1bb941522ebf 36:37675581a273
14 14
15 apply_manifest(pp, :catch_failures => true) 15 apply_manifest(pp, :catch_failures => true)
16 end 16 end
17 17
18 describe file("#{$vhost_dir}/15-default.conf") do 18 describe file("#{$vhost_dir}/15-default.conf") do
19 it { should_not be_file } 19 it { is_expected.not_to be_file }
20 end 20 end
21 21
22 describe file("#{$vhost_dir}/15-default-ssl.conf") do 22 describe file("#{$vhost_dir}/15-default-ssl.conf") do
23 it { should_not be_file } 23 it { is_expected.not_to be_file }
24 end 24 end
25 end 25 end
26 26
27 context "default vhost without ssl" do 27 context "default vhost without ssl" do
28 it 'should create a default vhost config' do 28 it 'should create a default vhost config' do
32 32
33 apply_manifest(pp, :catch_failures => true) 33 apply_manifest(pp, :catch_failures => true)
34 end 34 end
35 35
36 describe file("#{$vhost_dir}/15-default.conf") do 36 describe file("#{$vhost_dir}/15-default.conf") do
37 it { should contain '<VirtualHost \*:80>' } 37 it { is_expected.to contain '<VirtualHost \*:80>' }
38 end 38 end
39 39
40 describe file("#{$vhost_dir}/15-default-ssl.conf") do 40 describe file("#{$vhost_dir}/15-default-ssl.conf") do
41 it { should_not be_file } 41 it { is_expected.not_to be_file }
42 end 42 end
43 end 43 end
44 44
45 context 'default vhost with ssl' do 45 context 'default vhost with ssl' do
46 it 'should create default vhost configs' do 46 it 'should create default vhost configs' do
57 EOS 57 EOS
58 apply_manifest(pp, :catch_failures => true) 58 apply_manifest(pp, :catch_failures => true)
59 end 59 end
60 60
61 describe file("#{$vhost_dir}/15-default.conf") do 61 describe file("#{$vhost_dir}/15-default.conf") do
62 it { should contain '<VirtualHost \*:80>' } 62 it { is_expected.to contain '<VirtualHost \*:80>' }
63 end 63 end
64 64
65 describe file("#{$vhost_dir}/15-default-ssl.conf") do 65 describe file("#{$vhost_dir}/15-default-ssl.conf") do
66 it { should contain '<VirtualHost \*:443>' } 66 it { is_expected.to contain '<VirtualHost \*:443>' }
67 it { should contain "SSLEngine on" } 67 it { is_expected.to contain "SSLEngine on" }
68 end 68 end
69 end 69 end
70 70
71 context 'new vhost on port 80' do 71 context 'new vhost on port 80' do
72 it 'should configure an apache vhost' do 72 it 'should configure an apache vhost' do
85 EOS 85 EOS
86 apply_manifest(pp, :catch_failures => true) 86 apply_manifest(pp, :catch_failures => true)
87 end 87 end
88 88
89 describe file("#{$vhost_dir}/25-first.example.com.conf") do 89 describe file("#{$vhost_dir}/25-first.example.com.conf") do
90 it { should contain '<VirtualHost \*:80>' } 90 it { is_expected.to contain '<VirtualHost \*:80>' }
91 it { should contain "ServerName first.example.com" } 91 it { is_expected.to contain "ServerName first.example.com" }
92 end 92 end
93 end 93 end
94 94
95 context 'new proxy vhost on port 80' do 95 context 'new proxy vhost on port 80' do
96 it 'should configure an apache proxy vhost' do 96 it 'should configure an apache proxy vhost' do
100 port => '80', 100 port => '80',
101 docroot => '/var/www/proxy', 101 docroot => '/var/www/proxy',
102 proxy_pass => [ 102 proxy_pass => [
103 { 'path' => '/foo', 'url' => 'http://backend-foo/'}, 103 { 'path' => '/foo', 'url' => 'http://backend-foo/'},
104 ], 104 ],
105 proxy_preserve_host => true,
105 } 106 }
106 EOS 107 EOS
107 apply_manifest(pp, :catch_failures => true) 108 apply_manifest(pp, :catch_failures => true)
108 end 109 end
109 110
110 describe file("#{$vhost_dir}/25-proxy.example.com.conf") do 111 describe file("#{$vhost_dir}/25-proxy.example.com.conf") do
111 it { should contain '<VirtualHost \*:80>' } 112 it { is_expected.to contain '<VirtualHost \*:80>' }
112 it { should contain "ServerName proxy.example.com" } 113 it { is_expected.to contain "ServerName proxy.example.com" }
113 it { should contain "ProxyPass" } 114 it { is_expected.to contain "ProxyPass" }
114 it { should_not contain "<Proxy \*>" } 115 it { is_expected.to contain "ProxyPreserveHost On" }
116 it { is_expected.not_to contain "<Proxy \*>" }
115 end 117 end
116 end 118 end
117 119
118 context 'new vhost on port 80' do 120 context 'new vhost on port 80' do
119 it 'should configure two apache vhosts' do 121 it 'should configure two apache vhosts' do
140 EOS 142 EOS
141 apply_manifest(pp, :catch_failures => true) 143 apply_manifest(pp, :catch_failures => true)
142 end 144 end
143 145
144 describe service($service_name) do 146 describe service($service_name) do
145 it { should be_enabled } 147 it { is_expected.to be_enabled }
146 it { should be_running } 148 it { is_expected.to be_running }
147 end 149 end
148 150
149 it 'should answer to first.example.com' do 151 it 'should answer to first.example.com' do
150 shell("/usr/bin/curl first.example.com:80", {:acceptable_exit_codes => 0}) do |r| 152 shell("/usr/bin/curl first.example.com:80", {:acceptable_exit_codes => 0}) do |r|
151 r.stdout.should == "Hello from first\n" 153 expect(r.stdout).to eq("Hello from first\n")
152 end 154 end
153 end 155 end
154 156
155 it 'should answer to second.example.com' do 157 it 'should answer to second.example.com' do
156 shell("/usr/bin/curl second.example.com:80", {:acceptable_exit_codes => 0}) do |r| 158 shell("/usr/bin/curl second.example.com:80", {:acceptable_exit_codes => 0}) do |r|
157 r.stdout.should == "Hello from second\n" 159 expect(r.stdout).to eq("Hello from second\n")
158 end 160 end
159 end 161 end
160 end 162 end
161 163
162 context 'apache_directories' do 164 context 'apache_directories' do
163 describe 'readme example, adapted' do 165 describe 'readme example, adapted' do
164 it 'should configure a vhost with Files' do 166 it 'should configure a vhost with Files' do
165 pp = <<-EOS 167 pp = <<-EOS
166 class { 'apache': } 168 class { 'apache': }
167 169
168 if $apache::apache_version >= 2.4 { 170 if versioncmp($apache::apache_version, '2.4') >= 0 {
169 $_files_match_directory = { 'path' => '(\.swp|\.bak|~)$', 'provider' => 'filesmatch', 'require' => 'all denied', } 171 $_files_match_directory = { 'path' => '(\.swp|\.bak|~)$', 'provider' => 'filesmatch', 'require' => 'all denied', }
170 } else { 172 } else {
171 $_files_match_directory = { 'path' => '(\.swp|\.bak|~)$', 'provider' => 'filesmatch', 'deny' => 'from all', } 173 $_files_match_directory = { 'path' => '(\.swp|\.bak|~)$', 'provider' => 'filesmatch', 'deny' => 'from all', }
172 } 174 }
173 175
192 EOS 194 EOS
193 apply_manifest(pp, :catch_failures => true) 195 apply_manifest(pp, :catch_failures => true)
194 end 196 end
195 197
196 describe service($service_name) do 198 describe service($service_name) do
197 it { should be_enabled } 199 it { is_expected.to be_enabled }
198 it { should be_running } 200 it { is_expected.to be_running }
199 end 201 end
200 202
201 it 'should answer to files.example.net' do 203 it 'should answer to files.example.net' do
202 shell("/usr/bin/curl -sSf files.example.net:80/index.html").stdout.should eq("Hello World\n") 204 expect(shell("/usr/bin/curl -sSf files.example.net:80/index.html").stdout).to eq("Hello World\n")
203 shell("/usr/bin/curl -sSf files.example.net:80/index.html.bak", {:acceptable_exit_codes => 22}).stderr.should match(/curl: \(22\) The requested URL returned error: 403/) 205 expect(shell("/usr/bin/curl -sSf files.example.net:80/index.html.bak", {:acceptable_exit_codes => 22}).stderr).to match(/curl: \(22\) The requested URL returned error: 403/)
204 end 206 end
205 end 207 end
206 208
207 describe 'other Directory options' do 209 describe 'other Directory options' do
208 it 'should configure a vhost with multiple Directory sections' do 210 it 'should configure a vhost with multiple Directory sections' do
209 pp = <<-EOS 211 pp = <<-EOS
210 class { 'apache': } 212 class { 'apache': }
211 213
212 if $apache::apache_version >= 2.4 { 214 if versioncmp($apache::apache_version, '2.4') >= 0 {
213 $_files_match_directory = { 'path' => 'private.html$', 'provider' => 'filesmatch', 'require' => 'all denied' } 215 $_files_match_directory = { 'path' => 'private.html$', 'provider' => 'filesmatch', 'require' => 'all denied' }
214 } else { 216 } else {
215 $_files_match_directory = { 'path' => 'private.html$', 'provider' => 'filesmatch', 'deny' => 'from all' } 217 $_files_match_directory = [
218 { 'path' => 'private.html$', 'provider' => 'filesmatch', 'deny' => 'from all' },
219 { 'path' => '/bar/bar.html', 'provider' => 'location', allow => [ 'from 127.0.0.1', ] },
220 ]
216 } 221 }
217 222
218 $_directories = [ 223 $_directories = [
219 { 'path' => '/var/www/files', }, 224 { 'path' => '/var/www/files', },
220 { 'path' => '/foo/', 'provider' => 'location', 'directoryindex' => 'notindex.html', }, 225 { 'path' => '/foo/', 'provider' => 'location', 'directoryindex' => 'notindex.html', },
234 } 239 }
235 file { '/var/www/files/private.html': 240 file { '/var/www/files/private.html':
236 ensure => file, 241 ensure => file,
237 content => "Hello World\\n", 242 content => "Hello World\\n",
238 } 243 }
244 file { '/var/www/files/bar':
245 ensure => directory,
246 }
247 file { '/var/www/files/bar/bar.html':
248 ensure => file,
249 content => "Hello Bar\\n",
250 }
239 host { 'files.example.net': ip => '127.0.0.1', } 251 host { 'files.example.net': ip => '127.0.0.1', }
240 EOS 252 EOS
241 apply_manifest(pp, :catch_failures => true) 253 apply_manifest(pp, :catch_failures => true)
242 end 254 end
243 255
244 describe service($service_name) do 256 describe service($service_name) do
245 it { should be_enabled } 257 it { is_expected.to be_enabled }
246 it { should be_running } 258 it { is_expected.to be_running }
247 end 259 end
248 260
249 it 'should answer to files.example.net' do 261 it 'should answer to files.example.net' do
250 shell("/usr/bin/curl -sSf files.example.net:80/").stdout.should eq("Hello World\n") 262 expect(shell("/usr/bin/curl -sSf files.example.net:80/").stdout).to eq("Hello World\n")
251 shell("/usr/bin/curl -sSf files.example.net:80/foo/").stdout.should eq("Hello Foo\n") 263 expect(shell("/usr/bin/curl -sSf files.example.net:80/foo/").stdout).to eq("Hello Foo\n")
252 shell("/usr/bin/curl -sSf files.example.net:80/private.html", {:acceptable_exit_codes => 22}).stderr.should match(/curl: \(22\) The requested URL returned error: 403/) 264 expect(shell("/usr/bin/curl -sSf files.example.net:80/private.html", {:acceptable_exit_codes => 22}).stderr).to match(/curl: \(22\) The requested URL returned error: 403/)
265 expect(shell("/usr/bin/curl -sSf files.example.net:80/bar/bar.html").stdout).to eq("Hello Bar\n")
253 end 266 end
254 end 267 end
255 268
256 describe 'SetHandler directive' do 269 describe 'SetHandler directive' do
257 it 'should configure a vhost with a SetHandler directive' do 270 it 'should configure a vhost with a SetHandler directive' do
273 EOS 286 EOS
274 apply_manifest(pp, :catch_failures => true) 287 apply_manifest(pp, :catch_failures => true)
275 end 288 end
276 289
277 describe service($service_name) do 290 describe service($service_name) do
291 it { is_expected.to be_enabled }
292 it { is_expected.to be_running }
293 end
294
295 it 'should answer to files.example.net' do
296 expect(shell("/usr/bin/curl -sSf files.example.net:80/index.html").stdout).to eq("Hello World\n")
297 expect(shell("/usr/bin/curl -sSf files.example.net:80/server-status?auto").stdout).to match(/Scoreboard: /)
298 end
299 end
300
301 describe 'Satisfy and Auth directive', :unless => $apache_version == '2.4' do
302 it 'should configure a vhost with Satisfy and Auth directive' do
303 pp = <<-EOS
304 class { 'apache': }
305 host { 'files.example.net': ip => '127.0.0.1', }
306 apache::vhost { 'files.example.net':
307 docroot => '/var/www/files',
308 directories => [
309 {
310 path => '/var/www/files/foo',
311 auth_type => 'Basic',
312 auth_name => 'Basic Auth',
313 auth_user_file => '/var/www/htpasswd',
314 auth_require => "valid-user",
315 },
316 {
317 path => '/var/www/files/bar',
318 auth_type => 'Basic',
319 auth_name => 'Basic Auth',
320 auth_user_file => '/var/www/htpasswd',
321 auth_require => 'valid-user',
322 satisfy => 'Any',
323 },
324 {
325 path => '/var/www/files/baz',
326 allow => 'from 10.10.10.10',
327 auth_type => 'Basic',
328 auth_name => 'Basic Auth',
329 auth_user_file => '/var/www/htpasswd',
330 auth_require => 'valid-user',
331 satisfy => 'Any',
332 },
333 ],
334 }
335 file { '/var/www/files/foo':
336 ensure => directory,
337 }
338 file { '/var/www/files/bar':
339 ensure => directory,
340 }
341 file { '/var/www/files/baz':
342 ensure => directory,
343 }
344 file { '/var/www/files/foo/index.html':
345 ensure => file,
346 content => "Hello World\\n",
347 }
348 file { '/var/www/files/bar/index.html':
349 ensure => file,
350 content => "Hello World\\n",
351 }
352 file { '/var/www/files/baz/index.html':
353 ensure => file,
354 content => "Hello World\\n",
355 }
356 file { '/var/www/htpasswd':
357 ensure => file,
358 content => "login:IZ7jMcLSx0oQk", # "password" as password
359 }
360 EOS
361 apply_manifest(pp, :catch_failures => true)
362 end
363
364 describe service($service_name) do
278 it { should be_enabled } 365 it { should be_enabled }
279 it { should be_running } 366 it { should be_running }
280 end 367 end
281 368
282 it 'should answer to files.example.net' do 369 it 'should answer to files.example.net' do
283 shell("/usr/bin/curl -sSf files.example.net:80/index.html").stdout.should eq("Hello World\n") 370 shell("/usr/bin/curl -sSf files.example.net:80/foo/index.html", {:acceptable_exit_codes => 22}).stderr.should match(/curl: \(22\) The requested URL returned error: 401/)
284 shell("/usr/bin/curl -sSf files.example.net:80/server-status?auto").stdout.should match(/Scoreboard: /) 371 shell("/usr/bin/curl -sSf -u login:password files.example.net:80/foo/index.html").stdout.should eq("Hello World\n")
372 shell("/usr/bin/curl -sSf files.example.net:80/bar/index.html").stdout.should eq("Hello World\n")
373 shell("/usr/bin/curl -sSf -u login:password files.example.net:80/bar/index.html").stdout.should eq("Hello World\n")
374 shell("/usr/bin/curl -sSf files.example.net:80/baz/index.html", {:acceptable_exit_codes => 22}).stderr.should match(/curl: \(22\) The requested URL returned error: 401/)
375 shell("/usr/bin/curl -sSf -u login:password files.example.net:80/baz/index.html").stdout.should eq("Hello World\n")
285 end 376 end
286 end 377 end
287 end 378 end
288 379
289 case fact('lsbdistcodename') 380 case fact('lsbdistcodename')
304 EOS 395 EOS
305 apply_manifest(pp, :catch_failures => true) 396 apply_manifest(pp, :catch_failures => true)
306 end 397 end
307 398
308 describe service($service_name) do 399 describe service($service_name) do
309 it { should be_enabled } 400 it { is_expected.to be_enabled }
310 it { should be_running } 401 it { is_expected.to be_running }
311 end 402 end
312 403
313 it 'should answer to fallback.example.net' do 404 it 'should answer to fallback.example.net' do
314 shell("/usr/bin/curl fallback.example.net:80/Does/Not/Exist") do |r| 405 shell("/usr/bin/curl fallback.example.net:80/Does/Not/Exist") do |r|
315 r.stdout.should == "Hello World\n" 406 expect(r.stdout).to eq("Hello World\n")
316 end 407 end
317 end 408 end
318 409
319 end 410 end
320 else 411 else
345 EOS 436 EOS
346 apply_manifest(pp, :catch_failures => true) 437 apply_manifest(pp, :catch_failures => true)
347 end 438 end
348 439
349 describe service($service_name) do 440 describe service($service_name) do
350 it { should be_enabled } 441 it { is_expected.to be_enabled }
351 it { should be_running } 442 it { is_expected.to be_running }
352 end 443 end
353 444
354 it 'should answer to a.virt.example.com' do 445 it 'should answer to a.virt.example.com' do
355 shell("/usr/bin/curl a.virt.example.com:80", {:acceptable_exit_codes => 0}) do |r| 446 shell("/usr/bin/curl a.virt.example.com:80", {:acceptable_exit_codes => 0}) do |r|
356 r.stdout.should == "Hello from a.virt\n" 447 expect(r.stdout).to eq("Hello from a.virt\n")
357 end 448 end
358 end 449 end
359 450
360 it 'should answer to b.virt.example.com' do 451 it 'should answer to b.virt.example.com' do
361 shell("/usr/bin/curl b.virt.example.com:80", {:acceptable_exit_codes => 0}) do |r| 452 shell("/usr/bin/curl b.virt.example.com:80", {:acceptable_exit_codes => 0}) do |r|
362 r.stdout.should == "Hello from b.virt\n" 453 expect(r.stdout).to eq("Hello from b.virt\n")
363 end 454 end
364 end 455 end
365 end 456 end
366 457
367 context 'proxy_pass for alternative vhost' do 458 context 'proxy_pass for alternative vhost' do
387 file { ['/var/www/local', '/var/www/local/subdir']: ensure => directory, } 478 file { ['/var/www/local', '/var/www/local/subdir']: ensure => directory, }
388 file { '/var/www/local/subdir/index.html': 479 file { '/var/www/local/subdir/index.html':
389 ensure => file, 480 ensure => file,
390 content => "Hello from localhost\\n", 481 content => "Hello from localhost\\n",
391 } 482 }
392 }, :catch_failures => true) 483 }, :catch_failures => true)
393 end 484 end
394 485
395 describe service($service_name) do 486 describe service($service_name) do
396 it { should be_enabled } 487 it { is_expected.to be_enabled }
397 it { should be_running } 488 it { is_expected.to be_running }
398 end 489 end
399 490
400 it 'should get a response from the back end' do 491 it 'should get a response from the back end' do
401 shell("/usr/bin/curl --max-redirs 0 proxy.example.com:80") do |r| 492 shell("/usr/bin/curl --max-redirs 0 proxy.example.com:80") do |r|
402 r.stdout.should == "Hello from localhost\n" 493 expect(r.stdout).to eq("Hello from localhost\n")
403 r.exit_code.should == 0 494 expect(r.exit_code).to eq(0)
404 end 495 end
405 end 496 end
406 end 497 end
407 498
408 describe 'ip_based' do 499 describe 'ip_based' do
418 EOS 509 EOS
419 apply_manifest(pp, :catch_failures => true) 510 apply_manifest(pp, :catch_failures => true)
420 end 511 end
421 512
422 describe file($ports_file) do 513 describe file($ports_file) do
423 it { should be_file } 514 it { is_expected.to be_file }
424 it { should_not contain 'NameVirtualHost test.server' } 515 it { is_expected.not_to contain 'NameVirtualHost test.server' }
425 end 516 end
426 end 517 end
427 518
428 describe 'add_listen' do 519 describe 'add_listen' do
429 it 'applies cleanly' do 520 it 'applies cleanly' do
440 EOS 531 EOS
441 apply_manifest(pp, :catch_failures => true) 532 apply_manifest(pp, :catch_failures => true)
442 end 533 end
443 534
444 describe file($ports_file) do 535 describe file($ports_file) do
445 it { should be_file } 536 it { is_expected.to be_file }
446 it { should_not contain 'Listen 80' } 537 it { is_expected.not_to contain 'Listen 80' }
447 it { should contain 'Listen 81' } 538 it { is_expected.to contain 'Listen 81' }
448 end 539 end
449 end 540 end
450 541
451 describe 'docroot' do 542 describe 'docroot' do
452 it 'applies cleanly' do 543 it 'applies cleanly' do
464 EOS 555 EOS
465 apply_manifest(pp, :catch_failures => true) 556 apply_manifest(pp, :catch_failures => true)
466 end 557 end
467 558
468 describe file('/tmp/test') do 559 describe file('/tmp/test') do
469 it { should be_directory } 560 it { is_expected.to be_directory }
470 it { should be_owned_by 'test_owner' } 561 it { is_expected.to be_owned_by 'test_owner' }
471 it { should be_grouped_into 'test_group' } 562 it { is_expected.to be_grouped_into 'test_group' }
472 it { should be_mode 750 } 563 it { is_expected.to be_mode 750 }
473 end 564 end
474 end 565 end
475 566
476 describe 'default_vhost' do 567 describe 'default_vhost' do
477 it 'applies cleanly' do 568 it 'applies cleanly' do
485 EOS 576 EOS
486 apply_manifest(pp, :catch_failures => true) 577 apply_manifest(pp, :catch_failures => true)
487 end 578 end
488 579
489 describe file($ports_file) do 580 describe file($ports_file) do
490 it { should be_file } 581 it { is_expected.to be_file }
491 if fact('osfamily') == 'RedHat' and fact('operatingsystemmajrelease') == '7' 582 if fact('osfamily') == 'RedHat' and fact('operatingsystemmajrelease') == '7'
492 it { should_not contain 'NameVirtualHost test.server' } 583 it { is_expected.not_to contain 'NameVirtualHost test.server' }
493 elsif fact('operatingsystem') == 'Ubuntu' and fact('operatingsystemrelease') =~ /(14\.04|13\.10)/ 584 elsif fact('operatingsystem') == 'Ubuntu' and fact('operatingsystemrelease') =~ /(14\.04|13\.10)/
494 it { should_not contain 'NameVirtualHost test.server' } 585 it { is_expected.not_to contain 'NameVirtualHost test.server' }
495 else 586 else
496 it { should contain 'NameVirtualHost test.server' } 587 it { is_expected.to contain 'NameVirtualHost test.server' }
497 end 588 end
498 end 589 end
499 590
500 describe file("#{$vhost_dir}/10-test.server.conf") do 591 describe file("#{$vhost_dir}/10-test.server.conf") do
501 it { should be_file } 592 it { is_expected.to be_file }
502 end 593 end
503 end 594 end
504 595
505 describe 'options' do 596 describe 'options' do
506 it 'applies cleanly' do 597 it 'applies cleanly' do
514 EOS 605 EOS
515 apply_manifest(pp, :catch_failures => true) 606 apply_manifest(pp, :catch_failures => true)
516 end 607 end
517 608
518 describe file("#{$vhost_dir}/25-test.server.conf") do 609 describe file("#{$vhost_dir}/25-test.server.conf") do
519 it { should be_file } 610 it { is_expected.to be_file }
520 it { should contain 'Options Indexes FollowSymLinks ExecCGI' } 611 it { is_expected.to contain 'Options Indexes FollowSymLinks ExecCGI' }
521 end 612 end
522 end 613 end
523 614
524 describe 'override' do 615 describe 'override' do
525 it 'applies cleanly' do 616 it 'applies cleanly' do
533 EOS 624 EOS
534 apply_manifest(pp, :catch_failures => true) 625 apply_manifest(pp, :catch_failures => true)
535 end 626 end
536 627
537 describe file("#{$vhost_dir}/25-test.server.conf") do 628 describe file("#{$vhost_dir}/25-test.server.conf") do
538 it { should be_file } 629 it { is_expected.to be_file }
539 it { should contain 'AllowOverride All' } 630 it { is_expected.to contain 'AllowOverride All' }
540 end 631 end
541 end 632 end
542 633
543 describe 'logroot' do 634 describe 'logroot' do
544 it 'applies cleanly' do 635 it 'applies cleanly' do
552 EOS 643 EOS
553 apply_manifest(pp, :catch_failures => true) 644 apply_manifest(pp, :catch_failures => true)
554 end 645 end
555 646
556 describe file("#{$vhost_dir}/25-test.server.conf") do 647 describe file("#{$vhost_dir}/25-test.server.conf") do
557 it { should be_file } 648 it { is_expected.to be_file }
558 it { should contain ' CustomLog "/tmp' } 649 it { is_expected.to contain ' CustomLog "/tmp' }
559 end 650 end
560 end 651 end
561 652
562 ['access', 'error'].each do |logtype| 653 ['access', 'error'].each do |logtype|
563 case logtype 654 case logtype
573 class { 'apache': } 664 class { 'apache': }
574 host { 'test.server': ip => '127.0.0.1' } 665 host { 'test.server': ip => '127.0.0.1' }
575 apache::vhost { 'test.server': 666 apache::vhost { 'test.server':
576 docroot => '/tmp', 667 docroot => '/tmp',
577 logroot => '/tmp', 668 logroot => '/tmp',
578 #{logtype}_log => false, 669 #{logtype}_log => false,
579 } 670 }
580 EOS 671 EOS
581 apply_manifest(pp, :catch_failures => true) 672 apply_manifest(pp, :catch_failures => true)
582 end 673 end
583 674
584 describe file("#{$vhost_dir}/25-test.server.conf") do 675 describe file("#{$vhost_dir}/25-test.server.conf") do
585 it { should be_file } 676 it { is_expected.to be_file }
586 it { should_not contain " #{logname} \"/tmp" } 677 it { is_expected.not_to contain " #{logname} \"/tmp" }
587 end 678 end
588 end 679 end
589 680
590 describe "#{logtype}_log_pipe" do 681 describe "#{logtype}_log_pipe" do
591 it 'applies cleanly' do 682 it 'applies cleanly' do
593 class { 'apache': } 684 class { 'apache': }
594 host { 'test.server': ip => '127.0.0.1' } 685 host { 'test.server': ip => '127.0.0.1' }
595 apache::vhost { 'test.server': 686 apache::vhost { 'test.server':
596 docroot => '/tmp', 687 docroot => '/tmp',
597 logroot => '/tmp', 688 logroot => '/tmp',
598 #{logtype}_log_pipe => '|/bin/sh', 689 #{logtype}_log_pipe => '|/bin/sh',
599 } 690 }
600 EOS 691 EOS
601 apply_manifest(pp, :catch_failures => true) 692 apply_manifest(pp, :catch_failures => true)
602 end 693 end
603 694
604 describe file("#{$vhost_dir}/25-test.server.conf") do 695 describe file("#{$vhost_dir}/25-test.server.conf") do
605 it { should be_file } 696 it { is_expected.to be_file }
606 it { should contain " #{logname} \"|/bin/sh" } 697 it { is_expected.to contain " #{logname} \"|/bin/sh" }
607 end 698 end
608 end 699 end
609 700
610 describe "#{logtype}_log_syslog" do 701 describe "#{logtype}_log_syslog" do
611 it 'applies cleanly' do 702 it 'applies cleanly' do
613 class { 'apache': } 704 class { 'apache': }
614 host { 'test.server': ip => '127.0.0.1' } 705 host { 'test.server': ip => '127.0.0.1' }
615 apache::vhost { 'test.server': 706 apache::vhost { 'test.server':
616 docroot => '/tmp', 707 docroot => '/tmp',
617 logroot => '/tmp', 708 logroot => '/tmp',
618 #{logtype}_log_syslog => 'syslog', 709 #{logtype}_log_syslog => 'syslog',
619 } 710 }
620 EOS 711 EOS
621 apply_manifest(pp, :catch_failures => true) 712 apply_manifest(pp, :catch_failures => true)
622 end 713 end
623 714
624 describe file("#{$vhost_dir}/25-test.server.conf") do 715 describe file("#{$vhost_dir}/25-test.server.conf") do
625 it { should be_file } 716 it { is_expected.to be_file }
626 it { should contain " #{logname} \"syslog\"" } 717 it { is_expected.to contain " #{logname} \"syslog\"" }
627 end 718 end
628 end 719 end
629 end 720 end
630 721
631 describe 'access_log_format' do 722 describe 'access_log_format' do
642 EOS 733 EOS
643 apply_manifest(pp, :catch_failures => true) 734 apply_manifest(pp, :catch_failures => true)
644 end 735 end
645 736
646 describe file("#{$vhost_dir}/25-test.server.conf") do 737 describe file("#{$vhost_dir}/25-test.server.conf") do
647 it { should be_file } 738 it { is_expected.to be_file }
648 it { should contain 'CustomLog "syslog" "%h %l"' } 739 it { is_expected.to contain 'CustomLog "syslog" "%h %l"' }
649 end 740 end
650 end 741 end
651 742
652 describe 'access_log_env_var' do 743 describe 'access_log_env_var' do
653 it 'applies cleanly' do 744 it 'applies cleanly' do
663 EOS 754 EOS
664 apply_manifest(pp, :catch_failures => true) 755 apply_manifest(pp, :catch_failures => true)
665 end 756 end
666 757
667 describe file("#{$vhost_dir}/25-test.server.conf") do 758 describe file("#{$vhost_dir}/25-test.server.conf") do
668 it { should be_file } 759 it { is_expected.to be_file }
669 it { should contain 'CustomLog "syslog" combined env=admin' } 760 it { is_expected.to contain 'CustomLog "syslog" combined env=admin' }
761 end
762 end
763
764 describe 'multiple access_logs' do
765 it 'applies cleanly' do
766 pp = <<-EOS
767 class { 'apache': }
768 host { 'test.server': ip => '127.0.0.1' }
769 apache::vhost { 'test.server':
770 docroot => '/tmp',
771 logroot => '/tmp',
772 access_logs => [
773 {'file' => 'log1'},
774 {'file' => 'log2', 'env' => 'admin' },
775 {'file' => '/var/tmp/log3', 'format' => '%h %l'},
776 {'syslog' => 'syslog' }
777 ]
778 }
779 EOS
780 apply_manifest(pp, :catch_failures => true)
781 end
782
783 describe file("#{$vhost_dir}/25-test.server.conf") do
784 it { is_expected.to be_file }
785 it { is_expected.to contain 'CustomLog "/tmp/log1" combined' }
786 it { is_expected.to contain 'CustomLog "/tmp/log2" combined env=admin' }
787 it { is_expected.to contain 'CustomLog "/var/tmp/log3" "%h %l"' }
788 it { is_expected.to contain 'CustomLog "syslog" combined' }
670 end 789 end
671 end 790 end
672 791
673 describe 'aliases' do 792 describe 'aliases' do
674 it 'applies cleanly' do 793 it 'applies cleanly' do
675 pp = <<-EOS 794 pp = <<-EOS
676 class { 'apache': } 795 class { 'apache': }
677 host { 'test.server': ip => '127.0.0.1' } 796 host { 'test.server': ip => '127.0.0.1' }
678 apache::vhost { 'test.server': 797 apache::vhost { 'test.server':
679 docroot => '/tmp', 798 docroot => '/tmp',
680 aliases => [{ alias => '/image', path => '/ftp/pub/image' }], 799 aliases => [
681 } 800 { alias => '/image' , path => '/ftp/pub/image' } ,
682 EOS 801 { scriptalias => '/myscript' , path => '/usr/share/myscript' }
683 apply_manifest(pp, :catch_failures => true) 802 ],
684 end 803 }
685 804 EOS
686 describe file("#{$vhost_dir}/25-test.server.conf") do 805 apply_manifest(pp, :catch_failures => true)
687 it { should be_file } 806 end
688 it { should contain 'Alias /image "/ftp/pub/image"' } 807
808 describe file("#{$vhost_dir}/25-test.server.conf") do
809 it { is_expected.to be_file }
810 it { is_expected.to contain 'Alias /image "/ftp/pub/image"' }
811 it { is_expected.to contain 'ScriptAlias /myscript "/usr/share/myscript"' }
689 end 812 end
690 end 813 end
691 814
692 describe 'scriptaliases' do 815 describe 'scriptaliases' do
693 it 'applies cleanly' do 816 it 'applies cleanly' do
701 EOS 824 EOS
702 apply_manifest(pp, :catch_failures => true) 825 apply_manifest(pp, :catch_failures => true)
703 end 826 end
704 827
705 describe file("#{$vhost_dir}/25-test.server.conf") do 828 describe file("#{$vhost_dir}/25-test.server.conf") do
706 it { should be_file } 829 it { is_expected.to be_file }
707 it { should contain 'ScriptAlias /myscript "/usr/share/myscript"' } 830 it { is_expected.to contain 'ScriptAlias /myscript "/usr/share/myscript"' }
708 end 831 end
709 end 832 end
710 833
711 describe 'proxy' do 834 describe 'proxy' do
712 it 'applies cleanly' do 835 it 'applies cleanly' do
720 EOS 843 EOS
721 apply_manifest(pp, :catch_failures => true) 844 apply_manifest(pp, :catch_failures => true)
722 end 845 end
723 846
724 describe file("#{$vhost_dir}/25-test.server.conf") do 847 describe file("#{$vhost_dir}/25-test.server.conf") do
725 it { should be_file } 848 it { is_expected.to be_file }
726 it { should contain 'ProxyPass / test2/' } 849 it { is_expected.to contain 'ProxyPass / test2/' }
727 end 850 end
728 end 851 end
729 852
730 describe 'actions' do 853 describe 'actions' do
731 it 'applies cleanly' do 854 it 'applies cleanly' do
740 pp = pp + "\nclass { 'apache::mod::actions': }" if fact('osfamily') == 'Debian' 863 pp = pp + "\nclass { 'apache::mod::actions': }" if fact('osfamily') == 'Debian'
741 apply_manifest(pp, :catch_failures => true) 864 apply_manifest(pp, :catch_failures => true)
742 end 865 end
743 866
744 describe file("#{$vhost_dir}/25-test.server.conf") do 867 describe file("#{$vhost_dir}/25-test.server.conf") do
745 it { should be_file } 868 it { is_expected.to be_file }
746 it { should contain 'Action php-fastcgi /cgi-bin virtual' } 869 it { is_expected.to contain 'Action php-fastcgi /cgi-bin virtual' }
747 end 870 end
748 end 871 end
749 872
750 describe 'suphp' do 873 describe 'suphp' do
751 it 'applies cleanly' do 874 it 'applies cleanly' do
761 EOS 884 EOS
762 apply_manifest(pp, :catch_failures => true) 885 apply_manifest(pp, :catch_failures => true)
763 end 886 end
764 887
765 describe file("#{$vhost_dir}/25-test.server.conf") do 888 describe file("#{$vhost_dir}/25-test.server.conf") do
766 it { should be_file } 889 it { is_expected.to be_file }
767 it { should contain "suPHP_AddHandler #{$suphp_handler}" } 890 it { is_expected.to contain "suPHP_AddHandler #{$suphp_handler}" }
768 it { should contain 'suPHP_Engine on' } 891 it { is_expected.to contain 'suPHP_Engine on' }
769 it { should contain "suPHP_ConfigPath \"#{$suphp_configpath}\"" } 892 it { is_expected.to contain "suPHP_ConfigPath \"#{$suphp_configpath}\"" }
770 end 893 end
771 end 894 end
772 895
773 describe 'no_proxy_uris' do 896 describe 'no_proxy_uris' do
774 it 'applies cleanly' do 897 it 'applies cleanly' do
783 EOS 906 EOS
784 apply_manifest(pp, :catch_failures => true) 907 apply_manifest(pp, :catch_failures => true)
785 end 908 end
786 909
787 describe file("#{$vhost_dir}/25-test.server.conf") do 910 describe file("#{$vhost_dir}/25-test.server.conf") do
788 it { should be_file } 911 it { is_expected.to be_file }
789 it { should contain 'ProxyPass / http://test2/' } 912 it { is_expected.to contain 'ProxyPass / http://test2/' }
790 it { should contain 'ProxyPass http://test2/test !' } 913 it { is_expected.to contain 'ProxyPass http://test2/test !' }
791 end 914 end
792 end 915 end
793 916
794 describe 'redirect' do 917 describe 'redirect' do
795 it 'applies cleanly' do 918 it 'applies cleanly' do
805 EOS 928 EOS
806 apply_manifest(pp, :catch_failures => true) 929 apply_manifest(pp, :catch_failures => true)
807 end 930 end
808 931
809 describe file("#{$vhost_dir}/25-test.server.conf") do 932 describe file("#{$vhost_dir}/25-test.server.conf") do
810 it { should be_file } 933 it { is_expected.to be_file }
811 it { should contain 'Redirect permanent /images http://test.server/' } 934 it { is_expected.to contain 'Redirect permanent /images http://test.server/' }
812 end 935 end
813 end 936 end
814 937
815 # Passenger isn't even in EPEL on el-5 938 # Passenger isn't even in EPEL on el-5
816 if default['platform'] !~ /^el-5/ 939 if default['platform'] !~ /^el-5/
836 EOS 959 EOS
837 apply_manifest(pp, :catch_failures => true) 960 apply_manifest(pp, :catch_failures => true)
838 end 961 end
839 962
840 describe file("#{$vhost_dir}/25-test.server.conf") do 963 describe file("#{$vhost_dir}/25-test.server.conf") do
841 it { should be_file } 964 it { is_expected.to be_file }
842 it { should contain 'RackBaseURI /test' } 965 it { is_expected.to contain 'RackBaseURI /test' }
843 end 966 end
844 end 967 end
845 end 968 end
846 end 969 end
847 970
858 EOS 981 EOS
859 apply_manifest(pp, :catch_failures => true) 982 apply_manifest(pp, :catch_failures => true)
860 end 983 end
861 984
862 describe file("#{$vhost_dir}/25-test.server.conf") do 985 describe file("#{$vhost_dir}/25-test.server.conf") do
863 it { should be_file } 986 it { is_expected.to be_file }
864 it { should contain 'append MirrorID "mirror 12"' } 987 it { is_expected.to contain 'append MirrorID "mirror 12"' }
865 end 988 end
866 end 989 end
867 990
868 describe 'rewrite rules' do 991 describe 'rewrite rules' do
869 it 'applies cleanly' do 992 it 'applies cleanly' do
882 EOS 1005 EOS
883 apply_manifest(pp, :catch_failures => true) 1006 apply_manifest(pp, :catch_failures => true)
884 end 1007 end
885 1008
886 describe file("#{$vhost_dir}/25-test.server.conf") do 1009 describe file("#{$vhost_dir}/25-test.server.conf") do
1010 it { is_expected.to be_file }
1011 it { is_expected.to contain '#test' }
1012 it { is_expected.to contain 'RewriteCond %{HTTP_USER_AGENT} ^Lynx/ [OR]' }
1013 it { is_expected.to contain 'RewriteRule ^index.html$ welcome.html' }
1014 end
1015 end
1016
1017 describe 'directory rewrite rules' do
1018 it 'applies cleanly' do
1019 pp = <<-EOS
1020 class { 'apache': }
1021 host { 'test.server': ip => '127.0.0.1' }
1022 if ! defined(Class['apache::mod::rewrite']) {
1023 include ::apache::mod::rewrite
1024 }
1025 apache::vhost { 'test.server':
1026 docroot => '/tmp',
1027 directories => [
1028 {
1029 path => '/tmp',
1030 rewrites => [
1031 {
1032 comment => 'Permalink Rewrites',
1033 rewrite_base => '/',
1034 },
1035 { rewrite_rule => [ '^index\\.php$ - [L]' ] },
1036 { rewrite_cond => [
1037 '%{REQUEST_FILENAME} !-f',
1038 '%{REQUEST_FILENAME} !-d', ], rewrite_rule => [ '. /index.php [L]' ], }
1039 ],
1040 },
1041 ],
1042 }
1043 EOS
1044 apply_manifest(pp, :catch_failures => true)
1045 end
1046
1047 describe file("#{$vhost_dir}/25-test.server.conf") do
887 it { should be_file } 1048 it { should be_file }
888 it { should contain '#test' } 1049 it { should contain '#Permalink Rewrites' }
889 it { should contain 'RewriteCond %{HTTP_USER_AGENT} ^Lynx/ [OR]' } 1050 it { should contain 'RewriteEngine On' }
890 it { should contain 'RewriteRule ^index.html$ welcome.html' } 1051 it { should contain 'RewriteBase /' }
1052 it { should contain 'RewriteRule ^index\.php$ - [L]' }
1053 it { should contain 'RewriteCond %{REQUEST_FILENAME} !-f' }
1054 it { should contain 'RewriteCond %{REQUEST_FILENAME} !-d' }
1055 it { should contain 'RewriteRule . /index.php [L]' }
891 end 1056 end
892 end 1057 end
893 1058
894 describe 'setenv/setenvif' do 1059 describe 'setenv/setenvif' do
895 it 'applies cleanly' do 1060 it 'applies cleanly' do
904 EOS 1069 EOS
905 apply_manifest(pp, :catch_failures => true) 1070 apply_manifest(pp, :catch_failures => true)
906 end 1071 end
907 1072
908 describe file("#{$vhost_dir}/25-test.server.conf") do 1073 describe file("#{$vhost_dir}/25-test.server.conf") do
909 it { should be_file } 1074 it { is_expected.to be_file }
910 it { should contain 'SetEnv TEST /test' } 1075 it { is_expected.to contain 'SetEnv TEST /test' }
911 it { should contain 'SetEnvIf Request_URI "\.gif$" object_is_image=gif' } 1076 it { is_expected.to contain 'SetEnvIf Request_URI "\.gif$" object_is_image=gif' }
912 end 1077 end
913 end 1078 end
914 1079
915 describe 'block' do 1080 describe 'block' do
916 it 'applies cleanly' do 1081 it 'applies cleanly' do
924 EOS 1089 EOS
925 apply_manifest(pp, :catch_failures => true) 1090 apply_manifest(pp, :catch_failures => true)
926 end 1091 end
927 1092
928 describe file("#{$vhost_dir}/25-test.server.conf") do 1093 describe file("#{$vhost_dir}/25-test.server.conf") do
929 it { should be_file } 1094 it { is_expected.to be_file }
930 it { should contain '<DirectoryMatch .*\.(svn|git|bzr)/.*>' } 1095 it { is_expected.to contain '<DirectoryMatch .*\.(svn|git|bzr)/.*>' }
931 end 1096 end
932 end 1097 end
933 1098
934 describe 'wsgi' do 1099 describe 'wsgi' do
935 it 'import_script applies cleanly' do 1100 it 'import_script applies cleanly' do
942 wsgi_application_group => '%{GLOBAL}', 1107 wsgi_application_group => '%{GLOBAL}',
943 wsgi_daemon_process => 'wsgi', 1108 wsgi_daemon_process => 'wsgi',
944 wsgi_daemon_process_options => {processes => '2'}, 1109 wsgi_daemon_process_options => {processes => '2'},
945 wsgi_process_group => 'nobody', 1110 wsgi_process_group => 'nobody',
946 wsgi_script_aliases => { '/test' => '/test1' }, 1111 wsgi_script_aliases => { '/test' => '/test1' },
1112 wsgi_pass_authorization => 'On',
947 } 1113 }
948 EOS 1114 EOS
949 apply_manifest(pp, :catch_failures => true) 1115 apply_manifest(pp, :catch_failures => true)
950 end 1116 end
951 1117
961 wsgi_daemon_process_options => {processes => '2'}, 1127 wsgi_daemon_process_options => {processes => '2'},
962 wsgi_import_script => '/test1', 1128 wsgi_import_script => '/test1',
963 wsgi_import_script_options => { application-group => '%{GLOBAL}', process-group => 'wsgi' }, 1129 wsgi_import_script_options => { application-group => '%{GLOBAL}', process-group => 'wsgi' },
964 wsgi_process_group => 'nobody', 1130 wsgi_process_group => 'nobody',
965 wsgi_script_aliases => { '/test' => '/test1' }, 1131 wsgi_script_aliases => { '/test' => '/test1' },
1132 wsgi_pass_authorization => 'On',
1133 wsgi_chunked_request => 'On',
966 } 1134 }
967 EOS 1135 EOS
968 apply_manifest(pp, :catch_failures => true) 1136 apply_manifest(pp, :catch_failures => true)
969 end 1137 end
970 1138
971 describe file("#{$vhost_dir}/25-test.server.conf"), :unless => (fact('lsbdistcodename') == 'lucid' or UNSUPPORTED_PLATFORMS.include?(fact('osfamily'))) do 1139 describe file("#{$vhost_dir}/25-test.server.conf"), :unless => (fact('lsbdistcodename') == 'lucid' or UNSUPPORTED_PLATFORMS.include?(fact('osfamily'))) do
972 it { should be_file } 1140 it { is_expected.to be_file }
973 it { should contain 'WSGIApplicationGroup %{GLOBAL}' } 1141 it { is_expected.to contain 'WSGIApplicationGroup %{GLOBAL}' }
974 it { should contain 'WSGIDaemonProcess wsgi processes=2' } 1142 it { is_expected.to contain 'WSGIDaemonProcess wsgi processes=2' }
975 it { should contain 'WSGIImportScript /test1 application-group=%{GLOBAL} process-group=wsgi' } 1143 it { is_expected.to contain 'WSGIImportScript /test1 application-group=%{GLOBAL} process-group=wsgi' }
976 it { should contain 'WSGIProcessGroup nobody' } 1144 it { is_expected.to contain 'WSGIProcessGroup nobody' }
977 it { should contain 'WSGIScriptAlias /test "/test1"' } 1145 it { is_expected.to contain 'WSGIScriptAlias /test "/test1"' }
1146 it { is_expected.to contain 'WSGIPassAuthorization On' }
1147 it { is_expected.to contain 'WSGIChunkedRequest On' }
978 end 1148 end
979 end 1149 end
980 1150
981 describe 'custom_fragment' do 1151 describe 'custom_fragment' do
982 it 'applies cleanly' do 1152 it 'applies cleanly' do
990 EOS 1160 EOS
991 apply_manifest(pp, :catch_failures => true) 1161 apply_manifest(pp, :catch_failures => true)
992 end 1162 end
993 1163
994 describe file("#{$vhost_dir}/25-test.server.conf") do 1164 describe file("#{$vhost_dir}/25-test.server.conf") do
995 it { should be_file } 1165 it { is_expected.to be_file }
996 it { should contain '#weird test string' } 1166 it { is_expected.to contain '#weird test string' }
997 end 1167 end
998 end 1168 end
999 1169
1000 describe 'itk' do 1170 describe 'itk' do
1001 it 'applies cleanly' do 1171 it 'applies cleanly' do
1009 EOS 1179 EOS
1010 apply_manifest(pp, :catch_failures => true) 1180 apply_manifest(pp, :catch_failures => true)
1011 end 1181 end
1012 1182
1013 describe file("#{$vhost_dir}/25-test.server.conf") do 1183 describe file("#{$vhost_dir}/25-test.server.conf") do
1014 it { should be_file } 1184 it { is_expected.to be_file }
1015 it { should contain 'AssignUserId nobody nobody' } 1185 it { is_expected.to contain 'AssignUserId nobody nobody' }
1016 end 1186 end
1017 end 1187 end
1018 1188
1019 # So what does this work on? 1189 # So what does this work on?
1020 if default['platform'] !~ /^(debian-(6|7)|el-(5|6|7))/ 1190 if default['platform'] !~ /^(debian-(6|7)|el-(5|6|7))/
1033 EOS 1203 EOS
1034 apply_manifest(pp, :catch_failures => true) 1204 apply_manifest(pp, :catch_failures => true)
1035 end 1205 end
1036 1206
1037 describe file("#{$vhost_dir}/25-test.server.conf") do 1207 describe file("#{$vhost_dir}/25-test.server.conf") do
1038 it { should be_file } 1208 it { is_expected.to be_file }
1039 it { should contain 'FastCgiExternalServer localhost -socket /tmp/fast/1234' } 1209 it { is_expected.to contain 'FastCgiExternalServer localhost -socket /tmp/fast/1234' }
1040 it { should contain '<Directory "/tmp/fast">' } 1210 it { is_expected.to contain '<Directory "/tmp/fast">' }
1041 end 1211 end
1042 end 1212 end
1043 end 1213 end
1044 1214
1045 describe 'additional_includes' do 1215 describe 'additional_includes' do
1046 it 'applies cleanly' do 1216 it 'applies cleanly' do
1047 pp = <<-EOS 1217 pp = <<-EOS
1048 if $::osfamily == 'RedHat' and $::selinux == 'true' { 1218 if $::osfamily == 'RedHat' and $::selinux {
1049 $semanage_package = $::operatingsystemmajrelease ? { 1219 $semanage_package = $::operatingsystemmajrelease ? {
1050 '5' => 'policycoreutils', 1220 '5' => 'policycoreutils',
1051 default => 'policycoreutils-python', 1221 default => 'policycoreutils-python',
1052 } 1222 }
1053 exec { 'set_apache_defaults': 1223 exec { 'set_apache_defaults':
1074 EOS 1244 EOS
1075 apply_manifest(pp, :catch_failures => true) 1245 apply_manifest(pp, :catch_failures => true)
1076 end 1246 end
1077 1247
1078 describe file("#{$vhost_dir}/25-test.server.conf") do 1248 describe file("#{$vhost_dir}/25-test.server.conf") do
1079 it { should be_file } 1249 it { is_expected.to be_file }
1080 it { should contain 'Include "/apache_spec/include"' } 1250 it { is_expected.to contain 'Include "/apache_spec/include"' }
1081 end 1251 end
1082 end 1252 end
1083 1253
1254 describe 'virtualhost without priority prefix' do
1255 it 'applies cleanly' do
1256 pp = <<-EOS
1257 class { 'apache': }
1258 apache::vhost { 'test.server':
1259 priority => false,
1260 docroot => '/tmp'
1261 }
1262 EOS
1263 apply_manifest(pp, :catch_failures => true)
1264 end
1265
1266 describe file("#{$vhost_dir}/test.server.conf") do
1267 it { is_expected.to be_file }
1268 end
1269 end
1084 end 1270 end