-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Allow and ExtendedStatus support to mod_status
I've extended the apache::mod::status class to accept an `$allow_from` parameter similar to the existing apache::mod::info class, as well as added an `$extended_status` parameter to control the ExtendedStatus directive. Added full testing support as well as updated the README.md to indicate that the status class accepts additional parameters.
- Loading branch information
Showing
4 changed files
with
143 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
# This function is called inside the OS specific contexts | ||
def general_status_specs | ||
it { should contain_apache__mod("status") } | ||
|
||
it do | ||
should contain_file("status.conf").with_content( | ||
"<Location /server-status>\n"\ | ||
" SetHandler server-status\n"\ | ||
" Order deny,allow\n"\ | ||
" Deny from all\n"\ | ||
" Allow from 127.0.0.1 ::1\n"\ | ||
"</Location>\n"\ | ||
"ExtendedStatus On\n"\ | ||
"\n"\ | ||
"<IfModule mod_proxy.c>\n"\ | ||
" # Show Proxy LoadBalancer status in mod_status\n"\ | ||
" ProxyStatus On\n"\ | ||
"</IfModule>\n" | ||
) | ||
end | ||
end | ||
|
||
describe 'apache::mod::status', :type => :class do | ||
let :pre_condition do | ||
'include apache' | ||
end | ||
|
||
context "on a Debian OS with default params" do | ||
let :facts do | ||
{ | ||
:osfamily => 'Debian', | ||
:operatingsystemrelease => '6', | ||
:concat_basedir => '/dne', | ||
} | ||
end | ||
|
||
# Load the more generic tests for this context | ||
general_status_specs() | ||
|
||
it { should contain_file("status.conf").with({ | ||
:ensure => 'file', | ||
:path => '/etc/apache2/mods-available/status.conf', | ||
} ) } | ||
it { should contain_file("status.conf symlink").with({ | ||
:ensure => 'link', | ||
:path => '/etc/apache2/mods-enabled/status.conf', | ||
} ) } | ||
end | ||
|
||
context "on a RedHat OS with default params" do | ||
let :facts do | ||
{ | ||
:osfamily => 'RedHat', | ||
:operatingsystemrelease => '6', | ||
:concat_basedir => '/dne', | ||
} | ||
end | ||
|
||
# Load the more generic tests for this context | ||
general_status_specs() | ||
|
||
it { should contain_file("status.conf").with_path("/etc/httpd/conf.d/status.conf") } | ||
end | ||
|
||
context "with $allow_from => ['10.10.10.10','11.11.11.11'], $extended_status => 'Off'" do | ||
let :facts do | ||
{ | ||
:osfamily => 'Debian', | ||
:operatingsystemrelease => '6', | ||
:concat_basedir => '/dne', | ||
} | ||
end | ||
let :params do | ||
{ | ||
:allow_from => ['10.10.10.10','11.11.11.11'], | ||
:extended_status => 'Off', | ||
} | ||
end | ||
it do | ||
should contain_file("status.conf").with_content( | ||
"<Location /server-status>\n"\ | ||
" SetHandler server-status\n"\ | ||
" Order deny,allow\n"\ | ||
" Deny from all\n"\ | ||
" Allow from 10.10.10.10 11.11.11.11\n"\ | ||
"</Location>\n"\ | ||
"ExtendedStatus Off\n"\ | ||
"\n"\ | ||
"<IfModule mod_proxy.c>\n"\ | ||
" # Show Proxy LoadBalancer status in mod_status\n"\ | ||
" ProxyStatus On\n"\ | ||
"</IfModule>\n" | ||
) | ||
end | ||
end | ||
|
||
context "with $allow_from => '10.10.10.10'" do | ||
let :facts do | ||
{ | ||
:osfamily => 'Debian', | ||
:operatingsystemrelease => '6', | ||
:concat_basedir => '/dne', | ||
} | ||
end | ||
let :params do | ||
{ :allow_from => '10.10.10.10' } | ||
end | ||
it 'should expect to fail array validation' do | ||
expect { | ||
should contain_file("status.conf") | ||
}.to raise_error(Puppet::Error) | ||
end | ||
end | ||
|
||
context "with $extended_status => 'Yes'" do | ||
let :facts do | ||
{ | ||
:osfamily => 'Debian', | ||
:operatingsystemrelease => '6', | ||
:concat_basedir => '/dne', | ||
} | ||
end | ||
let :params do | ||
{ :extended_status => 'Yes' } | ||
end | ||
it 'should expect to fail regular expression validation' do | ||
expect { | ||
should contain_file("status.conf") | ||
}.to raise_error(Puppet::Error) | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters