Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / spec / classes / router_spec.rb @ ece9be27

Historique | Voir | Annoter | Télécharger (4,96 ko)

1 d78c1613 tr
require 'spec_helper'
2
3
describe 'nftables' do
4
  let(:pre_condition) { 'Exec{path => "/bin"}' }
5
6
  on_supported_os.each do |os, os_facts|
7
    context "on #{os}" do
8
      let(:facts) { os_facts }
9
10 8f5d09ec tr
      context 'as router' do
11
        let(:pre_condition) do
12 d78c1613 tr
          """
13 351a88fb tr
          # inet-filter-chain-default_fwd
14 d78c1613 tr
          nftables::rule{
15
            'default_fwd-out':
16
              order   => '20',
17
              content => 'iifname eth1 oifname eth0 accept';
18
            'default_fwd-drop':
19
              order   => '90',
20
              content => 'iifname eth0 drop';
21 2a3b45ec tr
          }
22 af544fea tr

23 2a3b45ec tr
          nftables::rules::masquerade{
24
            'masquerade':
25
              order => '20',
26
              oif   => 'eth0';
27 d78c1613 tr
          }
28
          """
29 8f5d09ec tr
        end
30 d78c1613 tr
31
        it { is_expected.to compile }
32
33
        it { is_expected.to contain_concat('nftables-inet-filter-chain-default_fwd').with(
34
          :path           => '/etc/nftables/puppet/inet-filter-chain-default_fwd.nft',
35
          :owner          => 'root',
36
          :group          => 'root',
37
          :mode           => '0640',
38
          :ensure_newline => true,
39
        )}
40
        it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-header').with(
41
          :target  => 'nftables-inet-filter-chain-default_fwd',
42
          :content => /^chain default_fwd {$/,
43
          :order   => '00',
44
        )}
45
        it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-rule-out').with(
46
          :target  => 'nftables-inet-filter-chain-default_fwd',
47
          :content => /^  iifname eth1 oifname eth0 accept$/,
48
          :order   => '20',
49
        )}
50
        it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-rule-drop').with(
51
          :target  => 'nftables-inet-filter-chain-default_fwd',
52
          :content => /^  iifname eth0 drop$/,
53
          :order   => '90',
54
        )}
55
        it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-footer').with(
56
          :target  => 'nftables-inet-filter-chain-default_fwd',
57
          :content => /^}$/,
58
          :order   => '99',
59
        )}
60
61 95b1259b tr
        it { is_expected.to contain_concat('nftables-ip-nat-chain-PREROUTING').with(
62
          :path           => '/etc/nftables/puppet/ip-nat-chain-PREROUTING.nft',
63
          :owner          => 'root',
64
          :group          => 'root',
65
          :mode           => '0640',
66
          :ensure_newline => true,
67
        )}
68
        it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-header').with(
69
          :target  => 'nftables-ip-nat-chain-PREROUTING',
70
          :content => /^chain PREROUTING {$/,
71
          :order   => '00',
72
        )}
73
        it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-type').with(
74
          :target  => 'nftables-ip-nat-chain-PREROUTING',
75
          :content => /^  type nat hook prerouting priority -100$/,
76
          :order   => '01',
77
        )}
78
        it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-policy').with(
79
          :target  => 'nftables-ip-nat-chain-PREROUTING',
80
          :content => /^  policy accept$/,
81
          :order   => '02',
82
        )}
83
        it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-footer').with(
84
          :target  => 'nftables-ip-nat-chain-PREROUTING',
85
          :content => /^}$/,
86
          :order   => '99',
87
        )}
88
89 d78c1613 tr
        it { is_expected.to contain_concat('nftables-ip-nat-chain-POSTROUTING').with(
90
          :path           => '/etc/nftables/puppet/ip-nat-chain-POSTROUTING.nft',
91
          :owner          => 'root',
92
          :group          => 'root',
93
          :mode           => '0640',
94
          :ensure_newline => true,
95
        )}
96
        it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-header').with(
97
          :target  => 'nftables-ip-nat-chain-POSTROUTING',
98
          :content => /^chain POSTROUTING {$/,
99
          :order   => '00',
100
        )}
101
        it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-type').with(
102
          :target  => 'nftables-ip-nat-chain-POSTROUTING',
103
          :content => /^  type nat hook postrouting priority 100$/,
104
          :order   => '01',
105
        )}
106
        it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-policy').with(
107
          :target  => 'nftables-ip-nat-chain-POSTROUTING',
108
          :content => /^  policy accept$/,
109
          :order   => '02',
110
        )}
111
        it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-masquerade').with(
112
          :target  => 'nftables-ip-nat-chain-POSTROUTING',
113
          :content => /^  oifname eth0 masquerade$/,
114
          :order   => '20',
115
        )}
116
        it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-footer').with(
117
          :target  => 'nftables-ip-nat-chain-POSTROUTING',
118
          :content => /^}$/,
119
          :order   => '99',
120
        )}
121
      end
122
    end
123
  end
124
end