Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / spec / classes / rules / icmp_spec.rb @ 8842a597

Historique | Voir | Annoter | Télécharger (2,78 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 }
12

    
13
        it {
14
          expect(subject).to contain_nftables__rule('default_in-accept_icmpv4').with(
15
            content: 'ip protocol icmp accept',
16
            order: '10'
17
          )
18
        }
19

    
20
        it {
21
          expect(subject).to contain_nftables__rule('default_in-accept_icmpv6').with(
22
            content: 'ip6 nexthdr ipv6-icmp accept',
23
            order: '10'
24
          )
25
        }
26
      end
27

    
28
      context 'with custom ICMP types (v4 only)' do
29
        let(:params) do
30
          {
31
            v4_types: ['echo-request limit rate 4/second', 'echo-reply'],
32
          }
33
        end
34

    
35
        it { is_expected.to compile }
36

    
37
        it {
38
          expect(subject).to contain_nftables__rule('default_in-accept_icmpv4_echo_request').with(
39
            content: 'ip protocol icmp icmp type echo-request limit rate 4/second accept',
40
            order: '10'
41
          )
42
        }
43

    
44
        it {
45
          expect(subject).to contain_nftables__rule('default_in-accept_icmpv4_echo_reply').with(
46
            content: 'ip protocol icmp icmp type echo-reply accept',
47
            order: '10'
48
          )
49
        }
50

    
51
        it {
52
          expect(subject).to contain_nftables__rule('default_in-accept_icmpv6').with(
53
            content: 'ip6 nexthdr ipv6-icmp accept',
54
            order: '10'
55
          )
56
        }
57
      end
58

    
59
      context 'with custom ICMP types (both v4 and v6)' do
60
        let(:params) do
61
          {
62
            v4_types: ['echo-request limit rate 4/second', 'echo-reply'],
63
            v6_types: %w[echo-reply nd-router-advert],
64
          }
65
        end
66

    
67
        it { is_expected.to compile }
68

    
69
        it {
70
          expect(subject).to contain_nftables__rule('default_in-accept_icmpv4_echo_request').with(
71
            content: 'ip protocol icmp icmp type echo-request limit rate 4/second accept',
72
            order: '10'
73
          )
74
        }
75

    
76
        it {
77
          expect(subject).to contain_nftables__rule('default_in-accept_icmpv4_echo_reply').with(
78
            content: 'ip protocol icmp icmp type echo-reply accept',
79
            order: '10'
80
          )
81
        }
82

    
83
        it {
84
          expect(subject).to contain_nftables__rule('default_in-accept_icmpv6_echo_reply').with(
85
            content: 'ip6 nexthdr ipv6-icmp icmpv6 type echo-reply accept',
86
            order: '10'
87
          )
88
        }
89

    
90
        it {
91
          expect(subject).to contain_nftables__rule('default_in-accept_icmpv6_nd_router_advert').with(
92
            content: 'ip6 nexthdr ipv6-icmp icmpv6 type nd-router-advert accept',
93
            order: '10'
94
          )
95
        }
96
      end
97
    end
98
  end
99
end