From: tphoney Date: Mon, 4 Mar 2019 17:33:30 +0000 (+0000) Subject: stop using the beaker default function X-Git-Tag: 1.15.2~7^2~2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=ecb7cbf9f9949b6cfc2099a4a5c6cadfba07ceca;p=puppet-modules%2Fpuppetlabs-firewall.git stop using the beaker default function --- diff --git a/spec/acceptance/firewall_attributes_exceptions_spec.rb b/spec/acceptance/firewall_attributes_exceptions_spec.rb index 4989dcb..7ce6ede 100644 --- a/spec/acceptance/firewall_attributes_exceptions_spec.rb +++ b/spec/acceptance/firewall_attributes_exceptions_spec.rb @@ -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': } diff --git a/spec/acceptance/firewall_bridging_spec.rb b/spec/acceptance/firewall_bridging_spec.rb index dda7e84..590e96d 100644 --- a/spec/acceptance/firewall_bridging_spec.rb +++ b/spec/acceptance/firewall_bridging_spec.rb @@ -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 diff --git a/spec/acceptance/firewall_mss_spec.rb b/spec/acceptance/firewall_mss_spec.rb index a42a730..d1b438e 100644 --- a/spec/acceptance/firewall_mss_spec.rb +++ b/spec/acceptance/firewall_mss_spec.rb @@ -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 diff --git a/spec/acceptance/firewall_tee_spec.rb b/spec/acceptance/firewall_tee_spec.rb index 3a59683..2fca080 100644 --- a/spec/acceptance/firewall_tee_spec.rb +++ b/spec/acceptance/firewall_tee_spec.rb @@ -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 diff --git a/spec/acceptance/firewall_time_spec.rb b/spec/acceptance/firewall_time_spec.rb index 8c55429..d1b6fb1 100644 --- a/spec/acceptance/firewall_time_spec.rb +++ b/spec/acceptance/firewall_time_spec.rb @@ -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 diff --git a/spec/acceptance/ip6_fragment_spec.rb b/spec/acceptance/ip6_fragment_spec.rb index ffa7fba..9499a86 100644 --- a/spec/acceptance/ip6_fragment_spec.rb +++ b/spec/acceptance/ip6_fragment_spec.rb @@ -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 diff --git a/spec/acceptance/match_mark_spec.rb b/spec/acceptance/match_mark_spec.rb index c473382..b903d6d 100644 --- a/spec/acceptance/match_mark_spec.rb +++ b/spec/acceptance/match_mark_spec.rb @@ -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 diff --git a/spec/acceptance/resource_cmd_spec.rb b/spec/acceptance/resource_cmd_spec.rb index 6a22ecd..a06e10d 100644 --- a/spec/acceptance/resource_cmd_spec.rb +++ b/spec/acceptance/resource_cmd_spec.rb @@ -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' diff --git a/spec/acceptance/socket_spec.rb b/spec/acceptance/socket_spec.rb index 08b9812..47cea59 100644 --- a/spec/acceptance/socket_spec.rb +++ b/spec/acceptance/socket_spec.rb @@ -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