]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commitdiff
Update tests for EL 7
authorColleen Murphy <colleen@puppetlabs.com>
Mon, 27 Oct 2014 20:36:46 +0000 (13:36 -0700)
committerColleen Murphy <colleen@puppetlabs.com>
Mon, 27 Oct 2014 20:40:53 +0000 (13:40 -0700)
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

index e5864879c32ce23d866e99631a498b51df14b650..4d6f92c66cfb44e40d9a06249f4295e1bd917d77 100644 (file)
@@ -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'])