]> gitweb.fluxo.info Git - puppet-ferm.git/commitdiff
rubocop: autofix
authorTim <tim@bastelfreak.de>
Sun, 31 Oct 2021 17:42:03 +0000 (18:42 +0100)
committerTim <tim@bastelfreak.de>
Sun, 31 Oct 2021 17:42:03 +0000 (18:42 +0100)
12 files changed:
spec/acceptance/ferm_spec.rb
spec/classes/ferm_spec.rb
spec/defines/chain_spec.rb
spec/defines/ipset_spec.rb
spec/defines/rule_spec.rb
spec/spec_helper.rb
spec/spec_helper_acceptance.rb
spec/type_aliases/actions_spec.rb
spec/type_aliases/policies_spec.rb
spec/type_aliases/port_spec.rb
spec/type_aliases/protocols_spec.rb
spec/type_aliases/tables_spec.rb

index 326ed9fc32c778c49ab1b7f32513cd25558db752..1a6e39eae0c1c8511340810ea48c48971339ec9e 100644 (file)
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 require 'spec_helper_acceptance'
 
 os_name = fact('os.name')
@@ -57,6 +59,7 @@ describe 'ferm' do
     it 'works with no error' do
       apply_manifest(pp, catch_failures: true)
     end
+
     it 'works idempotently' do
       apply_manifest(pp, catch_changes: true)
     end
@@ -82,6 +85,7 @@ describe 'ferm' do
     it 'works with no error' do
       apply_manifest(pp, catch_failures: true)
     end
+
     it 'works idempotently' do
       apply_manifest(pp, catch_changes: true)
     end
@@ -101,7 +105,7 @@ describe 'ferm' do
 
     describe iptables do
       it do
-        is_expected.to have_rule(iptables_output[0]). \
+        expect(subject).to have_rule(iptables_output[0]). \
           with_table('filter'). \
           with_chain('INPUT')
       end
@@ -135,18 +139,20 @@ describe 'ferm' do
       it 'works with no error' do
         apply_manifest(pp, catch_failures: true)
       end
+
       it 'works idempotently' do
         apply_manifest(pp, catch_changes: true)
       end
 
       describe iptables do
         it do
-          is_expected.to have_rule(iptables_output[1]). \
+          expect(subject).to have_rule(iptables_output[1]). \
             with_table('filter'). \
             with_chain('INPUT')
         end
+
         it do
-          is_expected.to have_rule(iptables_output[2]). \
+          expect(subject).to have_rule(iptables_output[2]). \
             with_table('filter'). \
             with_chain('HTTP')
         end
@@ -177,6 +183,7 @@ describe 'ferm' do
       it 'works with no error' do
         apply_manifest(pp2, catch_failures: true)
       end
+
       it 'works idempotently' do
         apply_manifest(pp2, catch_changes: true)
       end
@@ -223,18 +230,20 @@ describe 'ferm' do
     it 'works with no error' do
       apply_manifest(pp, catch_failures: true)
     end
+
     it 'works idempotently' do
       apply_manifest(pp, catch_changes: true)
     end
 
     describe iptables do
       it do
-        is_expected.to have_rule(iptables_output_custom[0]). \
+        expect(subject).to have_rule(iptables_output_custom[0]). \
           with_table('filter'). \
           with_chain('FORWARD')
       end
+
       it do
-        is_expected.to have_rule(iptables_output_custom[1]). \
+        expect(subject).to have_rule(iptables_output_custom[1]). \
           with_table('filter'). \
           with_chain('OPENVPN_FORWORD_RULES')
       end
index 0f8c0788522432c5708e2c92a435241c3fa7f9c1..55eb3b11fc11977152cc18a0ece54a7c6779825f 100644 (file)
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 require 'spec_helper'
 
 describe 'ferm' do
@@ -6,7 +8,7 @@ describe 'ferm' do
   end
 
   on_supported_os.each do |os, facts|
-    context "on #{os} " do
+    context "on #{os}" do
       let :facts do
         facts
       end
@@ -16,6 +18,7 @@ describe 'ferm' do
         it { is_expected.to contain_class('ferm::config') }
         it { is_expected.to contain_class('ferm::service') }
         it { is_expected.to contain_class('ferm::install') }
+
         if facts[:os]['name'] == 'Debian'
           it { is_expected.to contain_file('/etc/ferm/ferm.d') }
           it { is_expected.to contain_file('/etc/ferm/ferm.d/definitions') }
@@ -35,9 +38,8 @@ describe 'ferm' do
 
         it { is_expected.not_to contain_service('ferm') }
         it { is_expected.not_to contain_file('/etc/ferm.conf') }
-        if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'].to_i <= 6
-          it { is_expected.not_to contain_file('/etc/init.d/ferm') }
-        end
+
+        it { is_expected.not_to contain_file('/etc/init.d/ferm') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'].to_i <= 6
       end
 
       context 'with managed service' do
@@ -47,11 +49,13 @@ describe 'ferm' do
 
         it { is_expected.to compile.with_all_deps }
         it { is_expected.to contain_service('ferm') }
+
         if facts[:os]['name'] == 'Ubuntu'
           it { is_expected.to contain_file_line('enable_ferm') }
           it { is_expected.to contain_file_line('disable_ferm_cache') }
         end
       end
+
       context 'with managed configfile' do
         let :params do
           { manage_configfile: true }
@@ -66,13 +70,16 @@ describe 'ferm' do
         it { is_expected.to contain_concat__fragment('ferm_header.conf') }
         it { is_expected.to contain_concat__fragment('ferm.conf') }
         # the following string exists only if we preserve chains
+
         it do
-          is_expected.to contain_concat__fragment('ferm.conf'). \
+          expect(subject).to contain_concat__fragment('ferm.conf'). \
             without_content(%r{@preserve;})
         end
+
         it { is_expected.to contain_concat__fragment('raw-PREROUTING-config-include') }
         it { is_expected.to contain_concat__fragment('raw-OUTPUT-config-include') }
         it { is_expected.to contain_concat__fragment('nat-PREROUTING-config-include') }
+
         if Gem::Version.new(facts[:kernelversion]) >= Gem::Version.new('2.6.36')
           it { is_expected.to contain_concat__fragment('nat-INPUT-config-include') }
         else
@@ -91,6 +98,7 @@ describe 'ferm' do
         it { is_expected.to contain_concat__fragment('raw-PREROUTING-policy') }
         it { is_expected.to contain_concat__fragment('raw-OUTPUT-policy') }
         it { is_expected.to contain_concat__fragment('nat-PREROUTING-policy') }
+
         if Gem::Version.new(facts[:kernelversion]) >= Gem::Version.new('2.6.36')
           it { is_expected.to contain_concat__fragment('nat-INPUT-policy') }
         else
@@ -106,10 +114,12 @@ describe 'ferm' do
         it { is_expected.to contain_concat__fragment('filter-INPUT-policy') }
         it { is_expected.to contain_concat__fragment('filter-FORWARD-policy') }
         it { is_expected.to contain_concat__fragment('filter-OUTPUT-policy') }
+
         if facts[:os]['name'] == 'Debian'
           it { is_expected.to contain_concat('/etc/ferm/ferm.d/chains/raw-PREROUTING.conf') }
           it { is_expected.to contain_concat('/etc/ferm/ferm.d/chains/raw-OUTPUT.conf') }
           it { is_expected.to contain_concat('/etc/ferm/ferm.d/chains/nat-PREROUTING.conf') }
+
           if Gem::Version.new(facts[:kernelversion]) >= Gem::Version.new('2.6.36')
             it { is_expected.to contain_concat('/etc/ferm/ferm.d/chains/nat-INPUT.conf') }
           else
@@ -129,6 +139,7 @@ describe 'ferm' do
           it { is_expected.to contain_concat('/etc/ferm.d/chains/raw-PREROUTING.conf') }
           it { is_expected.to contain_concat('/etc/ferm.d/chains/raw-OUTPUT.conf') }
           it { is_expected.to contain_concat('/etc/ferm.d/chains/nat-PREROUTING.conf') }
+
           if Gem::Version.new(facts[:kernelversion]) >= Gem::Version.new('2.6.36')
             it { is_expected.to contain_concat('/etc/ferm.d/chains/nat-INPUT.conf') }
           else
@@ -148,6 +159,7 @@ describe 'ferm' do
         it { is_expected.to contain_ferm__chain('raw-PREROUTING') }
         it { is_expected.to contain_ferm__chain('raw-OUTPUT') }
         it { is_expected.to contain_ferm__chain('nat-PREROUTING') }
+
         if Gem::Version.new(facts[:kernelversion]) >= Gem::Version.new('2.6.36')
           it { is_expected.to contain_ferm__chain('nat-INPUT') }
         else
@@ -164,6 +176,7 @@ describe 'ferm' do
         it { is_expected.to contain_ferm__chain('OUTPUT') }
         it { is_expected.to contain_ferm__chain('INPUT') }
       end
+
       context 'it preserves chains' do
         let :params do
           {
@@ -173,19 +186,23 @@ describe 'ferm' do
         end
 
         it { is_expected.to compile.with_all_deps }
+
         it do
-          is_expected.to contain_concat__fragment('ferm.conf'). \
+          expect(subject).to contain_concat__fragment('ferm.conf'). \
             with_content(%r{domain \(ip ip6\) table nat \{})
         end
+
         it do
-          is_expected.to contain_concat__fragment('ferm.conf'). \
+          expect(subject).to contain_concat__fragment('ferm.conf'). \
             with_content(%r{chain PREROUTING @preserve;})
         end
+
         it do
-          is_expected.to contain_concat__fragment('ferm.conf'). \
+          expect(subject).to contain_concat__fragment('ferm.conf'). \
             with_content(%r{chain POSTROUTING @preserve;})
         end
       end
+
       context 'it works with git clone' do
         let :params do
           {
@@ -203,6 +220,7 @@ describe 'ferm' do
         it { is_expected.to contain_file('/etc/ferm') }
         it { is_expected.to contain_vcsrepo('/opt/ferm') }
       end
+
       context 'it works with ensure latest' do
         let :params do
           {
index 52cc88c0335fc7e70a60e0585d15214d30c111b4..5e84ea5f23c43cac8b5d0c43aba145a1a37eec2c 100644 (file)
@@ -1,8 +1,10 @@
+# frozen_string_literal: true
+
 require 'spec_helper'
 
 describe 'ferm::chain', type: :define do
   on_supported_os.each do |os, facts|
-    context "on #{os} " do
+    context "on #{os}" do
       let :facts do
         facts
       end
@@ -22,14 +24,17 @@ describe 'ferm::chain', type: :define do
 
         it { is_expected.to compile.with_all_deps }
         it { is_expected.to contain_concat__fragment('filter-INPUT2-config-include') }
+
         it do
-          is_expected.to contain_concat__fragment('filter-INPUT2-policy'). \
+          expect(subject).to contain_concat__fragment('filter-INPUT2-policy'). \
             with_content(%r{ESTABLISHED RELATED})
         end
+
         it do
-          is_expected.to contain_concat__fragment('filter-INPUT2-footer'). \
+          expect(subject).to contain_concat__fragment('filter-INPUT2-footer'). \
             with_content(%r{LOG log-prefix 'INPUT2: ';})
         end
+
         if facts[:os]['name'] == 'Debian'
           it { is_expected.to contain_concat('/etc/ferm/ferm.d/chains/filter-INPUT2.conf') }
         else
@@ -47,13 +52,15 @@ describe 'ferm::chain', type: :define do
         end
 
         it { is_expected.to compile.with_all_deps }
+
         it do
-          is_expected.to contain_concat__fragment('filter-INPUT2-policy')
-          is_expected.not_to contain_concat__fragment('filter-INPUT2-policy'). \
+          expect(subject).to contain_concat__fragment('filter-INPUT2-policy')
+          expect(subject).not_to contain_concat__fragment('filter-INPUT2-policy'). \
             with_content(%r{ESTABLISHED RELATED})
         end
+
         it do
-          is_expected.not_to contain_concat__fragment('filter-INPUT2-footer'). \
+          expect(subject).not_to contain_concat__fragment('filter-INPUT2-footer'). \
             with_content(%r{LOG log-prefix 'INPUT2: ';})
         end
       end
@@ -81,16 +88,20 @@ describe 'ferm::chain', type: :define do
 
         it { is_expected.to compile.with_all_deps }
         it { is_expected.to contain_concat__fragment('filter-FERM-DSL-config-include') }
+
         it do
-          is_expected.to contain_concat__fragment('filter-FERM-DSL-custom-content'). \
+          expect(subject).to contain_concat__fragment('filter-FERM-DSL-custom-content'). \
             with_content(%r{mod rpfilter invert DROP;})
         end
+
         it do
-          is_expected.not_to contain_concat__fragment('filter-FERM-DSL-policy')
+          expect(subject).not_to contain_concat__fragment('filter-FERM-DSL-policy')
         end
+
         it do
-          is_expected.not_to contain_concat__fragment('filter-FERM-DSL-footer')
+          expect(subject).not_to contain_concat__fragment('filter-FERM-DSL-footer')
         end
+
         if facts[:os]['name'] == 'Debian'
           it { is_expected.to contain_concat('/etc/ferm/ferm.d/chains/filter-FERM-DSL.conf') }
         else
index 050e5efa2581648c99474563d79f5269ed057b91..88ef5c3fbb474672f8cfba93da80746ee50fa094 100644 (file)
@@ -1,8 +1,10 @@
+# frozen_string_literal: true
+
 require 'spec_helper'
 
 describe 'ferm::ipset', type: :define do
   on_supported_os.each do |os, facts|
-    context "on #{os} " do
+    context "on #{os}" do
       let :facts do
         facts
       end
index 7529fce9755c70b6297931145e81a5338e2ddde4..4b7b1d4357b71a4ba48de1bc9f8a3d70b8af3c2c 100644 (file)
@@ -1,8 +1,10 @@
+# frozen_string_literal: true
+
 require 'spec_helper'
 
 describe 'ferm::rule', type: :define do
   on_supported_os.each do |os, facts|
-    context "on #{os} " do
+    context "on #{os}" do
       let :facts do
         facts
       end
@@ -202,12 +204,15 @@ describe 'ferm::rule', type: :define do
 
         it { is_expected.to compile.with_all_deps }
         it { is_expected.to contain_concat__fragment('filter-SSH-policy') }
+
         it do
-          is_expected.to contain_concat__fragment('INPUT-filter-ssh').\
+          expect(subject).to contain_concat__fragment('INPUT-filter-ssh').\
             with_content("mod comment comment 'filter-ssh' proto tcp dport 22 jump SSH;\n"). \
             that_requires('Ferm::Chain[check-ssh]')
         end
+
         it { is_expected.to contain_concat__fragment('filter-INPUT-config-include') }
+
         if facts[:os]['name'] == 'Debian'
           it { is_expected.to contain_concat('/etc/ferm/ferm.d/chains/filter-SSH.conf') }
         else
index fb5f0cbeab68b24ceba1fd1cb248607f2c481297..4d617f3934475419e927859863216d8d51def3d2 100644 (file)
@@ -1,17 +1,17 @@
+# frozen_string_literal: true
+
 # Managed by modulesync - DO NOT EDIT
 # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/
 
 # puppetlabs_spec_helper will set up coverage if the env variable is set.
 # We want to do this if lib exists and it hasn't been explicitly set.
-ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../../lib', __FILE__))
+ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../lib', __dir__))
 
 require 'voxpupuli/test/spec_helper'
 
 if File.exist?(File.join(__dir__, 'default_module_facts.yml'))
   facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml')))
-  if facts
-    facts.each do |name, value|
-      add_custom_fact name.to_sym, value
-    end
+  facts&.each do |name, value|
+    add_custom_fact name.to_sym, value
   end
 end
index 7db1a99598041f37027073893105ca097e263914..7acf63019d7ddd962a743dc50aa398a254ba0574 100644 (file)
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 require 'voxpupuli/acceptance/spec_helper_acceptance'
 
 configure_beaker do |host|
index 5f6efb09f6c1765012bf1667e46dec0c4b0491aa..c5cc502e93b5b42467136d3404ba1d185f06e913 100644 (file)
@@ -1,21 +1,22 @@
-# rubocop:disable Style/WordArray
+# frozen_string_literal: true
+
 require 'spec_helper'
 
 describe 'Ferm::Actions' do
   describe 'valid values' do
-    [
-      'RETURN',
-      'ACCEPT',
-      'DROP',
-      'REJECT',
-      'NOTRACK',
-      'LOG',
-      'MARK',
-      'DNAT',
-      'SNAT',
-      'MASQUERADE',
-      'REDIRECT',
-      'MYFANCYCUSTOMCHAINNAMEISALSOVALID',
+    %w[
+      RETURN
+      ACCEPT
+      DROP
+      REJECT
+      NOTRACK
+      LOG
+      MARK
+      DNAT
+      SNAT
+      MASQUERADE
+      REDIRECT
+      MYFANCYCUSTOMCHAINNAMEISALSOVALID
     ].each do |value|
       describe value.inspect do
         it { is_expected.to allow_value(value) }
@@ -31,7 +32,7 @@ describe 'Ferm::Actions' do
         '',
         true,
         false,
-        ['meep', 'meep'],
+        %w[meep meep],
         65_538,
         [95_000, 67_000],
         {},
index 6cb6a2f4eecbe974957e33e2f67a7e64f04544c2..6708aa4b56f8e072697deb40a2d36abe831eabef 100644 (file)
@@ -1,11 +1,12 @@
-# rubocop:disable Style/WordArray
+# frozen_string_literal: true
+
 require 'spec_helper'
 
 describe 'Ferm::Policies' do
   describe 'valid values' do
-    [
-      'ACCEPT',
-      'DROP',
+    %w[
+      ACCEPT
+      DROP
     ].each do |value|
       describe value.inspect do
         it { is_expected.to allow_value(value) }
@@ -24,7 +25,7 @@ describe 'Ferm::Policies' do
         '',
         true,
         false,
-        ['meep', 'meep'],
+        %w[meep meep],
         65_538,
         [95_000, 67_000],
         {},
index 2e6c1c89803b496cfe61b2cc26bdfe51505cafee..671576e7d1a0c784d0c22cdfcdba3dcbbb8bc1d7 100644 (file)
@@ -1,4 +1,5 @@
-# rubocop:disable Style/WordArray
+# frozen_string_literal: true
+
 require 'spec_helper'
 
 describe 'Ferm::Port' do
@@ -23,7 +24,7 @@ describe 'Ferm::Port' do
         true,
         false,
         :symbol,
-        ['meep', 'meep'],
+        %w[meep meep],
         65_538,
         [95_000, 67_000],
         '12345',
index cab521fa89ce80fbe99f68d71a22c239bd9542d3..bd409c593e27fdbff9798dfdf8a52de8e648d533 100644 (file)
@@ -1,4 +1,5 @@
-# rubocop:disable Style/WordArray
+# frozen_string_literal: true
+
 require 'spec_helper'
 
 describe 'Ferm::Protocols' do
@@ -14,7 +15,7 @@ describe 'Ferm::Protocols' do
       'sctp',
       'mh',
       'all',
-      ['icmp', 'tcp', 'udp'],
+      %w[icmp tcp udp],
       0,
       [0, 4],
     ].each do |value|
@@ -33,7 +34,7 @@ describe 'Ferm::Protocols' do
         '',
         true,
         false,
-        ['meep', 'meep'],
+        %w[meep meep],
         65_538,
         [95_000, 67_000],
         {},
index 29274c3c8438a3684e1ee42a81e5f1329bb3d0b9..4df20a537b08c284b538f54b50192c2eeb126fa6 100644 (file)
@@ -1,13 +1,14 @@
-# rubocop:disable Style/WordArray
+# frozen_string_literal: true
+
 require 'spec_helper'
 
 describe 'Ferm::Tables' do
   describe 'valid values' do
-    [
-      'raw',
-      'mangle',
-      'nat',
-      'filter',
+    %w[
+      raw
+      mangle
+      nat
+      filter
     ].each do |value|
       describe value.inspect do
         it { is_expected.to allow_value(value) }
@@ -24,7 +25,7 @@ describe 'Ferm::Tables' do
         '',
         true,
         false,
-        ['meep', 'meep'],
+        %w[meep meep],
         65_538,
         [95_000, 67_000],
         {},