Skip to content

Commit

Permalink
Merge pull request voxpupuli#1296 from ekohl/require-files
Browse files Browse the repository at this point in the history
Automatically require SSL cert files in the server
  • Loading branch information
bastelfreak authored Feb 9, 2019
2 parents 275d662 + ead2422 commit 42255e8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 31 deletions.
3 changes: 2 additions & 1 deletion manifests/resource/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,8 @@
if $ssl {
# Access and error logs are named differently in ssl template

concat::fragment { "${name_sanitized}-ssl-header":
File <| title == $ssl_cert or path == $ssl_cert or title == $ssl_key or path == $ssl_key |>
-> concat::fragment { "${name_sanitized}-ssl-header":
target => $config_file,
content => template('nginx/server/server_ssl_header.erb'),
order => '700',
Expand Down
58 changes: 28 additions & 30 deletions spec/defines/resource_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -437,49 +437,47 @@
end

describe 'server_ssl_header template content' do
context 'without a value for the nginx_version fact do' do
let :facts do
facts[:nginx_version] ? facts.delete(:nginx_version) : facts
end
context 'with ssl' do
let :params do
default_params.merge(
ssl: true,
ssl_key: 'dummy.key',
ssl_cert: 'dummy.crt'
ssl_key: '/tmp/dummy.key',
ssl_cert: '/tmp/dummy.crt'
)
end

it { is_expected.to contain_concat__fragment("#{title}-ssl-header").with_content(%r{ ssl on;}) }
end
context 'with fact nginx_version=1.14.1' do
let :facts do
facts.merge(nginx_version: '1.14.1')
context 'without a value for the nginx_version fact do' do
let :facts do
facts[:nginx_version] ? facts.delete(:nginx_version) : facts
end

it { is_expected.to contain_concat__fragment("#{title}-ssl-header").with_content(%r{ ssl on;}) }
end
let :params do
default_params.merge(
ssl: true,
ssl_key: 'dummy.key',
ssl_cert: 'dummy.crt'
)
context 'with fact nginx_version=1.14.1' do
let(:facts) { facts.merge(nginx_version: '1.14.1') }

it { is_expected.to contain_concat__fragment("#{title}-ssl-header").with_content(%r{ ssl on;}) }
end

it { is_expected.to contain_concat__fragment("#{title}-ssl-header").with_content(%r{ ssl on;}) }
end
context 'with fact nginx_version=1.15.1' do
let(:facts) { facts.merge(nginx_version: '1.15.1') }

context 'with fact nginx_version=1.15.1' do
let :facts do
facts.merge(nginx_version: '1.15.1')
end
let :params do
default_params.merge(
ssl: true,
ssl_key: 'dummy.key',
ssl_cert: 'dummy.crt'
)
it { is_expected.to contain_concat__fragment("#{title}-ssl-header").without_content(%r{ ssl on;}) }
end

it { is_expected.not_to contain_concat__fragment("#{title}-ssl-header").with_content(%r{ ssl on;}) }
context 'with ssl cert and key definitions' do
let(:pre_condition) do
<<-PUPPET
file { ['/tmp/dummy.key', '/tmp/dummy.crt']: }
include nginx
PUPPET
end

it { is_expected.to contain_file('/tmp/dummy.key').with_path('/tmp/dummy.key') }
it { is_expected.to contain_concat__fragment("#{title}-ssl-header").that_requires(['File[/tmp/dummy.key]', 'File[/tmp/dummy.crt]']) }
end
end

[
{
title: 'should not contain www to non-www rewrite',
Expand Down

0 comments on commit 42255e8

Please sign in to comment.