root / spec / classes / snat4_spec.rb @ c94658e1
Historique | Voir | Annoter | Télécharger (3,87 ko)
1 | 3d29a6eb | 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 | context 'with snat4' do |
||
11 | let(:pre_condition) do |
||
12 | 01d8a819 | tr | '
|
13 | 3d29a6eb | tr | nftables::rules::snat4{
|
14 | 01d8a819 | tr | \'static\':
|
15 | order => \'60\',
|
||
16 | snat => \'198.51.100.1\',
|
||
17 | oif => \'eth0\';
|
||
18 | \'1_1\':
|
||
19 | order => \'61\',
|
||
20 | saddr => \'192.0.2.2\',
|
||
21 | snat => \'198.51.100.3\',
|
||
22 | oif => \'eth0\';
|
||
23 | \'1_1_smtp\':
|
||
24 | saddr => \'192.0.2.2\',
|
||
25 | snat => \'198.51.100.2\',
|
||
26 | dport => \'25\';
|
||
27 | \'1_1_wireguard\':
|
||
28 | saddr => \'192.0.2.2\',
|
||
29 | snat => \'198.51.100.2\',
|
||
30 | proto => \'udp\',
|
||
31 | dport => \'51820\';
|
||
32 | 3d29a6eb | tr | }
|
33 | 01d8a819 | tr | '
|
34 | 3d29a6eb | tr | end
|
35 | |||
36 | it { is_expected.to compile } |
||
37 | |||
38 | 01d8a819 | tr | it { |
39 | is_expected.to contain_concat('nftables-ip-nat-chain-POSTROUTING').with(
|
||
40 | 30462da1 | Steve Traylen | path: '/etc/nftables/puppet-preflight/ip-nat-chain-POSTROUTING.nft', |
41 | 01d8a819 | tr | owner: 'root', |
42 | group: 'root', |
||
43 | mode: '0640', |
||
44 | ensure_newline: true, |
||
45 | ) |
||
46 | } |
||
47 | it { |
||
48 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-header').with(
|
||
49 | target: 'nftables-ip-nat-chain-POSTROUTING', |
||
50 | content: %r{^chain POSTROUTING \{$}, |
||
51 | order: '00', |
||
52 | ) |
||
53 | } |
||
54 | it { |
||
55 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-type').with(
|
||
56 | target: 'nftables-ip-nat-chain-POSTROUTING', |
||
57 | content: %r{^ type nat hook postrouting priority 100$}, |
||
58 | 61f03b47 | Steve Traylen | order: '01-nftables-ip-nat-chain-POSTROUTING-rule-type-b', |
59 | 01d8a819 | tr | ) |
60 | } |
||
61 | it { |
||
62 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-policy').with(
|
||
63 | target: 'nftables-ip-nat-chain-POSTROUTING', |
||
64 | content: %r{^ policy accept$}, |
||
65 | 61f03b47 | Steve Traylen | order: '02-nftables-ip-nat-chain-POSTROUTING-rule-policy-b', |
66 | 01d8a819 | tr | ) |
67 | } |
||
68 | it { |
||
69 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-static').with(
|
||
70 | target: 'nftables-ip-nat-chain-POSTROUTING', |
||
71 | content: %r{^ oifname eth0 snat 198\.51\.100\.1$}, |
||
72 | 61f03b47 | Steve Traylen | order: '60-nftables-ip-nat-chain-POSTROUTING-rule-static-b', |
73 | 01d8a819 | tr | ) |
74 | } |
||
75 | it { |
||
76 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-1_1').with(
|
||
77 | target: 'nftables-ip-nat-chain-POSTROUTING', |
||
78 | content: %r{^ oifname eth0 ip saddr 192\.0\.2\.2 snat 198\.51\.100\.3$}, |
||
79 | 61f03b47 | Steve Traylen | order: '61-nftables-ip-nat-chain-POSTROUTING-rule-1_1-b', |
80 | 01d8a819 | tr | ) |
81 | } |
||
82 | it { |
||
83 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-1_1_smtp').with(
|
||
84 | target: 'nftables-ip-nat-chain-POSTROUTING', |
||
85 | content: %r{^ ip saddr 192\.0\.2\.2 tcp dport 25 snat 198\.51\.100\.2$}, |
||
86 | 61f03b47 | Steve Traylen | order: '70-nftables-ip-nat-chain-POSTROUTING-rule-1_1_smtp-b', |
87 | 01d8a819 | tr | ) |
88 | } |
||
89 | it { |
||
90 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-1_1_wireguard').with(
|
||
91 | target: 'nftables-ip-nat-chain-POSTROUTING', |
||
92 | content: %r{^ ip saddr 192\.0\.2\.2 udp dport 51820 snat 198\.51\.100\.2$}, |
||
93 | 61f03b47 | Steve Traylen | order: '70-nftables-ip-nat-chain-POSTROUTING-rule-1_1_wireguard-b', |
94 | 01d8a819 | tr | ) |
95 | } |
||
96 | it { |
||
97 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-footer').with(
|
||
98 | target: 'nftables-ip-nat-chain-POSTROUTING', |
||
99 | content: %r{^\}$}, |
||
100 | order: '99', |
||
101 | ) |
||
102 | } |
||
103 | 3d29a6eb | tr | end
|
104 | end
|
||
105 | end
|
||
106 | end |