root / spec / classes / nftables_spec.rb @ 37b2a3b7
Historique | Voir | Annoter | Télécharger (2,83 ko)
1 | 64134e4e | 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 | 5acb554a | tr | |
12 | it { is_expected.to contain_package('nftables') }
|
||
13 | |||
14 | 01d8a819 | tr | it { |
15 | is_expected.to contain_file('/etc/nftables/puppet.nft').with(
|
||
16 | ensure: 'file', |
||
17 | owner: 'root', |
||
18 | group: 'root', |
||
19 | mode: '0640', |
||
20 | source: 'puppet:///modules/nftables/config/puppet.nft', |
||
21 | ) |
||
22 | } |
||
23 | |||
24 | it { |
||
25 | is_expected.to contain_file('/etc/nftables/puppet').with(
|
||
26 | ensure: 'directory', |
||
27 | owner: 'root', |
||
28 | group: 'root', |
||
29 | mode: '0750', |
||
30 | purge: true, |
||
31 | force: true, |
||
32 | recurse: true, |
||
33 | ) |
||
34 | } |
||
35 | |||
36 | it { |
||
37 | is_expected.to contain_service('nftables').with(
|
||
38 | ensure: 'running', |
||
39 | enable: true, |
||
40 | ) |
||
41 | } |
||
42 | |||
43 | it { |
||
44 | is_expected.to contain_service('firewalld').with(
|
||
45 | ensure: 'stopped', |
||
46 | enable: 'mask', |
||
47 | ) |
||
48 | } |
||
49 | e17693e3 | Steve Traylen | it { is_expected.to contain_class('nftables::rules::out::http') }
|
50 | it { is_expected.to contain_class('nftables::rules::out::https') }
|
||
51 | it { is_expected.to contain_class('nftables::rules::out::dns') }
|
||
52 | it { is_expected.to contain_class('nftables::rules::out::chrony') }
|
||
53 | it { is_expected.not_to contain_class('nftables::rules::out::all') }
|
||
54 | it { is_expected.not_to contain_nftables__rule('default_out-all') }
|
||
55 | |||
56 | context 'with out_all set true' do |
||
57 | b171ac7f | mh | let(:params) do |
58 | { |
||
59 | out_all: true, |
||
60 | } |
||
61 | e17693e3 | Steve Traylen | end
|
62 | |||
63 | it { is_expected.to contain_class('nftables::rules::out::all') }
|
||
64 | it { is_expected.not_to contain_class('nftables::rules::out::http') }
|
||
65 | it { is_expected.not_to contain_class('nftables::rules::out::https') }
|
||
66 | it { is_expected.not_to contain_class('nftables::rules::out::dns') }
|
||
67 | it { is_expected.not_to contain_class('nftables::rules::out::chrony') }
|
||
68 | it { is_expected.to contain_nftables__rule('default_out-all').with_content('accept') } |
||
69 | it { is_expected.to contain_nftables__rule('default_out-all').with_order('90') } |
||
70 | end
|
||
71 | b3a7a6dd | tr | |
72 | context 'with custom rules' do |
||
73 | let(:params) do |
||
74 | { |
||
75 | rules: {
|
||
76 | 'INPUT-web_accept' => {
|
||
77 | order: '50', |
||
78 | content: 'iifname eth0 tcp dport { 80, 443 } accept', |
||
79 | }, |
||
80 | }, |
||
81 | } |
||
82 | end
|
||
83 | |||
84 | it { |
||
85 | is_expected.to contain_concat__fragment('nftables-inet-filter-chain-INPUT-rule-web_accept').with(
|
||
86 | target: 'nftables-inet-filter-chain-INPUT', |
||
87 | content: %r{^ iifname eth0 tcp dport \{ 80, 443 \} accept$}, |
||
88 | order: '50', |
||
89 | ) |
||
90 | } |
||
91 | end
|
||
92 | 64134e4e | tr | end
|
93 | end
|
||
94 | end |