root / spec / defines / config_spec.rb @ fcb1d356
Historique | Voir | Annoter | Télécharger (3,57 ko)
1 |
require 'spec_helper'
|
---|---|
2 |
|
3 |
describe 'nftables::config' do |
4 |
let(:pre_condition) { 'include nftables' } |
5 |
|
6 |
on_supported_os.each do |os, facts|
|
7 |
context "on #{os}" do |
8 |
let(:title) { 'FOO-BAR' } |
9 |
let(:facts) do |
10 |
facts |
11 |
end
|
12 |
|
13 |
context 'with source and content both unset' do |
14 |
it { is_expected.to compile } |
15 |
it { is_expected.to contain_concat('nftables-FOO-BAR') }
|
16 |
it { |
17 |
is_expected.to contain_concat('nftables-FOO-BAR').with(
|
18 |
path: '/etc/nftables/puppet-preflight/FOO-BAR.nft', |
19 |
ensure_newline: true, |
20 |
mode: '0640', |
21 |
) |
22 |
} |
23 |
it { is_expected.to contain_file('/etc/nftables/puppet/FOO-BAR.nft') }
|
24 |
it { |
25 |
is_expected.to contain_file('/etc/nftables/puppet/FOO-BAR.nft').with(
|
26 |
ensure: 'file', |
27 |
source: '/etc/nftables/puppet-preflight/FOO-BAR.nft', |
28 |
mode: '0640', |
29 |
) |
30 |
} |
31 |
it { is_expected.to contain_concat_fragment('nftables-FOO-BAR-header') }
|
32 |
it { |
33 |
is_expected.to contain_concat_fragment('nftables-FOO-BAR-header').with(
|
34 |
target: 'nftables-FOO-BAR', |
35 |
order: '00', |
36 |
content: 'table FOO BAR {', |
37 |
) |
38 |
} |
39 |
it { |
40 |
is_expected.to contain_concat_fragment('nftables-FOO-BAR-body').with(
|
41 |
target: 'nftables-FOO-BAR', |
42 |
order: '98', |
43 |
content: ' include "FOO-BAR-chain-*.nft"', |
44 |
) |
45 |
} |
46 |
end
|
47 |
|
48 |
context 'with a non hyphenated title' do |
49 |
let(:title) { 'STRING' } |
50 |
|
51 |
it { is_expected.not_to compile } |
52 |
end
|
53 |
|
54 |
context 'with source and content both set' do |
55 |
let(:params) do |
56 |
{ |
57 |
source: 'foo', |
58 |
content: 'puppet:///modules/foo/bar', |
59 |
} |
60 |
end
|
61 |
|
62 |
it { |
63 |
pending('Setting source and content should be made to fail')
|
64 |
is_expected.not_to compile |
65 |
} |
66 |
end
|
67 |
context 'with content set' do |
68 |
let(:params) do |
69 |
{ |
70 |
content: 'strange content', |
71 |
} |
72 |
end
|
73 |
|
74 |
it { is_expected.to compile } |
75 |
it { is_expected.to contain_concat('nftables-FOO-BAR') }
|
76 |
it { |
77 |
is_expected.to contain_concat('nftables-FOO-BAR').with(
|
78 |
path: '/etc/nftables/puppet-preflight/FOO-BAR.nft', |
79 |
ensure_newline: true, |
80 |
mode: '0640', |
81 |
) |
82 |
} |
83 |
it { is_expected.to contain_file('/etc/nftables/puppet/FOO-BAR.nft') }
|
84 |
it { |
85 |
is_expected.to contain_file('/etc/nftables/puppet/FOO-BAR.nft').with(
|
86 |
ensure: 'file', |
87 |
source: '/etc/nftables/puppet-preflight/FOO-BAR.nft', |
88 |
mode: '0640', |
89 |
) |
90 |
} |
91 |
it { is_expected.to contain_concat_fragment('nftables-FOO-BAR-header') }
|
92 |
it { |
93 |
is_expected.to contain_concat_fragment('nftables-FOO-BAR-header').with(
|
94 |
target: 'nftables-FOO-BAR', |
95 |
order: '00', |
96 |
content: 'table FOO BAR {', |
97 |
) |
98 |
} |
99 |
it { |
100 |
is_expected.to contain_concat_fragment('nftables-FOO-BAR-body').with(
|
101 |
target: 'nftables-FOO-BAR', |
102 |
order: '98', |
103 |
content: 'strange content', |
104 |
) |
105 |
} |
106 |
end
|
107 |
context 'with content set' do |
108 |
let(:params) do |
109 |
{ |
110 |
source: 'puppet:///modules/foo', |
111 |
} |
112 |
end
|
113 |
|
114 |
it { |
115 |
is_expected.to contain_concat_fragment('nftables-FOO-BAR-body').with(
|
116 |
target: 'nftables-FOO-BAR', |
117 |
order: '98', |
118 |
source: 'puppet:///modules/foo', |
119 |
) |
120 |
} |
121 |
end
|
122 |
end
|
123 |
end
|
124 |
end
|