]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commitdiff
stop using the beaker default function
authortphoney <tp@puppet.com>
Mon, 4 Mar 2019 17:33:30 +0000 (17:33 +0000)
committertphoney <tp@puppet.com>
Mon, 4 Mar 2019 22:54:28 +0000 (22:54 +0000)
spec/acceptance/firewall_attributes_exceptions_spec.rb
spec/acceptance/firewall_bridging_spec.rb
spec/acceptance/firewall_mss_spec.rb
spec/acceptance/firewall_tee_spec.rb
spec/acceptance/firewall_time_spec.rb
spec/acceptance/ip6_fragment_spec.rb
spec/acceptance/match_mark_spec.rb
spec/acceptance/resource_cmd_spec.rb
spec/acceptance/socket_spec.rb

index 4989dcb080eb0dabefcd8cb18acf9bf15581cb09..7ce6edee4c0e05fb22a3957377fb2bb93cb07041 100644 (file)
@@ -318,7 +318,7 @@ describe 'firewall basics', docker: true do
     end
   end
 
-  if default['platform'] !~ %r{el-5} && default['platform'] !~ %r{sles}
+  unless (os[:family] == 'redhat' && os[:release].start_with?('5')) || os[:family] == 'sles'
     describe 'checksum_fill' do
       context 'when virbr' do
         pp38 = <<-PUPPETCODE
@@ -375,7 +375,7 @@ describe 'firewall basics', docker: true do
   end
 
   # RHEL5 does not support --random
-  if default['platform'] !~ %r{el-5}
+  unless os[:family] == 'redhat' && os[:release].start_with?('5')
     describe 'random' do
       context 'when 192.168.1.1' do
         pp40 = <<-PUPPETCODE
@@ -748,7 +748,7 @@ describe 'firewall basics', docker: true do
     end
 
     # ip6tables has limited `-m socket` support
-    if default['platform'] !~ %r{el-5} && default['platform'] !~ %r{sles}
+    unless (os[:family] == 'redhat' && os[:release].start_with?('5')) || os[:family] == 'sles'
       describe 'socket' do
         context 'when true' do
           pp56 = <<-PUPPETCODE
@@ -1195,7 +1195,7 @@ describe 'firewall basics', docker: true do
   end
 
   # iptables version 1.3.5 does not support masks on MARK rules
-  if default['platform'] !~ %r{el-5}
+  unless os[:family] == 'redhat' && os[:release].start_with?('5')
     describe 'set_mark' do
       context 'when 0x3e8/0xffffffff' do
         pp73 = <<-PUPPETCODE
@@ -1224,7 +1224,7 @@ describe 'firewall basics', docker: true do
   end
 
   # RHEL5/SLES does not support -m socket
-  describe 'socket', unless: (default['platform'] =~ %r{el-5} || os[:family] == 'sles') do
+  describe 'socket', unless: (os[:family] == 'redhat' && os[:release].start_with?('5')) || (os[:family] == 'sles') do
     context 'when true' do
       pp78 = <<-PUPPETCODE
           class { '::firewall': }
index dda7e847b5c27529a95c5d6ca9ab75532cf2295a..590e96df3c7bf2d2f3034493c9b3eb1d6db2b1ad 100644 (file)
@@ -7,7 +7,7 @@ describe 'firewall bridging' do
   end
   describe 'iptables physdev tests' do
     # iptables version 1.3.5 is not suppored by the ip6tables provider
-    if default['platform'] !~ %r{el-5}
+    unless os[:family] == 'redhat' && os[:release].start_with?('5')
       describe 'ip6tables physdev tests' do
         context 'when physdev_in eth0' do
           pp8 = <<-PUPPETCODE
index a42a7307c09c450502ce61819578627c444eb42c..d1b438e7c288f4a55fbac508a71cd117723f60da 100644 (file)
@@ -6,7 +6,7 @@ describe 'firewall MSS' do
     ip6tables_flush_all_tables
   end
 
-  if default['platform'] !~ %r{el-5}
+  unless os[:family] == 'redhat' && os[:release].start_with?('5')
     describe 'mss ipv6 tests' do
       context 'when 1360' do
         pp3 = <<-PUPPETCODE
index 3a59683e29d6ecd918393502d4fc20732a2d84ef..2fca0808802f6e562f56ac3adfc8f5cdb48f5058 100644 (file)
@@ -1,59 +1,56 @@
 require 'spec_helper_acceptance'
 
-describe 'firewall tee' do
+describe 'firewall tee', unless: (os[:family] == 'redhat' && ['5', '6'].include?(os[:release][0])) || (os[:family] == 'sles') do
   before :all do
     iptables_flush_all_tables
     ip6tables_flush_all_tables
   end
+  describe 'tee_gateway' do
+    context 'when 10.0.0.2' do
+      pp1 = <<-PUPPETCODE
+          class { '::firewall': }
+          firewall {
+            '810 - tee_gateway':
+              chain   => 'PREROUTING',
+              table   => 'mangle',
+              jump    => 'TEE',
+              gateway => '10.0.0.2',
+              proto   => all,
+          }
+      PUPPETCODE
+      it 'applies' do
+        apply_manifest(pp1, catch_failures: true)
+      end
 
-  if default['platform'] =~ %r{ubuntu-1404} || default['platform'] =~ %r{debian-8} || default['platform'] =~ %r{el-7}
-    describe 'tee_gateway' do
-      context 'when 10.0.0.2' do
-        pp1 = <<-PUPPETCODE
-            class { '::firewall': }
-            firewall {
-              '810 - tee_gateway':
-                chain   => 'PREROUTING',
-                table   => 'mangle',
-                jump    => 'TEE',
-                gateway => '10.0.0.2',
-                proto   => all,
-            }
-        PUPPETCODE
-        it 'applies' do
-          apply_manifest(pp1, catch_failures: true)
-        end
-
-        it 'contains the rule' do
-          shell('iptables-save -t mangle') do |r|
-            expect(r.stdout).to match(%r{-A PREROUTING -m comment --comment "810 - tee_gateway" -j TEE --gateway 10.0.0.2})
-          end
+      it 'contains the rule' do
+        shell('iptables-save -t mangle') do |r|
+          expect(r.stdout).to match(%r{-A PREROUTING -m comment --comment "810 - tee_gateway" -j TEE --gateway 10.0.0.2})
         end
       end
     end
+  end
 
-    describe 'tee_gateway6' do
-      context 'when 2001:db8::1' do
-        pp2 = <<-PUPPETCODE
-            class { '::firewall': }
-            firewall {
-              '811 - tee_gateway6':
-                chain    => 'PREROUTING',
-                table    => 'mangle',
-                jump     => 'TEE',
-                gateway  => '2001:db8::1',
-                proto   => all,
-                provider => 'ip6tables',
-            }
-        PUPPETCODE
-        it 'applies' do
-          apply_manifest(pp2, catch_failures: true)
-        end
+  describe 'tee_gateway6' do
+    context 'when 2001:db8::1' do
+      pp2 = <<-PUPPETCODE
+          class { '::firewall': }
+          firewall {
+            '811 - tee_gateway6':
+              chain    => 'PREROUTING',
+              table    => 'mangle',
+              jump     => 'TEE',
+              gateway  => '2001:db8::1',
+              proto   => all,
+              provider => 'ip6tables',
+          }
+      PUPPETCODE
+      it 'applies' do
+        apply_manifest(pp2, catch_failures: true)
+      end
 
-        it 'contains the rule' do
-          shell('ip6tables-save -t mangle') do |r|
-            expect(r.stdout).to match(%r{-A PREROUTING -m comment --comment "811 - tee_gateway6" -j TEE --gateway 2001:db8::1})
-          end
+      it 'contains the rule' do
+        shell('ip6tables-save -t mangle') do |r|
+          expect(r.stdout).to match(%r{-A PREROUTING -m comment --comment "811 - tee_gateway6" -j TEE --gateway 2001:db8::1})
         end
       end
     end
index 8c554297e6fd792eeb149a089db2117bce7e41c4..d1b6fb1f21758a30c99df3889bd00ed4433c78ab 100644 (file)
@@ -1,71 +1,73 @@
 require 'spec_helper_acceptance'
 
-describe 'firewall time' do
+describe 'firewall time', unless: (os[:family] == 'redhat' && ['5', '6'].include?(os[:release][0])) || (os[:family] == 'sles') do
   before :all do
     iptables_flush_all_tables
     ip6tables_flush_all_tables
   end
 
-  if default['platform'] =~ %r{ubuntu-1404} || default['platform'] =~ %r{debian-8} || default['platform'] =~ %r{el-7}
-    describe 'time tests ipv4' do
-      context 'when set all time parameters' do
-        pp1 = <<-PUPPETCODE
-            class { '::firewall': }
-            firewall { '805 - test':
-              proto              => tcp,
-              dport              => '8080',
-              action             => accept,
-              chain              => 'OUTPUT',
-              date_start         => '2016-01-19T04:17:07',
-              date_stop          => '2038-01-19T04:17:07',
-              time_start         => '6:00',
-              time_stop          => '17:00:00',
-              month_days         => '7',
-              week_days          => 'Tue',
-              kernel_timezone    => true,
-            }
-        PUPPETCODE
-        it 'applies' do
-          apply_manifest(pp1, catch_failures: true)
-          apply_manifest(pp1, catch_changes: do_catch_changes)
-        end
+  describe 'time tests ipv4' do
+    context 'when set all time parameters' do
+      pp1 = <<-PUPPETCODE
+          class { '::firewall': }
+          firewall { '805 - test':
+            proto              => tcp,
+            dport              => '8080',
+            action             => accept,
+            chain              => 'OUTPUT',
+            date_start         => '2016-01-19T04:17:07',
+            date_stop          => '2038-01-19T04:17:07',
+            time_start         => '6:00',
+            time_stop          => '17:00:00',
+            month_days         => '7',
+            week_days          => 'Tue',
+            kernel_timezone    => true,
+          }
+      PUPPETCODE
+      it 'applies' do
+        apply_manifest(pp1, catch_failures: true)
+        apply_manifest(pp1, catch_changes: do_catch_changes)
+      end
 
-        it 'contains the rule' do
-          shell('iptables-save') do |r|
-            expect(r.stdout).to match(%r{-A OUTPUT -p tcp -m multiport --dports 8080 -m time --timestart 06:00:00 --timestop 17:00:00 --monthdays 7 --weekdays Tue --datestart 2016-01-19T04:17:07 --datestop 2038-01-19T04:17:07 --kerneltz -m comment --comment "805 - test" -j ACCEPT}) # rubocop:disable Metrics/LineLength : Cannot reduce line length to the required size
-          end
+      it 'contains the rule' do
+        shell('iptables-save') do |r|
+          expect(r.stdout).to match(
+            %r{-A OUTPUT -p tcp -m multiport --dports 8080 -m time --timestart 06:00:00 --timestop 17:00:00 --monthdays 7 --weekdays Tue --datestart 2016-01-19T04:17:07 --datestop 2038-01-19T04:17:07 --kerneltz -m comment --comment "805 - test" -j ACCEPT}, # rubocop:disable Metrics/LineLength
+          )
         end
       end
     end
+  end
 
-    describe 'time tests ipv6' do
-      context 'when when set all time parameters' do
-        pp2 = <<-PUPPETCODE
-            class { '::firewall': }
-            firewall { '805 - test':
-              proto              => tcp,
-              dport              => '8080',
-              action             => accept,
-              chain              => 'OUTPUT',
-              date_start         => '2016-01-19T04:17:07',
-              date_stop          => '2038-01-19T04:17:07',
-              time_start         => '6:00',
-              time_stop          => '17:00:00',
-              month_days         => '7',
-              week_days          => 'Tue',
-              kernel_timezone    => true,
-              provider           => 'ip6tables',
-            }
-        PUPPETCODE
-        it 'applies' do
-          apply_manifest(pp2, catch_failures: true)
-          apply_manifest(pp2, catch_changes: do_catch_changes)
-        end
+  describe 'time tests ipv6' do
+    context 'when when set all time parameters' do
+      pp2 = <<-PUPPETCODE
+          class { '::firewall': }
+          firewall { '805 - test':
+            proto              => tcp,
+            dport              => '8080',
+            action             => accept,
+            chain              => 'OUTPUT',
+            date_start         => '2016-01-19T04:17:07',
+            date_stop          => '2038-01-19T04:17:07',
+            time_start         => '6:00',
+            time_stop          => '17:00:00',
+            month_days         => '7',
+            week_days          => 'Tue',
+            kernel_timezone    => true,
+            provider           => 'ip6tables',
+          }
+      PUPPETCODE
+      it 'applies' do
+        apply_manifest(pp2, catch_failures: true)
+        apply_manifest(pp2, catch_changes: do_catch_changes)
+      end
 
-        it 'contains the rule' do
-          shell('ip6tables-save') do |r|
-            expect(r.stdout).to match(%r{-A OUTPUT -p tcp -m multiport --dports 8080 -m time --timestart 06:00:00 --timestop 17:00:00 --monthdays 7 --weekdays Tue --datestart 2016-01-19T04:17:07 --datestop 2038-01-19T04:17:07 --kerneltz -m comment --comment "805 - test" -j ACCEPT}) # rubocop:disable Metrics/LineLength : Cannot reduce line length to the required size
-          end
+      it 'contains the rule' do
+        shell('ip6tables-save') do |r|
+          expect(r.stdout).to match(
+            %r{-A OUTPUT -p tcp -m multiport --dports 8080 -m time --timestart 06:00:00 --timestop 17:00:00 --monthdays 7 --weekdays Tue --datestart 2016-01-19T04:17:07 --datestop 2038-01-19T04:17:07 --kerneltz -m comment --comment "805 - test" -j ACCEPT}, # rubocop:disable Metrics/LineLength
+          )
         end
       end
     end
index ffa7fba0676526ffb6b606c54a3c6f93b2a7d313..9499a8621108499dbcc9164754d062c943b5fd15 100644 (file)
@@ -1,6 +1,6 @@
 require 'spec_helper_acceptance'
 
-if default['platform'] =~ %r{el-5}
+if os[:family] == 'redhat' && os[:release].start_with?('5')
   describe "firewall ip6tables doesn't work on 1.3.5 because --comment is missing" do
     before :all do
       iptables_flush_all_tables
index c47338243009a1a1a32059401f7932fa5089c81c..b903d6dd7a8ae69fb11959958061beb439ce417b 100644 (file)
@@ -6,7 +6,7 @@ describe 'firewall match marks' do
     ip6tables_flush_all_tables
   end
 
-  if default['platform'] !~ %r{el-5}
+  unless os[:family] == 'redhat' && os[:release].start_with?('5')
     describe 'match_mark' do
       context 'when 0x1' do
         pp1 = <<-PUPPETCODE
index 6a22ecd171e9d970d876f32720201b1fb6519840..a06e10d2ed2ca44dfe52a95120906db8234753f3 100644 (file)
@@ -181,7 +181,7 @@ describe 'puppet resource firewall command' do
   # version of iptables that ships with el5 doesn't work with the
   # ip6tables provider
   # TODO: Test below fails if this file is run seperately. i.e. bundle exec rspec spec/acceptance/resource_cmd_spec.rb
-  if default['platform'] !~ %r{el-5}
+  unless os[:family] == 'redhat' && os[:release].start_with?('5')
     context 'when dport/sport with ip6tables' do
       before :all do
         if os['family'] == 'debian'
index 08b9812655ed58ad06d3687ac5b4120a8f5e9bb2..47cea599d98ad20d2940aa6d39a895f89ae8c9e4 100644 (file)
@@ -1,7 +1,7 @@
 require 'spec_helper_acceptance'
 
 # RHEL5 does not support -m socket
-describe 'firewall socket property', unless: default['platform'] =~ %r{el-5} || os[:family] == 'sles' do
+describe 'firewall socket property', unless: (os[:family] == 'redhat' && os[:release].start_with?('5')) || os[:family] == 'sles' do
   before :all do
     iptables_flush_all_tables
     ip6tables_flush_all_tables