From e05696995bbf269405aca86da75cb8f440000ac2 Mon Sep 17 00:00:00 2001
From: Ken Barber <ken@bob.sh>
Date: Sun, 14 Apr 2013 00:58:24 +0100
Subject: [PATCH] Add counter to a base number for order gen

Signed-off-by: Ken Barber <ken@bob.sh>
---
 lib/puppet/provider/firewall/iptables.rb   | 3 ++-
 spec/spec_helper_system.rb                 | 3 +++
 spec/system/purge_spec.rb                  | 7 ++++---
 spec/unit/puppet/provider/iptables_spec.rb | 2 +-
 4 files changed, 10 insertions(+), 5 deletions(-)

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
 
-- 
2.45.2