From: Jonathan Boyett Date: Wed, 15 Jun 2011 21:18:58 +0000 (-0700) Subject: add test for name, table, chain, dport, and sport parameters X-Git-Tag: v0.0.1~45 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=596b6c282f43292da8c54c8b5f14fee22197acda;p=puppet-modules%2Fpuppetlabs-firewall.git add test for name, table, chain, dport, and sport parameters --- diff --git a/spec/type/iptables_type_spec.rb b/spec/type/iptables_type_spec.rb index e7254db..aba534f 100644 --- a/spec/type/iptables_type_spec.rb +++ b/spec/type/iptables_type_spec.rb @@ -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