Skip to content
This repository has been archived by the owner on Jun 11, 2019. It is now read-only.

Commit

Permalink
added test to firewall
Browse files Browse the repository at this point in the history
  • Loading branch information
jerger committed Feb 5, 2013
1 parent f8a8bda commit e7191c2
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Rakefile
@@ -0,0 +1,9 @@
require 'rake'
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:test) do |t|
t.rspec_opts = ["--format", "doc", "--color"]
t.pattern = 'spec/*/*_spec.rb'
end

task :default => :test
2 changes: 0 additions & 2 deletions manifests/init.pp
Expand Up @@ -58,7 +58,5 @@
enable => $enable,
enable_v6 => $enable_v6,
}

}

}
24 changes: 24 additions & 0 deletions spec/defines/firewall_spec.rb
@@ -0,0 +1,24 @@
require "#{File.join(File.dirname(__FILE__),'..','spec_helper.rb')}"

describe 'firewall' do
let(:title) { 'firewall1' }
let(:node) { 'firewall.example42.com' }
let(:facts) { { :operatingsystem => 'ubuntu', :osver_maj => 12 } }

describe 'Test firewall with http rule' do
let(:params) {
{ 'port' => '80',
'protocol' => 'tcp',
'enable_v6' => true,
}
}

it { should contain_iptables__rule( "firewall1" ).with(
'port' => '80',
'protocol' => 'tcp',
'enable_v6' => true,
'source' => '',
'destination' => '',
) }
end
end
22 changes: 22 additions & 0 deletions spec/spec_helper.rb
@@ -0,0 +1,22 @@
require 'puppet'
require 'rspec-puppet'
require 'tmpdir'

RSpec.configure do |c|
c.before :each do
# Create a temporary puppet confdir area and temporary site.pp so
# when rspec-puppet runs we don't get a puppet error.
@puppetdir = Dir.mktmpdir("iptables")
manifestdir = File.join(@puppetdir, "manifests")
Dir.mkdir(manifestdir)
FileUtils.touch(File.join(manifestdir, "site.pp"))
Puppet[:confdir] = @puppetdir
end

c.after :each do
FileUtils.rm_rf(Dir.glob('/tmp/iptables20*') , :secure => true)
end

c.module_path = File.join(File.dirname(__FILE__), '../../')
end

0 comments on commit e7191c2

Please sign in to comment.