From 859f8ba5cb553d66c9dcdbc232d17a0b641624df Mon Sep 17 00:00:00 2001 From: Thore Bödecker Date: Wed, 10 Jul 2019 16:37:50 +0200 Subject: allow preserving of chains in tables --- spec/classes/ferm_spec.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'spec/classes/ferm_spec.rb') diff --git a/spec/classes/ferm_spec.rb b/spec/classes/ferm_spec.rb index 55e6739..e5669b8 100644 --- a/spec/classes/ferm_spec.rb +++ b/spec/classes/ferm_spec.rb @@ -59,6 +59,11 @@ describe 'ferm' do it { is_expected.to compile.with_all_deps } 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'). \ + without_content(%r{@preserve;}) + end end context 'with managed initfile' do let :params do @@ -88,6 +93,29 @@ 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 + { + manage_configfile: true, + preserve_chains_in_tables: { 'nat' => %w[PREROUTING POSTROUTING] } + } + end + + it { is_expected.to compile.with_all_deps } + it do + is_expected.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'). \ + with_content(%r{chain PREROUTING @preserve;}) + end + it do + is_expected.to contain_concat__fragment('ferm.conf'). \ + with_content(%r{chain POSTROUTING @preserve;}) + end + end end end end -- cgit v1.2.3