Saltstack Official UFW Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 line
1.8KB

  1. # frozen_string_literal: true
  2. control 'UFW configuration' do
  3. title 'Test UFW configuration'
  4. describe directory('/etc/ufw') do
  5. it { should exist }
  6. end
  7. describe file('/etc/ufw/ufw.conf') do
  8. its('content') { should include 'ENABLED=' }
  9. its('content') { should include 'LOGLEVEL=' }
  10. end
  11. describe command('ufw status verbose | grep Status') do
  12. its('exit_status') { should eq 0 }
  13. its('stdout') { should match(/active/) }
  14. end
  15. describe command('ufw status verbose | grep Logging') do
  16. its('exit_status') { should eq 0 }
  17. its('stdout') { should match(/low/) }
  18. end
  19. describe command('ufw status | grep MySQL') do
  20. its('exit_status') { should eq 0 }
  21. its('stdout') { should match(/ALLOW/) }
  22. end
  23. describe command('ufw status | grep Postgresql') do
  24. its('exit_status') { should eq 0 }
  25. its('stdout') { should match(/LIMIT/) }
  26. end
  27. describe command('ufw status | grep SSH223') do
  28. its('exit_status') { should eq 0 }
  29. its('stdout') { should match(/DENY/) }
  30. end
  31. describe command('ufw status | grep 10.0.0.0') do
  32. its('exit_status') { should eq 0 }
  33. its('stdout') { should match(/DENY/) }
  34. end
  35. describe command('ufw status | grep 22/tcp') do
  36. its('exit_status') { should eq 0 }
  37. its('stdout') { should match(/LIMIT/) }
  38. end
  39. describe command('ufw status | grep 80/tcp') do
  40. its('exit_status') { should eq 0 }
  41. its('stdout') { should match(/DENY/) }
  42. end
  43. describe command('ufw status | grep 443/tcp') do
  44. its('exit_status') { should eq 0 }
  45. its('stdout') { should match(/ALLOW/) }
  46. end
  47. describe command('ufw status | grep 10.0.0.1') do
  48. its('exit_status') { should eq 0 }
  49. its('stdout') { should match(/DENY/) }
  50. end
  51. describe command('ufw status | grep 10.0.0.2') do
  52. its('exit_status') { should eq 0 }
  53. its('stdout') { should match(/DENY/) }
  54. end
  55. end