PageRenderTime 51ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/test/cookbooks/iptables_ng_test/files/default/tests/minitest/lwrp_rule_create_default_test.rb

https://github.com/sewer2/cb-iptables-ng
Ruby | 26 lines | 20 code | 6 blank | 0 comment | 2 complexity | ebe4aed5c179e6d5f6904d3764e16919 MD5 | raw file
  1. require File.expand_path('../support/helpers', __FILE__)
  2. describe 'iptables-ng::lwrp_rule_create_default' do
  3. include Helpers::TestHelpers
  4. it 'should set SSH iptables rule' do
  5. file('/etc/iptables.d/filter/INPUT/ssh.rule_v4').must_include('--protocol tcp --dport 22 --match state --state NEW --jump ACCEPT')
  6. end
  7. it 'should set SSH ip6tables rule' do
  8. file('/etc/iptables.d/filter/INPUT/ssh.rule_v6').must_include('--protocol tcp --dport 22 --match state --state NEW --jump ACCEPT')
  9. end
  10. it 'should enable iptables serices' do
  11. service(node['iptables-ng']['service_ipv4']).must_be_enabled if node['iptables-ng']['service_ipv4']
  12. service(node['iptables-ng']['service_ipv6']).must_be_enabled if node['iptables-ng']['service_ipv6']
  13. end
  14. it 'should apply the specified iptables rules' do
  15. ipv4 = shell_out('iptables -L -n')
  16. ipv4.stdout.must_include('tcp dpt:22 state NEW')
  17. ipv6 = shell_out('ip6tables -L -n')
  18. ipv6.stdout.must_include('tcp dpt:22 state NEW')
  19. end
  20. end