3 # Helper function for testing the contents of `status.conf`
4 def status_conf_spec(allow_from, extended_status, status_path)
6 is_expected.to contain_file("status.conf").with_content(
7 "<Location #{status_path}>\n"\
8 " SetHandler server-status\n"\
11 " Allow from #{Array(allow_from).join(' ')}\n"\
13 "ExtendedStatus #{extended_status}\n"\
15 "<IfModule mod_proxy.c>\n"\
16 " # Show Proxy LoadBalancer status in mod_status\n"\
23 describe 'apache::mod::status', :type => :class do
28 context "on a Debian OS with default params" do
31 :osfamily => 'Debian',
32 :operatingsystemrelease => '6',
33 :concat_basedir => '/dne',
34 :lsbdistcodename => 'squeeze',
35 :operatingsystem => 'Debian',
38 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
43 it { is_expected.to contain_apache__mod("status") }
45 status_conf_spec(["127.0.0.1", "::1"], "On", "/server-status")
47 it { is_expected.to contain_file("status.conf").with({
49 :path => '/etc/apache2/mods-available/status.conf',
52 it { is_expected.to contain_file("status.conf symlink").with({
54 :path => '/etc/apache2/mods-enabled/status.conf',
59 context "on a RedHat OS with default params" do
62 :osfamily => 'RedHat',
63 :operatingsystemrelease => '6',
64 :concat_basedir => '/dne',
65 :operatingsystem => 'RedHat',
68 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
73 it { is_expected.to contain_apache__mod("status") }
75 status_conf_spec(["127.0.0.1", "::1"], "On", "/server-status")
77 it { is_expected.to contain_file("status.conf").with_path("/etc/httpd/conf.d/status.conf") }
81 context "with custom parameters $allow_from => ['10.10.10.10','11.11.11.11'], $extended_status => 'Off', $status_path => '/custom-status'" do
84 :osfamily => 'Debian',
85 :operatingsystemrelease => '6',
86 :concat_basedir => '/dne',
87 :lsbdistcodename => 'squeeze',
88 :operatingsystem => 'Debian',
91 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
97 :allow_from => ['10.10.10.10','11.11.11.11'],
98 :extended_status => 'Off',
99 :status_path => '/custom-status',
103 status_conf_spec(["10.10.10.10", "11.11.11.11"], "Off", "/custom-status")
107 context "with valid parameter type $allow_from => ['10.10.10.10']" do
110 :osfamily => 'Debian',
111 :operatingsystemrelease => '6',
112 :concat_basedir => '/dne',
113 :lsbdistcodename => 'squeeze',
114 :operatingsystem => 'Debian',
117 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
122 { :allow_from => ['10.10.10.10'] }
124 it 'should expect to succeed array validation' do
126 is_expected.to contain_file("status.conf")
127 }.not_to raise_error()
131 context "with invalid parameter type $allow_from => '10.10.10.10'" do
134 :osfamily => 'Debian',
135 :operatingsystemrelease => '6',
136 :concat_basedir => '/dne',
137 :operatingsystem => 'Debian',
140 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
145 { :allow_from => '10.10.10.10' }
147 it 'should expect to fail array validation' do
149 is_expected.to contain_file("status.conf")
150 }.to raise_error(Puppet::Error)
154 # Only On or Off are valid options
155 ['On', 'Off'].each do |valid_param|
156 context "with valid value $extended_status => '#{valid_param}'" do
159 :osfamily => 'Debian',
160 :operatingsystemrelease => '6',
161 :concat_basedir => '/dne',
162 :lsbdistcodename => 'squeeze',
163 :operatingsystem => 'Debian',
166 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
171 { :extended_status => valid_param }
173 it 'should expect to succeed regular expression validation' do
175 is_expected.to contain_file("status.conf")
176 }.not_to raise_error()
181 ['Yes', 'No'].each do |invalid_param|
182 context "with invalid value $extended_status => '#{invalid_param}'" do
185 :osfamily => 'Debian',
186 :operatingsystemrelease => '6',
187 :concat_basedir => '/dne',
188 :operatingsystem => 'Debian',
191 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
196 { :extended_status => invalid_param }
198 it 'should expect to fail regular expression validation' do
200 is_expected.to contain_file("status.conf")
201 }.to raise_error(Puppet::Error)