diff --git a/manifests/http_port.pp b/manifests/http_port.pp index 0ab0728..708a167 100644 --- a/manifests/http_port.pp +++ b/manifests/http_port.pp @@ -86,11 +86,11 @@ } if has_key($facts['os'],'selinux') and $facts['os']['selinux']['enabled'] == true { - selinux::port { "selinux port squid_port_t ${_port}": - ensure => 'present', - seltype => 'squid_port_t', - protocol => 'tcp', - port => $_port, - } + ensure_resource('selinux::port', "selinux port squid_port_t ${_port}", { + ensure => 'present', + seltype => 'squid_port_t', + protocol => 'tcp', + port => $_port, + }) } } diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 6f3aadc..954f729 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -513,7 +513,7 @@ it { is_expected.to contain_concat_fragment('squid_https_port_2001').with_content(%r{^https_port\s+2001\s+special for 2001$}) } end - if facts['osfamily'] == 'RedHat' + if facts[:osfamily] == 'RedHat' context 'with http_port parameters set + SELINUX' do let :params do { config: '/tmp/squid.conf', @@ -521,7 +521,7 @@ end let(:facts) do facts.merge( - selinux => true + selinux: true ) end @@ -538,7 +538,7 @@ end let(:facts) do facts.merge( - selinux => true + selinux: true ) end @@ -547,6 +547,26 @@ it { is_expected.to contain_concat_fragment('squid_https_port_2001').with_content(%r{^https_port\s+2001\s+special for 2001$}) } it { is_expected.to contain_selinux__port('selinux port squid_port_t 2001').with('ensure' => 'present', 'seltype' => 'squid_port_t', 'protocol' => 'tcp', 'port' => '2001') } end + + context 'with duplicate ports on different ip' do + let :params do + { config: '/tmp/squid.conf', + http_ports: { 'ipA' => { 'port' => 3128, 'host' => '192.168.1.10' }, 'ipB' => { 'port' => 3128, 'host' => '192.168.1.11' } } } + end + + let(:facts) do + facts.merge( + selinux: true + ) + end + + it { is_expected.to contain_concat_fragment('squid_header').with_target('/tmp/squid.conf') } + it { is_expected.to contain_concat_fragment('squid_http_port_ipA').with_order('30-05') } + it { is_expected.to contain_concat_fragment('squid_http_port_ipA').with_content(%r{http_port\s+192.168.1.10:3128}) } + it { is_expected.to contain_concat_fragment('squid_http_port_ipB').with_order('30-05') } + it { is_expected.to contain_concat_fragment('squid_http_port_ipB').with_content(%r{http_port\s+192.168.1.11:3128}) } + it { is_expected.to contain_selinux__port('selinux port squid_port_t 3128').with('ensure' => 'present', 'seltype' => 'squid_port_t', 'protocol' => 'tcp', 'port' => '3128') } + end end context 'with snmp_incoming_address parameter set' do