From 53faae954cc037ba6351f36c97310b949a996930 Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Thu, 23 May 2013 01:32:03 +0100 Subject: [PATCH] Add extra tests for logging parameters Signed-off-by: Ken Barber --- Gemfile | 2 +- spec/system/params_spec.rb | 33 ++++++++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index c7e53a4..cccc5a8 100644 --- 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'] diff --git a/spec/system/params_spec.rb b/spec/system/params_spec.rb index 1644527..33a71ad 100644 --- a/spec/system/params_spec.rb +++ b/spec/system/params_spec.rb @@ -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 -- 2.45.2