PageRenderTime 41ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

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

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