Skip to content

Commit 1cb153a

Browse files
authored
Merge pull request #1598 from TheMeier/fix_tests
raise default version to 1.16.0
2 parents bbfff0a + ab2fde9 commit 1cb153a

File tree

8 files changed

+43
-39
lines changed

8 files changed

+43
-39
lines changed

REFERENCE.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ already installed. If the fact is unavailable, it defaults to '1.6.0'.
281281
You may need to set this manually to get a working and idempotent
282282
configuration.
283283

284-
Default value: `pick(fact('nginx_version'), '1.6.0')`
284+
Default value: `pick(fact('nginx_version'), '1.16.0')`
285285

286286
##### <a name="-nginx--debug_connections"></a>`debug_connections`
287287

@@ -2918,15 +2918,15 @@ Default value: `'on'`
29182918

29192919
Data type: `Enum['on', 'off']`
29202920

2921-
Wheter to use proxy_protocol
2921+
Wheter to use proxy_protocol, only suppported with nginx >= 1.19.8
29222922

29232923
Default value: `'off'`
29242924

29252925
##### <a name="-nginx--resource--mailhost--proxy_smtp_auth"></a>`proxy_smtp_auth`
29262926

29272927
Data type: `Enum['on', 'off']`
29282928

2929-
Wheter to use proxy_smtp_auth
2929+
Wheter to use proxy_smtp_auth, only suppported with nginx >= 1.19.4
29302930

29312931
Default value: `'off'`
29322932

manifests/init.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@
240240
Hash $nginx_upstreams = {},
241241
Nginx::UpstreamDefaults $nginx_upstreams_defaults = {},
242242
Boolean $purge_passenger_repo = true,
243-
String[1] $nginx_version = pick(fact('nginx_version'), '1.6.0'),
243+
String[1] $nginx_version = pick(fact('nginx_version'), '1.16.0'),
244244

245245
### END Hiera Lookups ###
246246
) inherits nginx::params {

manifests/resource/mailhost.pp

+3-2
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@
7373
# @param xclient
7474
# Whether to use xclient for smtp
7575
# @param proxy_protocol
76-
# Wheter to use proxy_protocol
76+
# Wheter to use proxy_protocol, only suppported with nginx >= 1.19.8
7777
# @param proxy_smtp_auth
78-
# Wheter to use proxy_smtp_auth
78+
# Wheter to use proxy_smtp_auth, only suppported with nginx >= 1.19.4
7979
# @param imap_auth
8080
# Sets permitted methods of authentication for IMAP clients.
8181
# @param imap_capabilities
@@ -257,6 +257,7 @@
257257
smtp_auth => $smtp_auth,
258258
smtp_capabilities => $smtp_capabilities,
259259
xclient => $xclient,
260+
nginx_version => $nginx::nginx_version,
260261
})
261262

262263
concat { $config_file:

spec/acceptance/nginx_mail_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class { 'nginx':
8080
it { is_expected.to be_listening }
8181
end
8282

83-
context 'when configured for nginx 1.14' do
83+
context 'when configured for nginx 1.14', if: !%w[Debian Archlinux].include?(fact('os.family')) do
8484
it 'runs successfully' do
8585
pp = "
8686
if fact('os.family') == 'RedHat' {

spec/classes/nginx_spec.rb

+1-6
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,8 @@
189189
let(:params) { { package_source: 'passenger' } }
190190

191191
it { is_expected.to contain_package('nginx') }
192+
it { is_expected.to contain_package('libnginx-mod-http-passenger') }
192193

193-
if (facts.dig(:os, 'name') == 'Debian' && %w[11].include?(facts.dig(:os, 'release', 'major'))) ||
194-
(facts.dig(:os, 'name') == 'Ubuntu' && %w[bionic focal jammy].include?(facts.dig(:os, 'distro', 'codename')))
195-
it { is_expected.to contain_package('libnginx-mod-http-passenger') }
196-
else
197-
it { is_expected.to contain_package('passenger') }
198-
end
199194
it do
200195
is_expected.to contain_apt__source('nginx').with(
201196
'location' => 'https://oss-binaries.phusionpassenger.com/apt/passenger',

spec/defines/resource_mailhost_spec.rb

+28-25
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,6 @@
110110
value: 'off',
111111
match: ' xclient off;'
112112
},
113-
{
114-
title: 'should set proxy_protocol',
115-
attr: 'proxy_protocol',
116-
value: 'off',
117-
match: ' proxy_protocol off;'
118-
},
119-
{
120-
title: 'should set proxy_smtp_auth',
121-
attr: 'proxy_smtp_auth',
122-
value: 'off',
123-
match: ' proxy_smtp_auth off;'
124-
},
125113
{
126114
title: 'should set auth_http',
127115
attr: 'auth_http',
@@ -254,6 +242,23 @@
254242
end
255243
end
256244
end
245+
context 'mail proxy parameters' do
246+
let(:pre_condition) { ['class { "nginx": nginx_version => "1.20.0"}'] }
247+
let(:params) do
248+
{
249+
listen_port: 25,
250+
ipv6_enable: true,
251+
ssl_cert: 'dummy.crt',
252+
ssl_key: 'dummy.key'
253+
}
254+
end
255+
256+
it 'configures mail proxy settings' do
257+
content = catalogue.resource('concat::fragment', "#{title}-header").send(:parameters)[:content]
258+
expect(content).to include('proxy_protocol off;')
259+
expect(content).to include('proxy_smtp_auth off;')
260+
end
261+
end
257262
end
258263

259264
describe 'mailhost template content for imap' do
@@ -548,7 +553,7 @@
548553
title: 'should set the IPv4 SSL listen port',
549554
attr: 'ssl_port',
550555
value: 45,
551-
match: ' listen *:45;'
556+
match: ' listen *:45 ssl;'
552557
},
553558
{
554559
title: 'should enable IPv6',
@@ -598,18 +603,6 @@
598603
value: 'off',
599604
match: ' xclient off;'
600605
},
601-
{
602-
title: 'should set proxy_protocol',
603-
attr: 'proxy_protocol',
604-
value: 'off',
605-
match: ' proxy_protocol off;'
606-
},
607-
{
608-
title: 'should set proxy_smtp_auth',
609-
attr: 'proxy_smtp_auth',
610-
value: 'off',
611-
match: ' proxy_smtp_auth off;'
612-
},
613606
{
614607
title: 'should set auth_http',
615608
attr: 'auth_http',
@@ -712,6 +705,16 @@
712705
expect(content).to include('listen *:587 ssl;')
713706
end
714707
end
708+
709+
context 'mail proxy parameters' do
710+
let(:pre_condition) { ['class { "nginx": nginx_version => "1.20.0"}'] }
711+
712+
it 'configures mail proxy settings' do
713+
content = catalogue.resource('concat::fragment', "#{title}-ssl").send(:parameters)[:content]
714+
expect(content).to include('proxy_protocol off;')
715+
expect(content).to include('proxy_smtp_auth off;')
716+
end
717+
end
715718
end
716719
end
717720

spec/defines/resource_server_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@
672672
facts[:nginx_version] ? facts.delete(:nginx_version) : facts
673673
end
674674

675-
it { is_expected.to contain_concat__fragment("#{title}-ssl-header").with_content(%r{ ssl on;}) }
675+
it { is_expected.to contain_concat__fragment("#{title}-ssl-header").with_content(%r{listen \*:443 ssl;}) }
676676
end
677677

678678
context 'with fact nginx_version=1.14.1' do

templates/mailhost/mailhost_common.epp

+5
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,19 @@
1515
Optional[String] $smtp_auth,
1616
Optional[Array] $smtp_capabilities,
1717
Enum['on', 'off'] $xclient,
18+
String $nginx_version,
1819
| -%>
1920
server_name <%= $server_name.join(" ") %>;
2021
<%- if $protocol { -%>
2122
protocol <%= $protocol %>;
2223
<%- } -%>
2324
xclient <%= $xclient %>;
25+
<%- if versioncmp($nginx_version, '1.19.8') >= 0 { -%>
2426
proxy_protocol <%= $proxy_protocol %>;
27+
<%- } -%>
28+
<%- if versioncmp($nginx_version, '1.19.4') >= 0 { -%>
2529
proxy_smtp_auth <%= $proxy_smtp_auth %>;
30+
<%- } -%>
2631
<%- if $auth_http { -%>
2732
auth_http <%= $auth_http %>;
2833
<%- } -%>

0 commit comments

Comments
 (0)