Projet

Général

Profil

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

root / spec / defines / simplerule_spec.rb @ 316bc3f8

Historique | Voir | Annoter | Télécharger (2,54 ko)

1
require 'spec_helper'
2

    
3
describe 'nftables::simplerule' do
4
  let(:pre_condition) { 'include nftables' }
5

    
6
  let(:title) { 'my_default_rule_name' }
7

    
8
  on_supported_os.each do |os, os_facts|
9
    context "on #{os}" do
10
      let(:facts) { os_facts }
11

    
12
      describe 'minimum instantiation' do
13
        it { is_expected.to compile }
14
        it {
15
          is_expected.to contain_nftables__rule('default_in-my_default_rule_name').with(
16
            content: 'accept',
17
            order: '50',
18
          )
19
        }
20
      end
21

    
22
      describe 'all parameters provided' do
23
        let(:title) { 'my_big_rule' }
24
        let(:params) do
25
          {
26
            action: 'accept',
27
            comment: 'this is my rule',
28
            dport: 333,
29
            proto: 'udp',
30
            chain: 'default_out',
31
          }
32
        end
33

    
34
        it { is_expected.to compile }
35
        it {
36
          is_expected.to contain_nftables__rule('default_out-my_big_rule').with(
37
            content: 'udp dport 333 comment "this is my rule" accept',
38
            order: '50',
39
          )
40
        }
41
      end
42

    
43
      describe 'port range' do
44
        let(:params) do
45
          {
46
            dport: '333-334',
47
            proto: 'tcp',
48
          }
49
        end
50

    
51
        it { is_expected.to compile }
52
        it {
53
          is_expected.to contain_nftables__rule('default_in-my_default_rule_name').with(
54
            content: 'tcp dport 333-334 accept',
55
          )
56
        }
57
      end
58

    
59
      describe 'port array' do
60
        let(:params) do
61
          {
62
            dport: [333, 335],
63
            proto: 'tcp',
64
          }
65
        end
66

    
67
        it { is_expected.to compile }
68
        it {
69
          is_expected.to contain_nftables__rule('default_in-my_default_rule_name').with(
70
            content: 'tcp dport {333, 335} accept',
71
          )
72
        }
73
      end
74

    
75
      describe 'only IPv4 TCP traffic' do
76
        let(:params) do
77
          {
78
            dport: 333,
79
            proto: 'tcp4',
80
          }
81
        end
82

    
83
        it { is_expected.to compile }
84
        it {
85
          is_expected.to contain_nftables__rule('default_in-my_default_rule_name').with(
86
            content: 'ip version 4 tcp dport 333 accept',
87
          )
88
        }
89
      end
90

    
91
      describe 'only IPv6 UDP traffic' do
92
        let(:params) do
93
          {
94
            dport: 33,
95
            proto: 'udp6',
96
          }
97
        end
98

    
99
        it { is_expected.to compile }
100
        it {
101
          is_expected.to contain_nftables__rule('default_in-my_default_rule_name').with(
102
            content: 'ip version 6 udp dport 33 accept',
103
          )
104
        }
105
      end
106
    end
107
  end
108
end