From ed5dd3e5d0870fe8fe2925c9e5215f18813e7791 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Mon, 27 Oct 2014 13:36:46 -0700 Subject: [PATCH] Update tests for EL 7 Without this patch, unit tests make no distinction between EL < 7 and EL 7. This is a problem because the iptables save exec is different between the two operating systems, so the tests will fail for EL 7. This patch fixes the problem by updating the tests to include the new exec command for EL 7. --- spec/unit/puppet/util/firewall_spec.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spec/unit/puppet/util/firewall_spec.rb b/spec/unit/puppet/util/firewall_spec.rb index e586487..4d6f92c 100644 --- a/spec/unit/puppet/util/firewall_spec.rb +++ b/spec/unit/puppet/util/firewall_spec.rb @@ -143,13 +143,22 @@ describe 'Puppet::Util::Firewall' do subject.persist_iptables(proto) end - it 'should exec for CentOS identified from operatingsystem' do + it 'should exec for CentOS 6 identified from operatingsystem and operatingsystemrelease' do allow(Facter.fact(:osfamily)).to receive(:value).and_return(nil) allow(Facter.fact(:operatingsystem)).to receive(:value).and_return('CentOS') + allow(Facter.fact(:operatingsystemrelease)).to receive(:value).and_return('6.5') expect(subject).to receive(:execute).with(%w{/sbin/service iptables save}) subject.persist_iptables(proto) end + it 'should exec for CentOS 7 identified from operatingsystem and operatingsystemrelease' do + allow(Facter.fact(:osfamily)).to receive(:value).and_return(nil) + allow(Facter.fact(:operatingsystem)).to receive(:value).and_return('CentOS') + allow(Facter.fact(:operatingsystemrelease)).to receive(:value).and_return('7.0.1406') + expect(subject).to receive(:execute).with(%w{/usr/libexec/iptables/iptables.init save}) + subject.persist_iptables(proto) + end + it 'should exec for Archlinux identified from osfamily' do allow(Facter.fact(:osfamily)).to receive(:value).and_return('Archlinux') expect(subject).to receive(:execute).with(['/bin/sh', '-c', '/usr/sbin/iptables-save > /etc/iptables/iptables.rules']) -- 2.45.2