Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically require SSL cert files in the server #1296

Merged
merged 3 commits into from
Feb 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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