Projet

Général

Profil

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

root / spec / classes / router_spec.rb @ a5205d2f

Historique | Voir | Annoter | Télécharger (4,98 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 af544fea tr

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