has_feature :ishasmorefrags
has_feature :islastfrag
has_feature :isfirstfrag
+ has_feature :address_type
has_feature :iprange
optional_commands({
:destination => "-d",
:dport => ["-m multiport --dports", "--dport"],
:dst_range => '-m iprange --dst-range',
+ :dst_type => "-m addrtype --dst-type",
:gid => "-m owner --gid-owner",
:hop_limit => "-m hl --hl-eq",
:icmp => "-m icmp6 --icmpv6-type",
:source => "-s",
:sport => ["-m multiport --sports", "--sport"],
:src_range => '-m iprange --src-range',
+ :src_type => "-m addrtype --src-type",
:stat_every => '--every',
:stat_mode => "-m statistic --mode",
:stat_packet => '--packet',
# not provided with current parser [georg.koester])
@resource_list = [:table, :source, :destination, :iniface, :outiface,
:proto, :ishasmorefrags, :islastfrag, :isfirstfrag, :src_range, :dst_range,
- :tcp_flags, :gid, :uid, :sport, :dport,
- :port, :pkttype, :name, :state, :ctstate, :icmp, :hop_limit, :limit, :burst,
+ :tcp_flags, :gid, :uid, :sport, :dport, :port, :dst_type, :src_type,
+ :pkttype, :name, :state, :ctstate, :icmp, :hop_limit, :limit, :burst,
:recent, :rseconds, :reap, :rhitcount, :rttl, :rname, :rsource, :rdest,
:jump, :todest, :tosource, :toports, :log_level, :log_prefix, :reject,
:connlimit_above, :connlimit_mask, :connmark]
pp = <<-EOS
class { '::firewall': }
firewall { '601 - test':
- proto => tcp,
- port => '601',
- action => accept,
+ proto => tcp,
+ port => '601',
+ action => accept,
src_range => '2001:db8::1-2001:db8::ff',
- provider => 'ip6tables',
+ provider => 'ip6tables',
}
EOS
pp = <<-EOS
class { '::firewall': }
firewall { '601 - test':
- proto => tcp,
- port => '601',
- action => accept,
+ proto => tcp,
+ port => '601',
+ action => accept,
+ provider => 'ip6tables',
src_range => '2001::db8::1-2001:db8::ff',
}
EOS
end
it 'should not contain the rule' do
- shell('iptables-save') do |r|
+ shell('ip6tables-save') do |r|
expect(r.stdout).to_not match(/-A INPUT -p tcp -m iprange --src-range 2001::db8::1-2001:db8::ff -m multiport --ports 601 -m comment --comment "601 - test" -j ACCEPT/)
end
end
pp = <<-EOS
class { '::firewall': }
firewall { '602 - test':
- proto => tcp,
- port => '602',
- action => accept,
+ proto => tcp,
+ port => '602',
+ action => accept,
dst_range => '2001:db8::1-2001:db8::ff',
- provider => 'ip6tables',
+ provider => 'ip6tables',
}
EOS
pp = <<-EOS
class { '::firewall': }
firewall { '602 - test':
- proto => tcp,
- port => '602',
- action => accept,
+ proto => tcp,
+ port => '602',
+ action => accept,
+ provider => 'ip6tables',
dst_range => '2001::db8::1-2001:db8::ff',
}
EOS
end
it 'should not contain the rule' do
- shell('iptables-save') do |r|
+ shell('ip6tables-save') do |r|
expect(r.stdout).to_not match(/-A INPUT -p tcp -m iprange --dst-range 2001::db8::1-2001:db8::ff -m multiport --ports 602 -m comment --comment "602 - test" -j ACCEPT/)
end
end
end
end
+ # ip6tables on el5 and el6 doesn't support addrtype
+ if default['platform'] !~ /el-[5-6]/
+ ['dst_type', 'src_type'].each do |type|
+ describe "#{type}" do
+ context 'MULTICAST' do
+ it 'applies' do
+ pp = <<-EOS
+ class { '::firewall': }
+ firewall { '603 - test':
+ proto => tcp,
+ action => accept,
+ #{type} => 'MULTICAST',
+ provider => 'ip6tables',
+ }
+ EOS
+
+ apply_manifest(pp, :catch_failures => true)
+ unless fact('selinux') == 'true'
+ apply_manifest(pp, :catch_changes => true)
+ end
+ end
+
+ it 'should contain the rule' do
+ shell('ip6tables-save') do |r|
+ expect(r.stdout).to match(/-A INPUT -p tcp -m addrtype\s.*\sMULTICAST -m comment --comment "603 - test" -j ACCEPT/)
+ end
+ end
+ end
+
+ context 'BROKEN' do
+ it 'fails' do
+ pp = <<-EOS
+ class { '::firewall': }
+ firewall { '603 - test':
+ proto => tcp,
+ action => accept,
+ #{type} => 'BROKEN',
+ provider => 'ip6tables',
+ }
+ EOS
+
+ apply_manifest(pp, :expect_failures => true) do |r|
+ expect(r.stderr).to match(/Invalid value "BROKEN"./)
+ end
+ end
+
+ it 'should not contain the rule' do
+ shell('ip6tables-save') do |r|
+ expect(r.stdout).to_not match(/-A INPUT -p tcp -m addrtype\s.*\sBROKEN -m comment --comment "603 - test" -j ACCEPT/)
+ end
+ end
+ end
+ end
+ end
+ end
+
end
describe 'limit' do
expect(r.stdout).to match(/-A POSTROUTING -d 200.200.200.200(\/32)? -p tcp -m comment --comment "569 - test" -j NETMAP --to 192.168.1.1/)
end
end
- end
+ end
end
end