RSpec.configure do |config|
config.mock_with :rspec
end
+
+def with_debian_facts
+ let :facts do
+ {
+ :kernel => 'Linux',
+ :operatingsystem => 'Debian',
+ :operatingsystemrelease => '8.0',
+ :osfamily => 'Debian',
+ }
+ end
+end
:enable => 'true'
)}
end
-
+
context 'ensure => stopped' do
let(:params) {{ :ensure => 'stopped' }}
it { should contain_service('iptables').with(
:ensure => 'stopped'
)}
end
+
context 'enable => false' do
let(:params) {{ :enable => 'false' }}
it { should contain_service('iptables').with(
oldreleases.each do |osrel|
context "os #{os} and osrel #{osrel}" do
let(:facts) {{
- :osfamily => 'RedHat',
:operatingsystem => os,
- :operatingsystemrelease => osrel
+ :operatingsystemrelease => osrel,
+ :osfamily => 'RedHat',
+ :selinux => false,
}}
it { should_not contain_service('firewalld') }
it { should_not contain_package('iptables-services') }
-
+
it_behaves_like "ensures iptables service"
end
end
newreleases.each do |osrel|
context "os #{os} and osrel #{osrel}" do
let(:facts) {{
- :osfamily => 'RedHat',
:operatingsystem => os,
- :operatingsystemrelease => osrel
+ :operatingsystemrelease => osrel,
+ :osfamily => 'RedHat',
+ :selinux => false,
}}
it { should contain_service('firewalld').with(
require 'spec_helper'
describe 'firewall::linux', :type => :class do
- let(:facts_default) {{ :kernel => 'Linux' }}
- it { should contain_package('iptables').with_ensure('present') }
-
context 'RedHat like' do
%w{RedHat CentOS Fedora}.each do |os|
context "operatingsystem => #{os}" do
releases = (os == 'Fedora' ? ['14','15','Rawhide'] : ['6','7'])
releases.each do |osrel|
context "operatingsystemrelease => #{osrel}" do
- let(:facts) { facts_default.merge({ :operatingsystem => os,
- :operatingsystemrelease => osrel}) }
+ let(:facts) {{
+ :kernel => 'Linux',
+ :operatingsystem => os,
+ :operatingsystemrelease => osrel,
+ :osfamily => 'RedHat',
+ :selinux => false,
+ }}
it { should contain_class('firewall::linux::redhat').with_require('Package[iptables]') }
+ it { should contain_package('iptables').with_ensure('present') }
end
end
end
context "operatingsystem => #{os}" do
releases = (os == 'Debian' ? ['6','7','8'] : ['10.04','12.04','14.04'])
releases.each do |osrel|
- let(:facts) { facts_default.merge({ :operatingsystem => os, :operatingsystemrelease => osrel}) }
+ let(:facts) {{
+ :kernel => 'Linux',
+ :operatingsystem => os,
+ :operatingsystemrelease => osrel,
+ :osfamily => 'Debian',
+ :selinux => false,
+ }}
+
it { should contain_class('firewall::linux::debian').with_require('Package[iptables]') }
+ it { should contain_package('iptables').with_ensure('present') }
end
end
end
describe 'firewall', :type => :class do
context 'kernel => Linux' do
- let(:facts) {{ :kernel => 'Linux' }}
+ with_debian_facts
it { should contain_class('firewall::linux').with_ensure('running') }
end
end
context 'ensure => stopped' do
- let(:facts) {{ :kernel => 'Linux' }}
+ with_debian_facts
let(:params) {{ :ensure => 'stopped' }}
it { should contain_class('firewall::linux').with_ensure('stopped') }
end