1 require 'spec_helper_acceptance'
3 describe 'apache::mod::pagespeed class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
6 vhost_dir = '/etc/apache2/sites-enabled'
7 mod_dir = '/etc/apache2/mods-available'
8 service_name = 'apache2'
10 vhost_dir = '/etc/httpd/conf.d'
11 mod_dir = '/etc/httpd/conf.d'
12 service_name = 'httpd'
14 vhost_dir = '/usr/local/etc/apache24/Vhosts'
15 mod_dir = '/usr/local/etc/apache24/Modules'
16 service_name = 'apache24'
18 vhost_dir = '/etc/apache2/vhosts.d'
19 mod_dir = '/etc/apache2/modules.d'
20 service_name = 'apache2'
23 context "default pagespeed config" do
24 it 'succeeds in puppeting pagespeed' do
26 if $::osfamily == 'Debian' {
29 apt::source { 'mod-pagespeed':
31 key_server => 'pgp.mit.edu',
32 location => 'http://dl.google.com/linux/mod-pagespeed/deb/',
36 before => Class['apache'],
38 } elsif $::osfamily == 'RedHat' {
39 yumrepo { 'mod-pagespeed':
40 baseurl => "http://dl.google.com/linux/mod-pagespeed/rpm/stable/$::architecture",
43 gpgkey => 'https://dl-ssl.google.com/linux/linux_signing_key.pub',
44 before => Class['apache'],
49 mpm_module => 'prefork',
51 class { 'apache::mod::pagespeed':
52 enable_filters => ['remove_comments'],
53 disable_filters => ['extend_cache'],
54 forbid_filters => ['rewrite_javascript'],
56 apache::vhost { 'pagespeed.example.com':
58 docroot => '/var/www/pagespeed',
60 host { 'pagespeed.example.com': ip => '127.0.0.1', }
61 file { '/var/www/pagespeed/index.html':
63 content => "<html>\n<!-- comment -->\n<body>\n<p>Hello World!</p>\n</body>\n</html>",
66 apply_manifest(pp, :catch_failures => true)
69 describe service(service_name) do
70 it { is_expected.to be_enabled }
71 it { is_expected.to be_running }
74 describe file("#{mod_dir}/pagespeed.conf") do
75 it { is_expected.to contain "AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html" }
76 it { is_expected.to contain "ModPagespeedEnableFilters remove_comments" }
77 it { is_expected.to contain "ModPagespeedDisableFilters extend_cache" }
78 it { is_expected.to contain "ModPagespeedForbidFilters rewrite_javascript" }
81 it 'should answer to pagespeed.example.com and include <head/> and be stripped of comments by mod_pagespeed' do
82 shell("/usr/bin/curl pagespeed.example.com:80") do |r|
83 expect(r.stdout).to match(/<head\/>/)
84 expect(r.stdout).not_to match(/<!-- comment -->/)
85 expect(r.exit_code).to eq(0)