diff --git a/spec/classes/mod/passenger_spec.rb b/spec/classes/mod/passenger_spec.rb index fb568911..aed525e7 100644 --- a/spec/classes/mod/passenger_spec.rb +++ b/spec/classes/mod/passenger_spec.rb @@ -1,476 +1,468 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::passenger', type: :class do on_supported_os.each do |os, facts| context "on #{os} " do let :facts do facts end case facts[:os]['family'] when 'Debian' context 'validating all passenger params - using Debian' do it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('passenger') } it { is_expected.to contain_package('libapache2-mod-passenger') } it { is_expected.to contain_file('zpassenger.load').with('path' => '/etc/apache2/mods-available/zpassenger.load') } it { is_expected.to contain_file('passenger.conf').with('path' => '/etc/apache2/mods-available/passenger.conf') } passenger_config_options = { 'passenger_allow_encoded_slashes' => { type: 'OnOff', pass_opt: :PassengerAllowEncodedSlashes }, 'passenger_anonymous_telemetry_proxy' => { type: 'String', pass_opt: :PassengerAnonymousTelemetryProxy }, 'passenger_app_env' => { type: 'String', pass_opt: :PassengerAppEnv }, 'passenger_app_group_name' => { type: 'String', pass_opt: :PassengerAppGroupName }, 'passenger_app_root' => { type: 'FullPath', pass_opt: :PassengerAppRoot }, 'passenger_app_type' => { type: 'String', pass_opt: :PassengerAppType }, 'passenger_base_uri' => { type: 'URI', pass_opt: :PassengerBaseURI }, 'passenger_buffer_response' => { type: 'OnOff', pass_opt: :PassengerBufferResponse }, 'passenger_buffer_upload' => { type: 'OnOff', pass_opt: :PassengerBufferUpload }, 'passenger_concurrency_model' => { type: ['process', 'thread'], pass_opt: :PassengerConcurrencyModel }, 'passenger_data_buffer_dir' => { type: 'FullPath', pass_opt: :PassengerDataBufferDir }, 'passenger_debug_log_file' => { type: 'String', pass_opt: :PassengerDebugLogFile }, 'passenger_debugger' => { type: 'OnOff', pass_opt: :PassengerDebugger }, 'passenger_default_group' => { type: 'String', pass_opt: :PassengerDefaultGroup }, 'passenger_default_ruby' => { type: 'FullPath', pass_opt: :PassengerDefaultRuby }, 'passenger_default_user' => { type: 'String', pass_opt: :PassengerDefaultUser }, 'passenger_disable_anonymous_telemetry' => { type: 'Boolean', pass_opt: :PassengerDisableAnonymousTelemetry }, 'passenger_disable_log_prefix' => { type: 'Boolean', pass_opt: :PassengerDisableLogPrefix }, 'passenger_disable_security_update_check' => { type: 'OnOff', pass_opt: :PassengerDisableSecurityUpdateCheck }, 'passenger_enabled' => { type: 'OnOff', pass_opt: :PassengerEnabled }, 'passenger_error_override' => { type: 'OnOff', pass_opt: :PassengerErrorOverride }, 'passenger_file_descriptor_log_file' => { type: 'FullPath', pass_opt: :PassengerFileDescriptorLogFile }, 'passenger_fly_with' => { type: 'FullPath', pass_opt: :PassengerFlyWith }, 'passenger_force_max_concurrent_requests_per_process' => { type: 'Integer', pass_opt: :PassengerForceMaxConcurrentRequestsPerProcess }, 'passenger_friendly_error_pages' => { type: 'OnOff', pass_opt: :PassengerFriendlyErrorPages }, 'passenger_group' => { type: 'String', pass_opt: :PassengerGroup }, 'passenger_high_performance' => { type: 'OnOff', pass_opt: :PassengerHighPerformance }, 'passenger_instance_registry_dir' => { type: 'FullPath', pass_opt: :PassengerInstanceRegistryDir }, 'passenger_load_shell_envvars' => { type: 'OnOff', pass_opt: :PassengerLoadShellEnvvars }, 'passenger_log_file' => { type: 'FullPath', pass_opt: :PassengerLogFile }, 'passenger_log_level' => { type: 'Integer', pass_opt: :PassengerLogLevel }, 'passenger_lve_min_uid' => { type: 'Integer', pass_opt: :PassengerLveMinUid }, 'passenger_max_instances' => { type: 'Integer', pass_opt: :PassengerMaxInstances }, 'passenger_max_instances_per_app' => { type: 'Integer', pass_opt: :PassengerMaxInstancesPerApp }, 'passenger_max_pool_size' => { type: 'Integer', pass_opt: :PassengerMaxPoolSize }, 'passenger_max_preloader_idle_time' => { type: 'Integer', pass_opt: :PassengerMaxPreloaderIdleTime }, 'passenger_max_request_queue_size' => { type: 'Integer', pass_opt: :PassengerMaxRequestQueueSize }, 'passenger_max_request_time' => { type: 'Integer', pass_opt: :PassengerMaxRequestTime }, 'passenger_max_requests' => { type: 'Integer', pass_opt: :PassengerMaxRequests }, 'passenger_memory_limit' => { type: 'Integer', pass_opt: :PassengerMemoryLimit }, 'passenger_meteor_app_settings' => { type: 'FullPath', pass_opt: :PassengerMeteorAppSettings }, 'passenger_min_instances' => { type: 'Integer', pass_opt: :PassengerMinInstances }, 'passenger_nodejs' => { type: 'FullPath', pass_opt: :PassengerNodejs }, 'passenger_pool_idle_time' => { type: 'Integer', pass_opt: :PassengerPoolIdleTime }, 'passenger_pre_start' => { type: 'URI', pass_opt: :PassengerPreStart }, 'passenger_python' => { type: 'FullPath', pass_opt: :PassengerPython }, 'passenger_resist_deployment_errors' => { type: 'OnOff', pass_opt: :PassengerResistDeploymentErrors }, 'passenger_resolve_symlinks_in_document_root' => { type: 'OnOff', pass_opt: :PassengerResolveSymlinksInDocumentRoot }, 'passenger_response_buffer_high_watermark' => { type: 'Integer', pass_opt: :PassengerResponseBufferHighWatermark }, 'passenger_restart_dir' => { type: 'Path', pass_opt: :PassengerRestartDir }, 'passenger_rolling_restarts' => { type: 'OnOff', pass_opt: :PassengerRollingRestarts }, 'passenger_root' => { type: 'FullPath', pass_opt: :PassengerRoot }, 'passenger_ruby' => { type: 'FullPath', pass_opt: :PassengerRuby }, 'passenger_security_update_check_proxy' => { type: 'URI', pass_opt: :PassengerSecurityUpdateCheckProxy }, 'passenger_show_version_in_header' => { type: 'OnOff', pass_opt: :PassengerShowVersionInHeader }, 'passenger_socket_backlog' => { type: 'Integer', pass_opt: :PassengerSocketBacklog }, 'passenger_spawn_dir' => { type: 'FullPath', pass_opt: :PassengerSpawnDir }, 'passenger_spawn_method' => { type: ['smart', 'direct'], pass_opt: :PassengerSpawnMethod }, 'passenger_start_timeout' => { type: 'Integer', pass_opt: :PassengerStartTimeout }, 'passenger_startup_file' => { type: 'RelPath', pass_opt: :PassengerStartupFile }, 'passenger_stat_throttle_rate' => { type: 'Integer', pass_opt: :PassengerStatThrottleRate }, 'passenger_sticky_sessions' => { type: 'OnOff', pass_opt: :PassengerStickySessions }, 'passenger_sticky_sessions_cookie_name' => { type: 'String', pass_opt: :PassengerStickySessionsCookieName }, 'passenger_sticky_sessions_cookie_attributes' => { type: 'QuotedString', pass_opt: :PassengerStickySessionsCookieAttributes }, 'passenger_thread_count' => { type: 'Integer', pass_opt: :PassengerThreadCount }, 'passenger_use_global_queue' => { type: 'String', pass_opt: :PassengerUseGlobalQueue }, 'passenger_user' => { type: 'String', pass_opt: :PassengerUser }, 'passenger_user_switching' => { type: 'OnOff', pass_opt: :PassengerUserSwitching }, 'rack_auto_detect' => { type: 'String', pass_opt: :RackAutoDetect }, 'rack_autodetect' => { type: 'String', pass_opt: :RackAutoDetect }, 'rack_base_uri' => { type: 'String', pass_opt: :RackBaseURI }, 'rack_env' => { type: 'String', pass_opt: :RackEnv }, 'rails_allow_mod_rewrite' => { type: 'String', pass_opt: :RailsAllowModRewrite }, 'rails_app_spawner_idle_time' => { type: 'String', pass_opt: :RailsAppSpawnerIdleTime }, 'rails_auto_detect' => { type: 'String', pass_opt: :RailsAutoDetect }, 'rails_autodetect' => { type: 'String', pass_opt: :RailsAutoDetect }, 'rails_base_uri' => { type: 'String', pass_opt: :RailsBaseURI }, 'rails_default_user' => { type: 'String', pass_opt: :RailsDefaultUser }, 'rails_env' => { type: 'String', pass_opt: :RailsEnv }, 'rails_framework_spawner_idle_time' => { type: 'String', pass_opt: :RailsFrameworkSpawnerIdleTime }, 'rails_ruby' => { type: 'String', pass_opt: :RailsRuby }, 'rails_spawn_method' => { type: 'String', pass_opt: :RailsSpawnMethod }, 'rails_user_switching' => { type: 'String', pass_opt: :RailsUserSwitching }, 'wsgi_auto_detect' => { type: 'String', pass_opt: :WsgiAutoDetect }, } passenger_config_options.each do |config_option, config_hash| puppetized_config_option = config_option case config_hash[:type] # UnionStationFilter values are quoted strings when 'QuotedString' valid_config_values = ['"a quoted string"'] valid_config_values.each do |valid_value| describe "with #{puppetized_config_option} => '#{valid_value.delete('"')}'" do let :params do { puppetized_config_option.to_sym => valid_value } end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ #{config_hash[:pass_opt]} "#{valid_value}"$}) } end end when 'FullPath', 'RelPath', 'Path' valid_config_values = ['/some/path/to/somewhere'] valid_config_values.each do |valid_value| describe "with #{puppetized_config_option} => #{valid_value}" do let :params do { puppetized_config_option.to_sym => valid_value } end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ #{config_hash[:pass_opt]} "#{valid_value}"$}) } end end when 'URI', 'String', 'Integer' valid_config_values = ['some_value_for_you'] valid_config_values.each do |valid_value| describe "with #{puppetized_config_option} => #{valid_value}" do let :params do { puppetized_config_option.to_sym => valid_value } end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ #{config_hash[:pass_opt]} #{valid_value}$}) } end end when 'OnOff' valid_config_values = ['on', 'off'] valid_config_values.each do |valid_value| describe "with #{puppetized_config_option} => '#{valid_value}'" do let :params do { puppetized_config_option.to_sym => valid_value } end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ #{config_hash[:pass_opt]} #{valid_value}$}) } end end when 'Boolean' valid_config_values = [true, false] valid_config_values.each do |valid_value| describe "with #{puppetized_config_option} => #{valid_value}" do let :params do { puppetized_config_option.to_sym => valid_value } end let :expected_value do { true => 'On', false => 'Off', }[valid_value] end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ #{config_hash[:pass_opt]} #{expected_value}$}) } end end else valid_config_values = config_hash[:type] valid_config_values.each do |valid_value| describe "with #{puppetized_config_option} => '#{valid_value}'" do let :params do { puppetized_config_option.to_sym => valid_value } end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ #{config_hash[:pass_opt]} #{valid_value}$}) } end end end end end it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('passenger') } it { is_expected.to contain_package('libapache2-mod-passenger') } it { is_expected.to contain_file('zpassenger.load').with('path' => '/etc/apache2/mods-available/zpassenger.load') } it { is_expected.to contain_file('passenger.conf').with('path' => '/etc/apache2/mods-available/passenger.conf') } context 'passenger config with passenger_installed_version set', test: true do describe 'fails when an option is not valid for $passenger_installed_version' do let :params do { passenger_installed_version: '4.0.0', passenger_instance_registry_dir: '/some/path/to/nowhere', } end it { is_expected.to raise_error(%r{passenger_instance_registry_dir is not introduced until version 5.0.0}) } end describe 'fails when an option is removed' do let :params do { passenger_installed_version: '5.0.0', rails_autodetect: 'on', } end it { is_expected.to raise_error(%r{REMOVED PASSENGER OPTION}) } end describe 'warns when an option is deprecated' do let :params do { passenger_installed_version: '5.0.0', rails_ruby: '/some/path/to/ruby', } end specify { expect { warn(%r{DEPRECATED PASSENGER OPTION}) }.to output(%r{DEPRECATED PASSENGER OPTION}).to_stderr } end end describe "with passenger_root => '/usr/lib/example'" do let :params do { passenger_root: '/usr/lib/example' } end it { is_expected.to contain_file('passenger.conf').with_content(%r{PassengerRoot "/usr/lib/example"}) } end describe 'with passenger_ruby => /usr/lib/example/ruby' do let :params do { passenger_ruby: '/usr/lib/example/ruby' } end it { is_expected.to contain_file('passenger.conf').with_content(%r{PassengerRuby "/usr/lib/example/ruby"}) } end describe 'with passenger_default_ruby => /usr/lib/example/ruby1.9.3' do let :params do { passenger_ruby: '/usr/lib/example/ruby1.9.3' } end it { is_expected.to contain_file('passenger.conf').with_content(%r{PassengerRuby "/usr/lib/example/ruby1.9.3"}) } end describe 'with passenger_high_performance => on' do let :params do { passenger_high_performance: 'on' } end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ PassengerHighPerformance on$}) } end describe 'with passenger_pool_idle_time => 1200' do let :params do { passenger_pool_idle_time: 1200 } end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ PassengerPoolIdleTime 1200$}) } end describe 'with passenger_max_request_queue_size => 100' do let :params do { passenger_max_request_queue_size: 100 } end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ PassengerMaxRequestQueueSize 100$}) } end describe 'with passenger_max_requests => 20' do let :params do { passenger_max_requests: 20 } end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ PassengerMaxRequests 20$}) } end describe 'with passenger_spawn_method => direct' do let :params do { passenger_spawn_method: 'direct' } end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ PassengerSpawnMethod direct$}) } end describe 'with passenger_stat_throttle_rate => 10' do let :params do { passenger_stat_throttle_rate: 10 } end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ PassengerStatThrottleRate 10$}) } end describe 'with passenger_max_pool_size => 16' do let :params do { passenger_max_pool_size: 16 } end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ PassengerMaxPoolSize 16$}) } end describe 'with passenger_min_instances => 5' do let :params do { passenger_min_instances: 5 } end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ PassengerMinInstances 5$}) } end describe 'with passenger_max_instances_per_app => 8' do let :params do { passenger_max_instances_per_app: 8 } end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ PassengerMaxInstancesPerApp 8$}) } end describe 'with rack_autodetect => on' do let :params do { rack_autodetect: 'on' } end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ RackAutoDetect on$}) } end describe 'with rails_autodetect => on' do let :params do { rails_autodetect: 'on' } end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ RailsAutoDetect on$}) } end describe 'with passenger_use_global_queue => on' do let :params do { passenger_use_global_queue: 'on' } end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ PassengerUseGlobalQueue on$}) } end describe "with passenger_app_env => 'foo'" do let :params do { passenger_app_env: 'foo' } end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ PassengerAppEnv foo$}) } end describe "with passenger_log_file => '/var/log/apache2/passenger.log'" do let :params do { passenger_log_file: '/var/log/apache2/passenger.log' } end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ PassengerLogFile "/var/log/apache2/passenger.log"$}) } end describe 'with passenger_log_level => 3' do let :params do { passenger_log_level: 3 } end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ PassengerLogLevel 3$}) } end describe "with mod_path => '/usr/lib/foo/mod_foo.so'" do let :params do { mod_path: '/usr/lib/foo/mod_foo.so' } end it { is_expected.to contain_file('zpassenger.load').with_content(%r{^LoadModule passenger_module \/usr\/lib\/foo\/mod_foo\.so$}) } end describe "with mod_lib_path => '/usr/lib/foo'" do let :params do { mod_lib_path: '/usr/lib/foo' } end it { is_expected.to contain_file('zpassenger.load').with_content(%r{^LoadModule passenger_module \/usr\/lib\/foo\/mod_passenger\.so$}) } end describe "with mod_lib => 'mod_foo.so'" do let :params do { mod_lib: 'mod_foo.so' } end it { is_expected.to contain_file('zpassenger.load').with_content(%r{^LoadModule passenger_module \/usr\/lib\/apache2\/modules\/mod_foo\.so$}) } end describe "with mod_id => 'mod_foo'" do let :params do { mod_id: 'mod_foo' } end it { is_expected.to contain_file('zpassenger.load').with_content(%r{^LoadModule mod_foo \/usr\/lib\/apache2\/modules\/mod_passenger\.so$}) } end - context 'with Ubuntu 16.04 defaults' do + context 'with defaults' do it { is_expected.to contain_file('passenger.conf').with_content(%r{PassengerRoot "/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini"}) } it { is_expected.to contain_file('passenger.conf').without_content(%r{PassengerRuby}) } it { is_expected.to contain_file('passenger.conf').with_content(%r{PassengerDefaultRuby "/usr/bin/ruby"}) } end - - if facts[:os]['release']['major'].to_i == 8 - context 'with Debian 8 defaults' do - it { is_expected.to contain_file('passenger.conf').with_content(%r{PassengerRoot "/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini"}) } - it { is_expected.to contain_file('passenger.conf').without_content(%r{PassengerRuby}) } - it { is_expected.to contain_file('passenger.conf').with_content(%r{PassengerDefaultRuby "/usr/bin/ruby"}) } - end - end when 'RedHat' context 'on a RedHat OS' do case facts[:os]['release']['major'] when '6' context 'on EL6' do it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('passenger') } it { is_expected.to contain_package('mod_passenger') } it { is_expected.to contain_file('passenger_package.conf').with('path' => '/etc/httpd/conf.d/passenger.conf') } it { is_expected.to contain_file('passenger_package.conf').without_content } it { is_expected.to contain_file('passenger_package.conf').without_source } it { is_expected.to contain_file('zpassenger.load').with('path' => '/etc/httpd/conf.d/zpassenger.load') } it { is_expected.to contain_file('passenger.conf').without_content(%r{PassengerRoot}) } it { is_expected.to contain_file('passenger.conf').without_content(%r{PassengerRuby}) } describe "with passenger_root => '/usr/lib/example'" do let :params do { passenger_root: '/usr/lib/example' } end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ PassengerRoot "\/usr\/lib\/example"$}) } end describe 'with passenger_ruby => /usr/lib/example/ruby' do let :params do { passenger_ruby: '/usr/lib/example/ruby' } end it { is_expected.to contain_file('passenger.conf').with_content(%r{^ PassengerRuby "\/usr\/lib\/example\/ruby"$}) } end end when '7' context 'on EL7' do it { is_expected.to contain_file('passenger_package.conf').with('path' => '/etc/httpd/conf.d/passenger.conf') } it { is_expected.to contain_file('zpassenger.load').with('path' => '/etc/httpd/conf.modules.d/zpassenger.load') } end when '8' context 'on EL8' do it { is_expected.to contain_file('passenger_package.conf').with('path' => '/etc/httpd/conf.d/passenger.conf') } it { is_expected.to contain_file('zpassenger.load').with('path' => '/etc/httpd/conf.modules.d/zpassenger.load') } end end end when 'FreeBSD' context 'on a FreeBSD OS' do it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('passenger') } it { is_expected.to contain_package('www/rubygem-passenger') } end when 'Gentoo' context 'on a Gentoo OS' do it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('passenger') } it { is_expected.to contain_package('www-apache/passenger') } end end end end end diff --git a/spec/classes/mod/php_spec.rb b/spec/classes/mod/php_spec.rb index d5e8674d..ad62b6d4 100644 --- a/spec/classes/mod/php_spec.rb +++ b/spec/classes/mod/php_spec.rb @@ -1,348 +1,350 @@ # 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", ) } - end - context 'on buster 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", - ) - } + 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", ) } - end - context 'on bullseye 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", - ) - } + 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 stretch' do + 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 stretch' do + 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