]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commitdiff
add test for name, table, chain, dport, and sport parameters
authorJonathan Boyett <jonathan@failingservers.com>
Wed, 15 Jun 2011 21:18:58 +0000 (14:18 -0700)
committerJonathan Boyett <jonathan@failingservers.com>
Wed, 15 Jun 2011 21:18:58 +0000 (14:18 -0700)
spec/type/iptables_type_spec.rb

index e7254db3a32f1de44dced57227093c1e624d299a..aba534f8fbd38e5f5175e68cb6a46ea11311bc5a 100644 (file)
@@ -9,13 +9,47 @@ describe Puppet::Type.type(:firewall) do
     })
   end
 
-  it 'should accept a name' do
-    @resource[:name] = '000-test-foo'
-    @resource[:name].should == '000-test-foo'
+  describe ':name' do
+    it 'should accept a name' do
+      @resource[:name] = '000-test-foo'
+      @resource[:name].should == '000-test-foo'
+    end
+
+    it 'should not accept a name with non-ASCII chars' do
+      @resource[:name] = '%*#^(#$'
+      @resource[:name].should raise_error(Puppet::Type::Firewall)
+    end
+  end
+
+  describe ':chain' do
+    [:INPUT, :FORWARD, :OUTPUT, :PREROUTING, :POSTROUTING].each do |chain|
+      it "should accept chain value #{chain}" do
+        @resource[:chain] = chain
+        @resource[:chain].should == chain
+      end
+    end
   end
 
-  it 'should accept a dport' do
-    @resource[:dport] = '22'
-    @resource[:dport].should == [22]
+  describe ':table' do
+    [:nat, :mangle, :filter, :raw].each do |table|
+      it "should accept table value #{table}" do
+        @resource[:table] = table
+        @resource[:table].should == table
+      end
+    end
+  end
+
+  describe ':dport/sport' do
+    [:dport, :sport].each do |port|
+      it "should accept a #{port} as string" do
+        @resource[port] = '22'
+        @resource[port].should == [22]
+      end
+
+      it "should accept a #{port} as an array" do
+        @resource[port] = ['22','23']
+        @resource[port].should == [22,23]
+      end
+    end
   end
 end