Skip to content

Commit a991609

Browse files
committed
Correct handling of $serveraliases as string
1 parent 61b7ceb commit a991609

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

manifests/vhost.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2559,7 +2559,7 @@
25592559
concat::fragment { "${name}-serveralias":
25602560
target => "${priority_real}${filename}.conf",
25612561
order => 210,
2562-
content => epp('apache/vhost/_serveralias.epp', { 'serveraliases' => $serveraliases }),
2562+
content => epp('apache/vhost/_serveralias.epp', { 'serveraliases' => Array($serveraliases) }),
25632563
}
25642564
}
25652565

spec/defines/vhost_spec.rb

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@
776776
}
777777

778778
it { is_expected.to contain_concat__fragment('rspec.example.com-scriptalias') }
779-
it { is_expected.to contain_concat__fragment('rspec.example.com-serveralias') }
779+
it { is_expected.to contain_concat__fragment('rspec.example.com-serveralias').with_content(%r{^ ServerAlias test-example\.com$}) }
780780

781781
it {
782782
expect(subject).to contain_concat__fragment('rspec.example.com-setenv')
@@ -1221,6 +1221,32 @@
12211221
it { is_expected.not_to contain_concat__fragment('NameVirtualHost 127.0.0.1:8080') }
12221222
end
12231223

1224+
describe 'serveraliases parameter' do
1225+
let :params do
1226+
{
1227+
'serveraliases' => serveraliases,
1228+
}
1229+
end
1230+
1231+
context 'with a string' do
1232+
let(:serveraliases) { 'alias.example.com' }
1233+
1234+
it { is_expected.to compile.with_all_deps }
1235+
it { is_expected.to contain_concat__fragment('rspec.example.com-serveralias').with_content(%r{^ ServerAlias alias\.example\.com$}) }
1236+
end
1237+
1238+
context 'with an array' do
1239+
let(:serveraliases) { ['alias1.example.com', 'alias2.example.com'] }
1240+
1241+
it { is_expected.to compile.with_all_deps }
1242+
it do
1243+
expect(subject).to contain_concat__fragment('rspec.example.com-serveralias')
1244+
.with_content(%r{^ ServerAlias alias1\.example\.com$})
1245+
.with_content(%r{^ ServerAlias alias2\.example\.com$})
1246+
end
1247+
end
1248+
end
1249+
12241250
context 'vhost with multiple ip addresses, multiple ports' do
12251251
let :params do
12261252
{

templates/vhost/_serveralias.epp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
<%- | Array[String] $serveraliases | -%>
12
<% unless $serveraliases.empty { -%>
23

34
## Server aliases
4-
<%- Array($serveraliases).each |$serveralias| { -%>
5+
<%- $serveraliases.each |$serveralias| { -%>
56
ServerAlias <%= $serveralias %>
67
<%- } -%>
78
<% } -%>

0 commit comments

Comments
 (0)