view modules/firewall/spec/unit/classes/firewall_linux_redhat_spec.rb @ 39:d6f2a0ee45c0 puppet-3.6

Add "Firewall" module
author IBBoard <dev@ibboard.co.uk>
date Sat, 14 Mar 2015 20:58:03 +0000
parents
children
line wrap: on
line source

require 'spec_helper'

describe 'firewall::linux::redhat', :type => :class do
  %w{RedHat CentOS Fedora}.each do |os|
    oldreleases = (os == 'Fedora' ? ['14'] : ['6.5'])
    newreleases = (os == 'Fedora' ? ['15','Rawhide'] : ['7.0.1406'])

    oldreleases.each do |osrel|
      context "os #{os} and osrel #{osrel}" do
        let(:facts) {{
          :osfamily               => 'RedHat',
          :operatingsystem        => os,
          :operatingsystemrelease => osrel
        }}

        it { should_not contain_service('firewalld') }
        it { should_not contain_package('iptables-services') }
      end
    end

    newreleases.each do |osrel|
      context "os #{os} and osrel #{osrel}" do
        let(:facts) {{
          :osfamily               => 'RedHat',
          :operatingsystem        => os,
          :operatingsystemrelease => osrel
        }}

        it { should contain_service('firewalld').with(
          :ensure => 'stopped',
          :enable => false,
          :before => 'Package[iptables-services]'
        )}

        it { should contain_package('iptables-services').with(
          :ensure => 'present',
          :before => 'Service[iptables]'
        )}
      end
    end

    describe 'ensure' do
      context 'default' do
        it { should contain_service('iptables').with(
          :ensure => 'running',
          :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(
          :enable => 'false'
        )}
      end
    end
  end
end