From: Ken Barber Date: Sat, 13 Apr 2013 23:58:24 +0000 (+0100) Subject: Add counter to a base number for order gen X-Git-Tag: 0.3.0~4^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=e05696995bbf269405aca86da75cb8f440000ac2;p=puppet-modules%2Fpuppetlabs-firewall.git Add counter to a base number for order gen Signed-off-by: Ken Barber --- diff --git a/lib/puppet/provider/firewall/iptables.rb b/lib/puppet/provider/firewall/iptables.rb index 03da454..c8e9c94 100644 --- a/lib/puppet/provider/firewall/iptables.rb +++ b/lib/puppet/provider/firewall/iptables.rb @@ -232,7 +232,8 @@ Puppet::Type.type(:firewall).provide :iptables, :parent => Puppet::Provider::Fir # Puppet-firewall requires that all rules have comments (resource names) and will fail if # a rule in iptables does not have a comment. We get around this by appending a high level if ! hash[:name] - hash[:name] = "999#{counter} #{Digest::MD5.hexdigest(line)}" + num = 9000 + counter + hash[:name] = "#{num} #{Digest::MD5.hexdigest(line)}" end # Iptables defaults to log_level '4', so it is omitted from the output of iptables-save. diff --git a/spec/spec_helper_system.rb b/spec/spec_helper_system.rb index 9c36272..53a4f83 100644 --- a/spec/spec_helper_system.rb +++ b/spec/spec_helper_system.rb @@ -29,6 +29,9 @@ RSpec.configure do |c| # Project root for the firewall code proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + # Enable colour in Jenkins + c.tty = true + # Import in our local helpers c.include ::LocalHelpers diff --git a/spec/system/purge_spec.rb b/spec/system/purge_spec.rb index d245710..0c14ee1 100644 --- a/spec/system/purge_spec.rb +++ b/spec/system/purge_spec.rb @@ -4,9 +4,10 @@ describe "purge tests:" do it 'make sure duplicate existing rules get purged' do iptables_flush_all_tables - system_run('iptables -A INPUT -s 1.2.1.2') - system_run('iptables -A INPUT -s 1.2.1.2') + system_run('/sbin/iptables -A INPUT -s 1.2.1.2') + system_run('/sbin/iptables -A INPUT -s 1.2.1.2') pp = <<-EOS +class { 'firewall': } resources { 'firewall': purge => true, } @@ -16,7 +17,7 @@ resources { 'firewall': r[:exit_code].should == 2 end - system_run('iptables-save') do |r| + system_run('/sbin/iptables-save') do |r| r[:stdout].should_not =~ /1\.2\.1\.2/ r[:stderr].should == '' end diff --git a/spec/unit/puppet/provider/iptables_spec.rb b/spec/unit/puppet/provider/iptables_spec.rb index 37c6757..9bcde6e 100644 --- a/spec/unit/puppet/provider/iptables_spec.rb +++ b/spec/unit/puppet/provider/iptables_spec.rb @@ -121,7 +121,7 @@ describe 'iptables provider' do let(:instance) { provider.new(resource) } it 'rule name contains a MD5 sum of the line' do - resource[:name].should == "9999 #{Digest::MD5.hexdigest(resource[:line])}" + resource[:name].should == "9000 #{Digest::MD5.hexdigest(resource[:line])}" end end