root / spec / classes / ip_nat_spec.rb @ b3a7a6dd
Historique | Voir | Annoter | Télécharger (3,3 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 | 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 | 422b6851 | tr | |
21 | context 'chain prerouting' do |
||
22 | 01d8a819 | tr | it { |
23 | is_expected.to contain_concat('nftables-ip-nat-chain-PREROUTING').with(
|
||
24 | path: '/etc/nftables/puppet/ip-nat-chain-PREROUTING.nft', |
||
25 | owner: 'root', |
||
26 | group: 'root', |
||
27 | mode: '0640', |
||
28 | ensure_newline: true, |
||
29 | ) |
||
30 | } |
||
31 | it { |
||
32 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-header').with(
|
||
33 | target: 'nftables-ip-nat-chain-PREROUTING', |
||
34 | content: %r{^chain PREROUTING \{$}, |
||
35 | order: '00', |
||
36 | ) |
||
37 | } |
||
38 | it { |
||
39 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-type').with(
|
||
40 | target: 'nftables-ip-nat-chain-PREROUTING', |
||
41 | content: %r{^ type nat hook prerouting priority -100$}, |
||
42 | order: '01', |
||
43 | ) |
||
44 | } |
||
45 | it { |
||
46 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-policy').with(
|
||
47 | target: 'nftables-ip-nat-chain-PREROUTING', |
||
48 | content: %r{^ policy accept$}, |
||
49 | order: '02', |
||
50 | ) |
||
51 | } |
||
52 | it { |
||
53 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-footer').with(
|
||
54 | target: 'nftables-ip-nat-chain-PREROUTING', |
||
55 | content: %r{^\}$}, |
||
56 | order: '99', |
||
57 | ) |
||
58 | } |
||
59 | 422b6851 | tr | end
|
60 | |||
61 | context 'chain output' do |
||
62 | 01d8a819 | tr | it { |
63 | is_expected.to contain_concat('nftables-ip-nat-chain-POSTROUTING').with(
|
||
64 | path: '/etc/nftables/puppet/ip-nat-chain-POSTROUTING.nft', |
||
65 | owner: 'root', |
||
66 | group: 'root', |
||
67 | mode: '0640', |
||
68 | ensure_newline: true, |
||
69 | ) |
||
70 | } |
||
71 | it { |
||
72 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-header').with(
|
||
73 | target: 'nftables-ip-nat-chain-POSTROUTING', |
||
74 | content: %r{^chain POSTROUTING \{$}, |
||
75 | order: '00', |
||
76 | ) |
||
77 | } |
||
78 | it { |
||
79 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-type').with(
|
||
80 | target: 'nftables-ip-nat-chain-POSTROUTING', |
||
81 | content: %r{^ type nat hook postrouting priority 100$}, |
||
82 | order: '01', |
||
83 | ) |
||
84 | } |
||
85 | it { |
||
86 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-rule-policy').with(
|
||
87 | target: 'nftables-ip-nat-chain-POSTROUTING', |
||
88 | content: %r{^ policy accept$}, |
||
89 | order: '02', |
||
90 | ) |
||
91 | } |
||
92 | it { |
||
93 | is_expected.to contain_concat__fragment('nftables-ip-nat-chain-POSTROUTING-footer').with(
|
||
94 | target: 'nftables-ip-nat-chain-POSTROUTING', |
||
95 | content: %r{^\}$}, |
||
96 | order: '99', |
||
97 | ) |
||
98 | } |
||
99 | 422b6851 | tr | end
|
100 | end
|
||
101 | end
|
||
102 | end |