]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/apache/spec/acceptance/default_mods_spec.rb
add Openstack modules to 3rdparty
[dsa-puppet.git] / 3rdparty / modules / apache / spec / acceptance / default_mods_spec.rb
1 require 'spec_helper_acceptance'
2
3 case fact('osfamily')
4 when 'RedHat'
5   mod_dir     = '/etc/httpd/conf.d'
6   servicename = 'httpd'
7 when 'Debian'
8   mod_dir     = '/etc/apache2/mods-available'
9   servicename = 'apache2'
10 when 'FreeBSD'
11   mod_dir     = '/usr/local/etc/apache24/Modules'
12   servicename = 'apache24'
13 when 'Gentoo'
14   mod_dir     = '/etc/apache2/modules.d'
15   servicename = 'apache2'
16 end
17
18 describe 'apache::default_mods class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
19   describe 'no default mods' do
20     # Using puppet_apply as a helper
21     it 'should apply with no errors' do
22       pp = <<-EOS
23         class { 'apache':
24           default_mods => false,
25         }
26       EOS
27
28       # Run it twice and test for idempotency
29       apply_manifest(pp, :catch_failures => true)
30       expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
31     end
32
33     describe service(servicename) do
34       it { is_expected.to be_running }
35     end
36   end
37
38   describe 'no default mods and failing' do
39     # Using puppet_apply as a helper
40     it 'should apply with errors' do
41       pp = <<-EOS
42         class { 'apache':
43           default_mods => false,
44         }
45         apache::vhost { 'defaults.example.com':
46           docroot => '/var/www/defaults',
47           aliases => {
48             alias => '/css',
49             path  => '/var/www/css',
50           },
51           setenv  => 'TEST1 one',
52         }
53       EOS
54
55       apply_manifest(pp, { :expect_failures => true })
56     end
57
58     # Are these the same?
59     describe service(servicename) do
60       it { is_expected.not_to be_running }
61     end
62     describe "service #{servicename}" do
63       it 'should not be running' do
64         shell("pidof #{servicename}", {:acceptable_exit_codes => 1})
65       end
66     end
67   end
68
69   describe 'alternative default mods' do
70     # Using puppet_apply as a helper
71     it 'should apply with no errors' do
72       pp = <<-EOS
73         class { 'apache':
74           default_mods => [
75             'info',
76             'alias',
77             'mime',
78             'env',
79             'expires',
80           ],
81         }
82         apache::vhost { 'defaults.example.com':
83           docroot => '/var/www/defaults',
84           aliases => {
85             alias => '/css',
86             path  => '/var/www/css',
87           },
88           setenv  => 'TEST1 one',
89         }
90       EOS
91
92       apply_manifest(pp, :catch_failures => true)
93       shell('sleep 10')
94       expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
95     end
96
97     describe service(servicename) do
98       it { is_expected.to be_running }
99     end
100   end
101
102   describe 'change loadfile name' do
103     it 'should apply with no errors' do
104       pp = <<-EOS
105         class { 'apache': default_mods => false }
106         ::apache::mod { 'auth_basic':
107           loadfile_name => 'zz_auth_basic.load',
108         }
109       EOS
110       # Run it twice and test for idempotency
111       apply_manifest(pp, :catch_failures => true)
112       expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero
113     end
114
115     describe service(servicename) do
116       it { is_expected.to be_running }
117     end
118
119     describe file("#{mod_dir}/zz_auth_basic.load") do
120       it { is_expected.to be_file }
121     end
122   end
123 end