From f5c8409a1071fb19337d58216da386fbc8f87b97 Mon Sep 17 00:00:00 2001 From: William Yardley Date: Wed, 15 Feb 2017 22:46:54 -0800 Subject: [PATCH] Warn if $ssl=false but $ssl_port == $listen_port (#1015) --- manifests/resource/server.pp | 6 ++++++ spec/defines/resource_server_spec.rb | 10 ++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/manifests/resource/server.pp b/manifests/resource/server.pp index f8ab7e015..9f0caf653 100644 --- a/manifests/resource/server.pp +++ b/manifests/resource/server.pp @@ -354,6 +354,12 @@ } } + # Try to error in the case where the user sets ssl_port == listen_port but + # doesn't set ssl = true + if (!($ssl == true) and ($ssl_port == $listen_port)) { + warning('nginx: ssl must be true if listen_port is the same as ssl_port') + } + concat { $config_file: owner => $owner, group => $group, diff --git a/spec/defines/resource_server_spec.rb b/spec/defines/resource_server_spec.rb index de588f14a..51dd74102 100644 --- a/spec/defines/resource_server_spec.rb +++ b/spec/defines/resource_server_spec.rb @@ -990,14 +990,16 @@ it { is_expected.to contain_file('/etc/nginx/uwsgi_params').with_mode('0644') } end - context 'when listen_port == ssl_port' do + context 'when listen_port == ssl_port but ssl = false' do let :params do default_params.merge(listen_port: 80, - ssl_port: 80) + ssl_port: 80, + ssl: false) end - it { is_expected.not_to contain_concat__fragment("#{title}-header") } - it { is_expected.not_to contain_concat__fragment("#{title}-footer") } + # TODO: implement test after this can be tested + # msg = %r{nginx: ssl must be true if listen_port is the same as ssl_port} + it 'Testing for warnings not yet implemented in classes' end context 'when listen_port != ssl_port' do