root / spec / classes / rules / docker_ce_spec.rb @ c3515492
Historique | Voir | Annoter | Télécharger (5,44 ko)
1 |
require 'spec_helper'
|
---|---|
2 |
|
3 |
describe 'nftables::rules::docker_ce' do |
4 |
let(:pre_condition) { 'include nftables' } |
5 |
|
6 |
on_supported_os.each do |os, os_facts|
|
7 |
context "on #{os}" do |
8 |
let(:facts) { os_facts }
|
9 |
|
10 |
context 'default options' do |
11 |
it { is_expected.to compile } |
12 |
it { is_expected.to contain_nftables__chain('DOCKER') }
|
13 |
it { is_expected.to contain_nftables__chain('DOCKER_ISOLATION_STAGE_1') }
|
14 |
it { is_expected.to contain_nftables__chain('DOCKER_ISOLATION_STAGE_2') }
|
15 |
it { is_expected.to contain_nftables__chain('DOCKER_USER') }
|
16 |
it { |
17 |
is_expected.to contain_nftables__chain('DOCKER-nat').with(
|
18 |
chain: 'DOCKER', |
19 |
table: 'ip-nat', |
20 |
) |
21 |
} |
22 |
it { |
23 |
is_expected.to contain_nftables__chain('OUTPUT-nat').with(
|
24 |
chain: 'OUTPUT', |
25 |
table: 'ip-nat', |
26 |
) |
27 |
} |
28 |
it { |
29 |
is_expected.to contain_nftables__chain('INPUT-nat').with(
|
30 |
chain: 'INPUT', |
31 |
table: 'ip-nat', |
32 |
) |
33 |
} |
34 |
it { is_expected.to contain_nftables__rule('DOCKER_ISOLATION_STAGE_1-iifname').with_content('iifname "docker0" oifname != "docker0" counter jump DOCKER_ISOLATION_STAGE_2') } |
35 |
it { is_expected.to contain_nftables__rule('DOCKER_ISOLATION_STAGE_1-counter').with_content('counter return') } |
36 |
it { is_expected.to contain_nftables__rule('DOCKER_ISOLATION_STAGE_2-drop').with_content('oifname "docker0" counter drop') } |
37 |
it { is_expected.to contain_nftables__rule('DOCKER_ISOLATION_STAGE_2-counter').with_content('counter return') } |
38 |
it { is_expected.to contain_nftables__rule('DOCKER_USER-counter').with_content('counter return') } |
39 |
it { is_expected.to contain_nftables__rule('default_fwd-jump_docker_user').with_content('counter jump DOCKER_USER') } |
40 |
it { is_expected.to contain_nftables__rule('default_fwd-jump_docker_isolation_stage_1').with_content('counter jump DOCKER_ISOLATION_STAGE_1') } |
41 |
it { is_expected.to contain_nftables__rule('default_fwd-out_docker_accept').with_content('oifname "docker0" ct state established,related counter accept') } |
42 |
it { is_expected.to contain_nftables__rule('default_fwd-jump_docker').with_content('oifname "docker0" counter jump DOCKER') } |
43 |
it { is_expected.to contain_nftables__rule('default_fwd-idocker_onot_accept').with_content('iifname "docker0" oifname != "docker0" counter accept') } |
44 |
it { is_expected.to contain_nftables__rule('default_fwd-idocker_odocker_accept').with_content('iifname "docker0" oifname "docker0" counter accept') } |
45 |
|
46 |
it { |
47 |
is_expected.to contain_nftables__rule('POSTROUTING-docker').with(
|
48 |
content: 'oifname != "docker0" ip saddr 172.17.0.0/16 counter masquerade', |
49 |
table: 'ip-nat', |
50 |
) |
51 |
} |
52 |
it { |
53 |
is_expected.to contain_nftables__rule('PREROUTING-docker').with(
|
54 |
content: 'fib daddr type local counter jump DOCKER', |
55 |
table: 'ip-nat', |
56 |
) |
57 |
} |
58 |
it { |
59 |
is_expected.to contain_nftables__rule('OUTPUT-jump_docker@ip-nat').with(
|
60 |
rule_name: 'OUTPUT-jump_docker' |
61 |
content: 'ip daddr != 127.0.0.0/8 fib daddr type local counter jump DOCKER', |
62 |
table: 'ip-nat', |
63 |
) |
64 |
} |
65 |
it { |
66 |
is_expected.to contain_nftables__rule('DOCKER-counter').with(
|
67 |
content: 'iifname "docker0" counter return', |
68 |
table: 'ip-nat', |
69 |
) |
70 |
} |
71 |
it { |
72 |
is_expected.to contain_nftables__rule('INPUT-type@ip-nat').with(
|
73 |
rulename: 'INPUT-type' |
74 |
content: 'type nat hook input priority 100', |
75 |
table: 'ip-nat', |
76 |
) |
77 |
} |
78 |
it { |
79 |
is_expected.to contain_nftables__rule('INPUT-policy@ip-nat').with(
|
80 |
rulename: 'INPUT-policy' |
81 |
content: 'policy accept', |
82 |
table: 'ip-nat', |
83 |
) |
84 |
} |
85 |
end
|
86 |
|
87 |
context 'with custom interface and subnet' do |
88 |
let(:params) do |
89 |
{ |
90 |
docker_interface: 'ifdo0', |
91 |
docker_prefix: '192.168.4.0/24', |
92 |
} |
93 |
end
|
94 |
|
95 |
it { is_expected.to compile } |
96 |
it { is_expected.to contain_nftables__rule('DOCKER_ISOLATION_STAGE_1-iifname').with_content('iifname "ifdo0" oifname != "ifdo0" counter jump DOCKER_ISOLATION_STAGE_2') } |
97 |
it { is_expected.to contain_nftables__rule('DOCKER_ISOLATION_STAGE_2-drop').with_content('oifname "ifdo0" counter drop') } |
98 |
it { is_expected.to contain_nftables__rule('default_fwd-out_docker_accept').with_content('oifname "ifdo0" ct state established,related counter accept') } |
99 |
it { is_expected.to contain_nftables__rule('default_fwd-jump_docker').with_content('oifname "ifdo0" counter jump DOCKER') } |
100 |
it { is_expected.to contain_nftables__rule('default_fwd-idocker_onot_accept').with_content('iifname "ifdo0" oifname != "ifdo0" counter accept') } |
101 |
it { is_expected.to contain_nftables__rule('default_fwd-idocker_odocker_accept').with_content('iifname "ifdo0" oifname "ifdo0" counter accept') } |
102 |
|
103 |
it { |
104 |
is_expected.to contain_nftables__rule('POSTROUTING-docker').with(
|
105 |
content: 'oifname != "ifdo0" ip saddr 192.168.4.0/24 counter masquerade', |
106 |
table: 'ip-nat', |
107 |
) |
108 |
} |
109 |
it { |
110 |
is_expected.to contain_nftables__rule('DOCKER-counter').with(
|
111 |
content: 'iifname "ifdo0" counter return', |
112 |
table: 'ip-nat', |
113 |
) |
114 |
} |
115 |
end
|
116 |
end
|
117 |
end
|
118 |
end
|