]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commitdiff
Add tests and fix docs/whitespace
authorHunter Haugen <hunter@puppetlabs.com>
Wed, 28 May 2014 19:03:29 +0000 (12:03 -0700)
committerHunter Haugen <hunter@puppetlabs.com>
Wed, 28 May 2014 19:03:29 +0000 (12:03 -0700)
lib/puppet/type/firewall.rb
spec/acceptance/resource_cmd_spec.rb

index 22afbd21e2a7c2019e44df59b34c5e7014e32093..e6be89e25c20ae943bf99229a73c9bdcebb9faf6 100644 (file)
@@ -884,19 +884,19 @@ Puppet::Type.newtype(:firewall) do
   end
 
   newproperty(:ipsec_policy, :required_features => :ipsec_policy) do
-         desc <<-EOS
-                Sets the ipsec policy type
-         EOS
+    desc <<-EOS
+       Sets the ipsec policy type. May take a combination of arguments for any flags that can be passed to `--pol ipsec` such as: `--strict`, `--reqid 100`, `--next`, `--proto esp`, etc.
+    EOS
 
-         newvalues(:none, :ipsec)
+    newvalues(:none, :ipsec)
   end
 
   newproperty(:ipsec_dir, :required_features => :ipsec_dir) do
-         desc <<-EOS
-                Sets the ipsec policy direction
-         EOS
+    desc <<-EOS
+       Sets the ipsec policy direction
+    EOS
 
-         newvalues(:in, :out)
+    newvalues(:in, :out)
   end
 
   newproperty(:mask, :required_features => :mask) do
index c9a852d82648b0b4f9a8f3360916373ea3426bd0..573397b0d36aa0330f9b73e50fe801b4b7514798 100644 (file)
@@ -90,4 +90,23 @@ describe 'puppet resource firewall command:' do
       end
     end
   end
+
+  context 'accepts rules with negation' do
+    before :all do
+      iptables_flush_all_tables
+      shell('iptables -t nat -A POSTROUTING -s 192.168.122.0/24 -m policy --dir out --pol ipsec -j ACCEPT')
+      shell('iptables -t filter -A FORWARD -s 192.168.1.0/24 -d 192.168.122.0/24 -i eth0 -m policy --dir in --pol ipsec --reqid 108 --proto esp -j ACCEPT')
+      shell('iptables -t filter -A FORWARD -s 192.168.122.0/24 -d 192.168.1.0/24 -o eth0 -m policy --dir out --pol ipsec --reqid 108 --proto esp -j ACCEPT')
+      shell('iptables -t filter -A FORWARD -s 192.168.201.1/32 -d 192.168.122.0/24 -i eth0 -m policy --dir in --pol ipsec --reqid 107 --proto esp -j ACCEPT')
+      shell('iptables -t filter -A FORWARD -s 192.168.122.0/24 -d 192.168.201.1/32 -o eth0 -m policy --dir out --pol ipsec --reqid 107 --proto esp -j ACCEPT')
+    end
+
+    it do
+      shell('puppet resource firewall') do |r|
+        r.exit_code.should be_zero
+        # don't check stdout, testing preexisting rules, output is normal
+        r.stderr.should be_empty
+      end
+    end
+  end
 end