root / spec / classes / ip_nat_spec.rb @ 248ef9d5
Historique | Voir | Annoter | Télécharger (6,47 ko)
1 |
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 |
it { is_expected.to compile } |
11 |
|
12 |
it { |
13 |
is_expected.to contain_file('/etc/nftables/puppet/ip-nat.nft').with(
|
14 |
ensure: 'file', |
15 |
owner: 'root', |
16 |
group: 'root', |
17 |
mode: '0640', |
18 |
) |
19 |
} |
20 |
|
21 |
it { |
22 |
is_expected.to contain_file('/etc/nftables/puppet/ip6-nat.nft').with(
|
23 |
ensure: 'file', |
24 |
owner: 'root', |
25 |
group: 'root', |
26 |
mode: '0640', |
27 |
) |
28 |
} |
29 |
|
30 |
context 'table ip nat chain prerouting' do |
31 |
it { |
32 |
is_expected.to contain_concat('nftables-ip-nat-chain-PREROUTING').with(
|
33 |
path: '/etc/nftables/puppet/ip-nat-chain-PREROUTING.nft', |
34 |
owner: 'root', |
35 |
group: 'root', |
36 |
mode: '0640', |
37 |
ensure_newline: true, |
38 |
) |
39 |
} |
40 |
it { |
41 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-header').with(
|
42 |
target: 'nftables-ip-nat-chain-PREROUTING', |
43 |
content: %r{^chain PREROUTING \{$}, |
44 |
order: '00', |
45 |
) |
46 |
} |
47 |
it { |
48 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-type').with(
|
49 |
target: 'nftables-ip-nat-chain-PREROUTING', |
50 |
content: %r{^ type nat hook prerouting priority -100$}, |
51 |
order: '01', |
52 |
) |
53 |
} |
54 |
it { |
55 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-policy').with(
|
56 |
target: 'nftables-ip-nat-chain-PREROUTING', |
57 |
content: %r{^ policy accept$}, |
58 |
order: '02', |
59 |
) |
60 |
} |
61 |
it { |
62 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-footer').with(
|
63 |
target: 'nftables-ip-nat-chain-PREROUTING', |
64 |
content: %r{^\}$}, |
65 |
order: '99', |
66 |
) |
67 |
} |
68 |
end
|
69 |
|
70 |
context 'table ip nat chain postrouting' do |
71 |
it { |
72 |
is_expected.to contain_concat('nftables-ip-nat-chain-POSTROUTING').with(
|
73 |
path: '/etc/nftables/puppet/ip-nat-chain-POSTROUTING.nft', |
74 |
owner: 'root', |
75 |
group: 'root', |
76 |
mode: '0640', |
77 |
ensure_newline: true, |
78 |
) |
79 |
} |
80 |
it { |
81 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-header').with(
|
82 |
target: 'nftables-ip-nat-chain-POSTROUTING', |
83 |
content: %r{^chain POSTROUTING \{$}, |
84 |
order: '00', |
85 |
) |
86 |
} |
87 |
it { |
88 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-type').with(
|
89 |
target: 'nftables-ip-nat-chain-POSTROUTING', |
90 |
content: %r{^ type nat hook postrouting priority 100$}, |
91 |
order: '01', |
92 |
) |
93 |
} |
94 |
it { |
95 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-policy').with(
|
96 |
target: 'nftables-ip-nat-chain-POSTROUTING', |
97 |
content: %r{^ policy accept$}, |
98 |
order: '02', |
99 |
) |
100 |
} |
101 |
it { |
102 |
is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-footer').with(
|
103 |
target: 'nftables-ip-nat-chain-POSTROUTING', |
104 |
content: %r{^\}$}, |
105 |
order: '99', |
106 |
) |
107 |
} |
108 |
end
|
109 |
|
110 |
context 'table ip6 nat chain prerouting' do |
111 |
it { |
112 |
is_expected.to contain_concat('nftables-ip6-nat-chain-PREROUTING6').with(
|
113 |
path: '/etc/nftables/puppet/ip6-nat-chain-PREROUTING6.nft', |
114 |
owner: 'root', |
115 |
group: 'root', |
116 |
mode: '0640', |
117 |
ensure_newline: true, |
118 |
) |
119 |
} |
120 |
it { |
121 |
is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-PREROUTING6-header').with(
|
122 |
target: 'nftables-ip6-nat-chain-PREROUTING6', |
123 |
content: %r{^chain PREROUTING6 \{$}, |
124 |
order: '00', |
125 |
) |
126 |
} |
127 |
it { |
128 |
is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-PREROUTING6-rule-type').with(
|
129 |
target: 'nftables-ip6-nat-chain-PREROUTING6', |
130 |
content: %r{^ type nat hook prerouting priority -100$}, |
131 |
order: '01', |
132 |
) |
133 |
} |
134 |
it { |
135 |
is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-PREROUTING6-rule-policy').with(
|
136 |
target: 'nftables-ip6-nat-chain-PREROUTING6', |
137 |
content: %r{^ policy accept$}, |
138 |
order: '02', |
139 |
) |
140 |
} |
141 |
it { |
142 |
is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-PREROUTING6-footer').with(
|
143 |
target: 'nftables-ip6-nat-chain-PREROUTING6', |
144 |
content: %r{^\}$}, |
145 |
order: '99', |
146 |
) |
147 |
} |
148 |
end
|
149 |
|
150 |
context 'table ip nat chain postrouting' do |
151 |
it { |
152 |
is_expected.to contain_concat('nftables-ip6-nat-chain-POSTROUTING6').with(
|
153 |
path: '/etc/nftables/puppet/ip6-nat-chain-POSTROUTING6.nft', |
154 |
owner: 'root', |
155 |
group: 'root', |
156 |
mode: '0640', |
157 |
ensure_newline: true, |
158 |
) |
159 |
} |
160 |
it { |
161 |
is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-POSTROUTING6-header').with(
|
162 |
target: 'nftables-ip6-nat-chain-POSTROUTING6', |
163 |
content: %r{^chain POSTROUTING6 \{$}, |
164 |
order: '00', |
165 |
) |
166 |
} |
167 |
it { |
168 |
is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-POSTROUTING6-rule-type').with(
|
169 |
target: 'nftables-ip6-nat-chain-POSTROUTING6', |
170 |
content: %r{^ type nat hook postrouting priority 100$}, |
171 |
order: '01', |
172 |
) |
173 |
} |
174 |
it { |
175 |
is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-POSTROUTING6-rule-policy').with(
|
176 |
target: 'nftables-ip6-nat-chain-POSTROUTING6', |
177 |
content: %r{^ policy accept$}, |
178 |
order: '02', |
179 |
) |
180 |
} |
181 |
it { |
182 |
is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-POSTROUTING6-footer').with(
|
183 |
target: 'nftables-ip6-nat-chain-POSTROUTING6', |
184 |
content: %r{^\}$}, |
185 |
order: '99', |
186 |
) |
187 |
} |
188 |
end
|
189 |
end
|
190 |
end
|
191 |
end
|