root / spec / classes / ip_nat_spec.rb @ 30462da1
Historique | Voir | Annoter | Télécharger (8,14 ko)
1 | 422b6851 | 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 | it { is_expected.to compile } |
||
11 | |||
12 | 01d8a819 | tr | it { |
13 | e4c32222 | Nacho Barrientos | is_expected.to contain_concat('nftables-ip-nat').with(
|
14 | 30462da1 | Steve Traylen | path: '/etc/nftables/puppet-preflight/ip-nat.nft', |
15 | e4c32222 | Nacho Barrientos | ensure: 'present', |
16 | 01d8a819 | tr | owner: 'root', |
17 | group: 'root', |
||
18 | mode: '0640', |
||
19 | ) |
||
20 | } |
||
21 | 422b6851 | tr | |
22 | 248ef9d5 | tr | it { |
23 | e4c32222 | Nacho Barrientos | is_expected.to contain_concat__fragment('nftables-ip-nat-header').with(
|
24 | target: 'nftables-ip-nat', |
||
25 | content: %r{^table ip nat \{$}, |
||
26 | order: '00', |
||
27 | ) |
||
28 | } |
||
29 | |||
30 | it { |
||
31 | is_expected.to contain_concat__fragment('nftables-ip-nat-body').with(
|
||
32 | target: 'nftables-ip-nat', |
||
33 | order: '98', |
||
34 | ) |
||
35 | } |
||
36 | |||
37 | it { |
||
38 | is_expected.to contain_concat__fragment('nftables-ip-nat-footer').with(
|
||
39 | target: 'nftables-ip-nat', |
||
40 | content: %r{^\}$}, |
||
41 | order: '99', |
||
42 | ) |
||
43 | } |
||
44 | |||
45 | it { |
||
46 | is_expected.to contain_concat('nftables-ip6-nat').with(
|
||
47 | 30462da1 | Steve Traylen | path: '/etc/nftables/puppet-preflight/ip6-nat.nft', |
48 | e4c32222 | Nacho Barrientos | ensure: 'present', |
49 | 248ef9d5 | tr | owner: 'root', |
50 | group: 'root', |
||
51 | mode: '0640', |
||
52 | ) |
||
53 | } |
||
54 | |||
55 | e4c32222 | Nacho Barrientos | it { |
56 | is_expected.to contain_concat__fragment('nftables-ip6-nat-header').with(
|
||
57 | target: 'nftables-ip6-nat', |
||
58 | content: %r{^table ip6 nat \{$}, |
||
59 | order: '00', |
||
60 | ) |
||
61 | } |
||
62 | |||
63 | it { |
||
64 | is_expected.to contain_concat__fragment('nftables-ip6-nat-body').with(
|
||
65 | target: 'nftables-ip6-nat', |
||
66 | order: '98', |
||
67 | ) |
||
68 | } |
||
69 | |||
70 | it { |
||
71 | is_expected.to contain_concat__fragment('nftables-ip6-nat-footer').with(
|
||
72 | target: 'nftables-ip6-nat', |
||
73 | content: %r{^\}$}, |
||
74 | order: '99', |
||
75 | ) |
||
76 | } |
||
77 | |||
78 | 248ef9d5 | tr | context 'table ip nat chain prerouting' do |
79 | 01d8a819 | tr | it { |
80 | is_expected.to contain_concat('nftables-ip-nat-chain-PREROUTING').with(
|
||
81 | 30462da1 | Steve Traylen | path: '/etc/nftables/puppet-preflight/ip-nat-chain-PREROUTING.nft', |
82 | 01d8a819 | tr | owner: 'root', |
83 | group: 'root', |
||
84 | mode: '0640', |
||
85 | ensure_newline: true, |
||
86 | ) |
||
87 | } |
||
88 | it { |
||
89 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-header').with(
|
||
90 | target: 'nftables-ip-nat-chain-PREROUTING', |
||
91 | content: %r{^chain PREROUTING \{$}, |
||
92 | order: '00', |
||
93 | ) |
||
94 | } |
||
95 | it { |
||
96 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-type').with(
|
||
97 | target: 'nftables-ip-nat-chain-PREROUTING', |
||
98 | content: %r{^ type nat hook prerouting priority -100$}, |
||
99 | 61f03b47 | Steve Traylen | order: '01-nftables-ip-nat-chain-PREROUTING-rule-type-b', |
100 | 01d8a819 | tr | ) |
101 | } |
||
102 | it { |
||
103 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-policy').with(
|
||
104 | target: 'nftables-ip-nat-chain-PREROUTING', |
||
105 | content: %r{^ policy accept$}, |
||
106 | 61f03b47 | Steve Traylen | order: '02-nftables-ip-nat-chain-PREROUTING-rule-policy-b', |
107 | 01d8a819 | tr | ) |
108 | } |
||
109 | it { |
||
110 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-footer').with(
|
||
111 | target: 'nftables-ip-nat-chain-PREROUTING', |
||
112 | content: %r{^\}$}, |
||
113 | order: '99', |
||
114 | ) |
||
115 | } |
||
116 | 422b6851 | tr | end
|
117 | |||
118 | 248ef9d5 | tr | context 'table ip nat chain postrouting' do |
119 | 01d8a819 | tr | it { |
120 | is_expected.to contain_concat('nftables-ip-nat-chain-POSTROUTING').with(
|
||
121 | 30462da1 | Steve Traylen | path: '/etc/nftables/puppet-preflight/ip-nat-chain-POSTROUTING.nft', |
122 | 01d8a819 | tr | owner: 'root', |
123 | group: 'root', |
||
124 | mode: '0640', |
||
125 | ensure_newline: true, |
||
126 | ) |
||
127 | } |
||
128 | it { |
||
129 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-header').with(
|
||
130 | target: 'nftables-ip-nat-chain-POSTROUTING', |
||
131 | content: %r{^chain POSTROUTING \{$}, |
||
132 | order: '00', |
||
133 | ) |
||
134 | } |
||
135 | it { |
||
136 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-type').with(
|
||
137 | target: 'nftables-ip-nat-chain-POSTROUTING', |
||
138 | content: %r{^ type nat hook postrouting priority 100$}, |
||
139 | 61f03b47 | Steve Traylen | order: '01-nftables-ip-nat-chain-POSTROUTING-rule-type-b', |
140 | 01d8a819 | tr | ) |
141 | } |
||
142 | it { |
||
143 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-policy').with(
|
||
144 | target: 'nftables-ip-nat-chain-POSTROUTING', |
||
145 | content: %r{^ policy accept$}, |
||
146 | 61f03b47 | Steve Traylen | order: '02-nftables-ip-nat-chain-POSTROUTING-rule-policy-b', |
147 | 01d8a819 | tr | ) |
148 | } |
||
149 | it { |
||
150 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-footer').with(
|
||
151 | target: 'nftables-ip-nat-chain-POSTROUTING', |
||
152 | content: %r{^\}$}, |
||
153 | order: '99', |
||
154 | ) |
||
155 | } |
||
156 | 422b6851 | tr | end
|
157 | 248ef9d5 | tr | |
158 | context 'table ip6 nat chain prerouting' do |
||
159 | it { |
||
160 | is_expected.to contain_concat('nftables-ip6-nat-chain-PREROUTING6').with(
|
||
161 | 30462da1 | Steve Traylen | path: '/etc/nftables/puppet-preflight/ip6-nat-chain-PREROUTING6.nft', |
162 | 248ef9d5 | tr | owner: 'root', |
163 | group: 'root', |
||
164 | mode: '0640', |
||
165 | ensure_newline: true, |
||
166 | ) |
||
167 | } |
||
168 | it { |
||
169 | is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-PREROUTING6-header').with(
|
||
170 | target: 'nftables-ip6-nat-chain-PREROUTING6', |
||
171 | content: %r{^chain PREROUTING6 \{$}, |
||
172 | order: '00', |
||
173 | ) |
||
174 | } |
||
175 | it { |
||
176 | is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-PREROUTING6-rule-type').with(
|
||
177 | target: 'nftables-ip6-nat-chain-PREROUTING6', |
||
178 | content: %r{^ type nat hook prerouting priority -100$}, |
||
179 | 61f03b47 | Steve Traylen | order: '01-nftables-ip6-nat-chain-PREROUTING6-rule-type-b', |
180 | 248ef9d5 | tr | ) |
181 | } |
||
182 | it { |
||
183 | is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-PREROUTING6-rule-policy').with(
|
||
184 | target: 'nftables-ip6-nat-chain-PREROUTING6', |
||
185 | content: %r{^ policy accept$}, |
||
186 | 61f03b47 | Steve Traylen | order: '02-nftables-ip6-nat-chain-PREROUTING6-rule-policy-b', |
187 | 248ef9d5 | tr | ) |
188 | } |
||
189 | it { |
||
190 | is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-PREROUTING6-footer').with(
|
||
191 | target: 'nftables-ip6-nat-chain-PREROUTING6', |
||
192 | content: %r{^\}$}, |
||
193 | order: '99', |
||
194 | ) |
||
195 | } |
||
196 | end
|
||
197 | |||
198 | context 'table ip nat chain postrouting' do |
||
199 | it { |
||
200 | is_expected.to contain_concat('nftables-ip6-nat-chain-POSTROUTING6').with(
|
||
201 | 30462da1 | Steve Traylen | path: '/etc/nftables/puppet-preflight/ip6-nat-chain-POSTROUTING6.nft', |
202 | 248ef9d5 | tr | owner: 'root', |
203 | group: 'root', |
||
204 | mode: '0640', |
||
205 | ensure_newline: true, |
||
206 | ) |
||
207 | } |
||
208 | it { |
||
209 | is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-POSTROUTING6-header').with(
|
||
210 | target: 'nftables-ip6-nat-chain-POSTROUTING6', |
||
211 | content: %r{^chain POSTROUTING6 \{$}, |
||
212 | order: '00', |
||
213 | ) |
||
214 | } |
||
215 | it { |
||
216 | is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-POSTROUTING6-rule-type').with(
|
||
217 | target: 'nftables-ip6-nat-chain-POSTROUTING6', |
||
218 | content: %r{^ type nat hook postrouting priority 100$}, |
||
219 | 61f03b47 | Steve Traylen | order: '01-nftables-ip6-nat-chain-POSTROUTING6-rule-type-b', |
220 | 248ef9d5 | tr | ) |
221 | } |
||
222 | it { |
||
223 | is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-POSTROUTING6-rule-policy').with(
|
||
224 | target: 'nftables-ip6-nat-chain-POSTROUTING6', |
||
225 | content: %r{^ policy accept$}, |
||
226 | 61f03b47 | Steve Traylen | order: '02-nftables-ip6-nat-chain-POSTROUTING6-rule-policy-b', |
227 | 248ef9d5 | tr | ) |
228 | } |
||
229 | it { |
||
230 | is_expected.to contain_concat__fragment('nftables-ip6-nat-chain-POSTROUTING6-footer').with(
|
||
231 | target: 'nftables-ip6-nat-chain-POSTROUTING6', |
||
232 | content: %r{^\}$}, |
||
233 | order: '99', |
||
234 | ) |
||
235 | } |
||
236 | end
|
||
237 | 422b6851 | tr | end
|
238 | end
|
||
239 | end |