Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions manifests/http_port.pp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@
fail('port parameter was not specified and could not be determined from title')
}

if $_host != undef {
$_host_port = "${_host}:${_port}"
} else {
$_host_port = String($_port)
$_host_port = $_host ? {
undef => String($_port),
Stdlib::IP::Address::V6 => "[${_host}]:${_port}",
default => "${_host}:${_port}",
}

$protocol = $ssl ? {
Expand Down
13 changes: 13 additions & 0 deletions spec/defines/http_port_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,19 @@
it { is_expected.to contain_concat_fragment('squid_http_port_host:1650').with_content(%r{^http_port\s+1650$}) }
end

context 'with IPv6' do
let(:title) { 'ipv6_host' }
let(:params) do
{
host: '2001:db8::1',
port: 1650,
}
end

# Wrap IPv6addresses in square brackets
it { is_expected.to contain_concat_fragment('squid_http_port_ipv6_host').with_content(%r{^http_port\s+\[2001:db8::1\]:1650$}) }
end

context 'without a port specified' do
let(:title) { 'garbage' }
let(:params) do
Expand Down