--- /dev/null
+require 'spec_helper_acceptance'
+
+describe 'firewall type' do
+
+ describe 'connlimit_above' do
+ context '10' do
+ it 'applies' do
+ pp = <<-EOS
+ class { '::firewall': }
+ firewall { '500 - test':
+ proto => tcp,
+ dport => '22',
+ connlimit_above => '10',
+ action => reject,
+ }
+ EOS
+
+ apply_manifest(pp, :catch_failures => true)
+ end
+
+ it 'should contain the rule' do
+ shell('iptables-save') do |r|
+ expect(r.stdout).to match(/-A INPUT -p tcp -m multiport --dports 22 -m comment --comment "500 - test" -m connlimit --connlimit-above 10 --connlimit-mask 32 -j REJECT --reject-with icmp-port-unreachable/)
+ end
+ end
+ end
+ end
+
+ describe 'connlimit_mask' do
+ context '24' do
+ it 'applies' do
+ pp = <<-EOS
+ class { '::firewall': }
+ firewall { '501 - test':
+ proto => tcp,
+ dport => '22',
+ connlimit_above => '10',
+ connlimit_mask => '24',
+ action => reject,
+ }
+ EOS
+
+ apply_manifest(pp, :catch_failures => true)
+ end
+
+ it 'should contain the rule' do
+ shell('iptables-save') do |r|
+ expect(r.stdout).to match(/-A INPUT -p tcp -m multiport --dports 22 -m comment --comment "501 - test" -m connlimit --connlimit-above 10 --connlimit-mask 24 -j REJECT --reject-with icmp-port-unreachable/)
+ end
+ end
+ end
+ end
+end
:dport => ["20443"],
},
},
+ 'connlimit_above' => {
+ :line => '-A INPUT -p tcp -m multiport --dports 22 -m comment --comment "061 REJECT connlimit_above 10" -m connlimit --connlimit-above 10 --connlimit-mask 32 -j REJECT --reject-with icmp-port-unreachable',
+ :table => 'filter',
+ :params => {
+ :proto => 'tcp',
+ :dport => ["22"],
+ :connlimit_above => '10',
+ :action => 'reject',
+ },
+ },
+ 'connlimit_above_with_connlimit_mask' => {
+ :line => '-A INPUT -p tcp -m multiport --dports 22 -m comment --comment "061 REJECT connlimit_above 10 with mask 24" -m connlimit --connlimit-above 10 --connlimit-mask 24 -j REJECT --reject-with icmp-port-unreachable',
+ :table => 'filter',
+ :params => {
+ :proto => 'tcp',
+ :dport => ["22"],
+ :connlimit_above => '10',
+ :connlimit_mask => '24',
+ :action => 'reject',
+ },
+ },
+ 'connmark' => {
+ :line => '-A INPUT -m comment --comment "062 REJECT connmark" -m connmark --mark 0x1 -j REJECT --reject-with icmp-port-unreachable',
+ :table => 'filter',
+ :params => {
+ :proto => 'all',
+ :connmark => '0x1',
+ :action => 'reject',
+ },
+ },
}
# This hash is for testing converting a hash to an argument line.
},
:args => ['-t', :filter, '-p', :all, '-m', 'comment', '--comment', '050 testcomment-with-fdashf', '-j', 'ACCEPT'],
},
+ 'connlimit_above' => {
+ :params => {
+ :name => '061 REJECT connlimit_above 10',
+ :table => 'filter',
+ :proto => 'tcp',
+ :dport => ["22"],
+ :connlimit_above => '10',
+ :action => 'reject',
+ },
+ :args => ["-t", :filter, "-p", :tcp, "-m", "multiport", "--dports", "22", "-m", "comment", "--comment", "061 REJECT connlimit_above 10", "-j", "REJECT", "-m", "connlimit", "--connlimit-above", "10"],
+ },
+ 'connlimit_above_with_connlimit_mask' => {
+ :params => {
+ :name => '061 REJECT connlimit_above 10 with mask 24',
+ :table => 'filter',
+ :proto => 'tcp',
+ :dport => ["22"],
+ :connlimit_above => '10',
+ :connlimit_mask => '24',
+ :action => 'reject',
+ },
+ :args => ["-t", :filter, "-p", :tcp, "-m", "multiport", "--dports", "22", "-m", "comment", "--comment", "061 REJECT connlimit_above 10 with mask 24", "-j", "REJECT", "-m", "connlimit", "--connlimit-above", "10", "--connlimit-mask", "24"],
+ },
+ 'connmark' => {
+ :params => {
+ :name => '062 REJECT connmark',
+ :table => 'filter',
+ :proto => 'all',
+ :connmark => '0x1',
+ :action => 'reject',
+ },
+ :args => ["-t", :filter, "-p", :all, "-m", "comment", "--comment", "062 REJECT connmark", "-j", "REJECT", "-m", "connmark", "--mark", "0x1"],
+ },
}