diff --git a/manifests/dev.pp b/manifests/dev.pp
index b8c6991e..10654103 100644
--- a/manifests/dev.pp
+++ b/manifests/dev.pp
@@ -1,22 +1,22 @@
# @summary
# Installs Apache development libraries.
#
# The libraries installed depends on the `dev_packages` parameter of the `apache::params`
# class, based on your operating system:
-# - **Debian** : `libaprutil1-dev`, `libapr1-dev`; `apache2-dev` on Ubuntu 13.10 and Debian 8; `apache2-prefork-dev` on other versions.
+# - **Debian** : `libaprutil1-dev`, `libapr1-dev`; `apache2-dev`
# - **FreeBSD**: `undef`; on FreeBSD, you must declare the `apache::package` or `apache` classes before declaring `apache::dev`.
# - **Gentoo**: `undef`.
# - **Red Hat**: `httpd-devel`.
class apache::dev {
if ! defined(Class['apache']) {
fail('You must include the apache base class before using any apache defined resources')
}
$packages = $apache::dev_packages
if $packages { # FreeBSD doesn't have dev packages to install
package { $packages:
ensure => present,
require => Package['httpd'],
}
}
}
diff --git a/manifests/mod/suphp.pp b/manifests/mod/suphp.pp
index bbeeb872..ae884132 100644
--- a/manifests/mod/suphp.pp
+++ b/manifests/mod/suphp.pp
@@ -1,24 +1,23 @@
# @summary
# Installs `mod_suphp`.
#
# @see https://www.suphp.org/DocumentationView.html?file=apache/INSTALL for additional documentation.
#
class apache::mod::suphp (
) {
- if ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['major'], '15.10') >= 0) or
- $facts['os']['name'] == 'Debian' {
+ if $facts['os']['family'] == 'Debian' {
fail("suphp was declared EOL by it's creators as of 2013 and so is no longer supported on Ubuntu 15.10/Debian 8 and above. Please use php-fpm")
}
include apache
::apache::mod { 'suphp': }
file { 'suphp.conf':
ensure => file,
path => "${apache::mod_dir}/suphp.conf",
mode => $apache::file_mode,
content => template('apache/mod/suphp.conf.erb'),
require => Exec["mkdir ${apache::mod_dir}"],
before => File[$apache::mod_dir],
notify => Class['apache::service'],
}
}
diff --git a/manifests/params.pp b/manifests/params.pp
index cfa56b44..79313de8 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -1,820 +1,789 @@
# @summary
# This class manages Apache parameters
#
# @api private
class apache::params inherits ::apache::version {
if($::fqdn) {
$servername = $::fqdn
} else {
$servername = $::hostname
}
# The default error log level
$log_level = 'warn'
$use_optional_includes = false
# Default mime types settings
$mime_types_additional = {
'AddHandler' => { 'type-map' => 'var', },
'AddType' => { 'text/html' => '.shtml', },
'AddOutputFilter' => { 'INCLUDES' => '.shtml', },
}
# should we use systemd module?
$use_systemd = true
# Default mode for files
$file_mode = '0644'
# The default value for host hame lookup
$hostname_lookups = 'Off'
# Default options for / directory
$root_directory_options = ['FollowSymLinks']
$vhost_include_pattern = '*'
$modsec_audit_log_parts = 'ABIJDEFHZ'
$modsec_audit_log_type = 'Serial'
$modsec_custom_rules = false
$modsec_custom_rules_set = undef
# no client certs should be trusted for auth by default.
$ssl_certs_dir = undef
# Allow overriding the autoindex alias location
$icons_prefix = 'icons'
if ($apache::version::scl_httpd_version) {
if $apache::version::scl_php_version == undef {
fail('If you define apache::version::scl_httpd_version, you also need to specify apache::version::scl_php_version')
}
$_scl_httpd_version_nodot = regsubst($apache::version::scl_httpd_version, '\.', '')
$_scl_httpd_name = "httpd${_scl_httpd_version_nodot}"
$_scl_php_version_no_dot = regsubst($apache::version::scl_php_version, '\.', '')
$user = 'apache'
$group = 'apache'
$root_group = 'root'
$apache_name = "${_scl_httpd_name}-httpd"
$service_name = "${_scl_httpd_name}-httpd"
$httpd_root = "/opt/rh/${_scl_httpd_name}/root"
$httpd_dir = "${httpd_root}/etc/httpd"
$server_root = "${httpd_root}/etc/httpd"
$conf_dir = "${httpd_dir}/conf"
$confd_dir = "${httpd_dir}/conf.d"
$puppet_ssl_dir = "${httpd_dir}/puppet_ssl"
$mod_dir = $facts['operatingsystemmajrelease'] ? {
'7' => "${httpd_dir}/conf.modules.d",
default => "${httpd_dir}/conf.d",
}
$mod_enable_dir = undef
$vhost_dir = "${httpd_dir}/conf.d"
$vhost_enable_dir = undef
$conf_file = 'httpd.conf'
$conf_enabled = undef
$ports_file = "${conf_dir}/ports.conf"
$pidfile = 'run/httpd.pid'
$logroot = "/var/log/${_scl_httpd_name}"
$logroot_mode = undef
$lib_path = 'modules'
$mpm_module = 'prefork'
$dev_packages = "${_scl_httpd_name}-httpd-devel"
$default_ssl_cert = '/etc/pki/tls/certs/localhost.crt'
$default_ssl_key = '/etc/pki/tls/private/localhost.key'
$ssl_sessioncache = '/var/cache/mod_ssl/scache(512000)'
$passenger_conf_file = 'passenger_extra.conf'
$passenger_conf_package_file = 'passenger.conf'
$passenger_root = undef
$passenger_ruby = undef
$passenger_default_ruby = undef
$suphp_addhandler = 'php5-script'
$suphp_engine = 'off'
$suphp_configpath = undef
$php_version = $apache::version::scl_php_version
$mod_packages = {
'authnz_ldap' => "${_scl_httpd_name}-mod_ldap",
'ldap' => "${_scl_httpd_name}-mod_ldap",
"php${apache::version::scl_php_version}" => "rh-php${_scl_php_version_no_dot}-php",
'ssl' => "${_scl_httpd_name}-mod_ssl",
}
$mod_libs = {
'nss' => 'libmodnss.so',
}
$conf_template = 'apache/httpd.conf.erb'
$http_protocol_options = undef
$keepalive = 'On'
$keepalive_timeout = 15
$max_keepalive_requests = 100
$fastcgi_lib_path = undef
$mime_support_package = 'mailcap'
$mime_types_config = '/etc/mime.types'
$docroot = "${httpd_root}/var/www/html"
$alias_icons_path = $facts['operatingsystemmajrelease'] ? {
'7' => "${httpd_root}/usr/share/httpd/icons",
default => '/var/www/icons',
}
$error_documents_path = $facts['operatingsystemmajrelease'] ? {
'7' => "${httpd_root}/usr/share/httpd/error",
default => '/var/www/error'
}
if $::osfamily == 'RedHat' {
$wsgi_socket_prefix = '/var/run/wsgi'
} else {
$wsgi_socket_prefix = undef
}
$cas_cookie_path = '/var/cache/mod_auth_cas/'
$mellon_lock_file = '/run/mod_auth_mellon/lock'
$mellon_cache_size = 100
$mellon_post_directory = undef
$modsec_version = 1
$modsec_crs_package = 'mod_security_crs'
$modsec_crs_path = '/usr/lib/modsecurity.d'
$modsec_dir = '/etc/httpd/modsecurity.d'
$secpcrematchlimit = 1500
$secpcrematchlimitrecursion = 1500
$modsec_secruleengine = 'On'
$modsec_default_rules = [
'base_rules/modsecurity_35_bad_robots.data',
'base_rules/modsecurity_35_scanners.data',
'base_rules/modsecurity_40_generic_attacks.data',
'base_rules/modsecurity_50_outbound.data',
'base_rules/modsecurity_50_outbound_malware.data',
'base_rules/modsecurity_crs_20_protocol_violations.conf',
'base_rules/modsecurity_crs_21_protocol_anomalies.conf',
'base_rules/modsecurity_crs_23_request_limits.conf',
'base_rules/modsecurity_crs_30_http_policy.conf',
'base_rules/modsecurity_crs_35_bad_robots.conf',
'base_rules/modsecurity_crs_40_generic_attacks.conf',
'base_rules/modsecurity_crs_41_sql_injection_attacks.conf',
'base_rules/modsecurity_crs_41_xss_attacks.conf',
'base_rules/modsecurity_crs_42_tight_security.conf',
'base_rules/modsecurity_crs_45_trojans.conf',
'base_rules/modsecurity_crs_47_common_exceptions.conf',
'base_rules/modsecurity_crs_49_inbound_blocking.conf',
'base_rules/modsecurity_crs_50_outbound.conf',
'base_rules/modsecurity_crs_59_outbound_blocking.conf',
'base_rules/modsecurity_crs_60_correlation.conf',
]
$error_log = 'error_log'
$scriptalias = "${httpd_root}/var/www/cgi-bin"
$access_log_file = 'access_log'
}
elsif $::osfamily == 'RedHat' or $::operatingsystem =~ /^[Aa]mazon$/ {
$user = 'apache'
$group = 'apache'
$root_group = 'root'
$apache_name = 'httpd'
$service_name = 'httpd'
$httpd_dir = '/etc/httpd'
$server_root = '/etc/httpd'
$conf_dir = "${httpd_dir}/conf"
$confd_dir = "${httpd_dir}/conf.d"
$puppet_ssl_dir = "${httpd_dir}/puppet_ssl"
$conf_enabled = undef
if $::operatingsystem =~ /^[Aa]mazon$/ and $::operatingsystemmajrelease == '2' {
# Amazon Linux 2 uses the /conf.modules.d/ dir
$mod_dir = "${httpd_dir}/conf.modules.d"
} else {
$mod_dir = $facts['operatingsystemmajrelease'] ? {
'6' => "${httpd_dir}/conf.d",
default => "${httpd_dir}/conf.modules.d",
}
}
$mod_enable_dir = undef
$vhost_dir = "${httpd_dir}/conf.d"
$vhost_enable_dir = undef
$conf_file = 'httpd.conf'
$ports_file = "${conf_dir}/ports.conf"
$pidfile = 'run/httpd.pid'
$logroot = '/var/log/httpd'
$logroot_mode = undef
$lib_path = 'modules'
$mpm_module = 'prefork'
$dev_packages = 'httpd-devel'
$default_ssl_cert = '/etc/pki/tls/certs/localhost.crt'
$default_ssl_key = '/etc/pki/tls/private/localhost.key'
$ssl_sessioncache = '/var/cache/mod_ssl/scache(512000)'
$passenger_conf_file = 'passenger_extra.conf'
$passenger_conf_package_file = 'passenger.conf'
$passenger_root = undef
$passenger_ruby = undef
$passenger_default_ruby = undef
$suphp_addhandler = 'php5-script'
$suphp_engine = 'off'
$suphp_configpath = undef
$php_version = $facts['operatingsystemmajrelease'] ? {
'8' => '7', # RedHat8
default => '5', # RedHat5, RedHat6, RedHat7
}
$mod_packages = {
# NOTE: The auth_cas module isn't available on RH/CentOS without providing dependency packages provided by EPEL.
'auth_cas' => 'mod_auth_cas',
'auth_kerb' => 'mod_auth_kerb',
'auth_gssapi' => 'mod_auth_gssapi',
'auth_mellon' => 'mod_auth_mellon',
'auth_openidc' => 'mod_auth_openidc',
'authnz_ldap' => $facts['operatingsystemmajrelease'] ? {
'6' => 'mod_authz_ldap',
default => 'mod_ldap',
},
'authnz_pam' => 'mod_authnz_pam',
'fastcgi' => $facts['operatingsystemmajrelease'] ? {
'5' => 'mod_fastcgi',
'6' => 'mod_fastcgi',
default => undef,
},
'fcgid' => 'mod_fcgid',
'geoip' => 'mod_geoip',
'intercept_form_submit' => 'mod_intercept_form_submit',
'ldap' => $facts['operatingsystemmajrelease'] ? {
'5' => undef,
'6' => undef,
default => 'mod_ldap',
},
'lookup_identity' => 'mod_lookup_identity',
'md' => 'mod_md',
'pagespeed' => 'mod-pagespeed-stable',
# NOTE: The passenger module isn't available on RH/CentOS without
# providing dependency packages provided by EPEL and passenger
# repositories. See
# https://www.phusionpassenger.com/library/install/apache/install/oss/el7/
'passenger' => 'mod_passenger',
'perl' => 'mod_perl',
'php5' => $facts['operatingsystemmajrelease'] ? {
'5' => 'php53',
default => 'php',
},
'phpXXX' => 'php',
'proxy_html' => 'mod_proxy_html',
'python' => 'mod_python',
'security' => 'mod_security',
# NOTE: The module for Shibboleth is not available on RH/CentOS without
# providing dependency packages provided by Shibboleth's repositories.
# See http://wiki.aaf.edu.au/tech-info/sp-install-guide
'shibboleth' => 'shibboleth',
'ssl' => 'mod_ssl',
'wsgi' => $facts['operatingsystemmajrelease'] ? {
'6' => 'mod_wsgi', # RedHat6
'7' => 'mod_wsgi', # RedHat7
default => 'python3-mod_wsgi', # RedHat8+
},
'dav_svn' => 'mod_dav_svn',
'suphp' => 'mod_suphp',
'xsendfile' => 'mod_xsendfile',
'nss' => 'mod_nss',
'shib2' => 'shibboleth',
}
$mod_libs = {
'nss' => 'libmodnss.so',
'wsgi' => $facts['operatingsystemmajrelease'] ? {
'6' => 'mod_wsgi.so',
'7' => 'mod_wsgi.so',
default => 'mod_wsgi_python3.so',
},
}
$conf_template = 'apache/httpd.conf.erb'
$http_protocol_options = undef
$keepalive = 'On'
$keepalive_timeout = 15
$max_keepalive_requests = 100
$fastcgi_lib_path = undef
$mime_support_package = 'mailcap'
$mime_types_config = '/etc/mime.types'
$docroot = '/var/www/html'
$alias_icons_path = $facts['operatingsystemmajrelease'] ? {
'6' => '/var/www/icons',
default => '/usr/share/httpd/icons',
}
$error_documents_path = $facts['operatingsystemmajrelease'] ? {
'6' => '/var/www/error',
default => '/usr/share/httpd/error',
}
if $::osfamily == 'RedHat' {
$wsgi_socket_prefix = '/var/run/wsgi'
} else {
$wsgi_socket_prefix = undef
}
$cas_cookie_path = '/var/cache/mod_auth_cas/'
$mellon_lock_file = '/run/mod_auth_mellon/lock'
$mellon_cache_size = 100
$mellon_post_directory = undef
$modsec_version = 1
$modsec_crs_package = 'mod_security_crs'
$modsec_crs_path = '/usr/lib/modsecurity.d'
$modsec_dir = '/etc/httpd/modsecurity.d'
$secpcrematchlimit = 1500
$secpcrematchlimitrecursion = 1500
$modsec_secruleengine = 'On'
$modsec_default_rules = [
'base_rules/modsecurity_35_bad_robots.data',
'base_rules/modsecurity_35_scanners.data',
'base_rules/modsecurity_40_generic_attacks.data',
'base_rules/modsecurity_50_outbound.data',
'base_rules/modsecurity_50_outbound_malware.data',
'base_rules/modsecurity_crs_20_protocol_violations.conf',
'base_rules/modsecurity_crs_21_protocol_anomalies.conf',
'base_rules/modsecurity_crs_23_request_limits.conf',
'base_rules/modsecurity_crs_30_http_policy.conf',
'base_rules/modsecurity_crs_35_bad_robots.conf',
'base_rules/modsecurity_crs_40_generic_attacks.conf',
'base_rules/modsecurity_crs_41_sql_injection_attacks.conf',
'base_rules/modsecurity_crs_41_xss_attacks.conf',
'base_rules/modsecurity_crs_42_tight_security.conf',
'base_rules/modsecurity_crs_45_trojans.conf',
'base_rules/modsecurity_crs_47_common_exceptions.conf',
'base_rules/modsecurity_crs_49_inbound_blocking.conf',
'base_rules/modsecurity_crs_50_outbound.conf',
'base_rules/modsecurity_crs_59_outbound_blocking.conf',
'base_rules/modsecurity_crs_60_correlation.conf',
]
$error_log = 'error_log'
$scriptalias = '/var/www/cgi-bin'
$access_log_file = 'access_log'
} elsif $::osfamily == 'Debian' {
$user = 'www-data'
$group = 'www-data'
$root_group = 'root'
$apache_name = 'apache2'
$service_name = 'apache2'
$httpd_dir = '/etc/apache2'
$server_root = '/etc/apache2'
$conf_dir = $httpd_dir
$confd_dir = "${httpd_dir}/conf.d"
# Overwrite conf_enabled causes errors with Shibboleth when enabled on Ubuntu 18.04
$conf_enabled = undef #"${httpd_dir}/conf-enabled.d"
$puppet_ssl_dir = "${httpd_dir}/puppet_ssl"
$mod_dir = "${httpd_dir}/mods-available"
$mod_enable_dir = "${httpd_dir}/mods-enabled"
$vhost_dir = "${httpd_dir}/sites-available"
$vhost_enable_dir = "${httpd_dir}/sites-enabled"
$conf_file = 'apache2.conf'
$ports_file = "${conf_dir}/ports.conf"
$pidfile = "\${APACHE_PID_FILE}"
$logroot = '/var/log/apache2'
$logroot_mode = undef
$lib_path = '/usr/lib/apache2/modules'
$mpm_module = 'worker'
$default_ssl_cert = '/etc/ssl/certs/ssl-cert-snakeoil.pem'
$default_ssl_key = '/etc/ssl/private/ssl-cert-snakeoil.key'
$ssl_sessioncache = "\${APACHE_RUN_DIR}/ssl_scache(512000)"
$suphp_addhandler = 'x-httpd-php'
$suphp_engine = 'off'
$suphp_configpath = '/etc/php5/apache2'
- if ($::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '16.04') < 0) or ($::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '9') < 0) {
- # Only the major version is used here
- $php_version = '5'
- $mod_packages = {
- 'auth_cas' => 'libapache2-mod-auth-cas',
- 'auth_kerb' => 'libapache2-mod-auth-kerb',
- 'auth_openidc' => 'libapache2-mod-auth-openidc',
- 'auth_gssapi' => 'libapache2-mod-auth-gssapi',
- 'auth_mellon' => 'libapache2-mod-auth-mellon',
- 'authnz_pam' => 'libapache2-mod-authnz-pam',
- 'dav_svn' => 'libapache2-svn',
- 'fastcgi' => 'libapache2-mod-fastcgi',
- 'fcgid' => 'libapache2-mod-fcgid',
- 'geoip' => 'libapache2-mod-geoip',
- 'intercept_form_submit' => 'libapache2-mod-intercept-form-submit',
- 'jk' => 'libapache2-mod-jk',
- 'lookup_identity' => 'libapache2-mod-lookup-identity',
- 'nss' => 'libapache2-mod-nss',
- 'pagespeed' => 'mod-pagespeed-stable',
- 'passenger' => 'libapache2-mod-passenger',
- 'perl' => 'libapache2-mod-perl2',
- 'phpXXX' => 'libapache2-mod-phpXXX',
- 'proxy_html' => 'libapache2-mod-proxy-html',
- 'python' => 'libapache2-mod-python',
- 'rpaf' => 'libapache2-mod-rpaf',
- 'security' => 'libapache2-modsecurity',
- 'shib2' => 'libapache2-mod-shib2',
- 'suphp' => 'libapache2-mod-suphp',
- 'wsgi' => 'libapache2-mod-wsgi',
- 'xsendfile' => 'libapache2-mod-xsendfile',
- }
- } elsif ($::operatingsystem == 'Ubuntu') or ($::operatingsystem == 'Debian' and versioncmp($::operatingsystemmajrelease, '11') < 0) {
+ if ($::operatingsystem == 'Ubuntu') or ($::operatingsystem == 'Debian' and versioncmp($::operatingsystemmajrelease, '11') < 0) {
$php_version = $facts['operatingsystemmajrelease'] ? {
'9' => '7.0', # Debian Stretch
'16.04' => '7.0', # Ubuntu Xenial
'10' => '7.3', # Debian Buster
'20.04' => '7.4', # Ubuntu Foccal Fossal
default => '7.2', # Ubuntu Bionic, Cosmic and Disco
}
$mod_packages = {
'apreq2' => 'libapache2-mod-apreq2',
'auth_cas' => 'libapache2-mod-auth-cas',
'auth_kerb' => 'libapache2-mod-auth-kerb',
'auth_openidc' => 'libapache2-mod-auth-openidc',
'auth_gssapi' => 'libapache2-mod-auth-gssapi',
'auth_mellon' => 'libapache2-mod-auth-mellon',
'authnz_pam' => 'libapache2-mod-authnz-pam',
'dav_svn' => 'libapache2-mod-svn',
'fastcgi' => 'libapache2-mod-fastcgi',
'fcgid' => 'libapache2-mod-fcgid',
'geoip' => 'libapache2-mod-geoip',
'intercept_form_submit' => 'libapache2-mod-intercept-form-submit',
'jk' => 'libapache2-mod-jk',
'lookup_identity' => 'libapache2-mod-lookup-identity',
'nss' => 'libapache2-mod-nss',
'pagespeed' => 'mod-pagespeed-stable',
'passenger' => 'libapache2-mod-passenger',
'perl' => 'libapache2-mod-perl2',
'phpXXX' => 'libapache2-mod-phpXXX',
'python' => 'libapache2-mod-python',
'rpaf' => 'libapache2-mod-rpaf',
'security' => 'libapache2-mod-security2',
'shib2' => 'libapache2-mod-shib2',
'wsgi' => 'libapache2-mod-wsgi',
'xsendfile' => 'libapache2-mod-xsendfile',
}
} else {
$php_version = $facts['operatingsystemmajrelease'] ? {
default => '7.4', # Debian Bullseye
}
$mod_packages = {
'apreq2' => 'libapache2-mod-apreq2',
'auth_cas' => 'libapache2-mod-auth-cas',
'auth_kerb' => 'libapache2-mod-auth-kerb',
'auth_openidc' => 'libapache2-mod-auth-openidc',
'auth_gssapi' => 'libapache2-mod-auth-gssapi',
'auth_mellon' => 'libapache2-mod-auth-mellon',
'authnz_pam' => 'libapache2-mod-authnz-pam',
'dav_svn' => 'libapache2-mod-svn',
'fastcgi' => 'libapache2-mod-fastcgi',
'fcgid' => 'libapache2-mod-fcgid',
'geoip' => 'libapache2-mod-geoip',
'intercept_form_submit' => 'libapache2-mod-intercept-form-submit',
'jk' => 'libapache2-mod-jk',
'lookup_identity' => 'libapache2-mod-lookup-identity',
'nss' => 'libapache2-mod-nss',
'pagespeed' => 'mod-pagespeed-stable',
'passenger' => 'libapache2-mod-passenger',
'perl' => 'libapache2-mod-perl2',
'phpXXX' => 'libapache2-mod-phpXXX',
'python' => 'libapache2-mod-python',
'rpaf' => 'libapache2-mod-rpaf',
'security' => 'libapache2-mod-security2',
'shib2' => 'libapache2-mod-shib',
'wsgi' => 'libapache2-mod-wsgi-py3',
'xsendfile' => 'libapache2-mod-xsendfile',
}
}
$error_log = 'error.log'
$scriptalias = '/usr/lib/cgi-bin'
$access_log_file = 'access.log'
if ($::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '19.04') < 0) or ($::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '10') < 0) {
$shib2_lib = 'mod_shib2.so'
} else {
$shib2_lib = 'mod_shib.so'
}
$mod_libs = {
'shib2' => $shib2_lib,
}
$conf_template = 'apache/httpd.conf.erb'
$http_protocol_options = undef
$keepalive = 'On'
$keepalive_timeout = 15
$max_keepalive_requests = 100
$fastcgi_lib_path = '/var/lib/apache2/fastcgi'
$mime_support_package = 'mime-support'
$mime_types_config = '/etc/mime.types'
$docroot = '/var/www/html'
$cas_cookie_path = '/var/cache/apache2/mod_auth_cas/'
$mellon_lock_file = undef
$mellon_cache_size = undef
$mellon_post_directory = '/var/cache/apache2/mod_auth_mellon/'
$modsec_version = 1
$modsec_crs_package = 'modsecurity-crs'
$modsec_crs_path = '/usr/share/modsecurity-crs'
$modsec_dir = '/etc/modsecurity'
$secpcrematchlimit = 1500
$secpcrematchlimitrecursion = 1500
$modsec_secruleengine = 'On'
if ($::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '9') >= 0) or ($::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '18.04') >= 0) {
$modsec_default_rules = [
'crawlers-user-agents.data',
'iis-errors.data',
'java-code-leakages.data',
'java-errors.data',
'lfi-os-files.data',
'php-config-directives.data',
'php-errors.data',
'php-function-names-933150.data',
'php-function-names-933151.data',
'php-variables.data',
'restricted-files.data',
'scanners-headers.data',
'scanners-urls.data',
'scanners-user-agents.data',
'scripting-user-agents.data',
'sql-errors.data',
'sql-function-names.data',
'unix-shell.data',
'windows-powershell-commands.data',
]
} else {
$modsec_default_rules = [
'base_rules/modsecurity_35_bad_robots.data',
'base_rules/modsecurity_35_scanners.data',
'base_rules/modsecurity_40_generic_attacks.data',
'base_rules/modsecurity_50_outbound.data',
'base_rules/modsecurity_50_outbound_malware.data',
'base_rules/modsecurity_crs_20_protocol_violations.conf',
'base_rules/modsecurity_crs_21_protocol_anomalies.conf',
'base_rules/modsecurity_crs_23_request_limits.conf',
'base_rules/modsecurity_crs_30_http_policy.conf',
'base_rules/modsecurity_crs_35_bad_robots.conf',
'base_rules/modsecurity_crs_40_generic_attacks.conf',
'base_rules/modsecurity_crs_41_sql_injection_attacks.conf',
'base_rules/modsecurity_crs_41_xss_attacks.conf',
'base_rules/modsecurity_crs_42_tight_security.conf',
'base_rules/modsecurity_crs_45_trojans.conf',
'base_rules/modsecurity_crs_47_common_exceptions.conf',
'base_rules/modsecurity_crs_49_inbound_blocking.conf',
'base_rules/modsecurity_crs_50_outbound.conf',
'base_rules/modsecurity_crs_59_outbound_blocking.conf',
'base_rules/modsecurity_crs_60_correlation.conf',
]
}
$alias_icons_path = '/usr/share/apache2/icons'
$error_documents_path = '/usr/share/apache2/error'
$dev_packages = ['libaprutil1-dev', 'libapr1-dev', 'apache2-dev']
#
# Passenger-specific settings
#
$passenger_conf_file = 'passenger.conf'
$passenger_conf_package_file = undef
$passenger_root = '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini'
$passenger_ruby = undef
$passenger_default_ruby = '/usr/bin/ruby'
$wsgi_socket_prefix = undef
} elsif $::osfamily == 'FreeBSD' {
$user = 'www'
$group = 'www'
$root_group = 'wheel'
$apache_name = 'apache24'
$service_name = 'apache24'
$httpd_dir = '/usr/local/etc/apache24'
$server_root = '/usr/local'
$conf_dir = $httpd_dir
$confd_dir = "${httpd_dir}/Includes"
$conf_enabled = undef
$puppet_ssl_dir = "${httpd_dir}/puppet_ssl"
$mod_dir = "${httpd_dir}/Modules"
$mod_enable_dir = undef
$vhost_dir = "${httpd_dir}/Vhosts"
$vhost_enable_dir = undef
$conf_file = 'httpd.conf'
$ports_file = "${conf_dir}/ports.conf"
$pidfile = '/var/run/httpd.pid'
$logroot = '/var/log/apache24'
$logroot_mode = undef
$lib_path = '/usr/local/libexec/apache24'
$mpm_module = 'prefork'
$dev_packages = undef
$default_ssl_cert = '/usr/local/etc/apache24/server.crt'
$default_ssl_key = '/usr/local/etc/apache24/server.key'
$ssl_sessioncache = '/var/run/ssl_scache(512000)'
$passenger_conf_file = 'passenger.conf'
$passenger_conf_package_file = undef
$passenger_root = '/usr/local/lib/ruby/gems/2.0/gems/passenger-4.0.58'
$passenger_ruby = '/usr/local/bin/ruby'
$passenger_default_ruby = undef
$suphp_addhandler = 'php5-script'
$suphp_engine = 'off'
$suphp_configpath = undef
$php_version = '5'
$mod_packages = {
# NOTE: I list here only modules that are not included in www/apache24
# NOTE: 'passenger' needs to enable APACHE_SUPPORT in make config
# NOTE: 'php' needs to enable APACHE option in make config
# NOTE: 'dav_svn' needs to enable MOD_DAV_SVN make config
# NOTE: not sure where the shibboleth should come from
'auth_kerb' => 'www/mod_auth_kerb2',
'auth_gssapi' => 'www/mod_auth_gssapi',
'auth_openidc'=> 'www/mod_auth_openidc',
'fcgid' => 'www/mod_fcgid',
'passenger' => 'www/rubygem-passenger',
'perl' => 'www/mod_perl2',
'phpXXX' => 'www/mod_phpXXX',
'proxy_html' => 'www/mod_proxy_html',
'python' => 'www/mod_python3',
'wsgi' => 'www/mod_wsgi',
'dav_svn' => 'devel/subversion',
'xsendfile' => 'www/mod_xsendfile',
'rpaf' => 'www/mod_rpaf2',
'shib2' => 'security/shibboleth2-sp',
}
$mod_libs = {
}
$conf_template = 'apache/httpd.conf.erb'
$http_protocol_options = undef
$keepalive = 'On'
$keepalive_timeout = 15
$max_keepalive_requests = 100
$fastcgi_lib_path = undef # TODO: revisit
$mime_support_package = 'misc/mime-support'
$mime_types_config = '/usr/local/etc/mime.types'
$wsgi_socket_prefix = undef
$docroot = '/usr/local/www/apache24/data'
$alias_icons_path = '/usr/local/www/apache24/icons'
$error_documents_path = '/usr/local/www/apache24/error'
$error_log = 'httpd-error.log'
$scriptalias = '/usr/local/www/apache24/cgi-bin'
$access_log_file = 'httpd-access.log'
} elsif $::osfamily == 'Gentoo' {
$user = 'apache'
$group = 'apache'
$root_group = 'wheel'
$apache_name = 'www-servers/apache'
$service_name = 'apache2'
$httpd_dir = '/etc/apache2'
$server_root = '/var/www'
$conf_dir = $httpd_dir
$confd_dir = "${httpd_dir}/conf.d"
$conf_enabled = undef
$puppet_ssl_dir = "${httpd_dir}/puppet_ssl"
$mod_dir = "${httpd_dir}/modules.d"
$mod_enable_dir = undef
$vhost_dir = "${httpd_dir}/vhosts.d"
$vhost_enable_dir = undef
$conf_file = 'httpd.conf'
$ports_file = "${conf_dir}/ports.conf"
$logroot = '/var/log/apache2'
$logroot_mode = undef
$lib_path = '/usr/lib/apache2/modules'
$mpm_module = 'prefork'
$dev_packages = undef
$default_ssl_cert = '/etc/ssl/apache2/server.crt'
$default_ssl_key = '/etc/ssl/apache2/server.key'
$ssl_sessioncache = '/var/run/ssl_scache(512000)'
$passenger_root = '/usr'
$passenger_ruby = '/usr/bin/ruby'
$passenger_conf_file = 'passenger.conf'
$passenger_conf_package_file = undef
$passenger_default_ruby = undef
$suphp_addhandler = 'x-httpd-php'
$suphp_engine = 'off'
$suphp_configpath = '/etc/php5/apache2'
$php_version = '5'
$mod_packages = {
# NOTE: I list here only modules that are not included in www-servers/apache
'auth_kerb' => 'www-apache/mod_auth_kerb',
'auth_gssapi' => 'www-apache/mod_auth_gssapi',
'authnz_external' => 'www-apache/mod_authnz_external',
'fcgid' => 'www-apache/mod_fcgid',
'passenger' => 'www-apache/passenger',
'perl' => 'www-apache/mod_perl',
'phpXXX' => 'dev-lang/php',
'proxy_html' => 'www-apache/mod_proxy_html',
'proxy_fcgi' => 'www-apache/mod_proxy_fcgi',
'python' => 'www-apache/mod_python',
'wsgi' => 'www-apache/mod_wsgi',
'dav_svn' => 'dev-vcs/subversion',
'xsendfile' => 'www-apache/mod_xsendfile',
'rpaf' => 'www-apache/mod_rpaf',
'xml2enc' => 'www-apache/mod_xml2enc',
}
$mod_libs = {
}
$conf_template = 'apache/httpd.conf.erb'
$http_protocol_options = undef
$keepalive = 'On'
$keepalive_timeout = 15
$max_keepalive_requests = 100
$fastcgi_lib_path = undef # TODO: revisit
$mime_support_package = 'app-misc/mime-types'
$mime_types_config = '/etc/mime.types'
$wsgi_socket_prefix = undef
$docroot = '/var/www/localhost/htdocs'
$alias_icons_path = '/usr/share/apache2/icons'
$error_documents_path = '/usr/share/apache2/error'
$pidfile = '/var/run/apache2.pid'
$error_log = 'error.log'
$scriptalias = '/var/www/localhost/cgi-bin'
$access_log_file = 'access.log'
} elsif $::osfamily == 'Suse' {
$user = 'wwwrun'
$group = 'www'
$root_group = 'root'
$apache_name = 'apache2'
$service_name = 'apache2'
$httpd_dir = '/etc/apache2'
$server_root = '/etc/apache2'
$conf_dir = $httpd_dir
$confd_dir = "${httpd_dir}/conf.d"
$conf_enabled = undef
$puppet_ssl_dir = "${httpd_dir}/puppet_ssl"
$mod_dir = "${httpd_dir}/mods-available"
$mod_enable_dir = "${httpd_dir}/mods-enabled"
$vhost_dir = "${httpd_dir}/sites-available"
$vhost_enable_dir = "${httpd_dir}/sites-enabled"
$conf_file = 'httpd.conf'
$ports_file = "${conf_dir}/ports.conf"
$pidfile = '/var/run/httpd2.pid'
$logroot = '/var/log/apache2'
$logroot_mode = undef
$lib_path = '/usr/lib64/apache2' #changes for some modules based on mpm
$mpm_module = 'prefork'
if versioncmp($::operatingsystemrelease, '15') < 0 {
$default_ssl_cert = '/etc/apache2/ssl.crt/server.crt'
$default_ssl_key = '/etc/apache2/ssl.key/server.key'
$php_version = '5'
} else {
$default_ssl_cert = '/etc/apache2/ssl.crt/default-server.crt'
$default_ssl_key = '/etc/apache2/ssl.key/default-server.key'
$php_version = '7'
}
$suphp_configpath = "/etc/php${php_version}/apache2"
$ssl_sessioncache = '/var/lib/apache2/ssl_scache(512000)'
$suphp_addhandler = 'x-httpd-php'
$suphp_engine = 'off'
if versioncmp($::operatingsystemrelease, '11') < 0 or versioncmp($::operatingsystemrelease, '12') >= 0 {
$mod_packages = {
'auth_kerb' => 'apache2-mod_auth_kerb',
'auth_gssapi' => 'apache2-mod_auth_gssapi',
'dav_svn' => 'subversion-server',
'perl' => 'apache2-mod_perl',
'php5' => 'apache2-mod_php5',
'php7' => 'apache2-mod_php7',
'python' => 'apache2-mod_python',
'security' => 'apache2-mod_security2',
'worker' => 'apache2-worker',
}
} else {
$mod_packages = {
'auth_kerb' => 'apache2-mod_auth_kerb',
'auth_gssapi' => 'apache2-mod_auth_gssapi',
'dav_svn' => 'subversion-server',
'perl' => 'apache2-mod_perl',
'php5' => 'apache2-mod_php53',
'python' => 'apache2-mod_python',
'security' => 'apache2-mod_security2',
}
}
$mod_libs = {
'security' => '/usr/lib64/apache2/mod_security2.so',
'php53' => '/usr/lib64/apache2/mod_php5.so',
}
$conf_template = 'apache/httpd.conf.erb'
$http_protocol_options = undef
$keepalive = 'On'
$keepalive_timeout = 15
$max_keepalive_requests = 100
$fastcgi_lib_path = '/var/lib/apache2/fastcgi'
$mime_support_package = 'aaa_base'
$mime_types_config = '/etc/mime.types'
$docroot = '/srv/www'
$cas_cookie_path = '/var/cache/apache2/mod_auth_cas/'
$mellon_lock_file = undef
$mellon_cache_size = undef
$mellon_post_directory = undef
$alias_icons_path = '/usr/share/apache2/icons'
$error_documents_path = '/usr/share/apache2/error'
$dev_packages = ['libapr-util1-devel', 'libapr1-devel', 'libcurl-devel']
$modsec_version = 1
$modsec_crs_package = undef
$modsec_crs_path = undef
$modsec_default_rules = undef
$modsec_dir = '/etc/apache2/modsecurity'
$secpcrematchlimit = 1500
$secpcrematchlimitrecursion = 1500
$modsec_secruleengine = 'On'
$error_log = 'error.log'
$scriptalias = '/usr/lib/cgi-bin'
$access_log_file = 'access.log'
#
# Passenger-specific settings
#
$passenger_conf_file = 'passenger.conf'
$passenger_conf_package_file = undef
$passenger_root = '/usr/lib64/ruby/gems/1.8/gems/passenger-5.0.30'
$passenger_ruby = '/usr/bin/ruby'
$passenger_default_ruby = '/usr/bin/ruby'
$wsgi_socket_prefix = undef
} else {
fail("Class['apache::params']: Unsupported osfamily: ${::osfamily}")
}
if $::operatingsystem == 'SLES' {
$verify_command = '/usr/sbin/apache2ctl -t'
} elsif $::operatingsystem == 'FreeBSD' {
$verify_command = '/usr/local/sbin/apachectl -t'
} elsif ($apache::version::scl_httpd_version) {
$verify_command = "/opt/rh/${_scl_httpd_name}/root/usr/sbin/apachectl -t"
} else {
$verify_command = '/usr/sbin/apachectl -t'
}
if $::osfamily == 'RedHat' and versioncmp($facts['operatingsystemmajrelease'], '8') >= 0 {
$ssl_protocol = ['all'] # Implementations of the SSLv2 and SSLv3 protocol versions have been removed from OpenSSL (and hence mod_ssl) because these are no longer considered secure. For additional documentation https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/deploying_different_types_of_servers/setting-apache-web-server_deploying-different-types-of-servers
} else {
$ssl_protocol = ['all', '-SSLv2', '-SSLv3']
}
}
diff --git a/metadata.json b/metadata.json
index a90eca49..56c16b76 100644
--- a/metadata.json
+++ b/metadata.json
@@ -1,87 +1,85 @@
{
"name": "puppetlabs-apache",
"version": "6.5.1",
"author": "puppetlabs",
"summary": "Installs, configures, and manages Apache virtual hosts, web services, and modules.",
"license": "Apache-2.0",
"source": "https://github.com/puppetlabs/puppetlabs-apache",
"project_page": "https://github.com/puppetlabs/puppetlabs-apache",
"issues_url": "https://tickets.puppetlabs.com/browse/MODULES",
"dependencies": [
{
"name": "puppetlabs/stdlib",
"version_requirement": ">= 4.13.1 < 9.0.0"
},
{
"name": "puppetlabs/concat",
"version_requirement": ">= 2.2.1 < 8.0.0"
}
],
"operatingsystem_support": [
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"6",
"7",
"8"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"6",
"7",
"8"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
- "8",
"9",
"10",
"11"
]
},
{
"operatingsystem": "SLES",
"operatingsystemrelease": [
"12",
"15"
]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
- "14.04",
"16.04",
"18.04",
"20.04"
]
}
],
"requirements": [
{
"name": "puppet",
"version_requirement": ">= 6.0.0 < 8.0.0"
}
],
"description": "Module for Apache configuration",
"pdk-version": "2.1.0",
"template-url": "https://github.com/puppetlabs/pdk-templates.git#main",
"template-ref": "heads/main-0-g03daa92"
}
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 369a34e0..a66a683f 100644
--- a/spec/classes/mod/mime_magic_spec.rb
+++ b/spec/classes/mod/mime_magic_spec.rb
@@ -1,73 +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
-
- context 'with magic_file => /tmp/magic' do
- include_examples 'Debian 8'
-
- let :params do
- { magic_file: '/tmp/magic' }
- end
-
- it do
- is_expected.to contain_file('mime_magic.conf').with_content(
- "MIMEMagicFile \"/tmp/magic\"\n",
- )
- end
- 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/php_spec.rb b/spec/classes/mod/php_spec.rb
index ad62b6d4..a954e56b 100644
--- a/spec/classes/mod/php_spec.rb
+++ b/spec/classes/mod/php_spec.rb
@@ -1,350 +1,327 @@
# frozen_string_literal: true
require 'spec_helper'
describe 'apache::mod::php', type: :class do
on_supported_os.each do |os, facts|
context "on #{os} " do
let :facts do
facts
end
let :pre_condition do
'class { "apache": mpm_module => prefork, }'
end
case facts[:os]['family']
when 'Debian'
describe 'on a Debian OS' do
context 'with mpm_module => prefork' do
it { is_expected.to contain_class('apache::params') }
it { is_expected.to contain_class('apache::mod::prefork') }
end
case facts[:os]['release']['major']
- when '8'
- context 'on jessie' do
- it {
- is_expected.to contain_file('php5.load').with(
- content: "LoadModule php5_module /usr/lib/apache2/modules/libphp5.so\n",
- )
- }
- context 'with mpm_module => itk on jessie' do
- let :pre_condition do
- 'class { "apache": mpm_module => itk, }'
- end
-
- it { is_expected.to contain_class('apache::params') }
- it { is_expected.to contain_class('apache::mod::itk') }
- it { is_expected.to contain_apache__mod('php5') }
- it { is_expected.to contain_package('libapache2-mod-php5') }
- it {
- is_expected.to contain_file('php5.load').with(
- content: "LoadModule php5_module /usr/lib/apache2/modules/libphp5.so\n",
- )
- }
- end
- end
when '9'
context 'on stretch' do
it { is_expected.to contain_apache__mod('php7.0') }
it { is_expected.to contain_package('libapache2-mod-php7.0') }
it {
is_expected.to contain_file('php7.0.load').with(
content: "LoadModule php7_module /usr/lib/apache2/modules/libphp7.0.so\n",
)
}
end
when '10'
context 'on buster' do
it { is_expected.to contain_apache__mod('php7.3') }
it { is_expected.to contain_package('libapache2-mod-php7.3') }
it {
is_expected.to contain_file('php7.3.load').with(
content: "LoadModule php7_module /usr/lib/apache2/modules/libphp7.3.so\n",
)
}
context 'with experimental php8.0' do
let :params do
{ php_version: '8.0' }
end
it { is_expected.to contain_apache__mod('php') }
it { is_expected.to contain_package('libapache2-mod-php8.0') }
it {
is_expected.to contain_file('php.load').with(
content: "LoadModule php_module /usr/lib/apache2/modules/libphp.so\n",
)
}
end
end
when '11'
context 'on bullseye' do
it { is_expected.to contain_apache__mod('php7.4') }
it { is_expected.to contain_package('libapache2-mod-php7.4') }
it {
is_expected.to contain_file('php7.4.load').with(
content: "LoadModule php7_module /usr/lib/apache2/modules/libphp7.4.so\n",
)
}
context 'with experimental php8.0' do
let :params do
{ php_version: '8.0' }
end
it { is_expected.to contain_apache__mod('php') }
it { is_expected.to contain_package('libapache2-mod-php8.0') }
it {
is_expected.to contain_file('php.load').with(
content: "LoadModule php_module /usr/lib/apache2/modules/libphp.so\n",
)
}
end
end
when '16.04'
context 'on xenial' do
let :params do
{ content: 'somecontent' }
end
it {
is_expected.to contain_file('php7.0.conf').with(
content: 'somecontent',
)
}
end
when '18.04'
context 'on bionic' do
let :params do
{ content: 'somecontent' }
end
it {
is_expected.to contain_file('php7.2.conf').with(
content: 'somecontent',
)
}
end
end
end
when 'RedHat'
describe 'on a RedHat OS' do
context 'with default params' do
let :pre_condition do
'class { "apache": }'
end
it { is_expected.to contain_class('apache::params') }
it { is_expected.to contain_apache__mod('php5') } if facts[:os]['release']['major'].to_i < 8
it { is_expected.to contain_package('php') } if facts[:os]['release']['major'].to_i > 5
it { is_expected.to contain_file('php5.load').with(content: "LoadModule php5_module modules/libphp5.so\n") } if facts[:os]['release']['major'].to_i < 8
it { is_expected.to contain_file('php7.load').with(content: "LoadModule php7_module modules/libphp7.so\n") } if facts[:os]['release']['major'].to_i >= 8
end
context 'with alternative package name' do
let :pre_condition do
'class { "apache": }'
end
let :params do
{ package_name: 'php54' }
end
it { is_expected.to contain_package('php54') }
end
context 'with alternative path' do
let :pre_condition do
'class { "apache": }'
end
let :params do
{ path: 'alternative-path' }
end
it { is_expected.to contain_file('php5.load').with(content: "LoadModule php5_module alternative-path\n") } if facts[:os]['release']['major'].to_i < 8
it { is_expected.to contain_file('php7.load').with(content: "LoadModule php7_module alternative-path\n") } if facts[:os]['release']['major'].to_i >= 8
end
context 'with alternative extensions' do
let :pre_condition do
'class { "apache": }'
end
let :params do
{
extensions: ['.php', '.php5'],
}
end
it { is_expected.to contain_file('php5.conf').with_content(Regexp.new(Regexp.escape(''))) } if facts[:os]['release']['major'].to_i < 8
end
if facts[:os]['release']['major'].to_i > 5
context 'with specific version' do
let :pre_condition do
'class { "apache": }'
end
let :params do
{ package_ensure: '5.3.13' }
end
it {
is_expected.to contain_package('php').with(
ensure: '5.3.13',
)
}
end
end
context 'with mpm_module => prefork' do
it { is_expected.to contain_class('apache::params') }
it { is_expected.to contain_class('apache::mod::prefork') }
it { is_expected.to contain_apache__mod('php5') } if facts[:os]['release']['major'].to_i < 8
it { is_expected.to contain_package('php') } if facts[:os]['release']['major'].to_i > 5
it { is_expected.to contain_file('php5.load').with(content: "LoadModule php5_module modules/libphp5.so\n") } if facts[:os]['release']['major'].to_i < 8
it { is_expected.to contain_file('php7.load').with(content: "LoadModule php7_module modules/libphp7.so\n") } if facts[:os]['release']['major'].to_i >= 8
end
context 'with mpm_module => itk' do
let :pre_condition do
'class { "apache": mpm_module => itk, }'
end
it { is_expected.to contain_class('apache::params') }
it { is_expected.to contain_class('apache::mod::itk') }
it { is_expected.to contain_apache__mod('php5') } if facts[:os]['release']['major'].to_i < 8
it { is_expected.to contain_package('php') } if facts[:os]['release']['major'].to_i > 5
it { is_expected.to contain_file('php5.load').with(content: "LoadModule php5_module modules/libphp5.so\n") } if facts[:os]['release']['major'].to_i < 8
it { is_expected.to contain_file('php7.load').with(content: "LoadModule php7_module modules/libphp7.so\n") } if facts[:os]['release']['major'].to_i >= 8
end
end
when 'FreeBSD'
describe 'on a FreeBSD OS' do
context 'with mpm_module => prefork' do
it { is_expected.to contain_class('apache::params') }
it { is_expected.to contain_apache__mod('php5') }
it { is_expected.to contain_package('www/mod_php5') }
it { is_expected.to contain_file('php5.load') }
end
context 'with mpm_module => itk' do
let :pre_condition do
'class { "apache": mpm_module => itk, }'
end
it { is_expected.to contain_class('apache::params') }
it { is_expected.to contain_class('apache::mod::itk') }
it { is_expected.to contain_apache__mod('php5') }
it { is_expected.to contain_package('www/mod_php5') }
it { is_expected.to contain_file('php5.load') }
end
end
when 'Gentoo'
describe 'on a Gentoo OS' do
context 'with mpm_module => prefork' do
it { is_expected.to contain_class('apache::params') }
it { is_expected.to contain_apache__mod('php5') }
it { is_expected.to contain_package('dev-lang/php') }
it { is_expected.to contain_file('php5.load') }
end
context 'with mpm_module => itk' do
let :pre_condition do
'class { "apache": mpm_module => itk, }'
end
it { is_expected.to contain_class('apache::params') }
it { is_expected.to contain_class('apache::mod::itk') }
it { is_expected.to contain_apache__mod('php5') }
it { is_expected.to contain_package('dev-lang/php') }
it { is_expected.to contain_file('php5.load') }
end
end
end
# all the following tests are for legacy php/apache versions. They don't work on modern ubuntu and redhat 8
next if (facts[:os]['release']['major'].to_i > 15 && facts[:os]['name'] == 'Ubuntu') ||
(facts[:os]['release']['major'].to_i >= 15 && facts[:os]['name'] == 'SLES') ||
(facts[:os]['release']['major'].to_i >= 9 && facts[:os]['name'] == 'Debian') ||
(facts[:os]['release']['major'].to_i >= 8 && (facts[:os]['name'] == 'RedHat' || facts[:os]['name'] == 'CentOS'))
describe 'OS independent tests' do
context 'with content param' do
let :params do
{ content: 'somecontent' }
end
it {
is_expected.to contain_file('php5.conf').with(
content: 'somecontent',
)
}
end
context 'with template param' do
let :params do
{ template: 'apache/mod/php.conf.erb' }
end
it {
is_expected.to contain_file('php5.conf').with(
content: %r{^# PHP is an HTML-embedded scripting language which attempts to make it},
)
}
end
context 'with source param' do
let :params do
{ source: 'some-path' }
end
it {
is_expected.to contain_file('php5.conf').with(
source: 'some-path',
)
}
end
context 'content has priority over template' do
let :params do
{
template: 'apache/mod/php5.conf.erb',
content: 'somecontent',
}
end
it {
is_expected.to contain_file('php5.conf').with(
content: 'somecontent',
)
}
end
context 'source has priority over template' do
let :params do
{
template: 'apache/mod/php5.conf.erb',
source: 'some-path',
}
end
it {
is_expected.to contain_file('php5.conf').with(
source: 'some-path',
)
}
end
context 'source has priority over content' do
let :params do
{
content: 'somecontent',
source: 'some-path',
}
end
it {
is_expected.to contain_file('php5.conf').with(
source: 'some-path',
)
}
end
context 'with mpm_module => worker' do
let :pre_condition do
'class { "apache": mpm_module => worker, }'
end
it 'raises an error' do
is_expected.to compile.and_raise_error(%r{mpm_module => 'prefork' or mpm_module => 'itk'})
end
end
end
end
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 a0194163..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 jessie i386' do
+ 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 jessie x64' do
+ 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