root / spec / classes / rules / icmp_spec.rb @ e0bb7852
Historique | Voir | Annoter | Télécharger (2,72 ko)
1 |
# frozen_string_literal: true
|
---|---|
2 |
|
3 |
require 'spec_helper'
|
4 |
|
5 |
describe 'nftables::rules::icmp' do |
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.with_all_deps } |
12 |
|
13 |
it { is_expected.to contain_nftables__rule('default_in-accept_icmp').with_content('meta l4proto { icmp, icmpv6} accept').with_order('10') } |
14 |
it { is_expected.not_to contain_nftables__rule('default_in-accept_icmpv4') }
|
15 |
it { is_expected.not_to contain_nftables__rule('default_in-accept_icmpv6') }
|
16 |
end
|
17 |
|
18 |
context 'with custom ICMP types (v4 only)' do |
19 |
let(:params) do |
20 |
{ |
21 |
v4_types: ['echo-request limit rate 4/second', 'echo-reply'], |
22 |
} |
23 |
end
|
24 |
|
25 |
it { is_expected.to compile } |
26 |
|
27 |
it { |
28 |
expect(subject).to contain_nftables__rule('default_in-accept_icmpv4_echo_request').with(
|
29 |
content: 'ip protocol icmp icmp type echo-request limit rate 4/second accept', |
30 |
order: '10' |
31 |
) |
32 |
} |
33 |
|
34 |
it { |
35 |
expect(subject).to contain_nftables__rule('default_in-accept_icmpv4_echo_reply').with(
|
36 |
content: 'ip protocol icmp icmp type echo-reply accept', |
37 |
order: '10' |
38 |
) |
39 |
} |
40 |
|
41 |
it { |
42 |
expect(subject).to contain_nftables__rule('default_in-accept_icmpv6').with(
|
43 |
content: 'meta l4proto icmpv6 accept', |
44 |
order: '10' |
45 |
) |
46 |
} |
47 |
end
|
48 |
|
49 |
context 'with custom ICMP types (both v4 and v6)' do |
50 |
let(:params) do |
51 |
{ |
52 |
v4_types: ['echo-request limit rate 4/second', 'echo-reply'], |
53 |
v6_types: %w[echo-reply nd-router-advert], |
54 |
} |
55 |
end
|
56 |
|
57 |
it { is_expected.to compile } |
58 |
|
59 |
it { |
60 |
expect(subject).to contain_nftables__rule('default_in-accept_icmpv4_echo_request').with(
|
61 |
content: 'ip protocol icmp icmp type echo-request limit rate 4/second accept', |
62 |
order: '10' |
63 |
) |
64 |
} |
65 |
|
66 |
it { |
67 |
expect(subject).to contain_nftables__rule('default_in-accept_icmpv4_echo_reply').with(
|
68 |
content: 'ip protocol icmp icmp type echo-reply accept', |
69 |
order: '10' |
70 |
) |
71 |
} |
72 |
|
73 |
it { |
74 |
expect(subject).to contain_nftables__rule('default_in-accept_icmpv6_echo_reply').with(
|
75 |
content: 'ip6 nexthdr ipv6-icmp icmpv6 type echo-reply accept', |
76 |
order: '10' |
77 |
) |
78 |
} |
79 |
|
80 |
it { |
81 |
expect(subject).to contain_nftables__rule('default_in-accept_icmpv6_nd_router_advert').with(
|
82 |
content: 'ip6 nexthdr ipv6-icmp icmpv6 type nd-router-advert accept', |
83 |
order: '10' |
84 |
) |
85 |
} |
86 |
end
|
87 |
end
|
88 |
end
|
89 |
end
|