puppet-httpd/spec/acceptance/basic_spec.rb
Bruno Tavares faf9d932ba Fix proxy and redirect configuration file names.
While working on puppet-lodgeit acceptance tests we found that the
configuration file that `httpd::mod::proxy` creates was not being picked
up by Apache because it was missing the prefix `.conf`. This transition
is required to configure httpd modules correctly on Apache >= 2.4

To prevent Apache from loading two the same configuration twice, we
remove the file without extension, so this change does not affect
running systems.

This change has fixes for `httpd::mod::proxy` and `httpd::mod::redirect`
as they have the same issue. We added tests as well to increase the
confidence on the fix.

The acceptance will be fixed on the follow-up patch, as the redirect
grants are broken for 2.4 as well.

Change-Id: I82241038d687316f91f18209fe8323c12422e2f8
Co-Authored-By: Danilo Ramalho <dramalho@thoughtworks.com>
2015-10-19 15:43:51 -02:00

132 lines
3.9 KiB
Ruby

require 'spec_helper_acceptance'
describe 'puppet-httpd module' do
def pp_path
base_path = File.dirname(__FILE__)
File.join(base_path, 'fixtures')
end
def default_puppet_module
module_path = File.join(pp_path, 'default.pp')
File.read(module_path)
end
it 'should work with no errors' do
apply_manifest(default_puppet_module, catch_failures: true)
end
it 'should be idempotent', :if => ['debian', 'ubuntu'].include?(os[:family]) do
apply_manifest(default_puppet_module, catch_changes: true)
end
it 'should be idempotent', :if => ['fedora', 'redhat'].include?(os[:family]) do
pending('this module is not idempotent on CentOS yet')
apply_manifest(default_puppet_module, catch_changes: true)
end
describe 'required files' do
describe 'RedHat files', :if => ['fedora', 'redhat'].include?(os[:family]) do
describe file('/etc/httpd/conf.d/') do
it { should be_directory }
end
describe file('/etc/httpd/conf.d/50-localhost.conf') do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its(:content) { should include '<VirtualHost *:80>' }
end
end
describe 'Debian files', :if => ['debian', 'ubuntu'].include?(os[:family]) do
describe file('/etc/apache2/sites-enabled/') do
it { should be_directory }
end
describe file('/etc/apache2/sites-enabled/50-localhost.conf') do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its(:content) { should include '<VirtualHost *:80>' }
end
describe file('/etc/apache2/mods-enabled/python.load') do
it { should be_linked_to '../mods-available/python.load' }
end
describe file('/etc/apache2/mods-enabled/ssl.load') do
it { should be_linked_to '../mods-available/ssl.load' }
end
describe file('/etc/apache2/mods-enabled/rewrite.load') do
it { should be_linked_to '../mods-available/rewrite.load' }
end
end
end
describe 'required packages' do
describe 'RedHat packages', :if => ['fedora', 'redhat'].include?(os[:family]) do
required_packages = [
package('httpd'),
package('httpd-devel'),
package('php'),
package('mod_ssl'),
]
required_packages.each do |package|
describe package do
it { should be_installed }
end
end
end
describe 'Debian packages', :if => ['debian', 'ubuntu'].include?(os[:family]) do
required_packages = [
package('apache2'),
package('apache2-dev'),
package('libaprutil1-dev'),
package('libapr1-dev'),
package('libapache2-mod-php5'),
package('libapache2-mod-python'),
]
required_packages.each do |package|
describe package do
it { should be_installed }
end
end
end
end
describe 'required services' do
describe service('httpd'), :if => ['fedora', 'redhat'].include?(os[:family]) do
it { should be_enabled }
it { should be_running }
end
describe service('apache2'), :if => ['debian', 'ubuntu'].include?(os[:family]) do
it { should be_enabled }
it { should be_running }
end
describe command('a2query -m ssl'), :if => ['debian', 'ubuntu'].include?(os[:family]) do
its(:stdout) { should match 'enabled' }
end
describe 'vhosts' do
describe command('curl --verbose http://localhost') do
its(:stdout) { should include 'Index of /' }
end
describe command('curl --verbose -H "Host: proxy" http://localhost/acceptance.txt') do
its(:stdout) { should include 'Acceptance Test' }
end
describe command('curl --verbose -H "Host: redirect" http://localhost') do
its(:stdout) { should include '302' }
its(:stdout) { should include 'http://localhost:8080/acceptance.txt' }
end
end
end
end