Skip to content

Commit c07e6f7

Browse files
committed
Add DeflateFilterNote directives
Add the three standard DeflateFilterNote directives when using mod_deflate based on the examples in the documentation here: http://httpd.apache.org/docs/2.2/mod/mod_deflate.html
1 parent b02d29e commit c07e6f7

3 files changed

Lines changed: 122 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
require 'spec_helper_acceptance'
2+
3+
describe 'apache::mod::deflate class' do
4+
case fact('osfamily')
5+
when 'Debian'
6+
mod_dir = '/etc/apache2/mods-available'
7+
service_name = 'apache2'
8+
when 'RedHat'
9+
mod_dir = '/etc/httpd/conf.d'
10+
service_name = 'httpd'
11+
when 'FreeBSD'
12+
mod_dir = '/usr/local/etc/apache22/Modules'
13+
service_name = 'apache22'
14+
end
15+
16+
context "default deflate config" do
17+
it 'succeeds in puppeting deflate' do
18+
pp= <<-EOS
19+
class { 'apache': }
20+
include apache::mod::deflate
21+
EOS
22+
apply_manifest(pp, :catch_failures => true)
23+
end
24+
25+
describe service(service_name) do
26+
it { should be_enabled }
27+
it { should be_running }
28+
end
29+
30+
describe file("#{mod_dir}/deflate.conf") do
31+
it { should contain "AddOutputFilterByType DEFLATE text/html text/plain text/xml" }
32+
it { should contain "AddOutputFilterByType DEFLATE text/css" }
33+
it { should contain "AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript" }
34+
it { should contain "AddOutputFilterByType DEFLATE application/rss+xml" }
35+
it { should contain "DeflateFilterNote Input instream" }
36+
it { should contain "DeflateFilterNote Output outstream" }
37+
it { should contain "DeflateFilterNote Ratio ratio" }
38+
end
39+
end
40+
end

spec/classes/mod/deflate_spec.rb

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# This function is called inside the OS specific contexts
2+
def general_deflate_specs
3+
it { should contain_apache__mod("deflate") }
4+
5+
it do
6+
should contain_file("deflate.conf").with_content(
7+
"AddOutputFilterByType DEFLATE text/html text/plain text/xml\n"\
8+
"AddOutputFilterByType DEFLATE text/css\n"\
9+
"AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript\n"\
10+
"AddOutputFilterByType DEFLATE application/rss+xml\n"\
11+
"\n"\
12+
"DeflateFilterNote Input instream\n"\
13+
"DeflateFilterNote Output outstream\n"\
14+
"DeflateFilterNote Ratio ratio\n"
15+
)
16+
end
17+
end
18+
19+
describe 'apache::mod::deflate', :type => :class do
20+
let :pre_condition do
21+
'include apache'
22+
end
23+
24+
context "On a Debian OS with default params" do
25+
let :facts do
26+
{
27+
:osfamily => 'Debian',
28+
:operatingsystemrelease => '6',
29+
:concat_basedir => '/dne',
30+
}
31+
end
32+
33+
# Load the more generic tests for this context
34+
general_deflate_specs()
35+
36+
it { should contain_file("deflate.conf").with({
37+
:ensure => 'file',
38+
:path => '/etc/apache2/mods-available/deflate.conf',
39+
} ) }
40+
it { should contain_file("deflate.conf symlink").with({
41+
:ensure => 'link',
42+
:path => '/etc/apache2/mods-enabled/deflate.conf',
43+
} ) }
44+
end
45+
46+
context "on a RedHat OS with default params" do
47+
let :facts do
48+
{
49+
:osfamily => 'RedHat',
50+
:operatingsystemrelease => '6',
51+
:concat_basedir => '/dne',
52+
}
53+
end
54+
55+
# Load the more generic tests for this context
56+
general_deflate_specs()
57+
58+
it { should contain_file("deflate.conf").with_path("/etc/httpd/conf.d/deflate.conf") }
59+
end
60+
61+
context "On a FreeBSD OS with default params" do
62+
let :facts do
63+
{
64+
:osfamily => 'FreeBSD',
65+
:operatingsystemrelease => '9',
66+
:concat_basedir => '/dne',
67+
}
68+
end
69+
70+
# Load the more generic tests for this context
71+
general_deflate_specs()
72+
73+
it { should contain_file("deflate.conf").with({
74+
:ensure => 'file',
75+
:path => '/usr/local/etc/apache22/Modules/deflate.conf',
76+
} ) }
77+
end
78+
end

templates/mod/deflate.conf.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ AddOutputFilterByType DEFLATE text/html text/plain text/xml
22
AddOutputFilterByType DEFLATE text/css
33
AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript
44
AddOutputFilterByType DEFLATE application/rss+xml
5+
6+
DeflateFilterNote Input instream
7+
DeflateFilterNote Output outstream
8+
DeflateFilterNote Ratio ratio

0 commit comments

Comments
 (0)