Révision a5205d2f
Extract the dnat spec tests
spec/classes/router_spec.rb | ||
---|---|---|
10 | 10 |
context 'as router' do |
11 | 11 |
let(:pre_condition) do |
12 | 12 |
""" |
13 |
# inet-filter-chain-ingoing |
|
14 |
nftables::chain{ 'ingoing': |
|
15 |
inject => '20-default_fwd', |
|
16 |
inject_iif => 'eth0', |
|
17 |
inject_oif => 'eth1'; |
|
18 |
} |
|
19 |
|
|
20 |
# inet-filter-chain-default_fwd |
|
21 |
nftables::rules::dnat4{ |
|
22 |
'http': |
|
23 |
order => '10', |
|
24 |
chain => 'ingoing', |
|
25 |
daddr => '192.0.2.2', |
|
26 |
port => 'http'; |
|
27 |
'https': |
|
28 |
order => '10', |
|
29 |
chain => 'ingoing', |
|
30 |
daddr => '192.0.2.2', |
|
31 |
port => 'https'; |
|
32 |
'http_alt': |
|
33 |
order => '10', |
|
34 |
chain => 'ingoing', |
|
35 |
iif => 'eth0', |
|
36 |
daddr => '192.0.2.2', |
|
37 |
proto => 'tcp', |
|
38 |
port => 8080, |
|
39 |
dport => 80; |
|
40 |
'wireguard': |
|
41 |
order => '10', |
|
42 |
chain => 'ingoing', |
|
43 |
iif => 'eth0', |
|
44 |
daddr => '192.0.2.3', |
|
45 |
proto => 'udp', |
|
46 |
port => '51820'; |
|
47 |
} |
|
48 |
|
|
49 | 13 |
# inet-filter-chain-default_fwd |
50 | 14 |
nftables::rule{ |
51 | 15 |
'default_fwd-out': |
... | ... | |
82 | 46 |
:content => /^ iifname eth1 oifname eth0 accept$/, |
83 | 47 |
:order => '20', |
84 | 48 |
)} |
85 |
it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-rule-jump_ingoing').with( |
|
86 |
:target => 'nftables-inet-filter-chain-default_fwd', |
|
87 |
:content => /^ iifname eth0 oifname eth1 jump ingoing$/, |
|
88 |
:order => '20', |
|
89 |
)} |
|
90 | 49 |
it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-rule-drop').with( |
91 | 50 |
:target => 'nftables-inet-filter-chain-default_fwd', |
92 | 51 |
:content => /^ iifname eth0 drop$/, |
... | ... | |
98 | 57 |
:order => '99', |
99 | 58 |
)} |
100 | 59 |
|
101 |
it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-ingoing-header').with( |
|
102 |
:target => 'nftables-inet-filter-chain-ingoing', |
|
103 |
:content => /^chain ingoing {$/, |
|
104 |
:order => '00', |
|
105 |
)} |
|
106 |
it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-ingoing-rule-http').with( |
|
107 |
:target => 'nftables-inet-filter-chain-ingoing', |
|
108 |
:content => /^ ip daddr 192.0.2.2 tcp dport http accept$/, |
|
109 |
:order => '10', |
|
110 |
)} |
|
111 |
it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-ingoing-rule-https').with( |
|
112 |
:target => 'nftables-inet-filter-chain-ingoing', |
|
113 |
:content => /^ ip daddr 192.0.2.2 tcp dport https accept$/, |
|
114 |
:order => '10', |
|
115 |
)} |
|
116 |
it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-ingoing-rule-http_alt').with( |
|
117 |
:target => 'nftables-inet-filter-chain-ingoing', |
|
118 |
:content => /^ iifname eth0 ip daddr 192.0.2.2 tcp dport 80 accept$/, |
|
119 |
:order => '10', |
|
120 |
)} |
|
121 |
it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-ingoing-rule-wireguard').with( |
|
122 |
:target => 'nftables-inet-filter-chain-ingoing', |
|
123 |
:content => /^ iifname eth0 ip daddr 192.0.2.3 udp dport 51820 accept$/, |
|
124 |
:order => '10', |
|
125 |
)} |
|
126 |
it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-ingoing-footer').with( |
|
127 |
:target => 'nftables-inet-filter-chain-ingoing', |
|
128 |
:content => /^}$/, |
|
129 |
:order => '99', |
|
130 |
)} |
|
131 |
|
|
132 | 60 |
it { is_expected.to contain_concat('nftables-ip-nat-chain-PREROUTING').with( |
133 | 61 |
:path => '/etc/nftables/puppet/ip-nat-chain-PREROUTING.nft', |
134 | 62 |
:owner => 'root', |
... | ... | |
151 | 79 |
:content => /^ policy accept$/, |
152 | 80 |
:order => '02', |
153 | 81 |
)} |
154 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-http').with( |
|
155 |
:target => 'nftables-ip-nat-chain-PREROUTING', |
|
156 |
:content => /^ tcp dport http dnat to 192.0.2.2$/, |
|
157 |
:order => '10', |
|
158 |
)} |
|
159 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-https').with( |
|
160 |
:target => 'nftables-ip-nat-chain-PREROUTING', |
|
161 |
:content => /^ tcp dport https dnat to 192.0.2.2$/, |
|
162 |
:order => '10', |
|
163 |
)} |
|
164 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-http_alt').with( |
|
165 |
:target => 'nftables-ip-nat-chain-PREROUTING', |
|
166 |
:content => /^ iifname eth0 tcp dport 8080 dnat to 192.0.2.2:80$/, |
|
167 |
:order => '10', |
|
168 |
)} |
|
169 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-wireguard').with( |
|
170 |
:target => 'nftables-ip-nat-chain-PREROUTING', |
|
171 |
:content => /^ iifname eth0 udp dport 51820 dnat to 192.0.2.3$/, |
|
172 |
:order => '10', |
|
173 |
)} |
|
174 | 82 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-footer').with( |
175 | 83 |
:target => 'nftables-ip-nat-chain-PREROUTING', |
176 | 84 |
:content => /^}$/, |
Formats disponibles : Unified diff