diff --git a/spec/classes/apache_spec.rb b/spec/classes/apache_spec.rb index c2b27fde..65154029 100644 --- a/spec/classes/apache_spec.rb +++ b/spec/classes/apache_spec.rb @@ -1,828 +1,828 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache', type: :class do context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_package('httpd').with( 'notify' => 'Class[Apache::Service]', 'ensure' => 'installed', ) } it { is_expected.to contain_user('www-data') } it { is_expected.to contain_group('www-data') } it { is_expected.to contain_class('apache::service') } it { is_expected.to contain_file('/var/www/html').with( 'ensure' => 'directory', ) } it { is_expected.to contain_file('/etc/apache2/sites-enabled').with( 'ensure' => 'directory', 'recurse' => 'true', 'purge' => 'true' ).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]') } it { is_expected.to contain_file('/etc/apache2/mods-enabled').with( 'ensure' => 'directory', 'recurse' => 'true', 'purge' => 'true' ).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]') } it { is_expected.to contain_file('/etc/apache2/mods-available').with( 'ensure' => 'directory', 'recurse' => 'true', 'purge' => 'false' ).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]') } it { is_expected.to contain_concat('/etc/apache2/ports.conf').with( 'owner' => 'root', 'group' => 'root', 'mode' => '0644' ).that_notifies('Class[Apache::Service]') } # Assert that load files are placed and symlinked for these mods, but no conf file. ['auth_basic', 'authn_file', 'authz_groupfile', 'authz_host', 'authz_user', 'dav', 'env'].each do |modname| it { is_expected.to contain_file("#{modname}.load").with( 'path' => "/etc/apache2/mods-available/#{modname}.load", 'ensure' => 'file', ) } it { is_expected.to contain_file("#{modname}.load symlink").with( 'path' => "/etc/apache2/mods-enabled/#{modname}.load", 'ensure' => 'link', 'target' => "/etc/apache2/mods-available/#{modname}.load", ) } it { is_expected.not_to contain_file("#{modname}.conf") } it { is_expected.not_to contain_file("#{modname}.conf symlink") } end context 'with Apache version < 2.4' do let :params do { apache_version: '2.2' } end it { is_expected.to contain_file('/etc/apache2/apache2.conf').with_content %r{^Include "/etc/apache2/conf\.d/\*\.conf"$} } end context 'with Apache version >= 2.4' do let :params do { apache_version: '2.4', use_optional_includes: true, } end it { is_expected.to contain_file('/etc/apache2/apache2.conf').with_content %r{^IncludeOptional "/etc/apache2/conf\.d/\*\.conf"$} } end context 'when specifying slash encoding behaviour' do let :params do { allow_encoded_slashes: 'nodecode' } end it { is_expected.to contain_file('/etc/apache2/apache2.conf').with_content %r{^AllowEncodedSlashes nodecode$} } end context 'when specifying fileETag behaviour' do let :params do { file_e_tag: 'None' } end it { is_expected.to contain_file('/etc/apache2/apache2.conf').with_content %r{^FileETag None$} } end context 'when specifying canonical name behaviour' do let :params do { use_canonical_name: 'dns' } end it { is_expected.to contain_file('/etc/apache2/apache2.conf').with_content %r{^UseCanonicalName dns$} } end context 'when specifying default character set' do let :params do { default_charset: 'none' } end it { is_expected.to contain_file('/etc/apache2/apache2.conf').with_content %r{^AddDefaultCharset none$} } end # Assert that both load files and conf files are placed and symlinked for these mods ['alias', 'autoindex', 'dav_fs', 'deflate', 'dir', 'mime', 'negotiation', 'setenvif'].each do |modname| it { is_expected.to contain_file("#{modname}.load").with( 'path' => "/etc/apache2/mods-available/#{modname}.load", 'ensure' => 'file', ) } it { is_expected.to contain_file("#{modname}.load symlink").with( 'path' => "/etc/apache2/mods-enabled/#{modname}.load", 'ensure' => 'link', 'target' => "/etc/apache2/mods-available/#{modname}.load", ) } it { is_expected.to contain_file("#{modname}.conf").with( 'path' => "/etc/apache2/mods-available/#{modname}.conf", 'ensure' => 'file', ) } it { is_expected.to contain_file("#{modname}.conf symlink").with( 'path' => "/etc/apache2/mods-enabled/#{modname}.conf", 'ensure' => 'link', 'target' => "/etc/apache2/mods-available/#{modname}.conf", ) } end describe "Check default type with Apache version < 2.2 when default_type => 'none'" do let :params do { apache_version: '2.2', default_type: 'none', } end it { is_expected.to contain_file('/etc/apache2/apache2.conf').with_content %r{^DefaultType none$} } end describe "Check default type with Apache version < 2.2 when default_type => 'text/plain'" do let :params do { apache_version: '2.2', default_type: 'text/plain', } end it { is_expected.to contain_file('/etc/apache2/apache2.conf').with_content %r{^DefaultType text/plain$} } end describe 'Check default type with Apache version >= 2.4' do let :params do { apache_version: '2.4' } end it { is_expected.to contain_file('/etc/apache2/apache2.conf').without_content %r{^DefaultType [.]*$} } end describe "Don't create user resource when parameter manage_user is false" do let :params do { manage_user: false } end it { is_expected.not_to contain_user('www-data') } it { is_expected.to contain_file('/etc/apache2/apache2.conf').with_content %r{^User www-data\n} } end describe "Don't create group resource when parameter manage_group is false" do let :params do { manage_group: false } end it { is_expected.not_to contain_group('www-data') } it { is_expected.to contain_file('/etc/apache2/apache2.conf').with_content %r{^Group www-data\n} } end describe 'Add extra LogFormats When parameter log_formats is a hash' do let :params do { log_formats: { 'vhost_common' => '%v %h %l %u %t "%r" %>s %b', 'vhost_combined' => '%v %h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-agent}i"', } } end it { is_expected.to contain_file('/etc/apache2/apache2.conf').with_content %r{^LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost_common\n} } it { is_expected.to contain_file('/etc/apache2/apache2.conf').with_content %r{^LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%\{Referer\}i\" \"%\{User-agent\}i\"" vhost_combined\n} } end describe 'Override existing LogFormats When parameter log_formats is a hash' do let :params do { log_formats: { 'common' => '%v %h %l %u %t "%r" %>s %b', 'combined' => '%v %h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-agent}i"', } } end expected = [ %r{^LogFormat "%v %h %l %u %t \"%r\" %>s %b" common\n}, %r{^LogFormat "%v %h %l %u %t \"%r\" %>s %b" common\n}, %r{^LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%\{Referer\}i\" \"%\{User-agent\}i\"" combined\n}, ] unexpected = [ %r{^LogFormat "%h %l %u %t \"%r\" %>s %b \"%\{Referer\}i\" \"%\{User-agent\}i\"" combined\n}, %r{^LogFormat "%h %l %u %t \"%r\" %>s %b \"%\{Referer\}i\" \"%\{User-agent\}i\"" combined\n}, ] it 'Expected to contain' do expected.each do |reg| is_expected.to contain_file('/etc/apache2/apache2.conf').with_content reg end end it 'Not expected to contain' do unexpected.each do |reg| is_expected.to contain_file('/etc/apache2/apache2.conf').without_content reg end end end describe 'Alternate mpm_modules when declaring mpm_module => prefork' do let :params do { mpm_module: 'worker' } end it { is_expected.to contain_exec('/usr/sbin/a2dismod event') } it { is_expected.to contain_exec('/usr/sbin/a2dismod prefork') } end context 'on Ubuntu 18.04' do include_examples 'Ubuntu 18.04' it { is_expected.to contain_file('/var/www/html').with( 'ensure' => 'directory', ) } end end context 'on a RedHat 8 OS' do include_examples 'RedHat 8' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_package('httpd').with( 'notify' => 'Class[Apache::Service]', 'ensure' => 'installed', ) } it { is_expected.to contain_user('apache') } it { is_expected.to contain_group('apache') } it { is_expected.to contain_class('apache::service') } it { is_expected.to contain_file('/var/www/html').with( 'ensure' => 'directory', ) } it { is_expected.to contain_file('/etc/httpd/conf.d').with( 'ensure' => 'directory', 'recurse' => 'true', 'purge' => 'true' ).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]') } it { is_expected.to contain_concat('/etc/httpd/conf/ports.conf').with( 'owner' => 'root', 'group' => 'root', 'mode' => '0644' ).that_notifies('Class[Apache::Service]') } describe 'Alternate confd/mod/vhosts directory' do let :params do { vhost_dir: '/etc/httpd/site.d', confd_dir: '/etc/httpd/conf.d', mod_dir: '/etc/httpd/mod.d', } end ['mod.d', 'site.d', 'conf.d'].each do |dir| it { is_expected.to contain_file("/etc/httpd/#{dir}").with( 'ensure' => 'directory', 'recurse' => 'true', 'purge' => 'true' ).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]') } end # Assert that load files are placed for these mods, but no conf file. ['auth_basic', 'authn_file', 'authz_groupfile', 'authz_host', 'authz_user', 'dav', 'env'].each do |modname| it { is_expected.to contain_file("#{modname}.load").with_path( "/etc/httpd/mod.d/#{modname}.load", ) } it { is_expected.not_to contain_file("#{modname}.conf").with_path( "/etc/httpd/mod.d/#{modname}.conf", ) } end # Assert that both load files and conf files are placed for these mods ['alias', 'autoindex', 'dav_fs', 'deflate', 'dir', 'mime', 'negotiation', 'setenvif'].each do |modname| it { is_expected.to contain_file("#{modname}.load").with_path( "/etc/httpd/mod.d/#{modname}.load", ) } it { is_expected.to contain_file("#{modname}.conf").with_path( "/etc/httpd/mod.d/#{modname}.conf", ) } end it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^IncludeOptional "/etc/httpd/site\.d/\*"$} } it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^Include "/etc/httpd/mod\.d/\*\.conf"$} } it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^Include "/etc/httpd/mod\.d/\*\.load"$} } end describe 'Alternate confd/mod/vhosts directory with Apache version < 2.4' do let :params do { vhost_dir: '/etc/httpd/site.d', confd_dir: '/etc/httpd/conf.d', mod_dir: '/etc/httpd/mod.d', apache_version: '2.2', } end it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^Include "/etc/httpd/conf\.d/\*\.conf"$} } end describe 'Alternate confd/mod/vhosts directory with Apache version >= 2.4' do let :params do { vhost_dir: '/etc/httpd/site.d', confd_dir: '/etc/httpd/conf.d', mod_dir: '/etc/httpd/mod.d', apache_version: '2.4', use_optional_includes: true, } end it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^IncludeOptional "/etc/httpd/conf\.d/\*\.conf"$} } end describe 'Alternate confd/mod/vhosts directory with Apache version < 2.4' do let :params do { vhost_dir: '/etc/httpd/site.d', confd_dir: '/etc/httpd/conf.d', mod_dir: '/etc/httpd/mod.d', apache_version: '2.2', rewrite_lock: '/var/lock/subsys/rewrite-lock', } end it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^RewriteLock /var/lock/subsys/rewrite-lock$} } end describe 'Alternate confd/mod/vhosts directory with Apache version < 2.4' do let :params do { vhost_dir: '/etc/httpd/site.d', confd_dir: '/etc/httpd/conf.d', mod_dir: '/etc/httpd/mod.d', apache_version: '2.2', } end it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').without_content %r{^RewriteLock [.]*$} } end describe 'Alternate confd/mod/vhosts directory with Apache version >= 2.4' do let :params do { vhost_dir: '/etc/httpd/site.d', confd_dir: '/etc/httpd/conf.d', mod_dir: '/etc/httpd/mod.d', apache_version: '2.4', rewrite_lock: '/var/lock/subsys/rewrite-lock', } end it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').without_content %r{^RewriteLock [.]*$} } end describe 'Alternate confd/mod/vhosts directory when specifying slash encoding behaviour' do let :params do { vhost_dir: '/etc/httpd/site.d', confd_dir: '/etc/httpd/conf.d', mod_dir: '/etc/httpd/mod.d', allow_encoded_slashes: 'nodecode', } end it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^AllowEncodedSlashes nodecode$} } end describe 'Alternate confd/mod/vhosts directory when specifying default character set' do let :params do { vhost_dir: '/etc/httpd/site.d', confd_dir: '/etc/httpd/conf.d', mod_dir: '/etc/httpd/mod.d', default_charset: 'none', } end it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^AddDefaultCharset none$} } end describe "Alternate confd/mod/vhosts directory with Apache version < 2.4 when default_type => 'none'" do let :params do { vhost_dir: '/etc/httpd/site.d', confd_dir: '/etc/httpd/conf.d', mod_dir: '/etc/httpd/mod.d', apache_version: '2.2', default_type: 'none', } end it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^DefaultType none$} } end describe "Alternate confd/mod/vhosts directory with Apache version < 2.4 when default_type => 'text/plain'" do let :params do { vhost_dir: '/etc/httpd/site.d', confd_dir: '/etc/httpd/conf.d', mod_dir: '/etc/httpd/mod.d', apache_version: '2.2', default_type: 'text/plain', } end it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^DefaultType text/plain$} } end describe 'Alternate confd/mod/vhosts directory with Apache version >= 2.4' do let :params do { vhost_dir: '/etc/httpd/site.d', confd_dir: '/etc/httpd/conf.d', mod_dir: '/etc/httpd/mod.d', apache_version: '2.4', } end it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').without_content %r{^DefaultType [.]*$} } end describe 'Alternate conf directory' do let :params do { conf_dir: '/opt/rh/root/etc/httpd/conf' } end it { is_expected.to contain_file('/opt/rh/root/etc/httpd/conf/httpd.conf').with( 'ensure' => 'file', ).that_notifies('Class[Apache::Service]').that_requires(['Package[httpd]', 'Concat[/etc/httpd/conf/ports.conf]']) } end describe 'Alternate conf.d directory' do let :params do { confd_dir: '/etc/httpd/special_conf.d' } end it { is_expected.to contain_file('/etc/httpd/special_conf.d').with( 'ensure' => 'directory', 'recurse' => 'true', 'purge' => 'true' ).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]') } end describe 'Alternate mpm_modules when declaring mpm_module is false' do let :params do { mpm_module: false } end unexpected = ['apache::mod::event', 'apache::mod::itk', 'apache::mod::peruser', 'apache::mod::prefork', 'apache::mod::worker'] it 'does not declare mpm modules' do unexpected.each do |not_expect| is_expected.not_to contain_class(not_expect) end end end describe 'Alternate mpm_modules when declaring mpm_module => prefork' do let :params do { mpm_module: 'prefork' } end it { is_expected.to contain_class('apache::mod::prefork') } it { is_expected.not_to contain_class('apache::mod::event') } it { is_expected.not_to contain_class('apache::mod::itk') } it { is_expected.not_to contain_class('apache::mod::peruser') } it { is_expected.not_to contain_class('apache::mod::worker') } end describe 'Alternate mpm_modules when declaring mpm_module => worker' do let :params do { mpm_module: 'worker' } end it { is_expected.to contain_class('apache::mod::worker') } it { is_expected.not_to contain_class('apache::mod::event') } it { is_expected.not_to contain_class('apache::mod::itk') } it { is_expected.not_to contain_class('apache::mod::peruser') } it { is_expected.not_to contain_class('apache::mod::prefork') } end describe 'different templates for httpd.conf with default' do let :params do { conf_template: 'apache/httpd.conf.erb' } end it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^# Security\n} } end describe 'different templates for httpd.conf with non-default' do let :params do { conf_template: 'site_apache/fake.conf.erb' } end it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^Fake template for rspec.$} } end describe 'default mods without' do let :params do { default_mods: false } end it { is_expected.to contain_apache__mod('authz_host') } it { is_expected.not_to contain_apache__mod('env') } end describe 'default mods custom' do let :params do { default_mods: ['info', 'alias', 'mime', 'env', 'setenv', 'expires'] } end it { is_expected.to contain_apache__mod('authz_host') } it { is_expected.to contain_apache__mod('env') } it { is_expected.to contain_class('apache::mod::info') } it { is_expected.to contain_class('apache::mod::mime') } end describe "Don't create user resource when parameter manage_user is false" do let :params do { manage_user: false } end it { is_expected.not_to contain_user('apache') } it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^User apache\n} } end describe "Don't create group resource when parameter manage_group is false" do let :params do { manage_group: false } end it { is_expected.not_to contain_group('apache') } it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^Group apache\n} } end describe 'sendfile with invalid value' do let :params do { sendfile: 'foo' } end it 'fails' do expect { catalogue }.to raise_error(Puppet::PreformattedError, %r{Evaluation Error: Error while evaluating a Resource Statement, Class\[Apache\]: parameter 'sendfile' expects a match for Enum\['Off', 'On', 'off', 'on'\]}) # rubocop:disable Layout/LineLength end end describe 'sendfile On' do let :params do { sendfile: 'On' } end it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^EnableSendfile On\n} } end describe 'sendfile Off' do let :params do { sendfile: 'Off' } end it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^EnableSendfile Off\n} } end describe 'hostname lookup with invalid value' do let :params do { hostname_lookups: 'foo' } end it 'fails' do expect { catalogue }.to raise_error(Puppet::Error, %r{Evaluation Error}) end end describe 'hostname_lookups On' do let :params do { hostname_lookups: 'On' } end it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^HostnameLookups On\n} } end describe 'hostname_lookups Off' do let :params do { hostname_lookups: 'Off' } end it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^HostnameLookups Off\n} } end describe 'hostname_lookups Double' do let :params do { hostname_lookups: 'Double' } end it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{^HostnameLookups Double\n} } end context 'on Fedora 21' do include_examples 'Fedora 21' it { is_expected.to contain_class('apache').with_apache_version('2.4') } end context 'on Fedora Rawhide' do include_examples 'Fedora Rawhide' it { is_expected.to contain_class('apache').with_apache_version('2.4') } end # kinda obsolete context 'on Fedora 17' do include_examples 'Fedora 17' it { is_expected.to contain_class('apache').with_apache_version('2.2') } end end context 'on a FreeBSD OS' do include_examples 'FreeBSD 10' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_class('apache::package').with('ensure' => 'present') } it { is_expected.to contain_user('www') } it { is_expected.to contain_group('www') } it { is_expected.to contain_class('apache::service') } it { is_expected.to contain_file('/usr/local/www/apache24/data').with( 'ensure' => 'directory', ) } it { is_expected.to contain_file('/usr/local/etc/apache24/Vhosts').with( 'ensure' => 'directory', 'recurse' => 'true', 'purge' => 'true' ).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]') } it { is_expected.to contain_file('/usr/local/etc/apache24/Modules').with( 'ensure' => 'directory', 'recurse' => 'true', 'purge' => 'true' ).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]') } it { is_expected.to contain_concat('/usr/local/etc/apache24/ports.conf').with( 'owner' => 'root', 'group' => 'wheel', 'mode' => '0644' ).that_notifies('Class[Apache::Service]') } # Assert that load files are placed for these mods, but no conf file. ['auth_basic', 'authn_core', 'authn_file', 'authz_groupfile', 'authz_host', 'authz_user', 'dav', 'env'].each do |modname| it { is_expected.to contain_file("#{modname}.load").with( 'path' => "/usr/local/etc/apache24/Modules/#{modname}.load", 'ensure' => 'file', ) } it { is_expected.not_to contain_file("#{modname}.conf") } end # Assert that both load files and conf files are placed for these mods ['alias', 'autoindex', 'dav_fs', 'deflate', 'dir', 'mime', 'negotiation', 'setenvif'].each do |modname| it { is_expected.to contain_file("#{modname}.load").with( 'path' => "/usr/local/etc/apache24/Modules/#{modname}.load", 'ensure' => 'file', ) } it { is_expected.to contain_file("#{modname}.conf").with( 'path' => "/usr/local/etc/apache24/Modules/#{modname}.conf", 'ensure' => 'file', ) } end end context 'on a Gentoo OS' do include_examples 'Gentoo' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_user('apache') } it { is_expected.to contain_group('apache') } it { is_expected.to contain_class('apache::service') } it { is_expected.to contain_file('/var/www/localhost/htdocs').with( 'ensure' => 'directory', ) } it { is_expected.to contain_file('/etc/apache2/vhosts.d').with( 'ensure' => 'directory', 'recurse' => 'true', 'purge' => 'true' ).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]') } it { is_expected.to contain_file('/etc/apache2/modules.d').with( 'ensure' => 'directory', 'recurse' => 'true', 'purge' => 'true' ).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]') } it { is_expected.to contain_concat('/etc/apache2/ports.conf').with( 'owner' => 'root', 'group' => 'wheel', 'mode' => '0644' ).that_notifies('Class[Apache::Service]') } end context 'on all OSes' do include_examples 'RedHat 6' context 'with a custom apache_name parameter' do let :params do { apache_name: 'httpd24-httpd', } end it { is_expected.to contain_package('httpd').with( 'ensure' => 'installed', 'name' => 'httpd24-httpd', ).that_notifies('Class[Apache::Service]') } end context 'with a custom file_mode parameter' do let :params do { file_mode: '0640', } end it { is_expected.to contain_concat('/etc/httpd/conf/ports.conf').with( 'mode' => '0640', ) } end context 'with a custom root_directory_options parameter' do let :params do { root_directory_options: ['-Indexes', '-FollowSymLinks'], } end it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{Options -Indexes -FollowSymLinks} } end context 'with a custom root_directory_secured parameter and Apache < 2.4' do let :params do { apache_version: '2.2', root_directory_secured: true, } end it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{Options FollowSymLinks\n\s+AllowOverride None\n\s+Order deny,allow\n\s+Deny from all} } end context 'with a custom root_directory_secured parameter and Apache >= 2.4' do let :params do { apache_version: '2.4', root_directory_secured: true, } end it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{Options FollowSymLinks\n\s+AllowOverride None\n\s+Require all denied} } end context 'default vhost defaults' do it { is_expected.to contain_apache__vhost('default').with_ensure('present') } it { is_expected.to contain_apache__vhost('default-ssl').with_ensure('absent') } it { is_expected.to contain_file('/etc/httpd/conf/httpd.conf').with_content %r{Options FollowSymLinks} } end context 'without default non-ssl vhost' do let :params do { default_vhost: false, } end it { is_expected.to contain_apache__vhost('default').with_ensure('absent') } it { is_expected.not_to contain_file('/var/www/html') } end context 'with default ssl vhost' do let :params do { default_ssl_vhost: true, } end it { is_expected.to contain_apache__vhost('default-ssl').with_ensure('present') } it { is_expected.to contain_file('/var/www/html') } end end context 'with unsupported osfamily' do include_examples 'Darwin' it { is_expected.to compile.and_raise_error(%r{Unsupported osfamily}) } end end diff --git a/spec/classes/mod/alias_spec.rb b/spec/classes/mod/alias_spec.rb index 9d27c806..8ddb9ef9 100644 --- a/spec/classes/mod/alias_spec.rb +++ b/spec/classes/mod/alias_spec.rb @@ -1,70 +1,70 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::alias', type: :class do it_behaves_like 'a mod class, without including apache' context 'default configuration with parameters' do context 'on a Debian OS', :compile do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_apache__mod('alias') } it { is_expected.to contain_file('alias.conf').with(content: %r{Alias \/icons\/ "\/usr\/share\/apache2\/icons\/"}) } end context 'on a RedHat 6-based OS', :compile do include_examples 'RedHat 6' it { is_expected.to contain_apache__mod('alias') } it { is_expected.to contain_file('alias.conf').with(content: %r{Alias \/icons\/ "\/var\/www\/icons\/"}) } end context 'on a RedHat 7-based OS', :compile do include_examples 'RedHat 7' it { is_expected.to contain_apache__mod('alias') } it { is_expected.to contain_file('alias.conf').with(content: %r{Alias \/icons\/ "\/usr\/share\/httpd\/icons\/"}) } end context 'on a RedHat 8-based OS', :compile do include_examples 'RedHat 8' it { is_expected.to contain_apache__mod('alias') } it { is_expected.to contain_file('alias.conf').with(content: %r{Alias \/icons\/ "\/usr\/share\/httpd\/icons\/"}) } end context 'with icons options', :compile do let :pre_condition do 'class { apache: default_mods => false }' end let :params do { 'icons_options' => 'foo', } end include_examples 'RedHat 7' it { is_expected.to contain_apache__mod('alias') } it { is_expected.to contain_file('alias.conf').with(content: %r{Options foo}) } end context 'with icons path change', :compile do let :pre_condition do 'class { apache: default_mods => false }' end let :params do { 'icons_prefix' => 'apache-icons', } end include_examples 'RedHat 7' it { is_expected.to contain_apache__mod('alias') } it { is_expected.to contain_file('alias.conf').with(content: %r{Alias \/apache-icons\/ "\/usr\/share\/httpd\/icons\/"}) } end context 'on a FreeBSD OS', :compile do include_examples 'FreeBSD 10' it { is_expected.to contain_apache__mod('alias') } it { is_expected.to contain_file('alias.conf').with(content: %r{Alias \/icons\/ "\/usr\/local\/www\/apache24\/icons\/"}) } end end end diff --git a/spec/classes/mod/auth_cas_spec.rb b/spec/classes/mod/auth_cas_spec.rb index d8328d85..717dd58c 100644 --- a/spec/classes/mod/auth_cas_spec.rb +++ b/spec/classes/mod/auth_cas_spec.rb @@ -1,63 +1,63 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::auth_cas', type: :class do context 'default params' do let :params do { cas_login_url: 'https://cas.example.com/login', cas_validate_url: 'https://cas.example.com/validate', cas_cookie_path: '/var/cache/apache2/mod_auth_cas/', } end it_behaves_like 'a mod class, without including apache' end context 'default configuration with parameters' do let :params do { cas_login_url: 'https://cas.example.com/login', cas_validate_url: 'https://cas.example.com/validate', } end context 'on a Debian OS', :compile do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('auth_cas') } it { is_expected.to contain_package('libapache2-mod-auth-cas') } it { is_expected.to contain_file('auth_cas.conf').with_path('/etc/apache2/mods-available/auth_cas.conf') } it { is_expected.to contain_file('/var/cache/apache2/mod_auth_cas/').with_owner('www-data') } end context 'on a RedHat OS', :compile do include_examples 'RedHat 6' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('auth_cas') } it { is_expected.to contain_package('mod_auth_cas') } it { is_expected.to contain_file('auth_cas.conf').with_path('/etc/httpd/conf.d/auth_cas.conf') } it { is_expected.to contain_file('/var/cache/mod_auth_cas/').with_owner('apache') } end context 'vhost setup', :compile do let :pre_condition do "class { 'apache': } apache::vhost { 'test.server': docroot => '/var/www/html', cas_root_proxied_as => 'http://test.server', cas_cookie_path => '/my/cas/path'} " end include_examples 'RedHat 6' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('auth_cas') } it { is_expected.to contain_package('mod_auth_cas') } it { is_expected.to contain_file('auth_cas.conf').with_path('/etc/httpd/conf.d/auth_cas.conf') } it { is_expected.to contain_file('/var/cache/mod_auth_cas/').with_owner('apache') } it { is_expected.to contain_concat__fragment('test.server-auth_cas').with(content: %r{^\s+CASRootProxiedAs http://test.server$}) is_expected.to contain_concat__fragment('test.server-auth_cas').with(content: %r{^\s+CASCookiePath /my/cas/path$}) } end end end diff --git a/spec/classes/mod/auth_gssapi_spec.rb b/spec/classes/mod/auth_gssapi_spec.rb index 231450f0..c8efd071 100644 --- a/spec/classes/mod/auth_gssapi_spec.rb +++ b/spec/classes/mod/auth_gssapi_spec.rb @@ -1,38 +1,38 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::auth_gssapi', type: :class do it_behaves_like 'a mod class, without including apache' context 'default configuration with parameters' do context 'on a Debian OS', :compile do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('auth_gssapi') } it { is_expected.to contain_package('libapache2-mod-auth-gssapi') } end context 'on a RedHat OS', :compile do include_examples 'RedHat 6' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('auth_gssapi') } it { is_expected.to contain_package('mod_auth_gssapi') } end context 'on a FreeBSD OS', :compile do include_examples 'FreeBSD 9' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('auth_gssapi') } it { is_expected.to contain_package('www/mod_auth_gssapi') } end context 'on a Gentoo OS', :compile do include_examples 'Gentoo' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('auth_gssapi') } it { is_expected.to contain_package('www-apache/mod_auth_gssapi') } end end end diff --git a/spec/classes/mod/auth_kerb_spec.rb b/spec/classes/mod/auth_kerb_spec.rb index dd1dd482..d5fef032 100644 --- a/spec/classes/mod/auth_kerb_spec.rb +++ b/spec/classes/mod/auth_kerb_spec.rb @@ -1,57 +1,57 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::auth_kerb', type: :class do it_behaves_like 'a mod class, without including apache' context 'default configuration with parameters' do context 'on a Debian OS', :compile do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('auth_kerb') } it { is_expected.to contain_package('libapache2-mod-auth-kerb') } end context 'on a RedHat OS', :compile do include_examples 'RedHat 6' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('auth_kerb') } it { is_expected.to contain_package('mod_auth_kerb') } end context 'on a FreeBSD OS', :compile do include_examples 'FreeBSD 9' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('auth_kerb') } it { is_expected.to contain_package('www/mod_auth_kerb2') } end context 'on a Gentoo OS', :compile do include_examples 'Gentoo' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('auth_kerb') } it { is_expected.to contain_package('www-apache/mod_auth_kerb') } end end context 'overriding mod_packages' do context 'on a RedHat OS', :compile do include_examples 'RedHat 6' let :pre_condition do <<-MANIFEST include apache::params class { 'apache': mod_packages => merge($::apache::params::mod_packages, { 'auth_kerb' => 'httpd24-mod_auth_kerb', }) } MANIFEST end it { is_expected.to contain_apache__mod('auth_kerb') } it { is_expected.to contain_package('httpd24-mod_auth_kerb') } it { is_expected.not_to contain_package('mod_auth_kerb') } end end end diff --git a/spec/classes/mod/auth_mellon_spec.rb b/spec/classes/mod/auth_mellon_spec.rb index c7358a45..c1ccd4b2 100644 --- a/spec/classes/mod/auth_mellon_spec.rb +++ b/spec/classes/mod/auth_mellon_spec.rb @@ -1,66 +1,66 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::auth_mellon', type: :class do it_behaves_like 'a mod class, without including apache' context 'default configuration with parameters on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' describe 'with no parameters' do it { is_expected.to contain_apache__mod('auth_mellon') } it { is_expected.to contain_package('libapache2-mod-auth-mellon') } it { is_expected.to contain_file('auth_mellon.conf').with_path('/etc/apache2/mods-available/auth_mellon.conf') } it { is_expected.to contain_file('auth_mellon.conf').with_content("MellonPostDirectory \"\/var\/cache\/apache2\/mod_auth_mellon\/\"\n") } end describe 'with parameters' do let :params do { mellon_cache_size: '200', mellon_cache_entry_size: '2010', mellon_lock_file: '/tmp/junk', mellon_post_directory: '/tmp/post', mellon_post_ttl: '5', mellon_post_size: '8', mellon_post_count: '10' } end it { is_expected.to contain_file('auth_mellon.conf').with_content(%r{^MellonCacheSize\s+200$}) } it { is_expected.to contain_file('auth_mellon.conf').with_content(%r{^MellonCacheEntrySize\s+2010$}) } it { is_expected.to contain_file('auth_mellon.conf').with_content(%r{^MellonLockFile\s+"\/tmp\/junk"$}) } it { is_expected.to contain_file('auth_mellon.conf').with_content(%r{^MellonPostDirectory\s+"\/tmp\/post"$}) } it { is_expected.to contain_file('auth_mellon.conf').with_content(%r{^MellonPostTTL\s+5$}) } it { is_expected.to contain_file('auth_mellon.conf').with_content(%r{^MellonPostSize\s+8$}) } it { is_expected.to contain_file('auth_mellon.conf').with_content(%r{^MellonPostCount\s+10$}) } end end context 'default configuration with parameters on a RedHat OS' do include_examples 'RedHat 6' describe 'with no parameters' do it { is_expected.to contain_apache__mod('auth_mellon') } it { is_expected.to contain_package('mod_auth_mellon') } it { is_expected.to contain_file('auth_mellon.conf').with_path('/etc/httpd/conf.d/auth_mellon.conf') } it { is_expected.to contain_file('auth_mellon.conf').with_content("MellonCacheSize 100\nMellonLockFile \"/run/mod_auth_mellon/lock\"\n") } end describe 'with parameters' do let :params do { mellon_cache_size: '200', mellon_cache_entry_size: '2010', mellon_lock_file: '/tmp/junk', mellon_post_directory: '/tmp/post', mellon_post_ttl: '5', mellon_post_size: '8', mellon_post_count: '10' } end it { is_expected.to contain_file('auth_mellon.conf').with_content(%r{^MellonCacheSize\s+200$}) } it { is_expected.to contain_file('auth_mellon.conf').with_content(%r{^MellonCacheEntrySize\s+2010$}) } it { is_expected.to contain_file('auth_mellon.conf').with_content(%r{^MellonLockFile\s+"\/tmp\/junk"$}) } it { is_expected.to contain_file('auth_mellon.conf').with_content(%r{^MellonPostDirectory\s+"\/tmp\/post"$}) } it { is_expected.to contain_file('auth_mellon.conf').with_content(%r{^MellonPostTTL\s+5$}) } it { is_expected.to contain_file('auth_mellon.conf').with_content(%r{^MellonPostSize\s+8$}) } it { is_expected.to contain_file('auth_mellon.conf').with_content(%r{^MellonPostCount\s+10$}) } end end end diff --git a/spec/classes/mod/auth_openidc_spec.rb b/spec/classes/mod/auth_openidc_spec.rb index c8c90aca..dd40e83c 100644 --- a/spec/classes/mod/auth_openidc_spec.rb +++ b/spec/classes/mod/auth_openidc_spec.rb @@ -1,50 +1,50 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::auth_openidc', type: :class do it_behaves_like 'a mod class, without including apache' context 'default configuration with parameters' do context 'on a Debian OS', :compile do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('auth_openidc') } it { is_expected.to contain_package('libapache2-mod-auth-openidc') } end context 'on a RedHat OS', :compile do include_examples 'RedHat 6' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('auth_openidc') } it { is_expected.to contain_package('mod_auth_openidc') } end context 'on a FreeBSD OS', :compile do include_examples 'FreeBSD 9' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('auth_openidc') } it { is_expected.to contain_package('www/mod_auth_openidc') } end end context 'overriding mod_packages' do context 'on a RedHat OS', :compile do include_examples 'RedHat 6' let :pre_condition do <<-MANIFEST include apache::params class { 'apache': mod_packages => merge($::apache::params::mod_packages, { 'auth_openidc' => 'httpd24-mod_auth_openidc', }) } MANIFEST end it { is_expected.to contain_apache__mod('auth_openidc') } it { is_expected.to contain_package('httpd24-mod_auth_openidc') } it { is_expected.not_to contain_package('mod_auth_openidc') } end end end diff --git a/spec/classes/mod/authn_dbd_spec.rb b/spec/classes/mod/authn_dbd_spec.rb index afd39017..78674161 100644 --- a/spec/classes/mod/authn_dbd_spec.rb +++ b/spec/classes/mod/authn_dbd_spec.rb @@ -1,43 +1,43 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::authn_dbd', type: :class do context 'default params' do let :params do { authn_dbd_params: 'host=db_host port=3306 user=apache password=###### dbname=apache_auth', } end it_behaves_like 'a mod class, without including apache' end context 'default configuration with parameters' do let :params do { authn_dbd_params: 'host=db_host port=3306 user=apache password=###### dbname=apache_auth', authn_dbd_alias: 'db_authn', authn_dbd_query: 'SELECT password FROM authn WHERE username = %s', } end context 'on a Debian OS', :compile do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('authn_dbd') } it { is_expected.to contain_apache__mod('dbd') } it { is_expected.to contain_file('authn_dbd.conf').with_path('/etc/apache2/mods-available/authn_dbd.conf') } end context 'on a RedHat OS', :compile do include_examples 'RedHat 6' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('authn_dbd') } it { is_expected.to contain_apache__mod('dbd') } it { is_expected.to contain_file('authn_dbd.conf').with_path('/etc/httpd/conf.d/authn_dbd.conf') } end end end diff --git a/spec/classes/mod/authnz_ldap_spec.rb b/spec/classes/mod/authnz_ldap_spec.rb index dbd76c0e..27f75d66 100644 --- a/spec/classes/mod/authnz_ldap_spec.rb +++ b/spec/classes/mod/authnz_ldap_spec.rb @@ -1,84 +1,84 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::authnz_ldap', type: :class do it_behaves_like 'a mod class, without including apache' context 'default configuration with parameters on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_class('apache::mod::ldap') } it { is_expected.to contain_apache__mod('authnz_ldap') } context 'default verify_server_cert' do it { is_expected.to contain_file('authnz_ldap.conf').with_content(%r{^LDAPVerifyServerCert On$}) } end context 'verify_server_cert = false' do let(:params) { { verify_server_cert: false } } it { is_expected.to contain_file('authnz_ldap.conf').with_content(%r{^LDAPVerifyServerCert Off$}) } end context 'verify_server_cert = wrong' do let(:params) { { verify_server_cert: 'wrong' } } it 'raises an error' do is_expected.to compile.and_raise_error(%r{parameter 'verify_server_cert' expects a Boolean value, got String}) end end end # Debian context 'default configuration with parameters on a RedHat OS' do on_supported_os.each do |os, os_facts| next unless os.start_with?('redhat') context "On #{os}" do let :facts do os_facts end it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_class('apache::mod::ldap') } it { is_expected.to contain_apache__mod('authnz_ldap') } if os_facts[:operatingsystemmajrelease].to_i >= 7 it { is_expected.to contain_package('mod_ldap') } else it { is_expected.to contain_package('mod_authz_ldap') } end context 'default verify_server_cert' do it { is_expected.to contain_file('authnz_ldap.conf').with_content(%r{^LDAPVerifyServerCert On$}) } end context 'verify_server_cert = false' do let(:params) { { verify_server_cert: false } } it { is_expected.to contain_file('authnz_ldap.conf').with_content(%r{^LDAPVerifyServerCert Off$}) } end context 'verify_server_cert = wrong' do let(:params) { { verify_server_cert: 'wrong' } } it 'raises an error' do is_expected.to compile.and_raise_error(%r{parameter 'verify_server_cert' expects a Boolean value, got String}) end end context 'SCL', if: (os_facts[:operatingsystemmajrelease].to_i >= 6 && os_facts[:operatingsystemmajrelease].to_i < 8) do let(:pre_condition) do "class { 'apache::version': scl_httpd_version => '2.4', scl_php_version => '7.0', } include apache" end it { is_expected.to contain_package('httpd24-mod_ldap') } end end end end # Redhat end diff --git a/spec/classes/mod/authnz_pam_spec.rb b/spec/classes/mod/authnz_pam_spec.rb index 4361fb64..6fb9a6a6 100644 --- a/spec/classes/mod/authnz_pam_spec.rb +++ b/spec/classes/mod/authnz_pam_spec.rb @@ -1,25 +1,25 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::authnz_pam', type: :class do it_behaves_like 'a mod class, without including apache' context 'default configuration with parameters' do context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache') } it { is_expected.to contain_package('libapache2-mod-authnz-pam') } it { is_expected.to contain_apache__mod('authnz_pam') } end # Debian context 'on a RedHat OS' do include_examples 'RedHat 8' it { is_expected.to contain_class('apache') } it { is_expected.to contain_package('mod_authnz_pam') } it { is_expected.to contain_apache__mod('authnz_pam') } end # Redhat end end diff --git a/spec/classes/mod/data_spec.rb b/spec/classes/mod/data_spec.rb index f8491675..52a19f05 100644 --- a/spec/classes/mod/data_spec.rb +++ b/spec/classes/mod/data_spec.rb @@ -1,22 +1,22 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::data', type: :class do context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' let :params do { apache_version: '2.4' } end it { is_expected.to contain_apache__mod('data') } describe 'with Apache version < 2.3' do let :params do { apache_version: '2.2' } end it { is_expected.to compile.and_raise_error(%r{mod_data is only available in Apache 2.3 and later}) } end end end diff --git a/spec/classes/mod/dav_svn_spec.rb b/spec/classes/mod/dav_svn_spec.rb index affdb367..e30744e8 100644 --- a/spec/classes/mod/dav_svn_spec.rb +++ b/spec/classes/mod/dav_svn_spec.rb @@ -1,96 +1,96 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::dav_svn', type: :class do it_behaves_like 'a mod class, without including apache' context 'default configuration with parameters' do context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('dav_svn') } - it { is_expected.to contain_package('libapache2-svn') } + it { is_expected.to contain_package('libapache2-mod-svn') } it { is_expected.to contain_file('dav_svn.load').with_content(%r{LoadModule dav_svn_module}) } describe 'with parameters' do let :params do { 'authz_svn_enabled' => true, } end it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('dav_svn') } - it { is_expected.to contain_package('libapache2-svn') } + it { is_expected.to contain_package('libapache2-mod-svn') } it { is_expected.to contain_apache__mod('authz_svn') } it { is_expected.to contain_file('dav_svn_authz_svn.load').with_content(%r{LoadModule authz_svn_module}) } end end context 'on a RedHat OS' do include_examples 'RedHat 6' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('dav_svn') } it { is_expected.to contain_package('mod_dav_svn') } it { is_expected.to contain_file('dav_svn.load').with_content(%r{LoadModule dav_svn_module}) } describe 'with parameters' do let :params do { 'authz_svn_enabled' => true, } end it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('dav_svn') } it { is_expected.to contain_package('mod_dav_svn') } it { is_expected.to contain_apache__mod('authz_svn') } it { is_expected.to contain_file('dav_svn_authz_svn.load').with_content(%r{LoadModule authz_svn_module}) } end end context 'on a FreeBSD OS' do include_examples 'FreeBSD 9' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('dav_svn') } it { is_expected.to contain_package('devel/subversion') } it { is_expected.to contain_file('dav_svn.load').with_content(%r{LoadModule dav_svn_module}) } describe 'with parameters' do let :params do { 'authz_svn_enabled' => true, } end it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('dav_svn') } it { is_expected.to contain_package('devel/subversion') } it { is_expected.to contain_apache__mod('authz_svn') } it { is_expected.to contain_file('dav_svn_authz_svn.load').with_content(%r{LoadModule authz_svn_module}) } end end context 'on a Gentoo OS', :compile do include_examples 'Gentoo' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('dav_svn') } it { is_expected.to contain_package('dev-vcs/subversion') } it { is_expected.to contain_file('dav_svn.load').with_content(%r{LoadModule dav_svn_module}) } describe 'with parameters' do let :params do { 'authz_svn_enabled' => true, } end it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('dav_svn') } it { is_expected.to contain_package('dev-vcs/subversion') } it { is_expected.to contain_apache__mod('authz_svn') } it { is_expected.to contain_file('dav_svn_authz_svn.load').with_content(%r{LoadModule authz_svn_module}) } end end end end diff --git a/spec/classes/mod/deflate_spec.rb b/spec/classes/mod/deflate_spec.rb index 5c71e7a5..242ee2f2 100644 --- a/spec/classes/mod/deflate_spec.rb +++ b/spec/classes/mod/deflate_spec.rb @@ -1,88 +1,88 @@ # frozen_string_literal: true require 'spec_helper' # This function is called inside the OS specific contexts def general_deflate_specs it { is_expected.to contain_apache__mod('deflate') } expected = "AddOutputFilterByType DEFLATE application/rss+xml\n"\ "AddOutputFilterByType DEFLATE application/x-javascript\n"\ "AddOutputFilterByType DEFLATE text/css\n"\ "AddOutputFilterByType DEFLATE text/html\n"\ "\n"\ "DeflateFilterNote Input instream\n"\ "DeflateFilterNote Output outstream\n"\ "DeflateFilterNote Ratio ratio\n" it do is_expected.to contain_file('deflate.conf').with_content(expected) end end describe 'apache::mod::deflate', type: :class do it_behaves_like 'a mod class, without including apache' context 'default configuration with parameters' do let :pre_condition do 'class { "apache::mod::deflate": types => [ "text/html", "text/css" , "application/x-javascript", "application/rss+xml"], notes => { "Input" => "instream", "Ratio" => "ratio", "Output" => "outstream", } } ' end context 'On a Debian OS with default params' do - include_examples 'Debian 8' + include_examples 'Debian 11' # Load the more generic tests for this context general_deflate_specs it { is_expected.to contain_file('deflate.conf').with(ensure: 'file', path: '/etc/apache2/mods-available/deflate.conf') } it { is_expected.to contain_file('deflate.conf symlink').with(ensure: 'link', path: '/etc/apache2/mods-enabled/deflate.conf') } end context 'on a RedHat OS with default params' do include_examples 'RedHat 6' # Load the more generic tests for this context general_deflate_specs it { is_expected.to contain_file('deflate.conf').with_path('/etc/httpd/conf.d/deflate.conf') } end context 'On a FreeBSD OS with default params' do include_examples 'FreeBSD 9' # Load the more generic tests for this context general_deflate_specs it { is_expected.to contain_file('deflate.conf').with(ensure: 'file', path: '/usr/local/etc/apache24/Modules/deflate.conf') } end context 'On a Gentoo OS with default params' do include_examples 'Gentoo' # Load the more generic tests for this context general_deflate_specs it { is_expected.to contain_file('deflate.conf').with(ensure: 'file', path: '/etc/apache2/modules.d/deflate.conf') } end end end diff --git a/spec/classes/mod/dev_spec.rb b/spec/classes/mod/dev_spec.rb index 7a1200e0..53a61148 100644 --- a/spec/classes/mod/dev_spec.rb +++ b/spec/classes/mod/dev_spec.rb @@ -1,21 +1,21 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::dev', type: :class do let(:pre_condition) do [ 'include apache', ] end it_behaves_like 'a mod class, without including apache' - ['RedHat 6', 'Debian 8', 'FreeBSD 9'].each do |os| + ['RedHat 6', 'Debian 11', 'FreeBSD 9'].each do |os| context "on a #{os} OS" do include_examples os it { is_expected.to contain_class('apache::dev') } end end end diff --git a/spec/classes/mod/dir_spec.rb b/spec/classes/mod/dir_spec.rb index 919d8639..9b9ccc30 100644 --- a/spec/classes/mod/dir_spec.rb +++ b/spec/classes/mod/dir_spec.rb @@ -1,33 +1,33 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::dir', type: :class do - ['Debian 8', 'RedHat 6', 'FreeBSD 9', 'Gentoo'].each do |os| + ['Debian 11', 'RedHat 6', 'FreeBSD 9', 'Gentoo'].each do |os| context "default configuration with parameters on #{os}" do include_examples os context 'passing no parameters' do it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('dir') } it do is_expected.to contain_file('dir.conf') .with_content(%r{^DirectoryIndex }) .with_content(%r{ index\.html }) .with_content(%r{ index\.html\.var }) .with_content(%r{ index\.cgi }) .with_content(%r{ index\.pl }) .with_content(%r{ index\.php }) .with_content(%r{ index\.xhtml$}) end end context "passing indexes => ['example.txt','fearsome.aspx']" do let :params do { indexes: ['example.txt', 'fearsome.aspx'] } end it { is_expected.to contain_file('dir.conf').with_content(%r{ example\.txt }).with_content(%r{ fearsome\.aspx$}) } end end end end diff --git a/spec/classes/mod/disk_cache_spec.rb b/spec/classes/mod/disk_cache_spec.rb index e60e2af5..dc0dc589 100644 --- a/spec/classes/mod/disk_cache_spec.rb +++ b/spec/classes/mod/disk_cache_spec.rb @@ -1,297 +1,297 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::disk_cache', type: :class do context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' let(:params) do { cache_ignore_headers: 'Set-Cookie', } end context 'with Apache version < 2.4' do let :pre_condition do 'class{ "apache": apache_version => "2.2", default_mods => ["cache"], mod_dir => "/tmp/junk", }' end it { is_expected.to compile } it { is_expected.to contain_class('apache::mod::disk_cache') } it { is_expected.to contain_apache__mod('disk_cache') } it { is_expected.to contain_file('disk_cache.conf') .with(content: %r{CacheEnable disk \/\nCacheRoot \"\/var\/cache\/apache2\/mod_disk_cache\"\nCacheDirLevels 2\nCacheDirLength 1\nCacheIgnoreHeaders Set-Cookie}) } end context 'with Apache version >= 2.4' do let :pre_condition do 'class{ "apache": apache_version => "2.4", default_mods => ["cache"], mod_dir => "/tmp/junk", }' end it { is_expected.to compile } it { is_expected.to contain_class('apache::mod::disk_cache') } it { is_expected.to contain_class('apache::mod::cache').that_comes_before('Class[Apache::Mod::Disk_cache]') } it { is_expected.to contain_apache__mod('cache_disk') } it { is_expected.to contain_file('disk_cache.conf') .with(content: %r{CacheEnable disk \/\nCacheRoot \"\/var\/cache\/apache2\/mod_cache_disk\"\nCacheDirLevels 2\nCacheDirLength 1\nCacheIgnoreHeaders Set-Cookie}) } end context 'with $default_cache_enable = false' do let :pre_condition do 'class{ "apache": apache_version => "2.4", default_mods => ["cache"], mod_dir => "/tmp/junk", }' end let(:params) { { 'default_cache_enable' => false } } it { is_expected.to compile } it { is_expected.to contain_class('apache::mod::disk_cache') } it { is_expected.to contain_class('apache::mod::cache').that_comes_before('Class[Apache::Mod::Disk_cache]') } it { is_expected.to contain_apache__mod('cache_disk') } it { is_expected.to contain_file('disk_cache.conf') .with(content: %r{CacheRoot \"\/var\/cache\/apache2\/mod_cache_disk\"\nCacheDirLevels 2\nCacheDirLength 1\n}) } end context 'with $default_cache_enable = true' do let :pre_condition do 'class{ "apache": apache_version => "2.4", default_mods => ["cache"], mod_dir => "/tmp/junk", }' end let(:params) { { 'default_cache_enable' => true } } it { is_expected.to compile } it { is_expected.to contain_class('apache::mod::disk_cache') } it { is_expected.to contain_class('apache::mod::cache').that_comes_before('Class[Apache::Mod::Disk_cache]') } it { is_expected.to contain_apache__mod('cache_disk') } it { is_expected.to contain_file('disk_cache.conf') .with(content: %r{CacheEnable disk \/\nCacheRoot \"\/var\/cache\/apache2\/mod_cache_disk\"\nCacheDirLevels 2\nCacheDirLength 1\n}) } end context 'with $default_cache_enable = foo' do let :pre_condition do 'class{ "apache": apache_version => "2.4", default_mods => ["cache"], mod_dir => "/tmp/junk", }' end let(:params) { { 'default_cache_enable' => 'foo' } } it { is_expected.not_to compile } end end context 'on a RedHat 6-based OS' do include_examples 'RedHat 6' let(:params) do { cache_ignore_headers: 'Set-Cookie', } end context 'with Apache version < 2.4' do let :pre_condition do 'class{ "apache": apache_version => "2.2", default_mods => ["cache"], mod_dir => "/tmp/junk", }' end it { is_expected.to contain_apache__mod('disk_cache') } it { is_expected.to contain_file('disk_cache.conf') .with(content: %r{CacheEnable disk \/\nCacheRoot \"\/var\/cache\/mod_proxy\"\nCacheDirLevels 2\nCacheDirLength 1\nCacheIgnoreHeaders Set-Cookie}) } end context 'with Apache version >= 2.4' do let :pre_condition do 'class{ "apache": apache_version => "2.4", default_mods => ["cache"], mod_dir => "/tmp/junk", }' end it { is_expected.to contain_apache__mod('cache_disk') } it { is_expected.to contain_file('disk_cache.conf') .with(content: %r{CacheEnable disk \/\nCacheRoot \"\/var\/cache\/httpd\/proxy\"\nCacheDirLevels 2\nCacheDirLength 1\nCacheIgnoreHeaders Set-Cookie}) } end context 'with $default_cache_enable = false' do let :pre_condition do 'class{ "apache": apache_version => "2.4", default_mods => ["cache"], mod_dir => "/tmp/junk", }' end let(:params) { { 'default_cache_enable' => false } } it { is_expected.to compile } it { is_expected.to contain_class('apache::mod::disk_cache') } it { is_expected.to contain_class('apache::mod::cache').that_comes_before('Class[Apache::Mod::Disk_cache]') } it { is_expected.to contain_apache__mod('cache_disk') } it { is_expected.to contain_file('disk_cache.conf') .with(content: %r{CacheRoot \"\/var\/cache\/httpd\/proxy\"\nCacheDirLevels 2\nCacheDirLength 1\n}) } end context 'with $default_cache_enable = true' do let :pre_condition do 'class{ "apache": apache_version => "2.4", default_mods => ["cache"], mod_dir => "/tmp/junk", }' end let(:params) { { 'default_cache_enable' => true } } it { is_expected.to compile } it { is_expected.to contain_class('apache::mod::disk_cache') } it { is_expected.to contain_class('apache::mod::cache').that_comes_before('Class[Apache::Mod::Disk_cache]') } it { is_expected.to contain_apache__mod('cache_disk') } it { is_expected.to contain_file('disk_cache.conf') .with(content: %r{CacheEnable disk \/\nCacheRoot \"\/var\/cache\/httpd\/proxy\"\nCacheDirLevels 2\nCacheDirLength 1\n}) } end context 'with $default_cache_enable = foo' do let :pre_condition do 'class{ "apache": apache_version => "2.4", default_mods => ["cache"], mod_dir => "/tmp/junk", }' end let(:params) { { 'default_cache_enable' => 'foo' } } it { is_expected.not_to compile } end end context 'on a FreeBSD OS' do include_examples 'FreeBSD 10' let(:params) do { cache_ignore_headers: 'Set-Cookie', } end context 'with Apache version < 2.4' do let :pre_condition do 'class{ "apache": apache_version => "2.2", default_mods => ["cache"], mod_dir => "/tmp/junk", }' end it { is_expected.to compile } it { is_expected.to contain_class('apache::mod::disk_cache') } it { is_expected.to contain_class('apache::mod::cache').that_comes_before('Class[Apache::Mod::Disk_cache]') } it { is_expected.to contain_apache__mod('disk_cache') } it { is_expected.to contain_file('disk_cache.conf') .with(content: %r{CacheEnable disk \/\nCacheRoot \"\/var\/cache\/mod_disk_cache\"\nCacheDirLevels 2\nCacheDirLength 1\nCacheIgnoreHeaders Set-Cookie}) } end context 'with Apache version >= 2.4' do let :pre_condition do 'class{ "apache": apache_version => "2.4", default_mods => ["cache"], mod_dir => "/tmp/junk", }' end it { is_expected.to compile } it { is_expected.to contain_class('apache::mod::disk_cache') } it { is_expected.to contain_class('apache::mod::cache').that_comes_before('Class[Apache::Mod::Disk_cache]') } it { is_expected.to contain_apache__mod('cache_disk') } it { is_expected.to contain_file('disk_cache.conf') .with(content: %r{CacheEnable disk \/\nCacheRoot \"\/var\/cache\/mod_cache_disk\"\nCacheDirLevels 2\nCacheDirLength 1\nCacheIgnoreHeaders Set-Cookie}) } end context 'with $default_cache_enable = false' do let :pre_condition do 'class{ "apache": apache_version => "2.4", default_mods => ["cache"], mod_dir => "/tmp/junk", }' end let(:params) { { 'default_cache_enable' => false } } it { is_expected.to compile } it { is_expected.to contain_class('apache::mod::disk_cache') } it { is_expected.to contain_class('apache::mod::cache').that_comes_before('Class[Apache::Mod::Disk_cache]') } it { is_expected.to contain_apache__mod('cache_disk') } it { is_expected.to contain_file('disk_cache.conf') .with(content: %r{CacheRoot \"\/var\/cache\/mod_cache_disk\"\nCacheDirLevels 2\nCacheDirLength 1\n}) } end context 'with $default_cache_enable = true' do let :pre_condition do 'class{ "apache": apache_version => "2.4", default_mods => ["cache"], mod_dir => "/tmp/junk", }' end let(:params) { { 'default_cache_enable' => true } } it { is_expected.to compile } it { is_expected.to contain_class('apache::mod::disk_cache') } it { is_expected.to contain_class('apache::mod::cache').that_comes_before('Class[Apache::Mod::Disk_cache]') } it { is_expected.to contain_apache__mod('cache_disk') } it { is_expected.to contain_file('disk_cache.conf') .with(content: %r{CacheEnable disk \/\nCacheRoot \"\/var\/cache\/mod_cache_disk\"\nCacheDirLevels 2\nCacheDirLength 1\n}) } end context 'with $default_cache_enable = foo' do let :pre_condition do 'class{ "apache": apache_version => "2.4", default_mods => ["cache"], mod_dir => "/tmp/junk", }' end let(:params) { { 'default_cache_enable' => 'foo' } } it { is_expected.not_to compile } end end end diff --git a/spec/classes/mod/dumpio_spec.rb b/spec/classes/mod/dumpio_spec.rb index 529e2aa0..88420083 100644 --- a/spec/classes/mod/dumpio_spec.rb +++ b/spec/classes/mod/dumpio_spec.rb @@ -1,44 +1,44 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::dumpio', type: :class do context 'on a Debian OS' do let :pre_condition do 'class{"apache": default_mods => false, mod_dir => "/tmp/junk", }' end - include_examples 'Debian 8' + include_examples 'Debian 11' context 'default configuration fore parameters' do it { is_expected.to compile } it { is_expected.to contain_class('apache::mod::dumpio') } it { is_expected.to contain_file('dumpio.conf').with_path('/tmp/junk/dumpio.conf') } it { is_expected.to contain_file('dumpio.conf').with_content(%r{^\s*DumpIOInput\s+"Off"$}) } it { is_expected.to contain_file('dumpio.conf').with_content(%r{^\s*DumpIOOutput\s+"Off"$}) } end context 'with dumpio_input set to On' do let :params do { dump_io_input: 'On', } end it { is_expected.to contain_file('dumpio.conf').with_content(%r{^\s*DumpIOInput\s+"On"$}) } it { is_expected.to contain_file('dumpio.conf').with_content(%r{^\s*DumpIOOutput\s+"Off"$}) } end context 'with dumpio_ouput set to On' do let :params do { dump_io_output: 'On', } end it { is_expected.to contain_file('dumpio.conf').with_content(%r{^\s*DumpIOInput\s+"Off"$}) } it { is_expected.to contain_file('dumpio.conf').with_content(%r{^\s*DumpIOOutput\s+"On"$}) } end end end diff --git a/spec/classes/mod/event_spec.rb b/spec/classes/mod/event_spec.rb index 70073efc..572baefe 100644 --- a/spec/classes/mod/event_spec.rb +++ b/spec/classes/mod/event_spec.rb @@ -1,171 +1,171 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::event', type: :class do let :pre_condition do 'class { "apache": mpm_module => false, }' end context 'on a FreeBSD OS' do include_examples 'FreeBSD 9' it { is_expected.to contain_class('apache::params') } it { is_expected.not_to contain_apache__mod('event') } it { is_expected.to contain_file('/usr/local/etc/apache24/Modules/event.conf').with_ensure('file') } end context 'on a Gentoo OS' do include_examples 'Gentoo' it { is_expected.to contain_class('apache::params') } it { is_expected.not_to contain_apache__mod('event') } it { is_expected.to contain_file('/etc/apache2/modules.d/event.conf').with_ensure('file') } end context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache::params') } it { is_expected.not_to contain_apache__mod('event') } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file') } it { is_expected.to contain_file('/etc/apache2/mods-enabled/event.conf').with_ensure('link') } context 'Test mpm_event new params' do let :params do { serverlimit: '0', startservers: '1', maxclients: '2', minsparethreads: '3', maxsparethreads: '4', threadsperchild: '5', maxrequestsperchild: '6', threadlimit: '7', listenbacklog: '8', maxrequestworkers: '9', maxconnectionsperchild: '10', } end it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*ServerLimit\s*0}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*StartServers\s*1}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*MaxClients}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*MinSpareThreads\s*3}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*MaxSpareThreads\s*4}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*ThreadsPerChild\s*5}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*MaxRequestsPerChild}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*ThreadLimit\s*7}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*ListenBacklog\s*8}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*MaxRequestWorkers\s*9}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*MaxConnectionsPerChild\s*10}) } end context 'Test mpm_event old style params' do let :params do { serverlimit: '0', startservers: '1', maxclients: '2', minsparethreads: '3', maxsparethreads: '4', threadsperchild: '5', maxrequestsperchild: '6', threadlimit: '7', listenbacklog: '8', maxrequestworkers: :undef, maxconnectionsperchild: :undef, } end it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*ServerLimit\s*0}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*StartServers\s*1}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*MaxClients\s*2}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*MinSpareThreads\s*3}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*MaxSpareThreads\s*4}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*ThreadsPerChild\s*5}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*MaxRequestsPerChild\s*6}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*ThreadLimit\s*7}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').with_content(%r{^\s*ListenBacklog\s*8}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*MaxRequestWorkers}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*MaxConnectionsPerChild}) } end context 'Test mpm_event false params' do let :params do { serverlimit: false, startservers: false, maxclients: false, minsparethreads: false, maxsparethreads: false, threadsperchild: false, maxrequestsperchild: false, threadlimit: false, listenbacklog: false, maxrequestworkers: false, maxconnectionsperchild: false, } end it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*ServerLimit}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*StartServers}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*MaxClients}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*MinSpareThreads}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*MaxSpareThreads}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*ThreadsPerChild}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*MaxRequestsPerChild}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*ThreadLimit}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*ListenBacklog}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*MaxRequestWorkers}) } it { is_expected.to contain_file('/etc/apache2/mods-available/event.conf').with_ensure('file').without_content(%r{^\s*MaxConnectionsPerChild}) } end context 'with Apache version < 2.4' do let :params do { apache_version: '2.2', } end it { is_expected.not_to contain_file('/etc/apache2/mods-available/event.load') } it { is_expected.not_to contain_file('/etc/apache2/mods-enabled/event.load') } it { is_expected.to contain_package('apache2-mpm-event') } end context 'with Apache version >= 2.4' do let :params do { apache_version: '2.4', } end it { is_expected.to contain_file('/etc/apache2/mods-available/event.load').with('ensure' => 'file', 'content' => "LoadModule mpm_event_module /usr/lib/apache2/modules/mod_mpm_event.so\n") } it { is_expected.to contain_file('/etc/apache2/mods-enabled/event.load').with_ensure('link') } end end context 'on a RedHat OS' do include_examples 'RedHat 6' context 'with Apache version >= 2.4' do let :params do { apache_version: '2.4', } end it { is_expected.to contain_class('apache::params') } it { is_expected.not_to contain_apache__mod('worker') } it { is_expected.not_to contain_apache__mod('prefork') } it { is_expected.to contain_file('/etc/httpd/conf.d/event.conf').with_ensure('file') } it { is_expected.to contain_file('/etc/httpd/conf.d/event.load').with('ensure' => 'file', 'content' => "LoadModule mpm_event_module modules/mod_mpm_event.so\n") } end end end diff --git a/spec/classes/mod/expires_spec.rb b/spec/classes/mod/expires_spec.rb index 003a3255..759c46ad 100644 --- a/spec/classes/mod/expires_spec.rb +++ b/spec/classes/mod/expires_spec.rb @@ -1,58 +1,58 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::expires', type: :class do it_behaves_like 'a mod class, without including apache' context 'with expires active', :compile do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_apache__mod('expires') } it { is_expected.to contain_file('expires.conf').with(content: %r{ExpiresActive On\n}) } end context 'with expires default', :compile do let :pre_condition do 'class { apache: default_mods => false }' end let :params do { 'expires_default' => 'access plus 1 month', } end include_examples 'RedHat 7' it { is_expected.to contain_apache__mod('expires') } it { is_expected.to contain_file('expires.conf').with_content( "ExpiresActive On\n" \ "ExpiresDefault \"access plus 1 month\"\n", ) } end context 'with expires by type', :compile do let :pre_condition do 'class { apache: default_mods => false }' end let :params do { 'expires_by_type' => [ { 'text/json' => 'mod plus 1 day' }, { 'text/html' => 'access plus 1 year' }, ], } end include_examples 'RedHat 7' it { is_expected.to contain_apache__mod('expires') } it { is_expected.to contain_file('expires.conf').with_content( "ExpiresActive On\n" \ "ExpiresByType text/json \"mod plus 1 day\"\n" \ "ExpiresByType text/html \"access plus 1 year\"\n", ) } end end diff --git a/spec/classes/mod/ext_filter_spec.rb b/spec/classes/mod/ext_filter_spec.rb index 04d91bd8..7933211c 100644 --- a/spec/classes/mod/ext_filter_spec.rb +++ b/spec/classes/mod/ext_filter_spec.rb @@ -1,42 +1,42 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::ext_filter', type: :class do it_behaves_like 'a mod class, without including apache' context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' describe 'with no parameters' do it { is_expected.to contain_apache__mod('ext_filter') } it { is_expected.not_to contain_file('ext_filter.conf') } end describe 'with parameters' do let :params do { ext_filter_define: { 'filtA' => 'input=A output=B', 'filtB' => 'input=C cmd="C"' } } end it { is_expected.to contain_file('ext_filter.conf').with_content(%r{^ExtFilterDefine\s+filtA\s+input=A output=B$}) } it { is_expected.to contain_file('ext_filter.conf').with_content(%r{^ExtFilterDefine\s+filtB\s+input=C cmd="C"$}) } end end context 'on a RedHat OS' do include_examples 'RedHat 6' describe 'with no parameters' do it { is_expected.to contain_apache__mod('ext_filter') } it { is_expected.not_to contain_file('ext_filter.conf') } end describe 'with parameters' do let :params do { ext_filter_define: { 'filtA' => 'input=A output=B', 'filtB' => 'input=C cmd="C"' } } end it { is_expected.to contain_file('ext_filter.conf').with_path('/etc/httpd/conf.d/ext_filter.conf') } it { is_expected.to contain_file('ext_filter.conf').with_content(%r{^ExtFilterDefine\s+filtA\s+input=A output=B$}) } it { is_expected.to contain_file('ext_filter.conf').with_content(%r{^ExtFilterDefine\s+filtB\s+input=C cmd="C"$}) } end end end diff --git a/spec/classes/mod/fcgid_spec.rb b/spec/classes/mod/fcgid_spec.rb index 680bf787..bc6e76db 100644 --- a/spec/classes/mod/fcgid_spec.rb +++ b/spec/classes/mod/fcgid_spec.rb @@ -1,87 +1,87 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::fcgid', type: :class do it_behaves_like 'a mod class, without including apache' context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('fcgid').with('loadfile_name' => nil) } it { is_expected.to contain_package('libapache2-mod-fcgid') } end context 'on a RHEL6' do include_examples 'RedHat 6' describe 'without parameters' do it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('fcgid').with('loadfile_name' => nil) } it { is_expected.to contain_package('mod_fcgid') } end describe 'with parameters' do let :params do { options: { 'FcgidIPCDir' => '/var/run/fcgidsock', 'SharememPath' => '/var/run/fcgid_shm', 'FcgidMinProcessesPerClass' => '0', 'AddHandler' => 'fcgid-script .fcgi', }, } end expected = [ '', ' AddHandler fcgid-script .fcgi', ' FcgidIPCDir /var/run/fcgidsock', ' FcgidMinProcessesPerClass 0', ' SharememPath /var/run/fcgid_shm', '', ] it 'contains the correct config' do content = catalogue.resource('file', 'fcgid.conf').send(:parameters)[:content] expect(content.split("\n").reject { |c| c =~ %r{(^#|^$)} }).to eq(expected) end end end context 'on RHEL7' do include_examples 'RedHat 7' describe 'without parameters' do it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('fcgid').with('loadfile_name' => 'unixd_fcgid.load') } it { is_expected.to contain_package('mod_fcgid') } end end context 'on a FreeBSD OS' do include_examples 'FreeBSD 10' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('fcgid').with('loadfile_name' => 'unixd_fcgid.load') } it { is_expected.to contain_package('www/mod_fcgid') } end context 'on a Gentoo OS' do include_examples 'Gentoo' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('fcgid').with('loadfile_name' => nil) } it { is_expected.to contain_package('www-apache/mod_fcgid') } end end diff --git a/spec/classes/mod/http2_spec.rb b/spec/classes/mod/http2_spec.rb index af3ff161..347dccca 100644 --- a/spec/classes/mod/http2_spec.rb +++ b/spec/classes/mod/http2_spec.rb @@ -1,89 +1,89 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::http2', type: :class do it_behaves_like 'a mod class, without including apache' context 'default configuration with parameters on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache::mod::http2') } context 'with default values' do let(:expected_content) do <\n" it { is_expected.to contain_file('info.conf').with_content(expected) } end context 'passing restrict_access => false' do let :params do { restrict_access: false, } end it { is_expected.to contain_file('info.conf').with_content( "\n"\ " SetHandler server-info\n"\ "\n", ) } end context "passing allow_from => ['10.10.1.2', '192.168.1.2', '127.0.0.1']" do let :params do { allow_from: ['10.10.1.2', '192.168.1.2', '127.0.0.1'] } end expected = "\n"\ " SetHandler server-info\n"\ " Order deny,allow\n"\ " Deny from all\n"\ " Allow from 10.10.1.2\n"\ " Allow from 192.168.1.2\n"\ " Allow from 127.0.0.1\n"\ "\n" it { is_expected.to contain_file('info.conf').with_content(expected) } end context 'passing both restrict_access and allow_from' do let :params do { restrict_access: false, allow_from: ['10.10.1.2', '192.168.1.2', '127.0.0.1'], } end it { is_expected.to contain_file('info.conf').with_content( "\n"\ " SetHandler server-info\n"\ "\n", ) } end end def general_info_specs_apache24 it { is_expected.to contain_apache__mod('info') } context 'passing no parameters' do expected = "\n"\ " SetHandler server-info\n"\ " Require ip 127.0.0.1 ::1\n"\ "\n" it { is_expected.to contain_file('info.conf').with_content(expected) } end context 'passing restrict_access => false' do let :params do { restrict_access: false, } end it { is_expected.to contain_file('info.conf').with_content( "\n"\ " SetHandler server-info\n"\ "\n", ) } end context "passing allow_from => ['10.10.1.2', '192.168.1.2', '127.0.0.1']" do let :params do { allow_from: ['10.10.1.2', '192.168.1.2', '127.0.0.1'] } end expected = "\n"\ " SetHandler server-info\n"\ " Require ip 10.10.1.2 192.168.1.2 127.0.0.1\n"\ "\n" it { is_expected.to contain_file('info.conf').with_content(expected) } end context 'passing both restrict_access and allow_from' do let :params do { restrict_access: false, allow_from: ['10.10.1.2', '192.168.1.2', '127.0.0.1'], } end it { is_expected.to contain_file('info.conf').with_content( "\n"\ " SetHandler server-info\n"\ "\n", ) } end end describe 'apache::mod::info', type: :class do it_behaves_like 'a mod class, without including apache' context 'On a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' # Load the more generic tests for this context general_info_specs_apache24 it { is_expected.to contain_file('info.conf').with(ensure: 'file', path: '/etc/apache2/mods-available/info.conf') } it { is_expected.to contain_file('info.conf symlink').with(ensure: 'link', path: '/etc/apache2/mods-enabled/info.conf') } end context 'on a RedHat OS' do include_examples 'RedHat 6' # Load the more generic tests for this context general_info_specs_apache22 it { is_expected.to contain_file('info.conf').with(ensure: 'file', path: '/etc/httpd/conf.d/info.conf') } end context 'on a FreeBSD OS' do include_examples 'FreeBSD 10' # Load the more generic tests for this context general_info_specs_apache24 it { is_expected.to contain_file('info.conf').with(ensure: 'file', path: '/usr/local/etc/apache24/Modules/info.conf') } end context 'on a Gentoo OS' do include_examples 'Gentoo' # Load the more generic tests for this context general_info_specs_apache24 it { is_expected.to contain_file('info.conf').with(ensure: 'file', path: '/etc/apache2/modules.d/info.conf') } end end diff --git a/spec/classes/mod/intercept_form_submit_spec.rb b/spec/classes/mod/intercept_form_submit_spec.rb index 7d2d5571..651150fb 100644 --- a/spec/classes/mod/intercept_form_submit_spec.rb +++ b/spec/classes/mod/intercept_form_submit_spec.rb @@ -1,25 +1,25 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::intercept_form_submit', type: :class do it_behaves_like 'a mod class, without including apache' context 'default configuration with parameters' do context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache') } it { is_expected.to contain_package('libapache2-mod-intercept-form-submit') } it { is_expected.to contain_apache__mod('intercept_form_submit') } end # Debian context 'on a RedHat OS' do include_examples 'RedHat 6' it { is_expected.to contain_class('apache') } it { is_expected.to contain_package('mod_intercept_form_submit') } it { is_expected.to contain_apache__mod('intercept_form_submit') } end # Redhat end end diff --git a/spec/classes/mod/itk_spec.rb b/spec/classes/mod/itk_spec.rb index 4812840c..20819e9d 100644 --- a/spec/classes/mod/itk_spec.rb +++ b/spec/classes/mod/itk_spec.rb @@ -1,167 +1,167 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::itk', type: :class do let :pre_condition do 'class { "apache": mpm_module => false, }' end context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache::params') } it { is_expected.not_to contain_apache__mod('itk') } it { is_expected.to contain_file('/etc/apache2/mods-available/itk.conf').with_ensure('file') } it { is_expected.to contain_file('/etc/apache2/mods-enabled/itk.conf').with_ensure('link') } context 'with Apache version < 2.4' do let :params do { apache_version: '2.2', } end it { is_expected.not_to contain_file('/etc/apache2/mods-available/itk.load') } it { is_expected.not_to contain_file('/etc/apache2/mods-enabled/itk.load') } it { is_expected.to contain_package('apache2-mpm-itk') } end context 'with Apache version < 2.4 with enablecapabilities set' do let :params do { apache_version: '2.2', enablecapabilities: true, } end it { is_expected.not_to contain_file('/etc/apache2/mods-available/itk.conf').with_content(%r{EnableCapabilities}) } end context 'with Apache version >= 2.4' do let :pre_condition do 'class { "apache": mpm_module => prefork, }' end let :params do { apache_version: '2.4', } end it { is_expected.to contain_file('/etc/apache2/mods-available/itk.load').with('ensure' => 'file', 'content' => "LoadModule mpm_itk_module /usr/lib/apache2/modules/mod_mpm_itk.so\n") } it { is_expected.to contain_file('/etc/apache2/mods-enabled/itk.load').with_ensure('link') } end context 'with Apache version >= 2.4 with enablecapabilities not set' do let :pre_condition do 'class { "apache": mpm_module => prefork, }' end let :params do { apache_version: '2.4', } end it { is_expected.not_to contain_file('/etc/apache2/mods-available/itk.conf').with_content(%r{EnableCapabilities}) } end end context 'on a RedHat OS' do include_examples 'RedHat 6' it { is_expected.to contain_class('apache::params') } it { is_expected.not_to contain_apache__mod('itk') } it { is_expected.to contain_file('/etc/httpd/conf.d/itk.conf').with_ensure('file') } it { is_expected.to contain_package('httpd-itk') } context 'with Apache version < 2.4' do let :params do { apache_version: '2.2', } end it { is_expected.to contain_file_line('/etc/sysconfig/httpd itk enable').with('require' => 'Package[httpd]') } end context 'with Apache version < 2.4 with enablecapabilities set' do let :params do { apache_version: '2.2', enablecapabilities: 'On', } end it { is_expected.not_to contain_file('/etc/httpd/conf.d/itk.conf').with_content(%r{EnableCapabilities}) } end context 'with Apache version >= 2.4' do let :pre_condition do 'class { "apache": mpm_module => prefork, }' end let :params do { apache_version: '2.4', } end it { is_expected.to contain_file('/etc/httpd/conf.d/itk.load').with('ensure' => 'file', 'content' => "LoadModule mpm_itk_module modules/mod_mpm_itk.so\n") } end context 'with Apache version >= 2.4 with enablecapabilities set' do let :pre_condition do 'class { "apache": mpm_module => prefork, }' end let :params do { apache_version: '2.4', enablecapabilities: false, } end it { is_expected.to contain_file('/etc/httpd/conf.d/itk.conf').with_content(%r{EnableCapabilities Off}) } end end context 'on a FreeBSD OS' do let :pre_condition do 'class { "apache": mpm_module => false, }' end include_examples 'FreeBSD 10' # TODO: fact mpm_module itk? it { is_expected.to contain_class('apache::params') } it { is_expected.not_to contain_apache__mod('itk') } it { is_expected.to contain_file('/usr/local/etc/apache24/Modules/itk.conf').with_ensure('file') } it { is_expected.to contain_package('www/mod_mpm_itk') } context 'with Apache version < 2.4 with enablecapabilities not set' do let :params do { apache_version: '2.2', } end it { is_expected.not_to contain_file('/usr/local/etc/apache24/Modules/itk.conf').with_content(%r{EnableCapabilities}) } end context 'with Apache version >= 2.4 with enablecapabilities set' do let :params do { apache_version: '2.4', enablecapabilities: true, } end it { is_expected.to contain_file('/usr/local/etc/apache24/Modules/itk.conf').with_content(%r{EnableCapabilities On}) } end end end diff --git a/spec/classes/mod/jk_spec.rb b/spec/classes/mod/jk_spec.rb index b6093ab1..1d8593eb 100644 --- a/spec/classes/mod/jk_spec.rb +++ b/spec/classes/mod/jk_spec.rb @@ -1,184 +1,184 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::jk', type: :class do it_behaves_like 'a mod class, without including apache' shared_examples 'minimal resources' do |mod_dir| it { is_expected.to compile } it { is_expected.to compile.with_all_deps } it { is_expected.to create_class('apache::mod::jk') } it { is_expected.to contain_class('apache') } it { is_expected.to contain_apache__mod('jk') } it { is_expected.to contain_file('jk.conf').that_notifies('Class[apache::service]') } it { is_expected.to contain_file('jk.conf').with(path: "#{mod_dir}/jk.conf") } end shared_examples 'specific workers_file' do |mod_dir| # let(:pre_condition) do # 'include apache' # end let(:params) do { workers_file: "#{mod_dir}/workers.properties", workers_file_content: { 'worker_a' => { 'type' => 'ajp13', 'socket_keepalive' => 'true', 'comment' => 'This is worker A', }, 'worker_b' => { 'type' => 'ajp13', 'socket_keepalive' => 'true', 'comment' => 'This is worker B', }, 'worker_maintain' => 40, 'worker_lists' => ['worker_a,worker_b'], }, } end it { is_expected.to compile } it { is_expected.to compile.with_all_deps } expected_content = "# This file is generated automatically by Puppet - DO NOT EDIT\n"\ "# Any manual changes will be overwritten\n"\ "\n"\ "worker.list = worker_a,worker_b\n"\ "\n"\ "worker.maintain = 40\n"\ "\n"\ "# This is worker A\n"\ "worker.worker_a.socket_keepalive=true\n"\ "worker.worker_a.type=ajp13\n"\ "\n"\ "# This is worker B\n"\ "worker.worker_b.socket_keepalive=true\n"\ "worker.worker_b.type=ajp13\n" it { is_expected.to contain_file("#{mod_dir}/workers.properties").with_content(expected_content) } end default_ip = '192.168.1.1' altern8_ip = '10.1.2.3' default_port = 80 altern8_port = 8008 - context 'Debian 8' do - include_examples 'Debian 8' + context 'Debian 11' do + include_examples 'Debian 11' context 'with only required facts and default parameters' do let(:facts) { super().merge('ipaddress' => default_ip) } let(:pre_condition) do 'include apache' end let(:params) do { logroot: '/var/log/apache2', } end let(:mod_dir) { mod_dir } mod_dir = '/etc/apache2/mods-available' it_behaves_like 'minimal resources', mod_dir it_behaves_like 'specific workers_file', mod_dir it { is_expected.to contain_apache__listen("#{default_ip}:#{default_port}") } it { is_expected.to contain_package('libapache2-mod-jk') } it { verify_contents(catalogue, 'jk.conf', ['', '']) } end end context 'RHEL 6' do include_examples 'RedHat 6' let(:pre_condition) do 'include apache' end let(:params) do { logroot: '/var/log/httpd', } end context 'with required facts' do let(:facts) { super().merge('ipaddress' => default_ip) } context 'and default parameters' do let(:mod_dir) { mod_dir } mod_dir = '/etc/httpd/conf.d' it_behaves_like 'minimal resources', mod_dir it_behaves_like 'specific workers_file', mod_dir it { is_expected.to contain_apache__listen("#{default_ip}:#{default_port}") } it { verify_contents(catalogue, 'jk.conf', ['', '']) } end context 'and alternative IP' do let(:params) { super().merge(ip: altern8_ip) } it { is_expected.to contain_apache__listen("#{altern8_ip}:#{default_port}") } end context 'and alternative port' do let(:params) { super().merge(port: altern8_port) } it { is_expected.to contain_apache__listen("#{default_ip}:#{altern8_port}") } end context 'no binding' do let(:params) { super().merge(add_listen: false) } it { is_expected.not_to contain_apache__listen("#{default_ip}:#{default_port}") } end { default: { shm_file: :undef, log_file: :undef, shm_path: '/var/log/httpd/jk-runtime-status', log_path: '/var/log/httpd/mod_jk.log', }, relative: { shm_file: 'shm_file', log_file: 'log_file', shm_path: '/var/log/httpd/shm_file', log_path: '/var/log/httpd/log_file', }, absolute: { shm_file: '/run/shm_file', log_file: '/tmp/log_file', shm_path: '/run/shm_file', log_path: '/tmp/log_file', }, pipe: { shm_file: :undef, log_file: '"|rotatelogs /var/log/httpd/mod_jk.log.%Y%m%d 86400 -180"', shm_path: '/var/log/httpd/jk-runtime-status', log_path: '"|rotatelogs /var/log/httpd/mod_jk.log.%Y%m%d 86400 -180"', }, }.each do |option, paths| context "#{option} shm_file and log_file paths" do let(:params) do super().merge( shm_file: paths[:shm_file], log_file: paths[:log_file], ) end expected = "# This file is generated automatically by Puppet - DO NOT EDIT\n"\ "# Any manual changes will be overwritten\n"\ "\n"\ "\n"\ " JkShmFile #{paths[:shm_path]}\n"\ " JkLogFile #{paths[:log_path]}\n"\ "\n" it { is_expected.to contain_file('jk.conf').with_content(expected) } end end end end end diff --git a/spec/classes/mod/ldap_spec.rb b/spec/classes/mod/ldap_spec.rb index fd14cace..934b62da 100644 --- a/spec/classes/mod/ldap_spec.rb +++ b/spec/classes/mod/ldap_spec.rb @@ -1,97 +1,97 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::ldap', type: :class do it_behaves_like 'a mod class, without including apache' context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_class('apache::mod::ldap') } it { is_expected.to contain_apache__mod('ldap') } context 'default ldap_trusted_global_cert_file' do it { is_expected.to contain_file('ldap.conf').without_content(%r{^LDAPTrustedGlobalCert}) } end context 'ldap_trusted_global_cert_file param' do let(:params) { { ldap_trusted_global_cert_file: 'ca.pem' } } it { is_expected.to contain_file('ldap.conf').with_content(%r{^LDAPTrustedGlobalCert CA_BASE64 ca\.pem$}) } end context 'set multiple ldap params' do let(:params) do { ldap_trusted_global_cert_file: 'ca.pem', ldap_trusted_global_cert_type: 'CA_DER', ldap_trusted_mode: 'TLS', ldap_shared_cache_size: '500000', ldap_cache_entries: '1024', ldap_cache_ttl: '600', ldap_opcache_entries: '1024', ldap_opcache_ttl: '600', ldap_path: '/custom-ldap-status', } end it { is_expected.to contain_file('ldap.conf').with_content(%r{^LDAPTrustedGlobalCert CA_DER ca\.pem$}) } it { is_expected.to contain_file('ldap.conf').with_content(%r{^LDAPTrustedMode TLS$}) } it { is_expected.to contain_file('ldap.conf').with_content(%r{^LDAPSharedCacheSize 500000$}) } it { is_expected.to contain_file('ldap.conf').with_content(%r{^LDAPCacheEntries 1024$}) } it { is_expected.to contain_file('ldap.conf').with_content(%r{^LDAPCacheTTL 600$}) } it { is_expected.to contain_file('ldap.conf').with_content(%r{^LDAPOpCacheEntries 1024$}) } it { is_expected.to contain_file('ldap.conf').with_content(%r{^LDAPOpCacheTTL 600$}) } expected_ldap_path_re = "\n"\ "\s*SetHandler ldap-status\n"\ ".*\n"\ "\n" it { is_expected.to contain_file('ldap.conf').with_content(%r{#{expected_ldap_path_re}}m) } end end # Debian context 'on a RedHat OS' do include_examples 'RedHat 6' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_class('apache::mod::ldap') } it { is_expected.to contain_apache__mod('ldap') } context 'default ldap_trusted_global_cert_file' do it { is_expected.to contain_file('ldap.conf').without_content(%r{^LDAPTrustedGlobalCert}) } end context 'ldap_trusted_global_cert_file param' do let(:params) { { ldap_trusted_global_cert_file: 'ca.pem' } } it { is_expected.to contain_file('ldap.conf').with_content(%r{^LDAPTrustedGlobalCert CA_BASE64 ca\.pem$}) } end context 'ldap_trusted_global_cert_file and ldap_trusted_global_cert_type params' do let(:params) do { ldap_trusted_global_cert_file: 'ca.pem', ldap_trusted_global_cert_type: 'CA_DER', } end it { is_expected.to contain_file('ldap.conf').with_content(%r{^LDAPTrustedGlobalCert CA_DER ca\.pem$}) } end context 'SCL' do let(:pre_condition) do "class { 'apache::version': scl_httpd_version => '2.4', scl_php_version => '7.0', } include apache" end it { is_expected.to contain_package('httpd24-mod_ldap') } end end # Redhat end diff --git a/spec/classes/mod/lookup_identity.rb b/spec/classes/mod/lookup_identity.rb index 4557f990..30353cf3 100644 --- a/spec/classes/mod/lookup_identity.rb +++ b/spec/classes/mod/lookup_identity.rb @@ -1,25 +1,25 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::lookup_identity', type: :class do it_behaves_like 'a mod class, without including apache' context 'default configuration with parameters' do context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache') } it { is_expected.to contain_package('libapache2-mod-lookup-identity') } it { is_expected.to contain_apache__mod('lookup_identity') } end # Debian context 'on a RedHat OS' do include_examples 'RedHat 6' it { is_expected.to contain_class('apache') } it { is_expected.to contain_package('mod_lookup_identity') } it { is_expected.to contain_apache__mod('lookup_identity') } end # Redhat end end diff --git a/spec/classes/mod/mime_magic_spec.rb b/spec/classes/mod/mime_magic_spec.rb index c5b479f2..a66a683f 100644 --- a/spec/classes/mod/mime_magic_spec.rb +++ b/spec/classes/mod/mime_magic_spec.rb @@ -1,59 +1,59 @@ # frozen_string_literal: true require 'spec_helper' # This function is called inside the OS specific contexts def general_mime_magic_specs it { is_expected.to contain_apache__mod('mime_magic') } end describe 'apache::mod::mime_magic', type: :class do it_behaves_like 'a mod class, without including apache' context 'On a Debian OS with default params' do - include_examples 'Debian 8' + include_examples 'Debian 11' general_mime_magic_specs it do is_expected.to contain_file('mime_magic.conf').with_content( "MIMEMagicFile \"/etc/apache2/magic\"\n", ) end it { is_expected.to contain_file('mime_magic.conf').with(ensure: 'file', path: '/etc/apache2/mods-available/mime_magic.conf') } it { is_expected.to contain_file('mime_magic.conf symlink').with(ensure: 'link', path: '/etc/apache2/mods-enabled/mime_magic.conf') } context 'with magic_file => /tmp/Debian_magic' do let :params do { magic_file: '/tmp/Debian_magic' } end it do is_expected.to contain_file('mime_magic.conf').with_content( "MIMEMagicFile \"/tmp/Debian_magic\"\n", ) end end end context 'on a RedHat OS with default params' do include_examples 'RedHat 6' general_mime_magic_specs it do is_expected.to contain_file('mime_magic.conf').with_content( "MIMEMagicFile \"/etc/httpd/conf/magic\"\n", ) end it { is_expected.to contain_file('mime_magic.conf').with_path('/etc/httpd/conf.d/mime_magic.conf') } end end diff --git a/spec/classes/mod/mime_spec.rb b/spec/classes/mod/mime_spec.rb index b7b4525f..88bc6481 100644 --- a/spec/classes/mod/mime_spec.rb +++ b/spec/classes/mod/mime_spec.rb @@ -1,35 +1,35 @@ # frozen_string_literal: true require 'spec_helper' # This function is called inside the OS specific conte, :compilexts def general_mime_specs it { is_expected.to contain_apache__mod('mime') } it do is_expected.to contain_file('mime.conf').with_content(%r{AddHandler type-map var}) is_expected.to contain_file('mime.conf').with_content(%r{ddOutputFilter INCLUDES .shtml}) is_expected.to contain_file('mime.conf').with_content(%r{AddType text/html .shtml}) is_expected.to contain_file('mime.conf').with_content(%r{AddType application/x-compress .Z}) end end describe 'apache::mod::mime', type: :class do it_behaves_like 'a mod class, without including apache' context 'On a Debian OS with default params', :compile do - include_examples 'Debian 8' + include_examples 'Debian 11' general_mime_specs it { is_expected.to contain_file('mime.conf').with_path('/etc/apache2/mods-available/mime.conf') } end context 'on a RedHat OS with default params', :compile do include_examples 'RedHat 6' general_mime_specs it { is_expected.to contain_file('mime.conf').with_path('/etc/httpd/conf.d/mime.conf') } end end diff --git a/spec/classes/mod/negotiation_spec.rb b/spec/classes/mod/negotiation_spec.rb index 8f270526..0f4bd692 100644 --- a/spec/classes/mod/negotiation_spec.rb +++ b/spec/classes/mod/negotiation_spec.rb @@ -1,42 +1,42 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::negotiation', type: :class do it_behaves_like 'a mod class, without including apache' describe 'OS independent tests' do - include_examples 'Debian 8' + include_examples 'Debian 11' context 'default params' do it { is_expected.to contain_class('apache') } it do is_expected.to contain_file('negotiation.conf').with(ensure: 'file', content: 'LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW ForceLanguagePriority Prefer Fallback ') end end context 'with force_language_priority parameter' do let :params do { force_language_priority: 'Prefer' } end it do is_expected.to contain_file('negotiation.conf').with(ensure: 'file', content: %r{^ForceLanguagePriority Prefer$}) end end context 'with language_priority parameter' do let :params do { language_priority: ['en', 'es'] } end it do is_expected.to contain_file('negotiation.conf').with(ensure: 'file', content: %r{^LanguagePriority en es$}) end end end end diff --git a/spec/classes/mod/pagespeed_spec.rb b/spec/classes/mod/pagespeed_spec.rb index 38e9809e..a9e9d95c 100644 --- a/spec/classes/mod/pagespeed_spec.rb +++ b/spec/classes/mod/pagespeed_spec.rb @@ -1,38 +1,38 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::pagespeed', type: :class do context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('pagespeed') } it { is_expected.to contain_package('mod-pagespeed-stable') } context 'when setting additional_configuration to a Hash' do let :params do { additional_configuration: { 'Key' => 'Value' } } end it { is_expected.to contain_file('pagespeed.conf').with_content %r{Key Value} } end context 'when setting additional_configuration to an Array' do let :params do { additional_configuration: ['Key Value'] } end it { is_expected.to contain_file('pagespeed.conf').with_content %r{Key Value} } end end context 'on a RedHat OS' do include_examples 'RedHat 6' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('pagespeed') } it { is_expected.to contain_package('mod-pagespeed-stable') } it { is_expected.to contain_file('pagespeed.conf') } end end diff --git a/spec/classes/mod/perl_spec.rb b/spec/classes/mod/perl_spec.rb index d2f3d961..84d8cb98 100644 --- a/spec/classes/mod/perl_spec.rb +++ b/spec/classes/mod/perl_spec.rb @@ -1,35 +1,35 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::perl', type: :class do it_behaves_like 'a mod class, without including apache' context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('perl') } it { is_expected.to contain_package('libapache2-mod-perl2') } end context 'on a RedHat OS' do include_examples 'RedHat 6' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('perl') } it { is_expected.to contain_package('mod_perl') } end context 'on a FreeBSD OS' do include_examples 'FreeBSD 9' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('perl') } it { is_expected.to contain_package('www/mod_perl2') } end context 'on a Gentoo OS' do include_examples 'Gentoo' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('perl') } it { is_expected.to contain_package('www-apache/mod_perl') } end end diff --git a/spec/classes/mod/prefork_spec.rb b/spec/classes/mod/prefork_spec.rb index 83e27ed0..51eb8c09 100644 --- a/spec/classes/mod/prefork_spec.rb +++ b/spec/classes/mod/prefork_spec.rb @@ -1,99 +1,99 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::prefork', type: :class do let :pre_condition do 'class { "apache": mpm_module => false, }' end context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache::params') } it { is_expected.not_to contain_apache__mod('prefork') } it { is_expected.to contain_file('/etc/apache2/mods-available/prefork.conf').with_ensure('file') } it { is_expected.to contain_file('/etc/apache2/mods-enabled/prefork.conf').with_ensure('link') } context 'with Apache version < 2.4' do let :params do { apache_version: '2.2', } end it { is_expected.not_to contain_file('/etc/apache2/mods-available/prefork.load') } it { is_expected.not_to contain_file('/etc/apache2/mods-enabled/prefork.load') } it { is_expected.to contain_package('apache2-mpm-prefork') } end context 'with Apache version >= 2.4' do let :params do { apache_version: '2.4', } end it { is_expected.to contain_file('/etc/apache2/mods-available/prefork.load').with('ensure' => 'file', 'content' => "LoadModule mpm_prefork_module /usr/lib/apache2/modules/mod_mpm_prefork.so\n") } it { is_expected.to contain_file('/etc/apache2/mods-enabled/prefork.load').with_ensure('link') } end end context 'on a RedHat OS' do include_examples 'RedHat 6' it { is_expected.to contain_class('apache::params') } it { is_expected.not_to contain_apache__mod('prefork') } it { is_expected.to contain_file('/etc/httpd/conf.d/prefork.conf').with_ensure('file') } context 'with Apache version < 2.4' do let :params do { apache_version: '2.2', } end it { is_expected.to contain_file_line('/etc/sysconfig/httpd prefork enable').with('require' => 'Package[httpd]') } it { is_expected.to contain_file('/etc/httpd/conf.d/prefork.conf').without('content' => %r{MaxRequestWorkers}) } it { is_expected.to contain_file('/etc/httpd/conf.d/prefork.conf').without('content' => %r{MaxConnectionsPerChild}) } end context 'with Apache version >= 2.4' do let :params do { apache_version: '2.4', maxrequestworkers: '512', maxconnectionsperchild: '4000', } end it { is_expected.not_to contain_apache__mod('event') } it { is_expected.to contain_file('/etc/httpd/conf.d/prefork.load').with('ensure' => 'file', 'content' => "LoadModule mpm_prefork_module modules/mod_mpm_prefork.so\n") } it { is_expected.to contain_file('/etc/httpd/conf.d/prefork.conf').without('content' => %r{MaxClients}) } it { is_expected.to contain_file('/etc/httpd/conf.d/prefork.conf').without('content' => %r{MaxRequestsPerChild}) } end end context 'on a FreeBSD OS' do include_examples 'FreeBSD 9' it { is_expected.to contain_class('apache::params') } it { is_expected.not_to contain_apache__mod('prefork') } it { is_expected.to contain_file('/usr/local/etc/apache24/Modules/prefork.conf').with_ensure('file') } end context 'on a Gentoo OS' do include_examples 'Gentoo' it { is_expected.to contain_class('apache::params') } it { is_expected.not_to contain_apache__mod('prefork') } it { is_expected.to contain_file('/etc/apache2/modules.d/prefork.conf').with_ensure('file') } end end diff --git a/spec/classes/mod/proxy_balancer_spec.rb b/spec/classes/mod/proxy_balancer_spec.rb index 48739462..5ba4e4a4 100644 --- a/spec/classes/mod/proxy_balancer_spec.rb +++ b/spec/classes/mod/proxy_balancer_spec.rb @@ -1,56 +1,56 @@ # frozen_string_literal: true require 'spec_helper' # Helper function for testing the contents of `proxy_balancer.conf` def balancer_manager_conf_spec(allow_from, manager_path) expected = "\n"\ " SetHandler balancer-manager\n"\ " Require ip #{Array(allow_from).join(' ')}\n"\ "\n" it do is_expected.to contain_file('proxy_balancer.conf').with_content(expected) end end describe 'apache::mod::proxy_balancer', type: :class do let :pre_condition do [ 'include apache::mod::proxy', ] end it_behaves_like 'a mod class, without including apache' context 'default configuration with default parameters' do context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_apache__mod('proxy_balancer') } it { is_expected.not_to contain_file('proxy_balancer.conf') } it { is_expected.not_to contain_file('proxy_balancer.conf symlink') } end context 'on a RedHat OS' do include_examples 'RedHat 6' it { is_expected.to contain_apache__mod('proxy_balancer') } it { is_expected.not_to contain_file('proxy_balancer.conf') } it { is_expected.not_to contain_file('proxy_balancer.conf symlink') } end end context "default configuration with custom parameters $manager => true, $allow_from => ['10.10.10.10','11.11.11.11'], $status_path => '/custom-manager' on a Debian OS" do - include_examples 'Debian 8' + include_examples 'Debian 11' let :params do { manager: true, allow_from: ['10.10.10.10', '11.11.11.11'], manager_path: '/custom-manager', } end balancer_manager_conf_spec(['10.10.10.10', '11.11.11.11'], '/custom-manager') end end diff --git a/spec/classes/mod/proxy_html_spec.rb b/spec/classes/mod/proxy_html_spec.rb index 417530fe..b212edf7 100644 --- a/spec/classes/mod/proxy_html_spec.rb +++ b/spec/classes/mod/proxy_html_spec.rb @@ -1,66 +1,65 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::proxy_html', type: :class do let :pre_condition do [ 'include apache::mod::proxy', 'include apache::mod::proxy_http', ] end it_behaves_like 'a mod class, without including apache' context 'on a Debian OS' do shared_examples 'debian' do |loadfiles| it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('proxy_html').with(loadfiles: loadfiles) } - it { is_expected.to contain_package('libapache2-mod-proxy-html') } end - include_examples 'Debian 8' + include_examples 'Debian 11' context 'on i386' do let(:facts) do super().merge(hardwaremodel: 'i686', architecture: 'i386') end it { is_expected.to contain_apache__mod('xml2enc').with(loadfiles: nil) } it_behaves_like 'debian', ['/usr/lib/i386-linux-gnu/libxml2.so.2'] end context 'on x64' do let(:facts) do super().merge(hardwaremodel: 'x86_64', architecture: 'amd64') end it { is_expected.to contain_apache__mod('xml2enc').with(loadfiles: nil) } it_behaves_like 'debian', ['/usr/lib/x86_64-linux-gnu/libxml2.so.2'] end end context 'on a RedHat OS', :compile do include_examples 'RedHat 6' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('proxy_html').with(loadfiles: nil) } it { is_expected.to contain_package('mod_proxy_html') } it { is_expected.to contain_apache__mod('xml2enc').with(loadfiles: nil) } end context 'on a FreeBSD OS', :compile do include_examples 'FreeBSD 9' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('proxy_html').with(loadfiles: nil) } it { is_expected.to contain_apache__mod('xml2enc').with(loadfiles: nil) } it { is_expected.to contain_package('www/mod_proxy_html') } end context 'on a Gentoo OS', :compile do include_examples 'Gentoo' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('proxy_html').with(loadfiles: nil) } it { is_expected.to contain_apache__mod('xml2enc').with(loadfiles: nil) } it { is_expected.to contain_package('www-apache/mod_proxy_html') } end end diff --git a/spec/classes/mod/python_spec.rb b/spec/classes/mod/python_spec.rb index aa08c5db..5c7d024c 100644 --- a/spec/classes/mod/python_spec.rb +++ b/spec/classes/mod/python_spec.rb @@ -1,45 +1,45 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::python', type: :class do it_behaves_like 'a mod class, without including apache' context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('python') } it { is_expected.to contain_package('libapache2-mod-python') } end context 'on a RedHat OS' do include_examples 'RedHat 6' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('python') } it { is_expected.to contain_package('mod_python') } it { is_expected.to contain_file('python.load').with_path('/etc/httpd/conf.d/python.load') } describe 'with loadfile_name specified' do let :params do { loadfile_name: 'FooBar' } end it { is_expected.to contain_file('FooBar').with_path('/etc/httpd/conf.d/FooBar') } end end context 'on a FreeBSD OS' do include_examples 'FreeBSD 9' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('python') } it { is_expected.to contain_package('www/mod_python3') } end context 'on a Gentoo OS' do include_examples 'Gentoo' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('python') } it { is_expected.to contain_package('www-apache/mod_python') } end end diff --git a/spec/classes/mod/remoteip_spec.rb b/spec/classes/mod/remoteip_spec.rb index f83c0f2f..69498954 100644 --- a/spec/classes/mod/remoteip_spec.rb +++ b/spec/classes/mod/remoteip_spec.rb @@ -1,115 +1,115 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::remoteip', type: :class do context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' let :params do { apache_version: '2.4' } end it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('remoteip') } it { is_expected.to contain_file('remoteip.conf').with('path' => '/etc/apache2/mods-available/remoteip.conf') } describe 'with header X-Forwarded-For' do let :params do { header: 'X-Forwarded-For' } end it { is_expected.to contain_file('remoteip.conf').with_content(%r{^RemoteIPHeader X-Forwarded-For$}) } end describe 'with internal_proxy => [ 10.42.17.8, 10.42.18.99 ]' do let :params do { internal_proxy: ['10.42.17.8', '10.42.18.99'] } end it { is_expected.to contain_file('remoteip.conf').with_content(%r{^RemoteIPInternalProxy 10.42.17.8$}) } it { is_expected.to contain_file('remoteip.conf').with_content(%r{^RemoteIPInternalProxy 10.42.18.99$}) } end describe 'with IPv4 CIDR in internal_proxy => [ 192.168.1.0/24 ]' do let :params do { internal_proxy: ['192.168.1.0/24'] } end it { is_expected.to contain_file('remoteip.conf').with_content(%r{^RemoteIPInternalProxy 192.168.1.0/24$}) } end describe 'with IPv6 CIDR in internal_proxy => [ fd00:fd00:fd00:2000::/64 ]' do let :params do { internal_proxy: ['fd00:fd00:fd00:2000::/64'] } end it { is_expected.to contain_file('remoteip.conf').with_content(%r{^RemoteIPInternalProxy fd00:fd00:fd00:2000::/64$}) } end describe 'with proxy_ips => [ 10.42.17.8, 10.42.18.99 ]' do let :params do { proxy_ips: ['10.42.17.8', '10.42.18.99'] } end it { is_expected.to contain_file('remoteip.conf').with_content(%r{^RemoteIPInternalProxy 10.42.17.8$}) } it { is_expected.to contain_file('remoteip.conf').with_content(%r{^RemoteIPInternalProxy 10.42.18.99$}) } end describe 'with IPv4 CIDR in proxy_ips => [ 192.168.1.0/24 ]' do let :params do { proxy_ips: ['192.168.1.0/24'] } end it { is_expected.to contain_file('remoteip.conf').with_content(%r{^RemoteIPInternalProxy 192.168.1.0/24$}) } end describe 'with IPv6 CIDR in proxy_ips => [ fd00:fd00:fd00:2000::/64 ]' do let :params do { proxy_ips: ['fd00:fd00:fd00:2000::/64'] } end it { is_expected.to contain_file('remoteip.conf').with_content(%r{^RemoteIPInternalProxy fd00:fd00:fd00:2000::/64$}) } end describe 'with trusted_proxy => [ 10.42.17.8, 10.42.18.99 ]' do let :params do { trusted_proxy: ['10.42.17.8', '10.42.18.99'] } end it { is_expected.to contain_file('remoteip.conf').with_content(%r{^RemoteIPTrustedProxy 10.42.17.8$}) } it { is_expected.to contain_file('remoteip.conf').with_content(%r{^RemoteIPTrustedProxy 10.42.18.99$}) } end describe 'with trusted_proxy_ips => [ 10.42.17.8, 10.42.18.99 ]' do let :params do { trusted_proxy: ['10.42.17.8', '10.42.18.99'] } end it { is_expected.to contain_file('remoteip.conf').with_content(%r{^RemoteIPTrustedProxy 10.42.17.8$}) } it { is_expected.to contain_file('remoteip.conf').with_content(%r{^RemoteIPTrustedProxy 10.42.18.99$}) } end describe 'with proxy_protocol_exceptions => [ 10.42.17.8, 10.42.18.99 ]' do let :params do { proxy_protocol_exceptions: ['10.42.17.8', '10.42.18.99'] } end it { is_expected.to contain_file('remoteip.conf').with_content(%r{^RemoteIPProxyProtocolExceptions 10.42.17.8$}) } it { is_expected.to contain_file('remoteip.conf').with_content(%r{^RemoteIPProxyProtocolExceptions 10.42.18.99$}) } end describe 'with IPv4 CIDR in proxy_protocol_exceptions => [ 192.168.1.0/24 ]' do let :params do { proxy_protocol_exceptions: ['192.168.1.0/24'] } end it { is_expected.to contain_file('remoteip.conf').with_content(%r{^RemoteIPProxyProtocolExceptions 192.168.1.0/24$}) } end describe 'with IPv6 CIDR in proxy_protocol_exceptions => [ fd00:fd00:fd00:2000::/64 ]' do let :params do { proxy_protocol_exceptions: ['fd00:fd00:fd00:2000::/64'] } end it { is_expected.to contain_file('remoteip.conf').with_content(%r{^RemoteIPProxyProtocolExceptions fd00:fd00:fd00:2000::/64$}) } end describe 'with Apache version < 2.4' do let :params do { apache_version: '2.2' } end it { is_expected.to compile.and_raise_error(%r{mod_remoteip is only available in Apache 2.4}) } end end end diff --git a/spec/classes/mod/reqtimeout_spec.rb b/spec/classes/mod/reqtimeout_spec.rb index 7d72ea70..aee45edf 100644 --- a/spec/classes/mod/reqtimeout_spec.rb +++ b/spec/classes/mod/reqtimeout_spec.rb @@ -1,115 +1,115 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::reqtimeout', type: :class do it_behaves_like 'a mod class, without including apache' context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' context 'passing no parameters' do it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('reqtimeout') } it { is_expected.to contain_file('reqtimeout.conf').with_content(%r{^RequestReadTimeout header=20-40,minrate=500\nRequestReadTimeout body=10,minrate=500$}) } end context "passing timeouts => ['header=20-60,minrate=600', 'body=60,minrate=600']" do let :params do { timeouts: ['header=20-60,minrate=600', 'body=60,minrate=600'] } end it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('reqtimeout') } it { is_expected.to contain_file('reqtimeout.conf').with_content(%r{^RequestReadTimeout header=20-60,minrate=600\nRequestReadTimeout body=60,minrate=600$}) } end context "passing timeouts => 'header=20-60,minrate=600'" do let :params do { timeouts: 'header=20-60,minrate=600' } end it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('reqtimeout') } it { is_expected.to contain_file('reqtimeout.conf').with_content(%r{^RequestReadTimeout header=20-60,minrate=600$}) } end end context 'on a RedHat OS' do include_examples 'RedHat 6' context 'passing no parameters' do it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('reqtimeout') } it { is_expected.to contain_file('reqtimeout.conf').with_content(%r{^RequestReadTimeout header=20-40,minrate=500\nRequestReadTimeout body=10,minrate=500$}) } end context "passing timeouts => ['header=20-60,minrate=600', 'body=60,minrate=600']" do let :params do { timeouts: ['header=20-60,minrate=600', 'body=60,minrate=600'] } end it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('reqtimeout') } it { is_expected.to contain_file('reqtimeout.conf').with_content(%r{^RequestReadTimeout header=20-60,minrate=600\nRequestReadTimeout body=60,minrate=600$}) } end context "passing timeouts => 'header=20-60,minrate=600'" do let :params do { timeouts: 'header=20-60,minrate=600' } end it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('reqtimeout') } it { is_expected.to contain_file('reqtimeout.conf').with_content(%r{^RequestReadTimeout header=20-60,minrate=600$}) } end end context 'on a FreeBSD OS' do include_examples 'FreeBSD 9' context 'passing no parameters' do it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('reqtimeout') } it { is_expected.to contain_file('reqtimeout.conf').with_content(%r{^RequestReadTimeout header=20-40,minrate=500\nRequestReadTimeout body=10,minrate=500$}) } end context "passing timeouts => ['header=20-60,minrate=600', 'body=60,minrate=600']" do let :params do { timeouts: ['header=20-60,minrate=600', 'body=60,minrate=600'] } end it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('reqtimeout') } it { is_expected.to contain_file('reqtimeout.conf').with_content(%r{^RequestReadTimeout header=20-60,minrate=600\nRequestReadTimeout body=60,minrate=600$}) } end context "passing timeouts => 'header=20-60,minrate=600'" do let :params do { timeouts: 'header=20-60,minrate=600' } end it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('reqtimeout') } it { is_expected.to contain_file('reqtimeout.conf').with_content(%r{^RequestReadTimeout header=20-60,minrate=600$}) } end end context 'on a Gentoo OS' do include_examples 'Gentoo' context 'passing no parameters' do it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('reqtimeout') } it { is_expected.to contain_file('reqtimeout.conf').with_content(%r{^RequestReadTimeout header=20-40,minrate=500\nRequestReadTimeout body=10,minrate=500$}) } end context "passing timeouts => ['header=20-60,minrate=600', 'body=60,minrate=600']" do let :params do { timeouts: ['header=20-60,minrate=600', 'body=60,minrate=600'] } end it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('reqtimeout') } it { is_expected.to contain_file('reqtimeout.conf').with_content(%r{^RequestReadTimeout header=20-60,minrate=600\nRequestReadTimeout body=60,minrate=600$}) } end context "passing timeouts => 'header=20-60,minrate=600'" do let :params do { timeouts: 'header=20-60,minrate=600' } end it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('reqtimeout') } it { is_expected.to contain_file('reqtimeout.conf').with_content(%r{^RequestReadTimeout header=20-60,minrate=600$}) } end end end diff --git a/spec/classes/mod/rpaf_spec.rb b/spec/classes/mod/rpaf_spec.rb index 44a8e2cd..55063174 100644 --- a/spec/classes/mod/rpaf_spec.rb +++ b/spec/classes/mod/rpaf_spec.rb @@ -1,106 +1,106 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::rpaf', type: :class do it_behaves_like 'a mod class, without including apache' context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('rpaf') } it { is_expected.to contain_package('libapache2-mod-rpaf') } it { is_expected.to contain_file('rpaf.conf').with('path' => '/etc/apache2/mods-available/rpaf.conf') } it { is_expected.to contain_file('rpaf.conf').with_content(%r{^RPAFenable On$}) } describe 'with sethostname => true' do let :params do { sethostname: 'true' } end it { is_expected.to contain_file('rpaf.conf').with_content(%r{^RPAFsethostname On$}) } end describe 'with proxy_ips => [ 10.42.17.8, 10.42.18.99 ]' do let :params do { proxy_ips: ['10.42.17.8', '10.42.18.99'] } end it { is_expected.to contain_file('rpaf.conf').with_content(%r{^RPAFproxy_ips 10.42.17.8 10.42.18.99$}) } end describe 'with header => X-Real-IP' do let :params do { header: 'X-Real-IP' } end it { is_expected.to contain_file('rpaf.conf').with_content(%r{^RPAFheader X-Real-IP$}) } end end context 'on a FreeBSD OS' do include_examples 'FreeBSD 9' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('rpaf') } it { is_expected.to contain_package('www/mod_rpaf2') } it { is_expected.to contain_file('rpaf.conf').with('path' => '/usr/local/etc/apache24/Modules/rpaf.conf') } it { is_expected.to contain_file('rpaf.conf').with_content(%r{^RPAFenable On$}) } describe 'with sethostname => true' do let :params do { sethostname: 'true' } end it { is_expected.to contain_file('rpaf.conf').with_content(%r{^RPAFsethostname On$}) } end describe 'with proxy_ips => [ 10.42.17.8, 10.42.18.99 ]' do let :params do { proxy_ips: ['10.42.17.8', '10.42.18.99'] } end it { is_expected.to contain_file('rpaf.conf').with_content(%r{^RPAFproxy_ips 10.42.17.8 10.42.18.99$}) } end describe 'with header => X-Real-IP' do let :params do { header: 'X-Real-IP' } end it { is_expected.to contain_file('rpaf.conf').with_content(%r{^RPAFheader X-Real-IP$}) } end end context 'on a Gentoo OS' do include_examples 'Gentoo' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('rpaf') } it { is_expected.to contain_package('www-apache/mod_rpaf') } it { is_expected.to contain_file('rpaf.conf').with('path' => '/etc/apache2/modules.d/rpaf.conf') } it { is_expected.to contain_file('rpaf.conf').with_content(%r{^RPAFenable On$}) } describe 'with sethostname => true' do let :params do { sethostname: 'true' } end it { is_expected.to contain_file('rpaf.conf').with_content(%r{^RPAFsethostname On$}) } end describe 'with proxy_ips => [ 10.42.17.8, 10.42.18.99 ]' do let :params do { proxy_ips: ['10.42.17.8', '10.42.18.99'] } end it { is_expected.to contain_file('rpaf.conf').with_content(%r{^RPAFproxy_ips 10.42.17.8 10.42.18.99$}) } end describe 'with header => X-Real-IP' do let :params do { header: 'X-Real-IP' } end it { is_expected.to contain_file('rpaf.conf').with_content(%r{^RPAFheader X-Real-IP$}) } end end end diff --git a/spec/classes/mod/shib_spec.rb b/spec/classes/mod/shib_spec.rb index 2ade2eb5..f9e04429 100644 --- a/spec/classes/mod/shib_spec.rb +++ b/spec/classes/mod/shib_spec.rb @@ -1,21 +1,21 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::shib', type: :class do it_behaves_like 'a mod class, without including apache' context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' describe 'with no parameters' do it { is_expected.to contain_apache__mod('shib2').with_id('mod_shib') } end end context 'on a RedHat OS' do include_examples 'RedHat 6' describe 'with no parameters' do it { is_expected.to contain_apache__mod('shib2').with_id('mod_shib') } end end end diff --git a/spec/classes/mod/speling_spec.rb b/spec/classes/mod/speling_spec.rb index 2a698f0a..5f4e18c5 100644 --- a/spec/classes/mod/speling_spec.rb +++ b/spec/classes/mod/speling_spec.rb @@ -1,18 +1,18 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::speling', type: :class do it_behaves_like 'a mod class, without including apache' context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_apache__mod('speling') } end context 'on a RedHat OS' do include_examples 'RedHat 6' it { is_expected.to contain_apache__mod('speling') } end end diff --git a/spec/classes/mod/ssl_spec.rb b/spec/classes/mod/ssl_spec.rb index 52c62762..d1c1ef8f 100644 --- a/spec/classes/mod/ssl_spec.rb +++ b/spec/classes/mod/ssl_spec.rb @@ -1,347 +1,347 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::ssl', type: :class do it_behaves_like 'a mod class, without including apache' context 'on an unsupported OS' do include_examples 'Unsupported OS' it { is_expected.to compile.and_raise_error(%r{Unsupported osfamily:}) } end context 'on a RedHat' do context '6 OS' do include_examples 'RedHat 6' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('ssl') } it { is_expected.to contain_package('mod_ssl') } it { is_expected.to contain_file('ssl.conf').with_path('/etc/httpd/conf.d/ssl.conf') } it { is_expected.to contain_file('ssl.conf').with_content(%r{SSLProtocol all -SSLv2 -SSLv3}) } end context '8 OS' do include_examples 'RedHat 8' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('ssl') } it { is_expected.to contain_package('mod_ssl') } it { is_expected.to contain_file('ssl.conf').with_path('/etc/httpd/conf.modules.d/ssl.conf') } it { is_expected.to contain_file('ssl.conf').with_content(%r{SSLProtocol all}) } end context '6 OS with a custom package_name parameter' do include_examples 'RedHat 6' let :params do { package_name: 'httpd24-mod_ssl' } end it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('ssl') } it { is_expected.to contain_package('httpd24-mod_ssl') } it { is_expected.not_to contain_package('mod_ssl') } it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLSessionCache "shmcb:/var/cache/mod_ssl/scache\(512000\)"$}) } end context '7 OS with custom directories for PR#1635' do include_examples 'RedHat 7' let :pre_condition do "class { 'apache': confd_dir => '/etc/httpd/conf.puppet.d', default_mods => false, default_vhost => false, mod_dir => '/etc/httpd/conf.modules.puppet.d', vhost_dir => '/etc/httpd/conf.puppet.d', }" end it { is_expected.to contain_package('mod_ssl') } it { is_expected.to contain_file('ssl.conf').with_path('/etc/httpd/conf.puppet.d/ssl.conf') } end end context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('ssl') } it { is_expected.not_to contain_package('libapache2-mod-ssl') } it { is_expected.to contain_file('ssl.conf').with_content(%r{SSLProtocol all -SSLv2 -SSLv3}) } end context 'on a FreeBSD OS' do include_examples 'FreeBSD 9' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('ssl') } end context 'on a Gentoo OS' do include_examples 'Gentoo' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('ssl') } it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLSessionCache "shmcb:/var/run/ssl_scache\(512000\)"$}) } end context 'on a Suse OS' do include_examples 'SLES 12' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('ssl') } it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLSessionCache "shmcb:/var/lib/apache2/ssl_scache\(512000\)"$}) } end # Template config doesn't vary by distro context 'on all distros' do include_examples 'RedHat 6' context 'not setting ssl_pass_phrase_dialog' do it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLPassPhraseDialog builtin$}) } end context 'setting ssl_cert' do let :params do { ssl_cert: '/etc/pki/some/path/localhost.crt', } end it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLCertificateFile}) } end context 'setting ssl_key' do let :params do { ssl_key: '/etc/pki/some/path/localhost.key', } end it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLCertificateKeyFile}) } end context 'setting ssl_ca to a path' do let :params do { ssl_ca: '/etc/pki/some/path/ca.crt', } end it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLCACertificateFile}) } end context 'setting ssl_cert with reload' do let :params do { ssl_cert: '/etc/pki/some/path/localhost.crt', ssl_reload_on_change: true, } end it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLCertificateFile}) } it { is_expected.to contain_file('_etc_pki_some_path_localhost.crt') } end context 'with Apache version < 2.4 - ssl_compression with default value' do let :params do { apache_version: '2.2', } end it { is_expected.not_to contain_file('ssl.conf').with_content(%r{^ SSLCompression Off$}) } end context 'with Apache version < 2.4 - setting ssl_compression to true' do let :params do { apache_version: '2.2', ssl_compression: true, } end it { is_expected.not_to contain_file('ssl.conf').with_content(%r{^ SSLCompression On$}) } end context 'with Apache version < 2.4 - setting ssl_stapling to true' do let :params do { apache_version: '2.2', ssl_stapling: true, } end it { is_expected.not_to contain_file('ssl.conf').with_content(%r{^ SSLUseStapling}) } end context 'with Apache version >= 2.4 - ssl_compression with default value' do let :params do { apache_version: '2.4', } end it { is_expected.not_to contain_file('ssl.conf').with_content(%r{^ SSLCompression Off$}) } end context 'with Apache version >= 2.4' do let :params do { apache_version: '2.4', ssl_compression: true, } end it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLCompression On$}) } end context 'with Apache version >= 2.4 - ssl_sessiontickets with default value' do let :params do { apache_version: '2.4', } end it { is_expected.not_to contain_file('ssl.conf').with_content(%r{^ SSLSessionTickets (Off|On)$}) } end context 'with Apache version >= 2.4 - setting ssl_sessiontickets to false' do let :params do { apache_version: '2.4', ssl_sessiontickets: false, } end it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLSessionTickets Off$}) } end context 'with Apache version >= 2.4 - setting ssl_stapling to true' do let :params do { apache_version: '2.4', ssl_stapling: true, } end it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLUseStapling On$}) } end context 'with Apache version >= 2.4 - setting ssl_stapling_return_errors to true' do let :params do { apache_version: '2.4', ssl_stapling_return_errors: true, } end it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLStaplingReturnResponderErrors On$}) } end context 'with Apache version >= 2.4 - setting stapling_cache' do let :params do { apache_version: '2.4', stapling_cache: '/tmp/customstaplingcache(51200)', } end it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLStaplingCache "shmcb:/tmp/customstaplingcache\(51200\)"$}) } end context 'setting ssl_pass_phrase_dialog' do let :params do { ssl_pass_phrase_dialog: 'exec:/path/to/program', } end it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLPassPhraseDialog exec:\/path\/to\/program$}) } end context 'setting ssl_random_seed_bytes' do let :params do { ssl_random_seed_bytes: '1024', } end it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLRandomSeed startup file:/dev/urandom 1024$}) } end context 'setting ssl_openssl_conf_cmd' do let :params do { ssl_openssl_conf_cmd: 'DHParameters "foo.pem"', } end it { is_expected.to contain_file('ssl.conf').with_content(%r{^\s+SSLOpenSSLConfCmd DHParameters "foo.pem"$}) } end context 'setting ssl_mutex' do let :params do { ssl_mutex: 'posixsem', } end it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLMutex posixsem$}) } end context 'setting ssl_sessioncache' do let :params do { ssl_sessioncache: '/tmp/customsessioncache(51200)', } end it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLSessionCache "shmcb:/tmp/customsessioncache\(51200\)"$}) } end context 'setting ssl_proxy_protocol' do let :params do { ssl_proxy_protocol: ['-ALL', '+TLSv1'], } end it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLProxyProtocol -ALL \+TLSv1$}) } end context 'setting ssl_honorcipherorder' do context 'default value' do it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLHonorCipherOrder On$}) } end context 'force on' do let :params do { ssl_honorcipherorder: true, } end it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLHonorCipherOrder On$}) } end context 'force off' do let :params do { ssl_honorcipherorder: false, } end it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLHonorCipherOrder Off$}) } end context 'set on' do let :params do { ssl_honorcipherorder: 'on', } end it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLHonorCipherOrder On$}) } end context 'set off' do let :params do { ssl_honorcipherorder: 'off', } end it { is_expected.to contain_file('ssl.conf').with_content(%r{^ SSLHonorCipherOrder Off$}) } end end end end diff --git a/spec/classes/mod/status_spec.rb b/spec/classes/mod/status_spec.rb index c4d814bd..1b8740a1 100644 --- a/spec/classes/mod/status_spec.rb +++ b/spec/classes/mod/status_spec.rb @@ -1,234 +1,234 @@ # frozen_string_literal: true require 'spec_helper' # Helper function for testing the contents of `status.conf` # Apache < 2.4 shared_examples 'status_conf_spec' do |allow_from, extended_status, status_path| expected = "\n"\ " SetHandler server-status\n"\ " Order deny,allow\n"\ " Deny from all\n"\ " Allow from #{Array(allow_from).join(' ')}\n"\ "\n"\ "ExtendedStatus #{extended_status}\n"\ "\n"\ "\n"\ " # Show Proxy LoadBalancer status in mod_status\n"\ " ProxyStatus On\n"\ "\n" it('status conf') do is_expected.to contain_file('status.conf').with_content(expected) end end # Apache >= 2.4 def require_directives(requires) if requires == :undef " Require ip 127.0.0.1 ::1\n" elsif requires.is_a?(String) if ['', 'unmanaged'].include? requires.downcase '' else " Require #{requires}\n" end elsif requires.is_a?(Array) requires.map { |req| " Require #{req}\n" }.join('') elsif requires.is_a?(Hash) if requires.key?(:enforce) \ " \n" + \ requires[:requires].map { |req| " Require #{req}\n" }.join('') + \ " \n" else requires[:requires].map { |req| " Require #{req}\n" }.join('') end end end shared_examples 'status_conf_spec_require' do |requires, extended_status, status_path| expected = "\n"\ " SetHandler server-status\n"\ "#{require_directives(requires)}"\ "\n"\ "ExtendedStatus #{extended_status}\n"\ "\n"\ "\n"\ " # Show Proxy LoadBalancer status in mod_status\n"\ " ProxyStatus On\n"\ "\n" it('status conf require') do is_expected.to contain_file('status.conf').with_content(expected) end end describe 'apache::mod::status', type: :class do it_behaves_like 'a mod class, without including apache' context 'default configuration with parameters' do - context 'on a Debian 8 OS' do - include_examples 'Debian 8' + context 'on a Debian 11 OS' do + include_examples 'Debian 11' context 'with default params' do it { is_expected.to contain_apache__mod('status') } include_examples 'status_conf_spec_require', 'ip 127.0.0.1 ::1', 'On', '/server-status' it { is_expected.to contain_file('status.conf').with(ensure: 'file', path: '/etc/apache2/mods-available/status.conf') } it { is_expected.to contain_file('status.conf symlink').with(ensure: 'link', path: '/etc/apache2/mods-enabled/status.conf') } end context "with custom parameters $allow_from => ['10.10.10.10','11.11.11.11'], $extended_status => 'Off', $status_path => '/custom-status'" do let :params do { allow_from: ['10.10.10.10', '11.11.11.11'], extended_status: 'Off', status_path: '/custom-status', } end it { is_expected.to compile } include_examples 'status_conf_spec_require', 'ip 10.10.10.10 11.11.11.11', 'Off', '/custom-status' end context "with valid parameter type $allow_from => ['10.10.10.10']" do let :params do { allow_from: ['10.10.10.10'] } end it 'expects to succeed array validation' do is_expected.to compile end end context "with invalid parameter type $allow_from => '10.10.10.10'" do let :params do { allow_from: '10.10.10.10' } end it 'expects to fail array validation' do is_expected.to compile.and_raise_error(%r{allow_from}) end end # Only On or Off are valid options ['On', 'Off'].each do |valid_param| context "with valid value $extended_status => '#{valid_param}'" do let :params do { extended_status: valid_param } end it 'expects to succeed regular expression validation' do is_expected.to compile end end end ['Yes', 'No'].each do |invalid_param| context "with invalid value $extended_status => '#{invalid_param}'" do let :params do { extended_status: invalid_param } end it 'expects to fail regular expression validation' do is_expected.to compile.and_raise_error(%r{extended_status}) end end end end context 'on a RedHat 6 OS' do include_examples 'RedHat 6' context 'with default params' do it { is_expected.to contain_apache__mod('status') } include_examples 'status_conf_spec', ['127.0.0.1', '::1'], 'On', '/server-status' it { is_expected.to contain_file('status.conf').with_path('/etc/httpd/conf.d/status.conf') } end end valid_requires = { undef: :undef, empty: '', unmanaged: 'unmanaged', string: 'ip 127.0.0.1 192.168', array: [ 'ip 127.0.0.1', 'ip ::1', 'host localhost', ], hash: { requires: [ 'ip 10.1', 'host somehost', ], }, enforce: { enforce: 'all', requires: [ 'ip 127.0.0.1', 'host localhost', ], }, } valid_requires.each do |req_key, req_value| context "with default params and #{req_key} requires" do let :params do { requires: req_value, } end - context 'on a Debian 8 OS' do - include_examples 'Debian 8' + context 'on a Debian 11 OS' do + include_examples 'Debian 11' it { is_expected.to contain_apache__mod('status') } include_examples 'status_conf_spec_require', req_value, 'On', '/server-status' it { is_expected.to contain_file('status.conf').with(ensure: 'file', path: '/etc/apache2/mods-available/status.conf') } it { is_expected.to contain_file('status.conf symlink').with(ensure: 'link', path: '/etc/apache2/mods-enabled/status.conf') } end context 'on a RedHat 7 OS' do include_examples 'RedHat 7' it { is_expected.to contain_apache__mod('status') } include_examples 'status_conf_spec_require', req_value, 'On', '/server-status' it { is_expected.to contain_file('status.conf').with_path('/etc/httpd/conf.modules.d/status.conf') } end context 'on a RedHat 8 OS' do include_examples 'RedHat 8' it { is_expected.to contain_apache__mod('status') } include_examples 'status_conf_spec_require', req_value, 'On', '/server-status' it { is_expected.to contain_file('status.conf').with_path('/etc/httpd/conf.modules.d/status.conf') } end end end end end diff --git a/spec/classes/mod/userdir_spec.rb b/spec/classes/mod/userdir_spec.rb index 89b54ab7..34493738 100644 --- a/spec/classes/mod/userdir_spec.rb +++ b/spec/classes/mod/userdir_spec.rb @@ -1,80 +1,80 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::userdir', type: :class do context 'on a Debian OS' do let :pre_condition do 'class { "apache": default_mods => false, mod_dir => "/tmp/junk", }' end - include_examples 'Debian 8' + include_examples 'Debian 11' context 'default parameters' do it { is_expected.to compile } end context 'with dir set to something' do let :params do { dir: 'hi', } end it { is_expected.to contain_file('userdir.conf').with_content(%r{^\s*UserDir\s+/home/\*/hi$}) } it { is_expected.to contain_file('userdir.conf').with_content(%r{^\s*\$}) } end context 'with home set to something' do let :params do { home: '/u', } end it { is_expected.to contain_file('userdir.conf').with_content(%r{^\s*UserDir\s+/u/\*/public_html$}) } it { is_expected.to contain_file('userdir.conf').with_content(%r{^\s*\$}) } end context 'with path set to something' do let :params do { path: '/home/*/*/public_html', } end it { is_expected.to contain_file('userdir.conf').with_content(%r{^\s*UserDir\s+/home/\*/\*/public_html$}) } it { is_expected.to contain_file('userdir.conf').with_content(%r{^\s*\$}) } end context 'with userdir set to something' do let :params do { path: '/home/*/*/public_html', userdir: 'public_html', } end it { is_expected.to contain_file('userdir.conf').with_content(%r{^\s*UserDir\s+public_html$}) } it { is_expected.to contain_file('userdir.conf').with_content(%r{^\s*\$}) } end context 'with unmanaged_path set to true' do let :params do { unmanaged_path: true, } end it { is_expected.to contain_file('userdir.conf').with_content(%r{^\s*UserDir\s+/home/\*/public_html$}) } it { is_expected.not_to contain_file('userdir.conf').with_content(%r{^\s*\ false, }' end context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache::params') } it { is_expected.not_to contain_apache__mod('worker') } it { is_expected.to contain_file('/etc/apache2/mods-available/worker.conf').with_ensure('file') } it { is_expected.to contain_file('/etc/apache2/mods-enabled/worker.conf').with_ensure('link') } context 'with Apache version < 2.4' do let :params do { apache_version: '2.2', } end it { is_expected.not_to contain_file('/etc/apache2/mods-available/worker.load') } it { is_expected.not_to contain_file('/etc/apache2/mods-enabled/worker.load') } it { is_expected.to contain_package('apache2-mpm-worker') } end context 'with Apache version >= 2.4' do let :params do { apache_version: '2.4', } end it { is_expected.to contain_file('/etc/apache2/mods-available/worker.load').with('ensure' => 'file', 'content' => "LoadModule mpm_worker_module /usr/lib/apache2/modules/mod_mpm_worker.so\n") } it { is_expected.to contain_file('/etc/apache2/mods-enabled/worker.load').with_ensure('link') } end end context 'on a RedHat OS' do include_examples 'RedHat 6' it { is_expected.to contain_class('apache::params') } it { is_expected.not_to contain_apache__mod('worker') } it { is_expected.to contain_file('/etc/httpd/conf.d/worker.conf').with_ensure('file') } context 'with Apache version < 2.4' do let :params do { apache_version: '2.2', } end it { is_expected.to contain_file_line('/etc/sysconfig/httpd worker enable').with('require' => 'Package[httpd]') } end context 'with Apache version >= 2.4' do let :params do { apache_version: '2.4', } end it { is_expected.not_to contain_apache__mod('event') } it { is_expected.to contain_file('/etc/httpd/conf.d/worker.load').with('ensure' => 'file', 'content' => "LoadModule mpm_worker_module modules/mod_mpm_worker.so\n") } end end context 'on a FreeBSD OS' do include_examples 'FreeBSD 9' it { is_expected.to contain_class('apache::params') } it { is_expected.not_to contain_apache__mod('worker') } it { is_expected.to contain_file('/usr/local/etc/apache24/Modules/worker.conf').with_ensure('file') } end context 'on a Gentoo OS' do include_examples 'Gentoo' it { is_expected.to contain_class('apache::params') } it { is_expected.not_to contain_apache__mod('worker') } it { is_expected.to contain_file('/etc/apache2/modules.d/worker.conf').with_ensure('file') } end # Template config doesn't vary by distro context 'on all distros' do include_examples 'RedHat 6' context 'defaults' do it { is_expected.to contain_file('/etc/httpd/conf.d/worker.conf').with(content: %r{^$}) } it { is_expected.to contain_file('/etc/httpd/conf.d/worker.conf').with(content: %r{^\s+ServerLimit\s+25$}) } it { is_expected.to contain_file('/etc/httpd/conf.d/worker.conf').with(content: %r{^\s+StartServers\s+2$}) } it { is_expected.to contain_file('/etc/httpd/conf.d/worker.conf').with(content: %r{^\s+MaxClients\s+150$}) } it { is_expected.to contain_file('/etc/httpd/conf.d/worker.conf').with(content: %r{^\s+MinSpareThreads\s+25$}) } it { is_expected.to contain_file('/etc/httpd/conf.d/worker.conf').with(content: %r{^\s+MaxSpareThreads\s+75$}) } it { is_expected.to contain_file('/etc/httpd/conf.d/worker.conf').with(content: %r{^\s+ThreadsPerChild\s+25$}) } it { is_expected.to contain_file('/etc/httpd/conf.d/worker.conf').with(content: %r{^\s+MaxRequestsPerChild\s+0$}) } it { is_expected.to contain_file('/etc/httpd/conf.d/worker.conf').with(content: %r{^\s+ThreadLimit\s+64$}) } it { is_expected.to contain_file('/etc/httpd/conf.d/worker.conf').with(content: %r{^\s*ListenBacklog\s*511}) } end context 'setting params' do let :params do { serverlimit: 10, startservers: 11, maxclients: 12, minsparethreads: 13, maxsparethreads: 14, threadsperchild: 15, maxrequestsperchild: 16, threadlimit: 17, listenbacklog: 8, } end it { is_expected.to contain_file('/etc/httpd/conf.d/worker.conf').with(content: %r{^$}) } it { is_expected.to contain_file('/etc/httpd/conf.d/worker.conf').with(content: %r{^\s+ServerLimit\s+10$}) } it { is_expected.to contain_file('/etc/httpd/conf.d/worker.conf').with(content: %r{^\s+StartServers\s+11$}) } it { is_expected.to contain_file('/etc/httpd/conf.d/worker.conf').with(content: %r{^\s+MaxClients\s+12$}) } it { is_expected.to contain_file('/etc/httpd/conf.d/worker.conf').with(content: %r{^\s+MinSpareThreads\s+13$}) } it { is_expected.to contain_file('/etc/httpd/conf.d/worker.conf').with(content: %r{^\s+MaxSpareThreads\s+14$}) } it { is_expected.to contain_file('/etc/httpd/conf.d/worker.conf').with(content: %r{^\s+ThreadsPerChild\s+15$}) } it { is_expected.to contain_file('/etc/httpd/conf.d/worker.conf').with(content: %r{^\s+MaxRequestsPerChild\s+16$}) } it { is_expected.to contain_file('/etc/httpd/conf.d/worker.conf').with(content: %r{^\s+ThreadLimit\s+17$}) } it { is_expected.to contain_file('/etc/httpd/conf.d/worker.conf').with(content: %r{^\s*ListenBacklog\s*8}) } end end end diff --git a/spec/classes/mod/wsgi_spec.rb b/spec/classes/mod/wsgi_spec.rb index b8fadb10..b8883667 100644 --- a/spec/classes/mod/wsgi_spec.rb +++ b/spec/classes/mod/wsgi_spec.rb @@ -1,164 +1,164 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::wsgi', type: :class do it_behaves_like 'a mod class, without including apache' context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_class('apache::mod::wsgi').with( 'wsgi_socket_prefix' => nil, ) } - it { is_expected.to contain_package('libapache2-mod-wsgi') } + it { is_expected.to contain_package('libapache2-mod-wsgi-py3') } end context 'on a RedHat OS' do include_examples 'RedHat 6' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_class('apache::mod::wsgi').with( 'wsgi_socket_prefix' => '/var/run/wsgi', ) } it { is_expected.to contain_package('mod_wsgi') } context 'on RHEL8' do include_examples 'RedHat 8' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_file('wsgi.load').with_content(%r{LoadModule wsgi_module modules/mod_wsgi_python3.so}) } it { is_expected.to contain_package('python3-mod_wsgi') } end describe 'with WSGIRestrictEmbedded enabled' do let :params do { wsgi_restrict_embedded: 'On' } end it { is_expected.to contain_file('wsgi.conf').with_content(%r{^ WSGIRestrictEmbedded On$}) } end describe 'with custom WSGISocketPrefix' do let :params do { wsgi_socket_prefix: 'run/wsgi' } end it { is_expected.to contain_file('wsgi.conf').with_content(%r{^ WSGISocketPrefix run\/wsgi$}) } end describe 'with custom WSGIPythonHome' do let :params do { wsgi_python_home: '/path/to/virtenv' } end it { is_expected.to contain_file('wsgi.conf').with_content(%r{^ WSGIPythonHome "\/path\/to\/virtenv"$}) } end describe 'with custom WSGIApplicationGroup' do let :params do { wsgi_application_group: '%{GLOBAL}' } end it { is_expected.to contain_file('wsgi.conf').with_content(%r{^ WSGIApplicationGroup "%{GLOBAL}"$}) } end describe 'with custom WSGIPythonOptimize' do let :params do { wsgi_python_optimize: 1 } end it { is_expected.to contain_file('wsgi.conf').with_content(%r{^ WSGIPythonOptimize 1$}) } end describe 'with custom package_name and mod_path' do let :params do { package_name: 'mod_wsgi_package', mod_path: '/foo/bar/baz', } end it { is_expected.to contain_apache__mod('wsgi').with('package' => 'mod_wsgi_package', 'path' => '/foo/bar/baz') } it { is_expected.to contain_package('mod_wsgi_package') } it { is_expected.to contain_file('wsgi.load').with_content(%r{LoadModule wsgi_module /foo/bar/baz}) } end describe 'with custom mod_path not containing /' do let :params do { package_name: 'mod_wsgi_package', mod_path: 'wsgi_mod_name.so', } end it { is_expected.to contain_apache__mod('wsgi').with('path' => 'modules/wsgi_mod_name.so', 'package' => 'mod_wsgi_package') } it { is_expected.to contain_file('wsgi.load').with_content(%r{LoadModule wsgi_module modules/wsgi_mod_name.so}) } end describe 'with package_name but no mod_path' do let :params do { mod_path: '/foo/bar/baz', } end it { is_expected.to compile.and_raise_error(%r{apache::mod::wsgi - both package_name and mod_path must be specified!}) } end describe 'with mod_path but no package_name' do let :params do { package_name: '/foo/bar/baz', } end it { is_expected.to compile.and_raise_error(%r{apache::mod::wsgi - both package_name and mod_path must be specified!}) } end end context 'on a FreeBSD OS' do include_examples 'FreeBSD 9' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_class('apache::mod::wsgi').with( 'wsgi_socket_prefix' => nil, ) } it { is_expected.to contain_package('www/mod_wsgi') } end context 'on a Gentoo OS' do include_examples 'Gentoo' it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_class('apache::mod::wsgi').with( 'wsgi_socket_prefix' => nil, ) } it { is_expected.to contain_package('www-apache/mod_wsgi') } end context 'overriding mod_libs' do context 'on a RedHat OS', :compile do include_examples 'Fedora 28' let :pre_condition do <<-MANIFEST include apache::params class { 'apache': mod_packages => merge($::apache::params::mod_packages, { 'wsgi' => 'python3-mod_wsgi', }), mod_libs => merge($::apache::params::mod_libs, { 'wsgi' => 'mod_wsgi_python3.so', }) } MANIFEST end it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_file('wsgi.load').with_content(%r{LoadModule wsgi_module modules/mod_wsgi_python3.so}) } it { is_expected.to contain_package('python3-mod_wsgi') } end end end diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb index a2a876ee..5faa269c 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::params', type: :class do context 'On a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to compile.with_all_deps } it { is_expected.to have_resource_count(0) } end end diff --git a/spec/classes/service_spec.rb b/spec/classes/service_spec.rb index 824b2eab..5e9aba39 100644 --- a/spec/classes/service_spec.rb +++ b/spec/classes/service_spec.rb @@ -1,134 +1,134 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::service', type: :class do let :pre_condition do 'include apache::params' end context 'on a Debian OS' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_service('httpd').with( 'name' => 'apache2', 'ensure' => 'running', 'enable' => 'true', ) } context "with $service_name => 'foo'" do let(:params) { { service_name: 'foo' } } it { is_expected.to contain_service('httpd').with( 'name' => 'foo', ) } end context 'with $service_enable => true' do let(:params) { { service_enable: true } } it { is_expected.to contain_service('httpd').with( 'name' => 'apache2', 'ensure' => 'running', 'enable' => 'true', ) } end context 'with $service_enable => false' do let(:params) { { service_enable: false } } it { is_expected.to contain_service('httpd').with( 'name' => 'apache2', 'ensure' => 'running', 'enable' => 'false', ) } end context "with $service_ensure => 'running'" do let(:params) { { service_ensure: 'running' } } it { is_expected.to contain_service('httpd').with( 'ensure' => 'running', 'enable' => 'true', ) } end context "with $service_ensure => 'stopped'" do let(:params) { { service_ensure: 'stopped' } } it { is_expected.to contain_service('httpd').with( 'ensure' => 'stopped', 'enable' => 'true', ) } end context "with $service_ensure => 'UNDEF'" do let(:params) { { service_ensure: 'UNDEF' } } it { is_expected.to contain_service('httpd').without_ensure } end context 'with $service_restart unset' do it { is_expected.to contain_service('httpd').without_restart } end context "with $service_restart => '/usr/sbin/apachectl graceful'" do let(:params) { { service_restart: '/usr/sbin/apachectl graceful' } } it { is_expected.to contain_service('httpd').with( 'restart' => '/usr/sbin/apachectl graceful', ) } end end context 'on a RedHat 8 OS, do not manage service' do include_examples 'RedHat 8' let(:params) do { 'service_ensure' => 'running', 'service_name' => 'httpd', 'service_manage' => false, } end it { is_expected.not_to contain_service('httpd') } end context 'on a FreeBSD 9 OS' do include_examples 'FreeBSD 9' it { is_expected.to contain_service('httpd').with( 'name' => 'apache24', 'ensure' => 'running', 'enable' => 'true', ) } end context 'on a Gentoo OS' do include_examples 'Gentoo' it { is_expected.to contain_service('httpd').with( 'name' => 'apache2', 'ensure' => 'running', 'enable' => 'true', ) } end end diff --git a/spec/defines/balancer_spec.rb b/spec/defines/balancer_spec.rb index 5d805469..b9cdaae6 100644 --- a/spec/defines/balancer_spec.rb +++ b/spec/defines/balancer_spec.rb @@ -1,75 +1,75 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::balancer', type: :define do let :title do 'myapp' end - include_examples 'Debian 8' + include_examples 'Debian 11' describe 'apache pre_condition with defaults' do let :pre_condition do 'include apache' end describe 'works when only declaring resource title' do it { is_expected.to contain_concat('apache_balancer_myapp') } it { is_expected.to contain_concat__fragment('00-myapp-header').with_content(%r{^$}) } end describe 'accept a target parameter and use it' do let :params do { target: '/tmp/myapp.conf', } end it { is_expected.to contain_concat('apache_balancer_myapp').with(path: '/tmp/myapp.conf') } end describe 'accept an options parameter and use it' do let :params do { options: ['timeout=0', 'nonce=none'], } end it { is_expected.to contain_concat__fragment('00-myapp-header').with_content( %r{^$}, ) } end end describe 'apache pre_condition with conf_dir set' do let :pre_condition do 'class{"apache": confd_dir => "/junk/path" }' end it { is_expected.to contain_concat('apache_balancer_myapp').with(path: '/junk/path/balancer_myapp.conf') } end describe 'with lbmethod and with apache::mod::proxy_balancer::apache_version set' do let :pre_condition do 'class{"apache::mod::proxy_balancer": apache_version => "2.4" }' end let :params do { proxy_set: { 'lbmethod' => 'bytraffic', }, } end it { is_expected.to contain_apache__mod('slotmem_shm') } it { is_expected.to contain_apache__mod('lbmethod_bytraffic') } end end diff --git a/spec/defines/balancermember_spec.rb b/spec/defines/balancermember_spec.rb index 23d169a0..9521d52e 100644 --- a/spec/defines/balancermember_spec.rb +++ b/spec/defines/balancermember_spec.rb @@ -1,55 +1,55 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::balancermember', type: :define do let :pre_condition do 'include apache' end - include_examples 'Debian 8' + include_examples 'Debian 11' describe 'allows multiple balancermembers with the same url' do let :pre_condition do 'include apache apache::balancer {"balancer":} apache::balancer {"balancer-external":} apache::balancermember {"http://127.0.0.1:8080-external": url => "http://127.0.0.1:8080/", balancer_cluster => "balancer-external"} ' end let :title do 'http://127.0.0.1:8080/' end let :params do { options: [], url: 'http://127.0.0.1:8080/', balancer_cluster: 'balancer-internal', } end it { is_expected.to contain_concat__fragment('BalancerMember http://127.0.0.1:8080/') } end describe 'allows balancermember with a different target' do let :pre_condition do 'include apache apache::balancer {"balancername": target => "/etc/apache/balancer.conf"} apache::balancermember {"http://127.0.0.1:8080-external": url => "http://127.0.0.1:8080/", balancer_cluster => "balancername"} ' end let :title do 'http://127.0.0.1:8080/' end let :params do { options: [], url: 'http://127.0.0.1:8080/', balancer_cluster: 'balancername', } end it { is_expected.to contain_concat__fragment('BalancerMember http://127.0.0.1:8080/').with(target: 'apache_balancer_balancername') } end end diff --git a/spec/defines/custom_config_spec.rb b/spec/defines/custom_config_spec.rb index 59119a53..2e31b1f7 100644 --- a/spec/defines/custom_config_spec.rb +++ b/spec/defines/custom_config_spec.rb @@ -1,104 +1,104 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::custom_config', type: :define do let :pre_condition do 'class { "apache": }' end let :title do 'rspec' end - include_examples 'Debian 8' + include_examples 'Debian 11' context 'defaults with content' do let :params do { 'content' => '# Test', } end it { is_expected.to contain_exec('syntax verification for rspec') .with('refreshonly' => 'true', 'command' => '/usr/sbin/apachectl -t') .that_subscribes_to('File[apache_rspec]') .that_notifies('Class[Apache::Service]') .that_comes_before('Exec[remove rspec if invalid]') } it { is_expected.to contain_exec('remove rspec if invalid') .with('unless' => '/usr/sbin/apachectl -t', 'refreshonly' => 'true') .that_subscribes_to('File[apache_rspec]') } it { is_expected.to contain_file('apache_rspec') .with('ensure' => 'present', 'content' => '# Test') .that_requires('Package[httpd]') } end context 'set everything with source' do let :params do { 'confdir' => '/dne', 'priority' => '30', 'source' => 'puppet:///modules/apache/test', 'verify_command' => '/bin/true', } end it { is_expected.to contain_exec('syntax verification for rspec').with('command' => '/bin/true') } it { is_expected.to contain_exec('remove rspec if invalid').with('command' => '/bin/rm /dne/30-rspec.conf', 'unless' => '/bin/true') } it { is_expected.to contain_file('apache_rspec') .that_requires('Package[httpd]') .with('path' => '/dne/30-rspec.conf', 'ensure' => 'present', 'source' => 'puppet:///modules/apache/test') } end context 'verify_config => false' do let :params do { 'content' => '# test', 'verify_config' => false, } end it { is_expected.not_to contain_exec('syntax verification for rspec') } it { is_expected.not_to contain_exec('remove rspec if invalid') } it { is_expected.to contain_file('apache_rspec').that_notifies('Class[Apache::Service]') } end context 'ensure => absent' do let :params do { 'ensure' => 'absent', } end it { is_expected.not_to contain_exec('syntax verification for rspec') } it { is_expected.not_to contain_exec('remove rspec if invalid') } it { is_expected.to contain_file('apache_rspec').with('ensure' => 'absent') } end describe 'validation' do context 'both content and source' do let :params do { 'content' => 'foo', 'source' => 'bar', } end it { is_expected.to compile.and_raise_error(%r{Only one of \$content and \$source can be specified\.}) } end context 'neither content nor source' do it { is_expected.to compile.and_raise_error(%r{One of \$content and \$source must be specified\.}) } end end end diff --git a/spec/defines/mod_spec.rb b/spec/defines/mod_spec.rb index 14a7e292..f873b0cf 100644 --- a/spec/defines/mod_spec.rb +++ b/spec/defines/mod_spec.rb @@ -1,102 +1,102 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod', type: :define do let :pre_condition do 'include apache' end let :title do 'spec_m' end context 'on a RedHat osfamily' do include_examples 'RedHat 6' describe 'for non-special modules' do it { is_expected.to contain_class('apache::params') } it 'manages the module load file' do is_expected.to contain_file('spec_m.load').with(path: '/etc/httpd/conf.d/spec_m.load', content: "LoadModule spec_m_module modules/mod_spec_m.so\n", owner: 'root', group: 'root', mode: '0644') end end describe 'with file_mode set' do let :pre_condition do "class {'::apache': file_mode => '0640'}" end it 'manages the module load file' do is_expected.to contain_file('spec_m.load').with(mode: '0640') end end describe 'with shibboleth module and package param passed' do # name/title for the apache::mod define let :title do 'xsendfile' end # parameters let(:params) { { package: 'mod_xsendfile' } } it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_package('mod_xsendfile') } end end context 'on a Debian osfamily' do - include_examples 'Debian 8' + include_examples 'Debian 11' describe 'for non-special modules' do it { is_expected.to contain_class('apache::params') } it 'manages the module load file' do is_expected.to contain_file('spec_m.load').with(path: '/etc/apache2/mods-available/spec_m.load', content: "LoadModule spec_m_module /usr/lib/apache2/modules/mod_spec_m.so\n", owner: 'root', group: 'root', mode: '0644') end it 'links the module load file' do is_expected.to contain_file('spec_m.load symlink').with(path: '/etc/apache2/mods-enabled/spec_m.load', target: '/etc/apache2/mods-available/spec_m.load', owner: 'root', group: 'root', mode: '0644') end end end context 'on a FreeBSD osfamily' do include_examples 'FreeBSD 9' describe 'for non-special modules' do it { is_expected.to contain_class('apache::params') } it 'manages the module load file' do is_expected.to contain_file('spec_m.load').with(path: '/usr/local/etc/apache24/Modules/spec_m.load', content: "LoadModule spec_m_module /usr/local/libexec/apache24/mod_spec_m.so\n", owner: 'root', group: 'wheel', mode: '0644') end end end context 'on a Gentoo osfamily' do include_examples 'Gentoo' describe 'for non-special modules' do it { is_expected.to contain_class('apache::params') } it 'manages the module load file' do is_expected.to contain_file('spec_m.load').with(path: '/etc/apache2/modules.d/spec_m.load', content: "LoadModule spec_m_module /usr/lib/apache2/modules/mod_spec_m.so\n", owner: 'root', group: 'wheel', mode: '0644') end end end end diff --git a/spec/defines/vhost_custom_spec.rb b/spec/defines/vhost_custom_spec.rb index c5db0b82..9409ed61 100644 --- a/spec/defines/vhost_custom_spec.rb +++ b/spec/defines/vhost_custom_spec.rb @@ -1,62 +1,62 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::vhost::custom', type: :define do let :title do 'rspec.example.com' end let(:params) do { content: 'foobar', } end describe 'os-dependent items' do context 'on RedHat based systems' do include_examples 'RedHat 6' it { is_expected.to compile } end context 'on Debian based systems' do - include_examples 'Debian 8' + include_examples 'Debian 11' it { is_expected.to contain_file('apache_rspec.example.com').with( ensure: 'present', content: 'foobar', path: '/etc/apache2/sites-available/25-rspec.example.com.conf', ) } it { is_expected.to contain_file('25-rspec.example.com.conf symlink').with( ensure: 'link', path: '/etc/apache2/sites-enabled/25-rspec.example.com.conf', target: '/etc/apache2/sites-available/25-rspec.example.com.conf', ) } end context 'on FreeBSD systems' do include_examples 'FreeBSD 9' it { is_expected.to contain_file('apache_rspec.example.com').with( ensure: 'present', content: 'foobar', path: '/usr/local/etc/apache24/Vhosts/25-rspec.example.com.conf', ) } end context 'on Gentoo systems' do include_examples 'Gentoo' it { is_expected.to contain_file('apache_rspec.example.com').with( ensure: 'present', content: 'foobar', path: '/etc/apache2/vhosts.d/25-rspec.example.com.conf', ) } end end end diff --git a/spec/spec_helper_local.rb b/spec/spec_helper_local.rb index b5031e3e..bef086ac 100644 --- a/spec/spec_helper_local.rb +++ b/spec/spec_helper_local.rb @@ -1,180 +1,180 @@ # frozen_string_literal: true if ENV['COVERAGE'] == 'yes' require 'simplecov' require 'simplecov-console' require 'codecov' SimpleCov.formatters = [ SimpleCov::Formatter::HTMLFormatter, SimpleCov::Formatter::Console, SimpleCov::Formatter::Codecov, ] SimpleCov.start do track_files 'lib/**/*.rb' add_filter '/spec' # do not track vendored files add_filter '/vendor' add_filter '/.vendor' # do not track gitignored files # this adds about 4 seconds to the coverage check # this could definitely be optimized add_filter do |f| # system returns true if exit status is 0, which with git-check-ignore means file is ignored system("git check-ignore --quiet #{f.filename}") end end end shared_examples :compile, compile: true do it { is_expected.to compile.with_all_deps } end shared_context 'a mod class, without including apache' do - let(:facts) { on_supported_os['debian-8-x86_64'] } + let(:facts) { on_supported_os['debian-10-x86_64'] } end -shared_context 'Debian 8' do - let(:facts) { on_supported_os['debian-8-x86_64'] } +shared_context 'Debian 11' do + let(:facts) { on_supported_os['debian-11-x86_64'] } end shared_context 'Ubuntu 18.04' do let(:facts) { on_supported_os['ubuntu-18.04-x86_64'] } end shared_context 'RedHat 6' do let(:facts) { on_supported_os['redhat-6-x86_64'] } end shared_context 'RedHat 7' do let(:facts) { on_supported_os['redhat-7-x86_64'] } end shared_context 'RedHat 8' do let(:facts) { on_supported_os['redhat-8-x86_64'] } end shared_context 'Fedora 17' do let :facts do { id: 'root', kernel: 'Linux', osfamily: 'RedHat', operatingsystem: 'Fedora', operatingsystemrelease: '17', operatingsystemmajrelease: '17', path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', } end end shared_context 'Fedora 21' do let :facts do { id: 'root', kernel: 'Linux', osfamily: 'RedHat', operatingsystem: 'Fedora', operatingsystemrelease: '21', operatingsystemmajrelease: '21', path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', } end end shared_context 'Fedora 28' do let :facts do { id: 'root', kernel: 'Linux', osfamily: 'RedHat', operatingsystem: 'Fedora', operatingsystemrelease: '28', operatingsystemmajrelease: '28', path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', } end end shared_context 'Fedora Rawhide' do let :facts do { id: 'root', kernel: 'Linux', osfamily: 'RedHat', operatingsystem: 'Fedora', operatingsystemrelease: 'Rawhide', operatingsystemmajrelease: 'Rawhide', path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', } end end shared_context 'FreeBSD 9' do let :facts do { osfamily: 'FreeBSD', operatingsystemrelease: '9', operatingsystem: 'FreeBSD', id: 'root', kernel: 'FreeBSD', path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', } end end shared_context 'FreeBSD 10' do let :facts do { id: 'root', kernel: 'FreeBSD', osfamily: 'FreeBSD', operatingsystem: 'FreeBSD', operatingsystemrelease: '10', path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', } end end shared_context 'Gentoo' do let :facts do { id: 'root', kernel: 'Linux', osfamily: 'Gentoo', operatingsystem: 'Gentoo', operatingsystemrelease: '2.7', operatingsystemmajrelease: '2.7', path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin', } end end shared_context 'Darwin' do let :facts do { osfamily: 'Darwin', operatingsystemrelease: '13.1.0', } end end shared_context 'Unsupported OS' do let :facts do { osfamily: 'Magic', operatingsystemrelease: '0', operatingsystem: 'Magic', id: 'root', kernel: 'Linux', path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', } end end shared_context 'SLES 12' do let(:facts) { on_supported_os['sles-12-x86_64'] } end