Skip to content

Commit

Permalink
Fixes #35870 - Ensure mod_expires is loaded
Browse files Browse the repository at this point in the history
In case only minimal Apache modules are loaded then mod_expires may not
be present. The result is that assets are sent without headers that
allow browsers to cache it.
  • Loading branch information
ekohl committed Jan 12, 2023
1 parent 0de12ff commit a132b68
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
6 changes: 5 additions & 1 deletion manifests/config/apache.pp
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,12 @@
if $suburi {
$custom_fragment = undef
} else {
# mod_env is required by configuration in _assets.conf.erb
# mod_env and mod_expires are required by configuration in _assets.conf.erb
include apache::mod::env
# apache::mod::expires pulls in a config file we don't want, like apache::default_mods
# It uses ensure_resource to be compatible with both $apache::default_mods set to true and false
include apache
ensure_resource('apache::mod', 'expires')
$custom_fragment = file('foreman/_assets.conf.erb')
}

Expand Down
22 changes: 22 additions & 0 deletions spec/classes/foreman_config_apache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
it { should compile.with_all_deps }

it 'should include apache with modules' do
should contain_class('apache::mod::env')
should contain_apache__mod('expires')
should contain_class('apache::mod::proxy')
should contain_class('apache::mod::proxy_http')
should contain_class('apache::mod::proxy_wstunnel')
Expand Down Expand Up @@ -79,6 +81,26 @@
should_not contain_apache__vhost('foreman-ssl')
end

describe 'with $apache::default_mods set to false' do
let(:pre_condition) do
<<~PUPPET
class { 'apache':
default_mods => false,
}
PUPPET
end

it { should compile.with_all_deps }
it 'includes apache modules' do
should contain_class('apache::mod::env')
should contain_apache__mod('expires')
should contain_class('apache::mod::proxy')
should contain_class('apache::mod::proxy_http')
should contain_class('apache::mod::proxy_wstunnel')
should contain_class('apache::mod::rewrite')
end
end

describe 'with keycloak' do
let(:params) { super().merge(keycloak: true) }

Expand Down

0 comments on commit a132b68

Please sign in to comment.