apache-formula/test/integration/modules/controls/config_spec.rb
noelmcloughlin 47818fc360 refactor(formula): align to template-formula & improve ci features
FEATURE: Archlinux support
FEATURE: Windows support
FEATURE: Enhanced CI/CD
FEATURE: modular states

BREAKING CHANGE: 'apache.sls' converted to new style 'init.ssl'
BREAKING CHANGE: "logrotate.sls" became "config/logrotate.sls"
BREAKING CHANGE: "debian_full.sls" became "config/debian_full.sls"
BREAKING CHANGE: "flags.sls" became "config/flags.sls"
BREAKING CHANGE: "manage_security" became "config/manage_security.sls"
BREAKING CHANGE: "mod_*.sls" became "config/mod_*.sls"
BREAKING CHANGE: "no_default_host.sls" became "config/no_default_host.sls"
BREAKING CHANGE: "own_default_host.sls" became "config/own_default_host.sls"
BREAKING CHANGE: "register_site.sls" became "config/register_site.sls"
BREAKING CHANGE: "server_status.sls" became "config/server_status.sls"
BREAKING CHANGE: "vhosts/" became "config/vhosts/"
BREAKING CHANGE: "mod_security/" became "config/mod_security/"

NOT-BREAKING CHANGE: 'config.sls' became 'config/init.sls'
NOT-BREAKING CHANGE: 'uninstall.sls' symlinked to 'clean.sls'
2020-10-05 14:24:15 +01:00

111 lines
3.0 KiB
Ruby

# frozen_string_literal: true
control 'apache configuration' do
title 'should match desired lines'
apachectl = 'apachectl -t'
case platform[:family]
when 'debian', 'suse'
vhostdir = '/etc/apache2/sites-available'
logrotatedir = '/etc/logrotate.d/apache2'
logdir = '/var/log/apache2'
moddir = '/etc/apache2/mods-enabled'
sitesdir = '/etc/apache2/sites-enabled'
when 'redhat', 'fedora'
vhostdir = '/etc/httpd/vhosts.d'
logrotatedir = '/etc/logrotate.d/httpd'
logdir = '/var/log/httpd'
moddir = '/etc/httpd/conf.modules.d'
sitesdir = '/etc/httpd/sites-enabled'
apachectl = 'httpd -t'
when 'gentoo'
vhostdir = '/etc/apache2/vhosts.d'
logrotatedir = '/etc/logrotate.d/apache2'
logdir = '/var/log/apache2'
moddir = '/etc/apache2/mods-enabled'
sitesdir = '/etc/apache2/sites-enabled'
# `linux` here is sufficient for `arch`
when 'linux', 'arch'
vhostdir = '/etc/httpd/conf/vhosts'
logrotatedir = '/etc/logrotate.d/httpd'
logdir = '/var/log/httpd'
moddir = '/etc/httpd/conf.modules.d'
sitesdir = '/etc/httpd/sites-enabled'
when 'bsd'
vhostdir = '/usr/local/etc/apache24/Includes'
logdir = '/var/log'
# logrotatedir = ?
# moddir = '?'
# sitesdir = '?'
end
describe command(apachectl) do
its('stdout') { should eq '' }
its('stderr') { should include 'Syntax OK' }
its('exit_status') { should eq 0 }
end
describe file(vhostdir) do
it { should exist }
it { should be_directory }
its('type') { should eq :directory }
end
describe file(logrotatedir) do
it { should exist }
its('type') { should eq :file }
end
describe file(logdir) do
it { should exist }
it { should be_directory }
its('type') { should eq :directory }
end
describe file(moddir) do
it { should exist }
it { should be_directory }
its('type') { should eq :directory }
end
describe file(sitesdir) do
it { should exist }
it { should be_directory }
its('type') { should eq :directory }
end
end
control 'apache configuration (unique)' do
title 'should match desired lines'
case platform[:family]
when 'debian'
config_file = '/etc/apache2/apache2.conf'
wwwdir = '/srv'
when 'suse'
config_file = '/etc/apache2/httpd.conf'
wwwdir = '/srv/www'
when 'redhat', 'fedora'
config_file = '/etc/httpd/conf/httpd.conf'
wwwdir = '/var/www'
when 'gentoo'
config_file = '/etc/apache2/httpd.conf'
wwwdir = '/var/www'
when 'linux', 'arch'
config_file = '/etc/httpd/conf/httpd.conf'
wwwdir = '/srv/http'
when 'bsd'
config_file = '/usr/local/etc/apache24/httpd.conf'
wwwdir = '/usr/local/www/apache24/'
end
describe file(config_file) do
it { should be_file }
it { should be_grouped_into 'root' }
its('mode') { should cmp '0644' }
its('content') do
should include(
'This file is managed by Salt! Do not edit by hand!'
)
end
end
describe file(wwwdir) do
it { should exist }
it { should be_directory }
its('type') { should eq :directory }
end
end