aboutsummaryrefslogtreecommitdiff
path: root/spec/defines/chain_spec.rb
blob: d3ab857ecab8f16b5d19dc5d2b8c1940d00ab441 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require 'spec_helper'

describe 'ferm::chain', type: :define do
  on_supported_os.each do |os, facts|
    context "on #{os} " do
      let :facts do
        facts
      end
      let(:title) { 'INPUT' }

      context 'default params creates INPUT chain' do
        let :params do
          {
            policy: 'DROP',
            disable_conntrack: false,
            log_dropped_packets: true
          }
        end

        it { is_expected.to compile.with_all_deps }
        it do
          is_expected.to contain_concat__fragment('INPUT-policy'). \
            with_content(%r{ESTABLISHED RELATED})
        end
        it do
          is_expected.to contain_concat__fragment('INPUT-footer'). \
            with_content(%r{LOG log-prefix 'INPUT: ';})
        end
        it { is_expected.to contain_concat('/etc/ferm.d/chains/INPUT.conf') }
        it { is_expected.to contain_ferm__chain('INPUT') }
      end

      context 'without conntrack' do
        let :params do
          {
            policy: 'DROP',
            disable_conntrack: true,
            log_dropped_packets: false
          }
        end

        it { is_expected.to compile.with_all_deps }
        it do
          is_expected.to contain_concat__fragment('INPUT-policy')
          is_expected.not_to contain_concat__fragment('INPUT-policy'). \
            with_content(%r{ESTABLISHED RELATED})
        end
        it do
          is_expected.not_to contain_concat__fragment('INPUT-footer'). \
            with_content(%r{LOG log-prefix 'INPUT: ';})
        end
      end
    end
  end
end