]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commitdiff
Add extra tests for logging parameters
authorKen Barber <ken@bob.sh>
Thu, 23 May 2013 00:32:03 +0000 (01:32 +0100)
committerKen Barber <ken@bob.sh>
Thu, 23 May 2013 00:32:03 +0000 (01:32 +0100)
Signed-off-by: Ken Barber <ken@bob.sh>
Gemfile
spec/system/params_spec.rb

diff --git a/Gemfile b/Gemfile
index c7e53a4b4cf024b4858bedd0de6c4cd35fd6b8af..cccc5a87ff393cf87a97504a9d0024eb4936fb3b 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
 
 group :development, :test do
   gem 'puppetlabs_spec_helper', :require => false
-  gem 'rspec-system-puppet', '~>1.0.0'
+  gem 'rspec-system-puppet', '~>1.1', '>=1.1.0'
 end
 
 if puppetversion = ENV['PUPPET_GEM_VERSION']
index 1644527bbd2f4cb0c3d55f29a961d5770ab188bb..33a71ad7ecaf911305b1bc88c2f08c66719a532f 100644 (file)
@@ -2,8 +2,9 @@ require 'spec_helper_system'
 
 describe "param based tests:" do
   def pp(params)
+    name = params.delete('name') || '100 test'
     pm = <<-EOS
-firewall { '100 test':
+firewall { '#{name}':
     EOS
 
     params.each do |k,v| 
@@ -18,7 +19,7 @@ firewall { '100 test':
     pm
   end
 
-  it 'test socket param' do
+  it 'test various params' do
     facts = system_node.facts
 
     unless (facts['operatingsystem'] == 'CentOS') && \
@@ -26,12 +27,13 @@ firewall { '100 test':
 
       iptables_flush_all_tables
 
-      param = {
+      ppm = pp({
         'table' => "'raw'",
         'socket' => 'true',
         'chain' => "'PREROUTING'",
-      }
-      ppm = pp(param)
+        'jump' => 'LOG',
+        'log_level' => 'debug',
+      })
       puppet_apply(ppm) do |r|
         r[:stderr].should == ''
         r[:exit_code].should == 2
@@ -45,4 +47,25 @@ firewall { '100 test':
     end
   end
 
+  it 'test log rule' do
+    iptables_flush_all_tables
+
+    ppm = pp({
+      'name' => '998 log all',
+      'proto' => 'all',
+      'jump' => 'LOG',
+      'log_level' => 'debug',
+    })
+    puppet_apply(ppm) do |r|
+      r.stderr.should == ''
+      r.exit_code.should == 2
+    end
+
+    # check idempotency
+    puppet_apply(ppm) do |r|
+      r.stderr.should == ''
+      r.exit_code.should == 0
+    end
+  end
+
 end